akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


int main()
{
	int n, k; cin >> n >> k;

	int ans = 0;
	REP(_i, n)
	{
		int a; cin >> a;
		if (a >= k) ++ans;
	}

	cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF 1000000001
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  ll A,B;
  cin>>A>>B;
  A--;
  vector<ll>a(64,0),b(64,0);
  for(int i=1;i<=64;i++){
    a[i-1]+=A/(ll)pow(2,i)*(ll)pow(2,i-1);
    b[i-1]+=B/(ll)pow(2,i)*(ll)pow(2,i-1);
  }
  for(int i=1;i<=64;i++){
    a[i-1]+=max(0ll,A%(ll)pow(2,i)-(ll)pow(2,i-1)+1);
    b[i-1]+=max(0ll,B%(ll)pow(2,i)-(ll)pow(2,i-1)+1);
  }
  ll ansA=0,ansB=0;
  for(int i=0;i<64;i++){
    if(a[i]%2){
      ansA+=pow(2,i);
    }
    if(b[i]%2){
      ansB+=pow(2,i);
    }
  }
  cout<<(ll)(ansA^ansB)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
 
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}
 
ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}
 
ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return 
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}
 
 
 
/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;

int main()
{
    IO;
	int n;
	string s;
	cin>>n>>s;
	int cnt = 0;
	for(int i =0 ;i +2 < n; i++){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        k: i32,
        a: i32,
        b: i32,
    }
    let c = b / k;
    println!("{}", if a <= c * k {"OK"} else {"NG"});
}


Measured memory_bytes: 2080
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-14 21:12:01 +0900
# LastModified: 2020-06-14 21:21:36 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))    
    if n==0:
        print(x)
        return
 
    for i in range(0,200):
        if not x-i in p:
            print(x-i)
            return 
        if not x+i in p:
            print(x+i)
            return
            


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
#include <iostream>
using namespace std;
int n, d[3003][3003] = {};
string s;
int main() {
    cin >> n >> s;
    for (int i = 0; i < n; i++) d[1][i] = 1;
    for (int i = 2; i <= n; i++) {
        int a = 0;
        if (s[i - 2] == '<') {
            for (int j = 0; j <= n - i; j++) {
                a = (a + d[i - 1][j]) % 1000000007;
                d[i][j] = (d[i][j] + a) % 1000000007;
            }
        } else {
            for (int j = n - i; j >= 0; j--) {
                a = (a + d[i - 1][j + 1]) % 1000000007;
                d[i][j] = (d[i][j] + a) % 1000000007;
            }
        }
    }
    cout << d[n][0] << '\n';
}


Measured memory_bytes: 35200
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
MOD = 10**9+7


def brute():
    S = input()[:-1]
    print(S)

    Q = [""]
    for c in reversed(S):
        tmp = []
        if c == "?":
            print("?")
            for q in Q:
                for i in range(0, 10):
                    tmp.append(str(i)+q)
        else:
            for q in Q:
                tmp.append(c+q)
        Q = tmp

    Q = sorted(Q)
    cnt = 0
    for q in Q:
        if int(q) % 13 == 5:
            cnt += 1
            print(int(q))
    print(cnt)
    print(cnt % MOD)


def solve():
    S = input()[:-1]
    # dp[i+1][j]イバン目まで見て、あまりがjのこすう
    dp = [[0]*13 for _ in range(len(S)+1)]
    dp[0][0] = 1

    S = list(reversed(S))
    for i in range(len(S)):
        if S[i] == "?":
            #dig = 10**i
            dig = pow(10, i, 13)
            for k in range(10):
                for j in range(13):
                   # dp[i+1][j] += dp[i][(k*dig+j) % 13]
                    dp[i+1][(k*dig+j) % 13] += dp[i][j]
                    dp[i+1][(k*dig+j) % 13] %= MOD

            pass
        else:
            dig = pow(10, i, 13)
            #dig = 10**i
            for j in range(13):
                dp[i+1][(int(S[i])*dig+j) % 13] += dp[i][j]
                #dp[i+1][j] = dp[i][(int(S[i])*dig+j) % 13]
                dp[i+1][(int(S[i])*dig+j) % 13] %= MOD

    ans = dp[-1][5]
    print(ans)


solve()


Measured memory_bytes: 64988
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int unsigned long long
#define F first 
#define S second
#define P make_pair 


signed main(void){
 
    
    int n,m,q,p,r,ans,t;
    string s;
    vector<int> v;
    ans=0;
    cin>>n>>m>>p;
    
    
    cout<<p<<" "<<n<<" "<<m<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

typedef pair<int, ll> type;
typedef pair<ll, type> event;

int main() {
   int N, Q;
   cin >> N >> Q;

   vector<event> v;
   for (int i = 0; i < N; i++) {
      int s, t, x;
      cin >> s >> t >> x;
      v.push_back({s - x, type(-1, x)});
      v.push_back({t - x, type(0, x)});
   }
   for (int i = 0; i < Q; i++) {
      int d;
      cin >> d;
      v.push_back({d, type(1, i)});
   }

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

   vector<ll> res(Q);
   multiset<ll> log;
   for (auto p : v) {
      int type = p.second.first;
      ll val = p.second.second;
      if (type == - 1) log.insert(val);
      else if (type == 0) log.erase(log.lower_bound(val));
      else res[val] = (log.empty() ? - 1 : *(log.begin()));
   }
   for (auto p : res) cout << p << endl;
   return 0;
}


Measured memory_bytes: 26596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<cassert>

using namespace std;

typedef long long ll;

typedef pair<int,pair<pair<int,int>,int>> P;

int di[]={0,-1,0,1};
int dj[]={1,0,-1,0};

int gcd(int a,int b)
{
	if(a<b) swap(a,b);
	if(b==0) return a;
	return a%b==0?b:gcd(b,a%b);
}

struct ST
{
	private:
		int n;
		vector<int> node;

	public:
		ST(vector<int> v)
		{
			int size=v.size();
			n=1;
			while(n<size) n*=2;
			node.resize(2*n-1,0);

			for(int i=0;i<size;i++) node[i+n-1]=v[i];
			for(int i=n-2;i>=0;i--) node[i]=gcd(node[2*i+1],node[2*i+2]);
		}

		void update(int x,int v)
		{
			x+=n-1;
			node[x]=v;
			while(x>0)
			{
				x=(x-1)/2;
				node[x]=gcd(node[2*x+1],node[2*x+2]);
			}
		}

		int get(int a,int b,int k=0,int l=0,int r=-1)
		{
			if(r<0) r=n;
			if(r<=a||b<=l) return 0;
			if(a<=l||r<=b) return node[k];

			int vl=get(a,b,2*k+1,l,(l+r)/2);
			int vr=get(a,b,2*k+2,(l+r)/2,r);
			return gcd(vl,vr);
		}
};

struct ST_
{
	private:
		int n;
		vector<int> v;

	public:
		ST_(vector<int> a)
		{
			n=1;
			while(n<a.size()) n*=2;
			v.resize(n*2-1,0);

			for(int i=0;i<a.size();i++) v[i+n-1]=a[i];
			for(int i=n-2;i>=0;i--) v[i]=gcd(v[i*2+1],v[i*2+2]);
		}

		void update(int x,int val)
		{
			x+=n-1;
			v[x]=val;
			while(x>0)
			{
				x=(x-1)/2;
				v[x]=gcd(v[x*2+1],v[x*2+2]);
			}
		}

		int get(int a,int b,int k=0,int l=0,int r=-1)
		{
			if(r==-1) r=n;

			if(r<=a||b<=l) return 0;
			if(a<=l&&r<=b) return v[k];

			int vl=get(a,b,k*2+1,l,(r+l)/2);
			int vr=get(a,b,k*2+2,(r+l)/2,r);
			return gcd(vl,vr);
		}
};

int main()
{
	int n;
	cin>>n;

	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];

	auto st=ST_(a);
	int res=0;
	for(int i=0;i<n;i++)
	{
		st.update(i,0);
		res=max(res,st.get(0,n));
		st.update(i,a[i]);
	}

	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
	double dis, a,b,c,d;
	scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
	dis = sqrt((a-c)*(a-c)+(b-d)*(b-d));
	printf("%.8f\n", dis);
	
	return 0 ;
}


Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;

long long ap(long long a, long long p){
  if (p == 0){
    return 1;
  }else{
    long long sum = (a % nmax) * (a % nmax);
    sum = sum % nmax;

    if (p % 2 == 0){
      return ap(sum, p / 2) % nmax;
    }else{
      return ((a % nmax) * ap(sum, p / 2)) % nmax;
    }
  }
}

long long nCr(long long n, long long r){
  long long ans = 1;
  for (int i = 0; i < r; i++){
    ans = (ans * (n - i)) % nmax;
    ans = (ans * (ap(r - i, nmax - 2) % nmax)) % nmax;
  }
  return ans;
}

int main(){

  int N, M; cin >> N >> M;

  vector <int> kosuu;

  int orM = M;
  for (int i = 2; i * i <= orM; i++){
    int num = i, cnt = 0;
    while (M % num == 0){
      cnt++;
      M = M / num;
    }
    if(cnt != 0) kosuu.push_back(cnt);
  }
  if(M != 1) kosuu.push_back(1);

  long long ans = 1;
  for (int i = 0; i < kosuu.size(); i++){
    ans = ans * nCr(N + kosuu[i] - 1, kosuu[i]);
    ans = ans % nmax;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

namespace _0522
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string now = Console.ReadLine();
                if (now == null)
                {
                    break;
                }
                int JOI = 0;
                int IOI = 0;
                for (int i = 0; i < now.Length; i++)
                {
                    if(now[i]=='J')
                    {
                        if(now[i+1]=='O')
                        {
                            if(now[i + 2] == 'I')
                            {
                                JOI++;
                            }
                        }
                    }
                    if (now[i] == 'I')
                    {
                        if (now[i + 1] == 'O')
                        {
                            if (now[i + 2] == 'I')
                            {
                                IOI++;
                            }
                        }
                    }
                }
                Console.WriteLine(JOI);
                Console.WriteLine(IOI);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9044
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int LINF=1e18;
const int MOD=1e9+7;
//
int main(){
    VE v;
    long int n,sum=0; cin>>n;
    FOR(i,0,n){
        int a; cin>>a;
        v.PB(a);
        sum+=a;
    }
    long int csum=0,m=LINF;
    FOR(i,0,v.size()-1){
        csum+=2*v[i];
        m=min(m,abs(csum-sum));
    }
    cout<<m<<endl;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;





signed main()
{
#ifndef ONLINE_JUDGE
	// freopen("out.txt", "w", stdout);
#endif
	int k, a, b;
	cin >> k >> a >> b;
	int x = b - a;
	int r = a % k;
	if(r + x >= k || r == 0) {
		puts("OK");
	} else {
		puts("NG");
	}


    
	return 0;
}

Measured memory_bytes: 3592
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k, a[N], ans = INF1;
main() {
  file("threesum");
  ios;
  cin >> k >> n;
  fo(i, 1, n, 1) cin >> a[i];
  sort(a + 1, a + n + 1);
  chmin(ans, a[n]-a[1]);
  fo(i, 1, n, 1) {
    chmin(ans, k - a[i] + a[i - 1]);
    chmin(ans, a[i] + k - a[i + 1]);
  }
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n,r;
	scanf("%d %d",&n,&r);
	if(n<10){
		n=100*(10-n);
		n=n+r;
	}
	else{
		n=r;
	}
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans=0;
int main(int argc, char* argv[]){
  double a,b,c,sum;
  scanf("%lf",&a);
  printf("%.0lf\n",pow(a,2));
}


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

int main(){

  double ax,ay,bx,by,cx,cy,dx,dy;

  while(cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy){
    double vxab = bx - ax;
    double vyab = by - ay;
    double vxcd = dx - cx;
    double vycd = dy - cy;
    if(vxab*vxcd + vyab*vycd < 1e-10 && vxab*vxcd + vyab*vycd > -(1e-10)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a = 0;
		int sum = 0;
		for(int i = 0; i < m; i++) {
			a = sc.nextInt();
			sum += a;
		}
		if(sum>n) {
			System.out.println(-1);
		}else {
			System.out.println(n-sum);
		}
		
	}
	
}


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

int main() {
	int n;
	bool f[100][10];
	int p[100][11];
	int res = -(1 << 30);
	cin >> n;
	for (int i = 0; i < n * 10;i++) {
		cin >> f[0][i];
	}
	for (int i = 0; i < n * 11;i++) {
		cin >> p[0][i];
	}
	for (int b = 1; b < (1 << 10);b++) {
		int cc = 0;
		for (int i = 0; i < n;i++) {
			int c = 0;
			for (int j = 0; j <10; j++) if ((b >> j & 1) && f[i][j]) c++;
			cc += p[i][c];
		}
		if (res < cc) {
			res = cc;
		}
	}
	cout << res;
}

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

int main() {
  int n, m, i, j, ans = 0, cnt;
  string s;
  cin >> n >> s;
  for (i = 0; i < n; i++) {
    cnt = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      bool l = false, r = false;
      for (j = 0; j < i; j++) {
        if (s[j] == c) {
          l = true;
        }
      }
      for (j = i; j < n; j++) {
        if (s[j] == c) {
          r = true;
        }
      }
      if (l & r) {
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << "\n";
}


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

int main() {
    double pi = 3.141592653589793;
    pi = asin(1) * 2;
    double A,B,H,M;cin >> A >> B >> H >> M;
    double t = (H * 60) + M;
    //double ra = t * (1 / 720) * pi * 2;
    //double rb = t * (1 / 60) * pi * 2;
    double ra = t / 720 * pi * 2;
    double rb = t / 60 * pi * 2;
    double ax = sin(ra) * A;double ay = cos(ra) * A;
    double bx = sin(rb) * B;double by = cos(rb) * B;
    double ans = pow(ax - bx,2) + pow(ay - by,2);
    ans = pow(ans,0.5);
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4196
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int a, b;
	
	scanf("%d", &a);
	scanf("%d", &b);

	if (a + b >= 10) {
		printf("error\n");
	}
	else {
		printf("%d\n", a + b);
	}
	return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin =new Scanner(System.in);
        String  s=cin.next();
        boolean sign=true;
        for(int i=0;i<s.length();i++)
        {
            char c=s.charAt(i);
            if(c=='U'||c=='D') continue;
            if( i%2==0 && c!='R' ){
                System.out.println("No");
                sign=false;
                break;
            }
            else if(i%2!=0 && c!='L'){
                System.out.println("No");
                sign=false;
                break;
            }
        }
        if(sign)
            System.out.println("Yes");
        cin.close();
    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct edge
{
    int to, cost;
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> g(n);
    for (int i = 0; i < m; i++)
    {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        g[l].emplace_back(edge{r, d});
        g[r].emplace_back(edge{l, -d});
    }
    // 根(0)からiまでの距離をdist[i]とする。
    vector<int> dist(n, INF);
    vector<bool> seen(n, false);
    bool ok = true;
    stack<pair<int,int>> st;
    for (int i = 0; i < n; i++)
    {
        if (!seen[i])
        {
            st.push(make_pair(i, 0));
        }
        while(st.size()){
            auto t = st.top(); st.pop();
            seen[t.first] = true;
            if(t.second != dist[t.first] && dist[t.first] != INF){
                ok = false;
            }else{
                dist[t.first] = t.second;
            }
            for(auto next:g[t.first]){
                if(!seen[next.to]){
                    st.push(make_pair(next.to, next.cost+dist[t.first]));
                }
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int N,C;cin>>N>>C;N++;
    int sum=0;
    rep(i,C){
        int n;cin>>n;
        sum+=n;
    }
    cout<<sum/N+min((int)1,sum%N)<<endl;
}



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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;


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

    int H, A;
    cin >> H >> A;
    int x = H/A;

    if (H%A) {
        ++x;
    }

    cout << x << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

  auto f = [&](int x) {
    string ss = "";
    REP(i,s.size()) {
      if (i >= x && i-x < t.size()) {
        if (s[i] != '?' && s[i] != t[i-x]) {
          return;
        }
        ss.push_back(t[i-x]);
      } else {
        ss.push_back(s[i] == '?' ? 'a' : s[i]);
      }
    }
    ans.push_back(ss);
  };

  REP(i,s.size() - (t.size()-1)) f(i);

  if (ans.size() > 0) {
    sort(ans.begin(), ans.end());
    COUT(ans[0]);
  } else  {
    COUT("UNRESTORABLE");
  }
  return 0;
}


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

int main() {
	int K;
	cin >> K;
	
	if(K%2==0){
		K = K/2;
		K = K*K;
	}else if(K%2==1){
		K = K/2;
		K = (K+1)*K;
	}
	
	cout << K;
	cout << endl;
	
	return 0;
}

/* 1からKまでの偶数と奇数の個数の積が組み合わせの個数 */
/* それぞれの個数は偶数ならKの半分個ずつ*/
/* 奇数なら奇数が1個だけ多くなる */

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int GCD = __gcd(a,b),counter=0;
  for (int i = GCD; i > 0; i--){
    if(GCD%i==0){
      counter++;
      if(counter==c) cout << i;
    }
  }
} 


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


typedef long long ll;
typedef vector < ll > vl;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
typedef vector < vpll > vvpll;

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> o_set;
 
#define pb push_back
#define pf push_front
#define FOR(i,x,y,z) for(i=(x);i<(y);i+=(z))
#define FOB(i,x,y,z) for(i=(x);i>(y);i-=(z))
#define REF(i,x) FOR(i,0,x,1)
#define REB(i,x) FOB(i,x-1,-1,1)
#define all(c) c.begin(), c.end()
#define tr(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define rtr(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define sz(c) (c).size()
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MAX 100000000

pll add_pair(pll a, pll b){return mp(a.ff+b.ff,a.ss+b.ss);}
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}

vvl G((ll)1e5+5, vl());
vl indeg((ll)1e5+5, 0), outdeg((ll)1e5+5, 0), dp((ll)1e5+5);
ll ans = 0;

void dfs(ll root){
    if(dp[root]!=0)return;
    tr(G[root],it){
        dfs(*it);
        dp[root]=max(dp[root],dp[*it]+1);
    }
    ans = max(ans, dp[root]);
}

int main(){
	boost;
	ll n, m, i, u, v;
	cin >> n >> m;
	REF(i,m){
	    cin >> u >> v;
	    G[u].pb(v);
	    indeg[v]++;
	    outdeg[u]++;
	}
	REF(i,n)dp[i+1] = 0;
	REF(i,n){
	    if(indeg[i+1] == 0){
	        dfs(i+1);
	    }
	}
	cout << ans << '\n';
	return 0;
}

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

/*
ループで回すと間に合わない。
a = p * x + c
b = (p * n) * x + c'
なので、nがわかれば答えがわかる。

e.g. 3 6 2
3 = 1 * x + 1
6 = 3 * x + 0
=> 2

aが割り切れる場合は +1
*/

int main() {
    long a, b, x;
    cin >> a >> b >> x;

    long res = 0;
    res += (b / x) - (a / x);
    if (a % x == 0)
        res++;
    cout << res << endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DRainFlowsIntoDams {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        ll n,k=-1,s=0;
        in>>n;
        vector<int> a(n);
        for(auto& i:a) in>>i,s+=i*(k*=-1);
        s/=2;
        fr(i,n){
            out<<2*s<<" ";
            s=a[i]-s;
        }
    }
};

int main() {
    DRainFlowsIntoDams solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  string s;
  cin>>s;

  int rev = 0;
  string fr,bc;

  int q;
  cin>>q;
  while(q--){
    int t;
    cin>>t;
    if(t==1){
      rev^=1;
    }else{
      int f;
      string c;
      cin>>f>>c;
      if(f==1){
        if(rev){
          bc+=c;
        }else{
          fr+=c;
        }
      }else{
        if(rev){
          fr+=c;
        }else{
          bc+=c;
        }
      }
    }
  }
  
  if(rev){
    reverse(s.begin(),s.end());
    reverse(bc.begin(),bc.end());
    cout<<bc<<s<<fr<<endl;
  }else{
    reverse(fr.begin(),fr.end());
    cout<<fr<<s<<bc<<endl;
  }

}

Measured memory_bytes: 1088
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m, x;
	cin >> n >> m >> x;
	while (m--)
	{
		int y;
		cin >> y;
		a[y] = 1;
	}
	cout << min(count(a, a + x, 1), count(a + x + 1, a + n + 1, 1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll f(vector<ll> A, ll a, ll b, ll c, ll x){
    ll g = a + b;
    ll ans = 0;
    for (ll i = 0; i < a; i++) {
        while(g < a+b+c && A[i] * A[g] >= x){
            g++;
        }
        ans += g-1 - (a+b-1);
    }

    return ans;
}

ll ff(vector<ll> A, ll a, ll b, ll c, ll x){
    ll g = a - 1;
    ll ans = 0;
    for (ll i = 0; i < a; i++) {
        while(g >= 0 && A[i] * A[g] < x){
            g--;
        }
        ans += g + 1;
        if(i <= g){
            ans--;
        }
    }
    ll h = a + b + c - 1;
    for (ll i = a+b; i < a+b+c; i++) {
        while(h >= a + b && A[i] * A[h] >= x){
            h--;
        }
        h++;
        ans += a + b + c - h;
        if(h <= i){
            ans--;
        }
        h--;
    }

    ans = ans / 2;
    return ans;
}


int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(ALL(A));
    ll a, b, c;
    a = 0; b = 0; c = 0;
    for (ll i = 0; i < N; i++) {
        if(A[i] < 0){
            a++;
        }
        else if(A[i] == 0){
            b++;
        }
        else{
            c++;
        }
    }

    ll ok;
    ll ng;
    ll mid;


    if( K <= a*c ){
        ok = - 1000000000000000000;
        ng = 0;
        while(ok + 1 < ng){
            mid = (ok + ng) / 2;
            if(f(A,a,b,c,mid) >= a*c - K + 1 && f(A,a,b,c,mid+1) >= a*c - K + 1){
                ok = mid+1;
            }
            else if(f(A,a,b,c,mid) < a*c - K + 1 && f(A,a,b,c,mid+1) < a*c - K + 1){
                ng = mid;
            }
            else{
                printf("%lld\n", mid);
                return 0;
            }
        }
        printf("%lld\n", ok);
    }
    else if( K <= a*c + b*(a+c) + b*(b-1)/2 ){
        printf("%lld\n", zero);
        return 0;
    }
    else{
        ng = 0;
        ok = 1000000000000000000;
        while( ng + 1 < ok ){
            mid = (ng + ok) / 2;
            if(ff(A,a,b,c,mid) >= N*(N-1)/2-K+1 && ff(A,a,b,c,mid+1) >= N*(N-1)/2-K+1){
                ng = mid;
            }
            else if(ff(A,a,b,c,mid) < N*(N-1)/2-K+1 && ff(A,a,b,c,mid+1) < N*(N-1)/2-K+1){
                ok = mid-1;
            }
            else{
                printf("%lld\n", mid);
                return 0;
            }
        }
        printf("%lld\n", ok);
    }






}

Measured memory_bytes: 7972
S = input()
lead = S[0]
sub = S[2:-1]
C = sub.count('C')
if lead == 'A' and C == 1:
  for x in range(1,len(S)):
    if S[x].islower() or S[x] == 'C':
      pass
    else:
      print('WA')
      exit()
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int R;
	cin>>R;
	if (R<1200){
		cout<<"ABC"<<endl;
	}else if (R<2800){
		cout<<"ARC"<<endl;
	}else{
		cout<<"AGC"<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
src = [list(input()) for i in range(H)]
ans=src

dxy = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)]
for y in range(H):
    for x in range(W):
        if src[y][x] == '#': continue
        c = 0
        for dx, dy in dxy:
            if x + dx < 0 or x + dx > W - 1 or y + dy < 0 or y + dy > H - 1: continue
            if src[y + dy][x + dx] == '#': c += 1
        ans[y][x] = c

for row in ans:
    print(''.join(list(map(str, row))))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;

int main(){
    string a,b;
    cin>>a;
    cin>>b;
    if(a.size()>b.size()){
        cout<<"GREATER"<<nl;
    }else if(b.size()>a.size()){
        cout<<"LESS"<<nl;
    }else{
    for(int i =0;i<a.size();i++){
        if(a[i]>b[i]){
            cout<<"GREATER"<<nl;
            
            return 0;
        }else if(a[i]<b[i]){
            cout<<"LESS"<<nl;
            return 0;
        }

    }
    cout<<"EQUAL"<<nl;
}
  
} 

Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,ll> P;

vector<P> V[110000];
ll d[110000];
int N,u,v;


void bfs(){
  queue<P> que;

  for(int i=0;i<N;i++){
    d[i]=INF;
  }

  que.push(P(0,0));

  d[0]=0;

  while(que.size()){
    P p=que.front(); que.pop();
    for(int i=0;i<V[p.first].size();i++){
        P x=V[p.first][i];
      if(d[x.first]==INF){
        que.push(P(x.first,x.second+p.second));
        d[x.first]=x.second+p.second;
      }
    }
  }

  return;
}


int main(){
    cin>>N;
    ll w;
    for(int i=0;i<N-1;i++){
        cin>>u>>v>>w;
        u--; v--;
        V[u].push_back(P(v,w));
        V[v].push_back(P(u,w));
    }

    bfs();
    for(int i=0;i<N;i++){
        if(d[i]%2==0) cout<<0<<endl;
        else cout<<1<<endl;
    }
}


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

int main (){
    int a;
    cin >> a;
    int p[] = {1,
               1,
               1,
               2,
               1,
               2,
               1,
               5,
               2,
               2,
               1,
               5,
               1,
               2,
               1,
               14,
               1,
               5,
               1,
               5,
               2,
               2,
               1,
               15,
               2,
               2,
               5,
               4,
               1,
               4,
               1,
               51};
    cout << p[a - 1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,pos=0;
	cin>>a>>b;
	while (1)
	{
		pos++;
		long long k=a*pos;
		if (k%b==0)
		{
			cout<<k<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>

using namespace std;


int top, S[1000];
void push(int x);
int pop();


int main() {
	int a, b;
	top = 0;
	char s[100];

	int t = 0;

	while (cin >> s) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}

	}

	cout << pop() << endl;

	return 0;
}

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}





Measured memory_bytes: 3100
# 高い物から足していく
def is_possible(arr_sorted, k, money):
  sum = 0
  for i in range(k):
    sum += arr_sorted[i]
    if sum > money:
      return False   
  return True

N, K  = [int(v) for v in input().split()]
p_arr = [int(v) for v in input().split()]
right = 1000 * 1000
left = 0
p_arr.sort()
while( right -left > 1):
  mid = (left+right) // 2
  if is_possible(p_arr, K, mid):
    right = mid
  else:
    left = mid
print(right)


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

int main(void) {
    int N, T, A;
    cin >> N;
    cin >> T;
    cin >> A;
    int D[1100];
    double min_diff = 999999;
    int result = -1;

    for (int i = 0; i < N; i++) {
        cin >> D[i];
        double diff = -1;
        /* 理想からどれだけ違うか. */
        double p = T - (D[i] * 0.006);
        if (A < p) diff = (p - A);
        else       diff = (A - p);

        /* 理想更新 */
        if (min_diff > diff) {
            min_diff = diff;
            result = i + 1;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
n,m=gets.chomp.split(" ").map(&:to_i);
ary =[]
hs = {}
m.times do |i|
  p,y=gets.chomp.split(" ").map(&:to_i);
  if hs[p].nil?
    hs[p] = [{year: y, idx: i}]
  else
    hs[p].push({year: y, idx: i})
  end
end
hs.each do |k, v|
  v.sort_by!{|x| x[:year]}
  v.each_with_index{|x,i| x[:id] = i+1; x[:ken] = k}
end
hs.values.flatten.sort_by{|x| x[:idx]}.each do |y|
  print("#{format("%06d%06d",y[:ken],y[:id])}\n")
end

Measured memory_bytes: 46456
def is_fizz(n):
  return True if (n % 3 == 0) else False

def is_buzz(n):
  return True if (n % 5 == 0) else False

def is_fizzbuzz(n):
  return True if (n % 3 == 0 and n % 5 == 0) else False

N = int(input())
sum = 0
for n in range(1, N + 1):
  if not is_fizz(n) and not is_buzz(n) and not is_fizzbuzz(n):
    sum += n
print(sum)

Measured memory_bytes: 9040
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(void){
    int n,k;cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a.begin(),a.end());

    ll facl = 1;
    for(ll i = 1;i <= n;i++)facl = (facl * i) % mod;

    vector<mint> dp(100010,0);
    dp[k] = (mint)1;
    for(ll x = k;x >= 1;x--){
        if(dp[x].x == 0)continue;
        mint cnt = 0;
        for(ll i = 0;i < n;i++){
            if(a[i] <= x)cnt = cnt + (mint)1;
        }
        if(cnt.x == 0){
            continue;
        }
        for(ll i = 0;i < n;i++){
            if(a[i] <= x){
                dp[x % a[i]] += dp[x]/cnt;
            }
        }
        dp[x] = 0;
    }
    mint sum = 0;
    for(ll x = k;x >= 0;x--){
       sum += (mint)x * dp[x];
    }
    sum *= facl;
    cout << sum.x << '\n';
}


Measured memory_bytes: 1024
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    n = int(input())
    x1 = n // 500
    n -= x1 * 500
    x2 = n // 5
    print(1000 * x1 + 5 * x2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=5;
    int arr[n],p;
    for(int i=1;i<=5;i++){
        cin>>arr[i];
        if(arr[i]==0){
        p=i;}
        
    }
    cout<<p;
    return 0;
    
}

Measured memory_bytes: 3556
n = input()

A = map(int, raw_input().split())
   
q = input()
   
M = map(int, raw_input().split())
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"

Measured memory_bytes: 6448
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,cnt=0;
  cin>>a>>b>>c;
  if(a==b and b==c and a%2==0 and b%2==0 and c%2==0){
    cout<<"-1"<<endl;
    return 0;
  }
  for(int i=0; i<1000000000; i++)
  {
    if(a%2+b%2+c%2!=0)break;
    int x=0,y=0,z=0;
    x+=b/2; x+=c/2;
    y+=a/2; y+=c/2;
    z+=a/2; z+=b/2;
    a=x; b=y; c=z;
    cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
N = int(input())
n = [int(input()) for i in range(N)]

def Is_prime(n):
    if n == 2:
        return True
    if n == 1:
        return False
    if n % 2 == 0:
        return False
    i = 3
    while i < int(n ** (0.5))+ 1:
        if n % i == 0:
            return False
        i += 2
    return True

count = 0
for j in n:
    if Is_prime(j):
        count += 1

print (count)

Measured memory_bytes: 8168