akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const ll MOD = 1e9 + 7;
template<ll MOD> struct ModInt {
    ll value;
    ModInt() : value(0) {}
    ModInt(const ll& v) : value(v % MOD) {
        if ( value < 0 ) value += MOD;
    }
    ModInt<MOD>& operator=(const ModInt& o) {
        value = o.value;
        return *this;
    }
    inline bool operator==(const ModInt& o) {
        return value == o.value;
    }
    inline bool operator!=(const ModInt& o) {
        return value != o.value;
    }
    ModInt<MOD>& operator+=(const ModInt& o) {
        value += o.value;
        if ( value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD>& operator-=(const ModInt& o) {
        value += MOD - o.value;
        if (value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD>& operator*=(const ModInt& o) {
        value *= o.value;
        value %= MOD;
        return *this;
    }
    ModInt<MOD>& operator/=(const ModInt& o) {
        value *= inverse(o.value);
        value %= MOD;
        return *this;
    }
    ModInt<MOD> operator-() {
        return ModInt<MOD>(-value);
    }
    ModInt<MOD> operator+(const ModInt& o) {
        ModInt<MOD> r(*this);
        r += o;
        return r;
    }
    ModInt<MOD> operator-(const ModInt& o) {
        ModInt<MOD> r(*this);
        r -= o;
        return r;
    }
    ModInt<MOD> operator*(const ModInt& o) {
        ModInt<MOD> r(*this);
        r *= o;
        return r;
    }
    ModInt<MOD> operator/(const ModInt& o) {
        ModInt<MOD> r(*this);
        r /= o;
        return r;
    }
    ModInt<MOD> pow(ll n) {
        ModInt<MOD> t(*this), r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) r *= t;
            t *= t;
            n >>= 1;
        }
        return r;
    }
private:
    ll inverse(ll a) {
        ModInt<MOD> t(a);
        return t.pow(MOD - 2).value;
    }
};
template<ll MOD> std::ostream& operator<< (std::ostream& os, const ModInt<MOD>& o) {
    os << o.value;
    return os;
}
template<ll MOD> std::istream& operator>> (std::istream& is, ModInt<MOD>& o) {
    is >> o.value;
    return is;
}

using Int = ModInt<MOD>;

ll solve() {
    ll H, W;
    cin >> H >> W;
    vector<string> A(H);
    for ( int i = 0; i < H; i++ ) {
        cin >> A[i];
    }
    vector<vector<Int>> dp(H+1, vector<Int>(W+1));
    dp[1][0] = Int(1);
    for ( int h = 1; h <= H; h++ ) {
        for ( int w = 1; w <= W; w++ ) {
            if ( A[h-1][w-1] == '#') continue;
            dp[h][w] += dp[h][w-1];
            dp[h][w] += dp[h-1][w];
        }
    }
    return dp[H][W].value;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>

using namespace std;

int main() {
    int N;
    int a, b;
    cin >> N;
    vector<pair<int, int>> v(N);
    for(int i = 0; i < N; i++) {
        cin >> a >> b;
        v[i].first = b;
        v[i].second = a;
    }

    sort(v.begin(), v.end());

    int t = 0;
    for(int i = 0; i < N; i++) {
        t += v[i].second;
        if(v[i].first < t) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;



int main() {

  int N;
  cin >> N;
  
  long A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  long minVal = LONG_MAX;
  int minusCount = 0;
  long sum = 0;
  for (int i = 0; i < N; i++) {
    sum += abs(A[i]);
    minVal = min(minVal,abs(A[i]));
    if(A[i]<0) minusCount++;
  }
  if(minusCount%2==1) sum -= (minVal*2);

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int i, N, K;
	long long x[51], y[51];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%lld %lld", &(x[i]), &(y[i]));
	
	int j, k, l, m, count;
	long long X[2], Y[2], min = (long long)1 << 62;
	for (i = 1; i < N; i++) {
		for (j = i + 1; j <= N; j++) {
			X[0] = (x[i] < x[j])? x[i]: x[j];
			X[1] = x[i] + x[j] - X[0];
			for (k = 1; k < N; k++) {
				for (l = k + 1; l <= N; l++) {
					Y[0] = (y[k] < y[l])? y[k]: y[l];
					Y[1] = y[k] + y[l] - Y[0];
					for (m = 1, count = 0; m <= N; m++) if (x[m] >= X[0] && x[m] <= X[1] && y[m] >= Y[0] && y[m] <= Y[1]) count++;
					if (count >= K && (X[1] - X[0]) * (Y[1] - Y[0]) < min) min = (X[1] - X[0]) * (Y[1] - Y[0]);
				}
			}
		}
	}
	
	printf("%lld\n", min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;

	int x = min(a, b);
	int y = min(c, d);

	cout << x + y << endl;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  string S;
  cin >>N >> S;

  map<char,int> abc;

  for(char &c:S){
    abc[c]++;
  }
  
  long long m = pow(10,9) + 7;

  long long ans = 1;
  for(auto &a: abc){
    ans *= a.second + 1;
    ans %= m;
  }

  cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,x; cin >> N >> x;
	vector<int> a(N);
	repp(i,0,N) cin >> a[i];
	sort(a.begin(),a.end());
	int z = 0;
	while(z < N && a[z] <= x){
		x -= a[z];
		++z;
	}
	if(z == N && x > 0) --z;
	cout << z << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;
int modpow(int a,int x){
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int h,w,k;
  int ans=0;
  cin>>h>>w>>k;
  char c[h][w];
  rep(i,h)rep(j,w)cin>>c[i][j];
  for(int bit1=0;bit1<(1<<h);bit1++){
    for(int bit2=0;bit2<(1<<w);bit2++){
      int temp=0;
      rep(i,h){
        rep(j,w){
          if((1<<i)&bit1||(1<<j)&bit2)continue;
          else{if(c[i][j]=='#')temp++;}
        }
      }
      if(temp==k)ans++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3636
#include<cstdio>
int main()
{
    int n,k;
    char a[50];
    scanf("%d%s%d",&n,a,&k);;
    k--;
    for(int i=0; i<n; i++)
    {
        if(a[i]!=a[k])
            printf("*");
        else
            printf("%c",a[i]);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define ANS(x) cout << ((x)?"YES":"NO") << endl;

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

int N, M, O, P;

bool judge(int x) {
    return (N == x || M == x || O == x || P == x);
}

int main() {

    cin >> N >> M >> O >> P;
    ANS((judge(1) && judge(9) && judge(7) && judge(4)));

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, mx=0, mn=INF;
    cin>>n;
    
    rep(i,n){
        int x; cin>>x;
        chmax(mx,x);
        chmin(mn,x);
    }
    cout1(mx-mn)
}

Measured memory_bytes: 256
let cnt = ref 0
let (g : int list ref) = ref []

let insertion_sort (a : int array) n g =
  for i = g to n - 1 do
    let v = a.(i) in
    let j = ref (i - g) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+g) <- a.(!j);
      j := !j - g;
      incr cnt;
    done;
    a.(!j+g) <- v;
  done

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  List.iter (fun g -> insertion_sort a n g) !g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  shell_sort a n;
  print_int (List.length !g); print_newline ();
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  print_int !cnt; print_newline ();
  Array.iter (fun n -> print_int n; print_newline ()) a

Measured memory_bytes: 12476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  string N;
  cin>>N;
  ll Sz=N.size();
  ll A=0;
  rep(i, Sz){
    A+=(N.at(i)-'0');
  }
  Yes(!(A%9));
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

int main(){
	string s,t;
	cin >> s;

	if(s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<string.h>

#include<algorithm>

/*void sort(int *a,string *S,int *P,int N)
{
	int i=0,j=N-1;
	string pivot = a[(i+j)/2];

	while(true)
	{
		while(strcmp(S[i],pivot) <= 0)i++;
		while(strcmp(S[j],pivot) >= 0)j--;

		if( i >= j )break;

		int hold = a[i];
		a[i] = a[j];
		a[j] = hold;

		hold = P[i];
		P[i] = P[j];
		P[j] = hold;

		string tmp = S[i];
		S[i] = S[j];
		S[j] = tmp;

		i++;
		j--;
	}

	if(i > 1)sort(a,S,P,i);
	if(n-j-1 > 1)sort(a+j+1,S+j+1,P+j+1,n-j-1);
}

void sortPair(int *a,string *S,int *P,int n)
{
	int i=0,j=n-1;
	int pivot = P[(i+j)/2];
 
	while(true)
	{
		while(P[i] > pivot)i++;
		while(P[j] < pivot)j--;
 
		if( i >= j )break;
 
		int hold = c[i];
		P[i] = P[j];
		P[j] = hold;

		hold = a[i];
		a[i] = a[j];
		a[j] = hold;
 
		string tmp = S[i];
		S[i] = S[j];
		S[j] = tmp;

		i++;
		j--;
	}
 
	if(i > 1)sortPair(a,S,P,i);
	if(n-j-1 > 1)sortPair(a+j+1,S+j+1,P+j+1,n-j-1);
}*/
using namespace std;

struct R{
	string name;
	int score;
	int id;

	bool operator<(const R &r2)
	{
		int cmp = strcmp(name.c_str(),r2.name.c_str());

		if(cmp < 0)
		{
			return true;
		}
		else if(cmp > 0)
		{
			return false;
		}
		else
		{
			if(score > r2.score)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}

};


int main()
{
	int N;

	cin >> N;

	vector<R> rest(N);

	for(int i=0;i<N;i++)
	{
		cin >> rest[i].name >> rest[i].score;
		rest[i].id = i+1;
	}

	sort(rest.begin(),rest.end());

	for(int i=0;i<N;i++)
	{
		cout << rest[i].id << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back
#define INF 1e17
#define fst first
#define snd second
typedef long long ll;

const int N = 410;
int n;
ll a[N];

ll dp[N][N];

ll sum[N + 1];

void init() {
    sum[0] = 0;
    fore(i, 1, n + 1) sum[i] = sum[i - 1] + a[i - 1];
}

ll calc(int i, int j) {
    if(i == j) return 0;

    ll &r = dp[i][j];
    if(r != -1) return r;
    ll res = INF;
    fore(k, i, j) {
        ll sumizq = sum[k + 1] - sum[i];
        ll sumder = sum[j + 1] - sum[k + 1];
        res = min(res, calc(i, k) + calc(k + 1, j) + sumizq + sumder);
    }
    // cout << i << " " << j << " " << res << endl;
    return r = res;
}

int main() {
    cin >> n; 
    fore(i, 0, n) cin >> a[i];
    memset(dp, -1, sizeof dp);
    init();
    cout << calc(0, n - 1) << endl;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,k,a[51];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int t=0;
	for(int i=n;i>n-k;i--)t+=a[i];
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char[] s, t;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        s = sc.next().toCharArray();
        t = sc.next().toCharArray();
        solve();
    }

    void solve() {
        char[] ans = s.clone();
        boolean replaceSub = false;
        for (int i = s.length - 1; i >= 0; i--) {
            boolean flag = true;
            if (i + t.length > s.length) {
                flag = false;
            } else {
                for (int j = i; j < i + t.length; j++) {
                    if (s[j] != t[j - i] && s[j] != '?') {
                        flag = false;
                        break;
                    }
                }
            }
            if (flag) {
                for (int j = i; j < i + t.length; j++) {
                    ans[j] = t[j - i];
                }
                replaceSub = true;
                break;
            }
        }
        if (replaceSub) {
            System.out.println((new String(ans)).replace('?', 'a'));
        } else {
            System.out.println("UNRESTORABLE");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		switch(BigInteger.valueOf(a - b).signum()){
		case 1:
			System.out.println("a > b");
			break;
		case -1:
			System.out.println("a < b");
			break;
		case 0:
			System.out.println("a == b");
		}
		sc.close();
	}

}

Measured memory_bytes: 17212
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
const int MAX_N=100,MAX_V=100000;
int N,W;
vector<int> w,v;
int dp[MAX_N+1][MAX_V+1];
signed main(){
	cin>>N>>W;
	w.resize(N);v.resize(N);
	rep(i,N) cin>>w[i]>>v[i];
	rep(i,N+1) rep(j,MAX_V+1){
		dp[i][j]=INT_MAX;
	}
	dp[N][0]=0;
	int ans=0;
	for(int i=N-1;i>=0;--i) rep(j,MAX_V+1){
		if(j-v[i]>=0) dp[i][j]=min(dp[i+1][j-v[i]]+w[i],dp[i+1][j]);
		else dp[i][j]=dp[i+1][j];
		if(i==0&&dp[i][j]<=W) ans=max(ans,j);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 79104
n,k=map(int,input().split())
ans=[[] for _ in range(n//2)]
if n%2==1:
  for i in range(1,k+1):
    ans[i-1].append(i)
  for i in range(1,k+1):
    ans[i-1].append(n-i+1)
  for i in range(k):
    print(*ans[i])
else:
  if n%4==0:
    for i in range(1,k+1):
      ans[i-1].append(i)
    for i in range(1,k+1):
      if i<=k//2+1:
        ans[i-1].append(n-i+1)
      else:
        ans[i-1].append(n-i)
  else:
    for i in range(1,k+1):
      ans[i-1].append(i)
    for i in range(1,k+1):
      if i<=k//2:
        ans[i-1].append(n-i+1)
      else:
        ans[i-1].append(n-i)
  for i in range(k):
    print(*ans[i])

Measured memory_bytes: 85660
#include <bits/stdc++.h>
using namespace std;

const int UNCALCULATED = -1;
const int MAXN = 100 + 10, MAXV = 100 * 1000 + 10;
long dp[MAXN][MAXV];
long v[MAXN], w[MAXN];

long calc(int i, int j) {
    if(j < 0)return LONG_MAX/10;
    if(i == 0)
        if(j == 0)return 0;
        else return LONG_MAX/10;
    if(dp[i][j] != UNCALCULATED)return dp[i][j];
    return dp[i][j] = min(w[i] + calc(i - 1, j - v[i]), calc(i - 1, j));
}

int main() {
    for(int i = 0; i < MAXN; i++) {
        for(int j = 0; j < MAXV; j++) {
            dp[i][j] = UNCALCULATED;
        }
    }
    int n, total;
    cin >> n >> total;
    for(int i = 1; i <= n; i++)cin >> w[i] >> v[i];
    for(int j = MAXV-1;j>=0;j--){
        if(calc(n,j) <= total){
            cout<<j<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 86144
#include <stdio.h>

int n, a[20];

int solve(int i, int m){
  int res;
  if (m == 0) {
    return 1;
  }
  if (i >= n) {
    return 0;
  }
  res = solve(i + 1, m) || solve(i + 1, m - a[i]);
  return res;
}

int main(void){
  int q, m[200];
  int i, j;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &m[i]);
  }

  for (i = 0; i < q; i++) {
    if (solve(0, m[i]) == 1) {
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 1980
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        int[][] wf = new int[10][10];
        for (int i = 0; i < 10; i++) {
        	for (int j = 0; j < 10; j++) {
        		wf[i][j] = sc.nextInt();
        	}
        }
        
        for (int k = 0; k < 10; k++) {
        	for (int i = 0; i < 10; i++) {
        		for (int j = 0; j < 10; j++) {
        			wf[i][j] = Math.min(wf[i][j], wf[i][k] + wf[k][j]);
        		}
        	}
        }
        
        int[] count = new int[10];
        for (int i = 0; i < H; i++) {
        	for (int j = 0; j < W; j++) {
        		int a = sc.nextInt();
        		if (a >= 0) {
        			count[a]++;
        		}
        	}
        }
        
        int sum = 0;
        for (int i = 0; i < 10; i++) {
        	if (i == 1)
        		continue;
        	
        	int cost = wf[i][1];
        	sum += cost*count[i];
        }
        
        System.out.println(sum);
    }
}

Measured memory_bytes: 43148
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.nextString();

            int max = 0;

            // i文字目の次で区切る
            for (int i = 0; i < n - 1; i++) {
                boolean[] contains = new boolean[26];
                for (int j = 0; j <= i; j++) {
                    contains[s.charAt(j) - 'a'] = true;
                }

                int cnt = 0;
                for (int j = i + 1; j < n; j++) {
                    int index = s.charAt(j) - 'a';
                    if (contains[index]) {
                        cnt++;
                        contains[index] = false;
                    }
                }

                max = Math.max(max, cnt);
            }

            out.println(max);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23380
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut graph: Vec<Vec<(usize, usize)>> = vec![vec![]; n];
    for _ in 0..(n - 1) {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        let bi: usize = iterator.next().unwrap().parse().unwrap();
        let ci: usize = iterator.next().unwrap().parse().unwrap();
        let ai = ai - 1;
        let bi = bi - 1;
        graph[ai].push((bi, ci));
        graph[bi].push((ai, ci));
    }

    let q: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let k = k - 1;

    const INF: usize = std::usize::MAX;
    let mut costs: Vec<usize> = vec![INF; n];
    costs[k] = 0;
    let mut queue = VecDeque::new();
    queue.push_back((k, 0_usize));
    while let Some((u, cost)) = queue.pop_front() {
        for &(v, c) in &graph[u] {
            if costs[v] != INF {
                continue;
            }
            costs[v] = cost + c;
            queue.push_back((v, costs[v]));
        }
    }

    let mut result = String::new();
    for _ in 0..q {
        let x1: usize = iterator.next().unwrap().parse().unwrap();
        let y1: usize = iterator.next().unwrap().parse().unwrap();
        let x1 = x1 - 1;
        let y1 = y1 - 1;
        result.push_str(&format!("{}\n", costs[x1] + costs[y1]));
    }
    result.trim().to_string()
}


Measured memory_bytes: 16628
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long amt = 100;
        long y = 0;
        while (amt < x) {
            amt += (amt/100);
            y++;
        }

        System.out.println(y);
    }
}

Measured memory_bytes: 35768
#include <iostream>
using namespace std;

int main() {

  while( true ) {

    long long int n, m, p;
    cin >> n >> m >> p;
    if ( n == 0 ) break;

    long long int b[8][8][8] = {};
    long long int t[8][8] = {};

    bool f = false;

    for ( long long int i = 0; i < p; i++ ) {

      long long int x, y;
      cin >> x >> y;
      if ( f == true ) continue;

      x--;
      y--;
      long long int k = ( i % 2 ) + 1;
      long long int z = t[x][y];
      b[x][y][z] = k;
      t[x][y]++;

      for ( long long int dx = -1; dx <= 1; dx++ ) {
	for ( long long int dy = -1; dy <= 1; dy++ ) {
	  for ( long long int dz = -1; dz <= 1; dz++ ) {
	    if ( dx == 0 && dy == 0 && dz == 0 ) continue;
	    long long int cnt = 0;
	    for ( long long int j = -m+1; j <= m-1; j++ ) {
	      long long int mx = x + dx * j;
	      long long int my = y + dy * j;
	      long long int mz = z + dz * j;
	      if ( mx >= 0 && mx < n && my >= 0 && my < n && mz >= 0 && mz < n && b[mx][my][mz] == k ) {
		cnt++;
		if ( cnt == m ) {
		  f = true;
		  if ( k == 1 ) {
		    cout << "Black " << i+1 << endl;
		  }else {
		    cout << "White " << i+1 << endl;
		  }
		  break;
		}
	      }else {
		cnt = 0;
	      }
	    }
	    if ( f == true ) break;
	  }
	  if ( f == true ) break;
	}
	if ( f == true ) break;
      }

    }

    if ( f == false ) {
      cout << "Draw" << endl;
    }

  }

  return 0;

}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


int main()
{
	int n;
	sc(n);
	int ans;
	ans=pow(n,3);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 200000;
ll a[N];

int main() {
  int n;
  fscanf(stdin, "%d ", &n);
  REP(i,n) fscanf(stdin, "%lld ", a+i);
  ll res = 0;
  ll b = 0;
  for (int i=n-1; i>=0; i--) {
    if (i < n-1) b = (b + a[i+1]) % mod;
    res = (res + (a[i]*b)%mod) % mod;
  }
  fprintf(stdout, "%lld\n", res);
  return 0;
}


Measured memory_bytes: 5384
use std::io;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn str_join<T: std::string::ToString>(s: &Vec<T>) -> String {
    s.iter()
        .map(|i| i.to_string())
        .collect::<Vec<_>>()
        .join(" ")
}

fn main() {
    loop {
        let nx: Vec<i32> = read_vec();
        let n = nx[0];
        let x = nx[1];
        if n == 0 && x == 0 {
            break;
        }
        let mut count = 0;
        for i in 1..n + 1 {
            for j in i + 1..n + 1 {
                let k = x - i - j;
                if k > j && k <= n {
                    count += 1;
                }
            }
        }
        println!("{}", count);
    }
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[300005],b[300002];
int main()
{
    ll t,n,d,ans=0,i;

    scanf("%lld %lld",&n,&d);
    for(i=1; i<=n; i++)
    {
        scanf("%lld %lld",&a[i],&b[i]);
        if(a[i]*a[i]+b[i]*b[i]<=d*d)
        {
            ans++;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 6884
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  ll ans = 0;
  rep(i, s.size()) {
    if (s[i] == 'B') {
      cnt++;
    } else {
      ans += cnt;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
n = gets.chomp.to_i

divisors = Array.new(1001,0)

1.upto(n) do |i|
  sq = Math.sqrt(i)
  ii = i
  j = 2
  while(true)
    break if ii == 1
    if ii % j == 0
      ii = ii / j
      divisors[j] += 1
      j = 2
    else
      j += 1
    end
  end
end

result = 1
divisors.each do |i|
 result = result * (i+1)
end

puts result % 1000000007


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,T;
  cin >> n >> T;
  ll c;
  ll t;
  ll ans = INF;
  rep(i,n){
    cin >> c >> t;
    if(t<=T) chmin(ans,c);
  }
  if(ans!=INF)pri(ans);
  else pri("TLE");


  return 0;
}


Measured memory_bytes: 256
N = int(input())
x, y = [], []
for _ in range(N):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)

res = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = x[i] - x[j]
        q = y[i] - y[j]
        
        cnt = 0
        for ii in range(N):
            for jj in range(N):
                pp = x[jj] - p
                qq = y[jj] - q
                if ii == jj:
                    continue
                if pp == x[ii] and qq == y[ii]:
                    cnt += 1
            res = max(res, cnt)

print(N - res)


Measured memory_bytes: 9152
#include <iostream>
using namespace std;
int main()
{
	int r, g, b, n, ans = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n / r; i++)
	{
		for (int j = 0; j <= n / g; j++)
		{
			if ((n - r*i - g*j) >= 0 && ((n-r*i-g*j) % b) == 0)
			{
				ans++;
			}

		}
	}
	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
main(){
	int x,y,count;
	for(count = 1; ;count++){
		scanf("%d%d",&x,&y);
		if(x == 0 && y == 0)
			break;


		if(x < y){

			printf("%d %d\n",x, y);

		}else{
			printf("%d %d\n",y, x);

		}
	}
return 0;


}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
using Graph = vector<vector<ll> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    string s;
    cin >> s;
    if(s=="SSS"){
        cout << 0 << endl;
        return 0;
    }
    if(s[1]=='S'){
        cout << 1 << endl;
        return 0;
    }
    if(s=="RRR"){
        cout << 3 << endl;
        return 0;
    }
    if(s[0]=='R'||s[2]=='R'){
        cout << 2 << endl;
        return 0;
    }
    cout << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, s[10], c[10], ans[4];
bool vis[4];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	bool ok = true;
	for (int i = 0; i < m; i++) {
		cin >> s[i] >> c[i];
	}
	for (int i = 0; i < m; i++) {
		if (vis[s[i]]) {
			if (ans[s[i]] != c[i]) {
				ok = false;
				break;
			}
		}
		else {
			vis[s[i]] = true;
			ans[s[i]] = c[i];
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			if (i == 1 && n > 1) ans[i] = 1;
			else ans[i] = 0;
		}
	}
	if (ok) {
		if (ans[1] == 0 && n > 1) ok = false;
	}
	if (ok) {
		for (int i = 1; i <= n; i++) {
			cout << ans[i];
		}
	}
	else cout << -1;
	cout << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<int> v[101010];

int dp[101010];

int search(int x) {
	if (dp[x]) return dp[x]+1;
	int r = 0;
	for (auto c : v[x]) {
		r = max(r, search(c));
	}
	dp[x] = r;
	return r+1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;

		v[a].push_back(b);
	}
	int mx = 0;
	for (int i = 1; i <= n; ++i) mx = max(mx, search(i) - 1);
	cout << mx << '\n';
}


Measured memory_bytes: 8192
#include <stdio.h>

int gcd(int s, int t)
{ 
  if(s % t == 0)
     return t; 
     
     return gcd(t, s % t); 
}

int main (void)
{
 int k,a,b,c;
 long long int sum = 0; 
  
  scanf("%d", &k);
  
  for(a=1;a<=k;a++){    
    for(b=1;b<=k;b++){        
      for(c=1;c<=k;c++){
         sum+=gcd(a,gcd(b,c));
      }
    }
  }
  
  printf("%lld", sum);
  
  return 0;
            
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;
	cin>>n;
	vi x(n);
	rep(i,n)cin>>x[i];

	vi a(n);
	rep(i,n)a[i]=x[i];
	sort(all(a));
	int k=a[n/2-1],l=a[n/2];

	rep(i,n){
		if(l<=x[i]){
			cout<<k<<endl;
		}else{
			cout<<l<<endl;
		}
	}


	return 0;


}


Measured memory_bytes: 6336
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N;
	cin >> N;

	if (N / 10 == 9 || N % 10 == 9) { cout << "Yes"; }
	else { cout << "No"; }


	system("PAUSE");

	

}


Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			string s = Console.ReadLine();
			char[] chars = s.ToArray();
			var chars2 = chars.Distinct().ToArray();
			if (chars.Length == chars2.Length)
			{
				Console.WriteLine($"yes");
			} else
			{
				Console.WriteLine($"no");
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13276
#include<bits/stdc++.h>
using namespace std;
long N,i,j,k,F[101][11],P[101][11],ans=LONG_MIN,cost,cnt;
int main(){
  cin>>N;
  for(i=0;i<N;i++)for(j=0;j<10;j++)cin>>F[i][j];
  for(i=0;i<N;i++)for(j=0;j<11;j++)cin>>P[i][j];
  for(i=1;i<1<<10;i++){
    cost=0;
    for(j=0;j<N;j++){
      cnt=0;
      for(k=0;k<10;k++)if((i&1<<k)&&F[j][k])cnt++;
      cost+=P[j][cnt];
    }
    ans=max(ans,cost);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;


int main (){
    int N;
    cin>>N;
    vector<int> V(N);
    int Count=0;
    int Border=0;
    for(int i=0; i<N; i++){
        cin>>V.at(i);
        if(V.at(i)>Border-1){
            Border=V.at(i);
            Count ++;
        }
    }
    cout<<Count<<endl;
   

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,f[100001];
int bb(int p){
	if(f[p]==p)return p;
	return f[p]=bb(f[p]);
}
int main(){
	cin>>n>>m;
	int i,x,y,z,t=m;
	for(i=1;i<=n;i++)f[i]=i;
	for(i=1;i<=m;i++){
		cin>>x>>y>>z;
		if(bb(x)==bb(y))t--;
		else f[bb(x)]=bb(y);
	}
	cout<<n-t;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<assert.h>

using namespace std;
 
#define pb push_back
#define mp make_pair
#define f first
#define s second
 
#define all(s) s.begin(),s.end()
#define spresent(s,v) ((s).find(v)!=s.end())
#define present(s,v) (find(all(s),v)!=s.end())
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL)
 
#define fill_1d(a,val) fill(a,a+sizeof(a)/sizeof(a[0]),val)
#define fill_2d(a,val) fill(&a[0][0],&a[0][0]+sizeof(a)/sizeof(a[0][0]),val)
#define fill_nd(a,p2f,val) fill(p2f,p2f+sizeof(a)/sizeof(*p2f),val)
 
#define deb(x) cout<<#x<<" = "<<x<<endl
#define dout(i,s) cout<<"Case #"<<i<<": "<<s<<"\n"
#define hout(i) cout<<"Case #"<<i<<": "

#define For(a,n) for(int i=a; (a<n?i<n:i>n) ; (a<n?++i:--i))
 
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
typedef struct node{
	ll val,more=0,less=0;
	bool operator <(const node& a){
		return val<a.val;
	}
}node;

struct House{
	int start, end, height;
};
ostream& operator << (ostream &os, const House &s) {
	return (os << "Start: " << s.start << ", End: " << s.end << ", Height: " << s.height);
}

struct Segment{
	int start, end, height;
	ll perimeter;
};
ostream& operator << (ostream &os, const Segment &s) {
	return (os << "Start: " << s.start << ", End: " << s.end << ", Height: " << s.height << ", Perimeter: " << s.perimeter);
}
bool operator <(const Segment& x, const Segment& y) {
    return x.start < y.start;
}



const int N = 50;
const int MOD = 1e9+7;



void solve(){


}


int main() {

	string n;

	ll sum =0;

	cin>>n;
	int sz = n.length();
	for(int i=0;i<sz;++i) {
		sum+=n[i]-'0';
	}

	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";








	return 0;
}





Measured memory_bytes: 3756
// in the name of god 
// vaght hast vali kam ast !

#include <bits/stdc++.h>
using namespace std ;

const int MAXN = 1e6 + 100 ;

int a[MAXN] ; 
int32_t main(){
	ios_base::sync_with_stdio(0) ;
	cin . tie(0) ; cout . tie(0) ; 

	int n ; cin >> n ; 
	int mn = MAXN , mx = 0 ; 
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i] ; 
		mn = min(a[i] , mn) ; 
		mx = max(a[i] , mx) ; 
	}
	if(mn == mx){
		if(mn > n / 2 && (mn != n - 1)) cout << "No\n" ; 
		else cout << "Yes\n" ; 
	} else if(mx > mn + 1){
		cout << "No\n" ; 
	} else {
		int num = 0 ; 
		for(int i = 0 ; i < n ; i ++)
			num += (mn == a[i]) ;  
		if(mn < num){cout << "No\n" ; return 0 ;}
		if((n - num) / 2 + num < mx){cout << "No\n" ; return 0 ;}
		cout <<"Yes\n" ; 
	}

}

Measured memory_bytes: 640
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N; cin >> N;
    while(N > 1000){
        N -= 1000;
    }
    pt(1000 - N);
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

string s;

int main(void)
{
  cin >> s;
  int n = s.size();
  int cnt= 0;
  for(int i = 0; i < s.size(); i++) if(s[i] == 'o') cnt++;
  if(cnt + 15-n >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			Integer[] ary = new Integer[2];
			ary[0] = scan.nextInt();
			ary[1] = scan.nextInt();
			
			Arrays.sort(ary);
			
			int divisor = 0, temp = 0;
			long multiple = 0;
			
			if(ary[0] != 0) {
				int m = ary[1];
				int n = ary[0];
				
				while(true) {
					if(m % n != 0) {
						temp = n;
						n = m % n;
						m = temp;
					}
					
					else if(m % n == 0){
						divisor = n;
						break;
					}
				}
			}
			
			else {
				divisor = ary[1];
			}
			
			multiple = (ary[0] * (long)ary[1]) / divisor;
			
			
			System.out.println(divisor + " " + multiple);
		}
	}
}

Measured memory_bytes: 17368
#include <stdio.h>

#define MAX_V 1000001
int prime [MAX_V];

int main()
{
	int i, k, n, a=0, b=0;
	int cnt[MAX_V];

	for(i=2; i<MAX_V; i++)
	{
		prime[i] = 1;
	}

	for(i=2; i*i<=MAX_V; i++)
	{
		if(prime[i])
		{
			for(k=2*i; k<MAX_V; k+=i)
			{
				prime[k] = 0;
			}
		}
	}

	for(i=2; i<MAX_V; i++)
	{
		if(prime[i])
		{
			b++;
		}
		cnt[i] = b;
	}

	while(scanf("%d",&n)!= EOF)
	{
		printf("%d\n",cnt[n]);
	}
	return 0;
}

Measured memory_bytes: 10484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = 3.14159265358979;

long double maxd(long double x, long double y){
    if(x>=y) return x;
    else return y;
}

long double mind(long double x, long double y){
    if(x>=y) return y;
    else return x;
}

int main() {
    long double A,B,H,M; cin>>A>>B>>H>>M;
    long double rH = PI*(H+M/60.0)/6.0;
    long double rM = PI*M/30.0;
    long double r = mind(maxd(rH-rM,rM-rH),2.0*PI-maxd(rH-rM,rM-rH));
    
    long double tmp = A*A + B*B - 2.0*A*B*cos(r);
    cout << setprecision(14) << sqrt(tmp) << endl;
}

Measured memory_bytes: 4072