akhauriyash/Code-Regression huggingface dataset:
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s)
    {
    	cout<<"Yes";
    }
    else
    {
    	cout<<"No";
    }
    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int roop,K,stk;
    int c = 0;
    cin >> roop >> K;
    for(int i=0;i<roop;i++){
        cin >> stk;
        c += min(stk,K-stk) * 2;
    }
    cout << c << endl;
    return 0;
}


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

using namespace std;

int main(){
	string s; cin >> s;
	bool f[26] = {};
	for(int i = 0; i < s.length(); i++) f[s[i] - 'a'] = 1;
	int res = 26;
	for(int i = 0; i < 26; i++) if(!f[i]){
		res = i; break;
	}
	if(res == 26) cout << "None" << endl;
	else cout << (char)('a' + res) << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int r,c;
    cin >> r >> c;
    int a[r+1][c+1]={};
    F(i,0,r) F(j,0,c) cin >> a[i][j];
    F(i,0,r){
        F(j,0,c){
            a[i][c]+=a[i][j];
            a[r][j]+=a[i][j];
            a[r][c]+=a[i][j];
        }
    }
    F(i,0,r+1){
        F(j,0,c+1){
            cout << a[i][j];
            if(j!=c) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
signed main() {
	string s, t = "keyence"; cin >> s;
	if (s.size() < 7) {
		cout << "NO\n";
		return 0;
	}
	for0(i, 7) {
		if (s.substr(0, 7 - i) == t.substr(0, 7 - i) && s.substr(s.size() - i, i) == t.substr(7 - i, i)) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    ll t=0;
    int n=s.size();
    for(int i=0;i<(1<<(n-1));i++){
        ll a=s[0]-'0';
        for(int j=0;j<n;j++){
            if(j==n-1 || i&(1<<j)){
                t+=a;
                a=0;
            }
            a=10*a+s[j+1]-'0';
        }
    }
    cout<<t<<endl;
}


Measured memory_bytes: 256
S = list(str(input()))
T = list(str(input()))
s = 0
t = 0
len_s = len(S)
len_t = len(T)
i = 0
ans = []

while i < len_s-len_t+1:
    cnt = 0
    #print(S[i:i+len_t])
    for ss, tt in zip(S[i:i+len_t], T):
        #print(ss,tt)
        if ss != tt:
            cnt +=1
    ans.append(cnt)
    i += 1

#print(ans)
print(min(ans))

Measured memory_bytes: 9124
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef double long dl;
typedef pair < ll , ll > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 2e6 + 2;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;
 
#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue
#define getsz(x) (int) log10(x)
 
int n, a, b;
ll q[maxn], p[maxn];
ll ans;
int main(){
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        cin >> q[i];
        if(i > 1){
            p[i - 1] = (q[i] - q[i - 1]) * a;
        }
    }
    sort(p + 1, p + n);
    for(int i = 1; i < n; i++){
        if(p[i] > b){
            ans += b;
        }
        else {
            ans += p[i];
        }
    }
    cout << ans;
}

Measured memory_bytes: 5120
a,b,k=map(int,input().split())
if (b-a+1)//2>=k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

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


bool pos[12][5010] = {};
bool dp[5010][1<<12];
bool dn[5010][1<<12];
string p[12];
string s;

int n,m;
bool dfs(int x,int bit){
	if( bit == 0 ) return 1;
	if( dn[x][bit] ) return dp[x][bit];
	bool ans = 0;
	for(int i = 0 ; i < n ; i++){
		if( (bit >> i & 1) && pos[i][x] ){
			ans |= dfs(x+p[i].size(),bit^(1<<i));
			if(ans)break;
		}
	}
	dn[x][bit] = true;
	return dp[x][bit] = ans;
}

int main(){
	while( cin >> n >> m && n ){
		memset(dp,0,sizeof(dp));
		memset(dn,0,sizeof(dn));
		memset(pos,0,sizeof(pos));
		
		
		for(int i = 0 ; i < n ; i++) cin >> p[i];
		s = "";
		for(int i = 0 ; i < m ; i++){
			string c; cin >> c;
			s += c;
		}
		for(int j = 0 ; j < n ; j++){
			for(int i = 0 ; i + p[j].size() <= s.size() ; i++){
				int f = 1;
				for(int k = 0 ; k < p[j].size() ; k++)
					if( p[j][k] != s[i+k] ){ f = 0; break; }
				if(f) pos[j][i] = 1;
			}
		}
		int ans = 0;
		for(int i = 0 ; i < s.size() ; i++){
			if( dfs(i,(1<<n)-1) ){
				ans++;
			}
		}
		cout << ans << endl;
		
	}
}

Measured memory_bytes: 41372
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
    L d=I->first;if(d-P[a])P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}
L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L x,L i){for(x=G(x)-M(i+1)+M(i++);i<1<<17;B[i]+=x,i+=i&-i);}
L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
main(){for(cin>>n>>k;++p<n;path[a][b]=path[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33464
// Aizu Vol0 // Aizu Vol0 0030: Sum of Integers
// 2017.8.1

#include <stdio.h>
#include <stdlib.h>

int combi(int n, int s, int min)
{
	int i, ans;

	if (min == 10 || min > s) return 0;
	if (n == 1) return s < 10;

	ans = 0;
	for (i = min; i < 10; i++) ans += combi(n - 1, s - i, i+1);
	return ans;
}

int main()
{
	int n, s;

	while (1) {
		scanf("%d%d", &n, &s);
		if (n < 1) break;
		printf("%d\n", combi(n, s, 0));
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void) {
	int n,i,ii,s1,s2,s3,s4,s5,max,min;
		while(scanf("%d",&ii), ii != 0){
			for(i = 1;i <= ii;i++){
				scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
				n = s1 + s2 + s3 + s4 + s5;
				if (i == 1){
					max = n;
					min = n;
				}
				else{
					if (max < n){
						max = n;
					}
					if (min > n){
						min = n;
					}
				}
			}
			printf("%d %d\n",max,min);
		}
	return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n,x;
	std::cin >> n >> x;
	std::vector<int> a(n);
	for (size_t i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	sort(a.begin(),a.end());
	int count = 0;
	for (size_t i = 0; i < n; i++) {
		if (x <= 0 || x < a[i]) {
			x -= a[i];
			break;
		}
		count++;
		x -= a[i];
	}

	if (x > 0) {
		count--;
	}

	std::cout << count << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{  

	public static void main(String[] args) {   
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int K = I.nextInt();
		long ans = 0;
		long choices = N/K;
		ans+=choices*choices*choices; //All multiples of K <= N
		//Odd numbers don't have identity N=2x, therefore special modular numbers won't work
		//for them when added pairwise
		if (K%2==0) { //Special modular numbers as well
			choices = 0;
			for (int chk = K/2; chk<=N; chk+=K) { //All numbers that have remainder K/2
				//when added pairwise, K/2+K/2 contributes as a multiple of K
				choices++;
			}
			ans+=choices*choices*choices;
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				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());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25588
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = []

for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []

for ab in AB[:K]:
    for c in C:
        ABC.append(ab + c)

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])


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

int main(){
  int n,m;
  cin >> n>>m;
  vector<uint64_t> h(n);
  for(auto &it :h){
    cin >> it;
  }
  
  set<int> good;
  for(int i=0; i<n;i++){
    good.insert(i);
  }
  
  for(int i=0; i<m;i++){
    int a,b;
    cin >> a>>b;
    a--; b--;
    if(h.at(a) == h.at(b)){
      good.erase(a);
      good.erase(b);
    }
    if(h.at(a)<h.at(b) )
      good.erase(a);
    if(h.at(b)<h.at(a) )
      good.erase(b);
  }
  cout << good.size() <<endl;
}


Measured memory_bytes: 8800
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

int ds[13] = {0, 1, -1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1};
string st[7] =  {"Monday",
                "Tuesday",
                "Wednesday",
                "Thursday",
                "Friday",
                "Saturday",
                "Sunday"};

signed main(){
    int m, d;
    while(cin >> m >> d){
        if(m + d == 0) break;
        int s = 30 * (m - 1) + d;
        rep(i, 1, m){
            s += ds[i];
        }
        s = (s + 2) % 7;
        o(st[s]);
    }
}

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

using namespace std;

int main() {

	int a, b;
	cin >> a >> b;

	int counter=0;
	for (int i = a; i <= b; i++) {
		if (i / 10000 == i % 10 && i / 1000 - (i / 10000)*10 == (i % 100 - i % 10)/10) {
			counter++;
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
def cal(a):
    a = int(str(a)[-1])
    b = 0
    if not a == 0:
        b = 10 - a
    return b

a = [int(input()) for _ in range(5)]
b = list(map(cal, a))
ans = 0

for i in range(5):
    index = b.index(min(b))
    ans += a[index]
    if not i == 4:
        ans += b[index]
    b[index] = 124

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   char n[2];
   cin >> n[0] >> n[1];
   cout << ((n[0] == '9' or n[1] == '9')? "Yes" : "No") << endl;
   return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100 + 5;
const int V = 1e3 + 5;
const ll INF = 1e18;

int main() { 
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    vector<int> weight(n), value(n);
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> value[i];
    }
    int sum = 0;
    for (int x : value) {
        sum += x;
    }
    vector<ll> dp(sum + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = sum - value[i]; j >= 0; j--) {
            dp[j + value[i]] = min(dp[j + value[i]], 1LL * weight[i] + dp[j]);
        }
    }
    int ans = 0;
    for (int j = sum; j >= 0; j--) {
        if (dp[j] <= w) {
            ans = j;
            break;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

A, B, C, D = map(int, input().split())

# B以下の整数で、CでもDでも割り切れないものの個数
ans_B = B - B//C - B//D + B//(C*D//gcd(C, D))
# A-1以下の整数で、CでもDでも割り切れないものの個数
ans_A = (A-1) - (A-1)//C - (A-1)//D + (A-1)//(C*D//gcd(C, D))

print(ans_B - ans_A)


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

int main() {
	ios_base::sync_with_stdio(false);
	int n, k, a[200000],x[200000];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x[i]=0;
	}
	for(int i=0;i<n;i++){
		x[a[i]-1]++;
	}
	sort(x,x+n);
	int ans=n;
	for(int i=0;i<k;i++){
		ans-=x[n-i-1];
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 110;
int _w;

int n, k, change[N], c1, c0;
char s[N];

int solve1() {
	int ans = 0;
	for( int i = 2; i <= n; ++i ) {
		if( s[i] == s[i-1] ) {
			change[i] = true;
			++i;
			++ans;
		}
	}
	return c1 = ans;
}

int solve2() {
	memset(change, 0, sizeof change);
	s[0] = s[n];
	int ans = 0;
	for( int i = 1; i <= n; ++i ) {
		if( s[i] == s[i-1] ) {
			change[i] = true;
			++i;
			++ans;
		}
	}
	return c0 = ans;
}

ll solve() {
	solve1();
	if( change[n] ) {
		return ll(k) * c1;
	} else {
		solve2();
		if( change[n] ) {
			return c0 * ll(k/2) + c1 * ll(k-k/2);
		} else {
			return c1 + ll(k-1) * c0;
		}
	}
}

int main() {
	_w = scanf( "%s", s+1 );
	n = (int)strlen(s+1);
	_w = scanf( "%d", &k );
	printf( "%lld\n", solve() );
	return 0;
}


Measured memory_bytes: 3828
#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;
#define faster ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
#define ld long double
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int mod = 1e9+7;
const int mod1 = 998244353;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int, int>&i, const pair<int, int>&j) {
    return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
   ll n;
   cin >> n;

   vector<ll> v(n);
   for(int i = 0; i < n; ++i) {
      cin >> v[i];
   }

   //vector<ll> x(n);
   ll xr = 0;
   for(int i = 0; i < n; i++) {
      xr ^= v[i];
   }

   for(int i = 0; i < n; i++) {
      cout << (xr ^ v[i]) << " ";
   }
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   faster;
   cout.precision(10);
   cout << fixed;

   int t = 1;
   //cin >> t;
   while(t--)
      test();

   return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll r;
    cin >> r;
    cout << r * r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    int i;
    int max = p;
    if(max < q) {
        max = q;
    }
    if(max < r){
        max = r;
    }

    if(max == p) {
        cout << r+q << endl;
    }else if(max == q) {
        cout << p+r << endl;
    }else if(max == r) {
        cout << p+q << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def recursion(queue, data, res)
  if data.size == 0
    res << queue.inject(0, :+)
  else
    d = data.slice(1..data.size)
    res = recursion(queue, d, res)
    res = recursion(queue + [data[0]], d, res)
  end
end

# main
n = gets.to_i
ary = gets.split(' ').map(&:to_i)
q = gets.to_i
targets = gets.split(' ').map(&:to_i)

res = recursion([], ary, [])
targets.each{ |t|
  if res.include?(t)
    puts 'yes'
  else
    puts 'no'
  end
}

Measured memory_bytes: 17160
#include <stdio.h>

int main(int argc, char const *argv[])
{
  int a;
  scanf("%d", &a);

  if (a < 1 || a > 100) {
    printf("err");
    return -1;
  }
  int b;
  scanf("%d", &b);
  if (b < 1 || b > 100) {
    return -1;
  }

  int c = a - b * 2;
  if (c < 1) {
    c = 0;
  }

  printf("%d\n", c);

  return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

class A9x9 {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b;
        in >> a >> b;
        int res = a * b;
        if (a >= 10 or b >= 10) {
            res = -1;
        }
        out << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    A9x9 solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void BubbleSort(int);
void SelectionSort(int);

typedef struct{
  char mark;
  int number;
} card;

card Bubble[100];
card Select[100];
card in[100];

int main()
{
  int i,j,N,flag = 0,a,b;
  char n;

  scanf("%d ",&N);

  for(i = 0;i < N;i++){
    scanf("%c",&in[i].mark);
    scanf("%d",&in[i].number);
    scanf("%c",&n);
  }

  for(i = 0;i < N;i++){
    Bubble[i].mark = in[i].mark;
    Bubble[i].number = in[i].number;
    }

  for(i = 0;i < N;i++){
    Select[i].mark = in[i].mark;
    Select[i].number = in[i].number;
    }

  /* バブルソート */
  BubbleSort(N);

  /* 選択ソート */
  SelectionSort(N);


  /* Stable */
  /* 選択ソートの安定性 */
  for(i = 0;i < N;i++){
    for(j = i + 1;j < N - 1;j++){
      for(a = 0;a < N;a++){
	for(b = a + 1;b < N - 1;b++){
	  if((in[i].number == in[j].number) &&
	     (in[i].number == Select[b].number) &&
	     (in[j].number == Select[a].number)) flag = 1; // false
	}
      }
    }
  }
  // flag == 0 : true	     

  for(i = 0;i < N;i++){
    printf("%c%d",Bubble[i].mark,Bubble[i].number);
    if(i != N-1) printf(" ");
  }
  printf("\n");

  printf("Stable\n");

  for(i = 0;i < N;i++){
    printf("%c%d",Select[i].mark,Select[i].number);
    if(i != N-1) printf(" ");
  }
  printf("\n");

  if(flag == 1) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}

void BubbleSort(int N)
{
  int i,j;
  int num;
  char pic;
  card sub;

  for(i = 0;i < N;i++){
    for(j = N-1;j >= 0;j--){
      if(Bubble[j].number < Bubble[j-1].number){
       	pic = Bubble[j].mark;
	num = Bubble[j].number;
	Bubble[j].mark = Bubble[j-1].mark;
	Bubble[j].number = Bubble[j-1].number;
        Bubble[j-1].mark = pic;
	Bubble[j-1].number = num;
      }
    }
  }
}

void SelectionSort(int N)
{
  int i,j,minj;
  int num;
  char pic;

   for(i = 0;i < N;i++){
    minj = i;
    for(j = i;j < N;j++){
      if(Select[j].number < Select[minj].number){
	minj = j;
      }
    }
    pic = Select[i].mark;
    num = Select[i].number;
    Select[i].mark = Select[minj].mark;
    Select[i].number = Select[minj].number;
    Select[minj].mark = pic;
    Select[minj].number = num;
   }
}


 

Measured memory_bytes: 612
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

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 SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N, long long D) {cout<<ceil((float)N/(2*D+1))<<endl;}

int main() {
  long long N;
  scanf("%lld", &N);
  long long D;
  scanf("%lld", &D);
  solve(N, D);
  return 0;
}


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

// MOD = 1000000007;
// MOD = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  vector<int> diff_abs(n);
  for(int i = 0; i < n; ++i) {
    cin >> diff_abs[i];
  }
  SORT(diff_abs);
  if(n % 2) {
    if(diff_abs[0] != 0) {
      cout << 0 << endl;
      return 0;
    }
    for(int i = 1; i < n-1; i += 2) {
      int correct_num = ceil(double(i)/2) * 2;
      if(diff_abs[i] != correct_num || diff_abs[i+1] != correct_num) {
        cout << 0 << endl;
        return 0;
      }
    }
    mint ans = 2;
    ans = ans.pow((n-1)/2);
    cout << ans << endl;
    return 0;
  }

  for(int i = 0; i < n-1; i += 2) {
    int correct_num = 1 + i;
    if(diff_abs[i] != correct_num || diff_abs[i+1] != correct_num) {
      cout << 0 << endl;
      return 0;
    }
  }
  mint ans = 2;
  ans = ans.pow(n/2);
  cout << ans << endl;
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1024
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	if minimum(a)>0
		println(n-1)
		for i in 1:n-1
			println(i," ",i+1)
		end
	elseif maximum(a)<0
		println(n-1)
		for i in n:-1:2
			println(i," ",i-1)
		end
	else
		r = indmax(a)
		l = indmin(a)
		println(2*n-1)
		if a[r]>-a[l]
			for i in 1:n
				println(r," ",i)
			end
			for i in 1:n-1
				println(i," ",i+1)
			end
		else
			for i in 1:n
				println(l," ",i)
			end
			for i in n:-1:2
				println(i," ",i-1)
			end
		end
	end
end

main()

Measured memory_bytes: 114860
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

int const MaxSize = 1e5 + 10;

int N;

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	cin >> N;

	int t, x, y;
	int curX = 0;
	int curY = 0;
	int curT = 0;

	LP(i, 0, N){
		cin >> t >> x >> y;
		int md = abs(curX - x) + abs(curY - y);
		int dt = t - curT;

		if(dt < md || (dt + md) % 2){
			cout << "No" << endl;
			return 0;
		}

		curT = t;
		curX = x;
		curY = y;
	}

	cout << "Yes";


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,N2,f;
  f=0;
  cin>>N;
  N2=N;
  while(N2>0){
    f+=N2%10;
    N2=(N2-N2%10)/10;
  }
  if(N%f==0){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, T, min = 10000;
    cin >> N >> T;
    vector<int> c(N), t(N);
    for (int i = 0; i < N; i++)
    {
        cin >> c[i] >> t[i];
    }
    for (int i = 0; i < N; i++)
    {
        if (min > c[i] && T >= t[i])
        {
            min = c[i];
        }
    }
    if (min == 10000)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << min << endl;
    }
}


Measured memory_bytes: 256
import math
def solve():
    N = int(input())
    divisors = calc_divisors(N)
    divisors.sort()

    now = N
    i = 1
    ans = 0
    while i != len(divisors):
        if isPrime(divisors[i]) and now % divisors[i] == 0:
            now /= divisors[i]
            ans += 1
        else:
            if len(set(prime_factorize(divisors[i]))) == 1 and now % divisors[i] == 0:
                now /= divisors[i]
                ans += 1
        i += 1
    
    print(ans)

def isPrime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def sieve(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False

    p = 0
    for i in range(2,n+1):
        if is_prime[i]:
            p = i
            for j in range(p+p, n+1, p):
                is_prime[j] = False
        
        if p * p > n:
            break
    
    primes = []
    for i in range(2,n+1):
        if is_prime[i]:
            primes.append(i)

    return primes

def prime_factorize(n):
    prime_numbers = []
    for p in range(2, int(math.sqrt(n)+1)):
        if n % p != 0:
            continue
        while n % p == 0:
            n /= p
            prime_numbers.append(p)

    if n != 1:
        prime_numbers.append(n)
    return prime_numbers

def calc_divisors(n):
    divisors = []
    for i in range(1,int(math.sqrt(n)+1)):
        if n % i == 0:
            divisors.append(i)
            if (i*i != n):
                divisors.append(n//i)

    return divisors
if __name__ == '__main__':
    solve()

Measured memory_bytes: 69140
S = input()
n = len(S)

flag = 0
for i in reversed(range(0,n+1)):
  for j in range(0,n-i+1):
    s = S[j:j+i].replace("A", "").replace("C", "").replace("G","").replace("T","")
    #print("+", s, "+", len(s))
    if len(s) == 0:
      flag=1
      break
  if flag==1:
    break

print(i)

Measured memory_bytes: 38384
from itertools import permutations


def dist(x, y):
    return ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** 0.5


n = int(input())
li = {}
for i in range(n):
    a, b = map(int, input().split())
    if i + 1 not in li:
        li[i + 1] = [a, b]
res = [i for i in range(1, n + 1)]
res = list(permutations(res))
c = 0
for i in res:
    for j in range(len(i)-1):
        c += dist(li[i[j]], li[i[j + 1]])
print(c / len(res))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define um map <ll,ll>
#define rep(i,z,n)  for(int i=z;i<n;i++)
#define repi(i,z,n) for(int i=z;i<=n;i++)
#define repn(i,z,n) for(int i=n-1;i>=z;i--)
#define vec vector<ll>
#define vecp vector<pair<ll,ll>>
#define pi (double)3.14159265358979323846
#define ld long double
#define all(z) z.begin(),z.end()

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; if (a == 0) return 0; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }
ll modInverse(ll a, ll m) {return power(a, m - 2, m);}
ll binpow(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll binlog2(ll n) {ll logValue = -1; while (n) {logValue++; n >>= 1;} return logValue;}
void print(vec a) {rep(i, 0, a.size())cout << a[i] << " "; cout << endl;}
const ll mod = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;




void solve() {
    ll n, w ;
    cin >> n >> w;

    vecp vp(n);
    rep(i, 0, n)
    cin >> vp[i].F >> vp[i].S;

    ll dp[n + 1][w + 1] = {};

    repi(i, 0, n) {
        repi(j, 0, w) {
            if (i == 0 || j == 0)
                dp[i][j] = 0;
            else if (j >= vp[i - 1].F) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - vp[i - 1].F] + vp[i - 1].S);
            }
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    cout << dp[n][w] << endl;

}





int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    speed;
    int test = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case #" << t1 << ": ";
        solve();
    }
    return 0;
}

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

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

    if (a < b) {
     cout << "a < b" << endl;
    } else if ( a > b) {
     cout << "a > b" << endl;
    } else {
     cout << "a == b" << endl;
     return 0;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end()
using namespace std;
//using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
//int myfunc(int, vvec);

//グローバル変数
//int N, M;
//vvec data(N, vec(M));

//関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N; cin >> N;
	vec L(N);
	rep(i, N) cin >> L[i];

	sort(all(L));

	int ct = 0;
	rep(j, N)rep(i, j) {
		int ij = L[i] + L[j];
		int r = lower_bound(all(L), ij) - L.begin(); //second bound.
		int l = j + 1; //first bound.
		//k = [l,r)
		ct += r - l;
	}

	cout << ct << endl;
	return 0;
}
//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector <int> b;
  if(n % 2 == 0) {
    for(int i = 0; i < n; i++) {
      if(i % 2 == 0) {
	b.push_back(a[i]);
      }
      else {
	b.insert(b.begin(), a[i]);
      }
    }
  }
  else {
    for(int i = 0; i < n; i++) {
      if(i % 2 != 0) {
	b.push_back(a[i]);
      }
      else {
	b.insert(b.begin(), a[i]);
      }
    }
  }

  string s;
  for(int i = 0; i < n; i++) {
    s += to_string(b[i]);
    s += " ";
  }
  s.pop_back();
  cout << s << endl;
}

Measured memory_bytes: 5752
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

int main() {
  string a, b;
  cin >> a >> b;

  const auto s1 = a.size(), s2 = b.size();
  if (s1 == s2) {
    const auto c = strcmp(a.c_str(), b.c_str());
    if (c < 0) {
      cout << "LESS" << endl;
    } else if (c > 0) {
      cout << "GREATER" << endl;
    } else {
      cout << "EQUAL" << endl;
    }
  } else if (s1 > s2) {
    cout << "GREATER" << endl;
  } else {
    cout << "LESS" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define EPS 1e-7

#define ENSYURITU 3.1415926535897932384626433832795028841

int main(void) {
	int n;
	int i,j,k;
	int count,max;
	int loopmax;
	double x[300],y[300];
	double cx,cy;
	while(scanf("%d",&n)==1 && n!=0) {
		for(i=0;i<n;i++)scanf("%lf%lf",&x[i],&y[i]);
		max=0;
		loopmax=500000/n;
		for(k=0;k<n;k++) {
			for(i=0;i<loopmax;i++) {
				cx=x[k]+cos(2*ENSYURITU*i/loopmax);
				cy=y[k]+sin(2*ENSYURITU*i/loopmax);
				count=0;
				for(j=0;j<n;j++) {
					if((x[j]-cx)*(x[j]-cx)+(y[j]-cy)*(y[j]-cy)<1+EPS)count++;
				}
				if(count>max)max=count;
				if(max==n)break;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 644
<?php

fscanf(STDIN, "%d %d", $n, $k);

const BI_MAX = 20;
$bi = [];
$bi[0] = 1;
for ($i = 1; $i < BI_MAX; ++$i) {
    $bi[$i] = pow(2, $i);
}

$prod = 0;
for ($i = 1; $i <= $n; ++$i) {
    $l = 0;
    $r = BI_MAX;
    while ($r - $l >= 1) {
        $mid = intdiv($r + $l, 2);

        if ($i * $bi[$mid] >= $k) {
            $r = $mid;
        } else {
            $l = $mid + 1;
        }
    }

    $prod += 1 / (pow(2, $r) * $n);
}

echo $prod;


Measured memory_bytes: 4856
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
const int MAX_V = 200010;

vector<int> G[MAX_V];
int V;
int color[MAX_V];
int color_cnt[2];
// 頂点を1と-1で塗っていく
bool dfs(int v, int c) {
    color[v] = c;
    if(c == 1) color_cnt[1]++;
    else color_cnt[0]++;
    for (int i = 0; i < G[v].size(); i++) {
        // 隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) return false;
        // 隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }

    // すべての頂点を塗れたらtrue
    return true;

}
int num[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    V = N;
    rep(i, N - 1) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    dfs(0, 1);
    //cout << color_cnt[0] << " " << color_cnt[1] << endl;
    int cnt1 = (N + 2)/3;
    int cnt2 = (N + 1)/3;
    int cnt3 = N/3;
    if (cnt3 >= color_cnt[1] || cnt3 >= color_cnt[0]) {
        if (cnt3 >= color_cnt[1]) {
            rep(i, N) {
                if (color[i] == 1) {
                    num[i] = cnt3 * 3;
                    cnt3--;
                }
            }
        } else if (cnt3 >= color_cnt[0]) {
            rep(i, N) {
                if (color[i] == -1) {
                    num[i] = cnt3 * 3;
                    cnt3--;
                }
            }
        }
        rep(i, N) {
            if (num[i] == 0) {
                if (cnt3 > 0) {
                    num[i] = cnt3 * 3;
                    cnt3--;
                }else if(cnt2 > 0) {
                    num[i] = cnt2 * 3 - 1;
                    cnt2--;
                } else {
                    num[i] = cnt1 * 3 - 2;
                    cnt1--;
                }
            }
        }
    }
    else {
        if (color_cnt[1] < color_cnt[0]) {
            rep(i, N) {
                if (cnt1 && color[i] == 1) {
                    num[i] = cnt1 * 3 - 2;
                    cnt1--;
                } else if (cnt2 && color[i] == -1) {
                    num[i] = cnt2 * 3 - 1;
                    cnt2--;
                }
            }
        } else {
            rep(i, N) {
                if (cnt2 && color[i] == 1) {
                    num[i] = cnt2 * 3 - 1;
                    cnt2--;
                } else if (cnt1 && color[i] == -1) {
                    num[i] = cnt1 * 3 - 2;
                    cnt1--;
                }
            }
        }
        
        rep(i, N) {
            if (num[i] == 0) {
                num[i] = cnt3 * 3;
                cnt3--;
            }
        }
    }
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << num[i];
    }
    // cout << endl;
    // rep(i, N) cout << i + 1 << " " << color[i] << " " << num[i] << endl;

    return 0;
}


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

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		if (k <= h) ans++;
	}	

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, raw_input().split())
S = raw_input()
countlist = []
flag = False
cnt = 0
for i in range(0, len(S)):
	if flag:
		if S[i] == 'C':
			cnt += 1
		flag = False
	if S[i] == 'A':
		flag = True
	countlist.append(cnt)

for i in range(0, Q):
	l, r = map(int, raw_input().split())
	print countlist[r-1] - countlist[l-1]

Measured memory_bytes: 8436
n=int(input())
s=input()

w = 0
e = 0
for i in s:
  if i =="W":
    pass
  else:
    e +=1
n=e
for i in s:
  if i=="E":
    e-=1
    n = min(n,e+w)
  if i =="W":
    w+=1
print(n)


Measured memory_bytes: 3700
S = input()

ans = 'YES'

while S:
    if S.endswith('eraser'):
        S = S[:-6]
    elif S.endswith('erase'):
        S = S[:-5]
    elif S.endswith('dreamer'):
        S = S[:-7]
    elif S.endswith('dream'):
        S = S[:-5]
    else:
        ans = 'NO'
        break

print(ans)


Measured memory_bytes: 3188
#include <array>
#include <iostream>
#include <vector>

int main() {
  uint32_t n = 0;
  std::cin >> n;

  std::vector<uint32_t> A(n);
  for (uint32_t i = 0; i < n; i++) std::cin >> A[i];

  std::array<uint32_t, 10'000 + 1> C;
  C.fill(0);
  for (uint32_t i = 0; i < n; i++) C[A[i]]++;
  for (size_t i = 1; i < C.size(); i++) C[i] += C[i - 1];

  std::vector<uint32_t> ans(n);
  for (size_t i = n; i > 0; i--) {
    C[A[i - 1]]--;
    ans[C[A[i - 1]]] = A[i - 1];
  }

  for (size_t i = 0; i < n - 1; i++) std::cout << ans[i] << " ";
  std::cout << ans[n - 1] << std::endl;

  return 0;
}


Measured memory_bytes: 18376
N = int(input())
a = 0
for i in range(N):
  if a == 3:
    break
  else:
    x, y = map(int,input().split())
  if x == y:
    a += 1
  else:
    a = 0
if a == 3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
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;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testNumber, Scanner in, PrintWriter out) {
			int n = in.nextInt();
			int a = in.nextInt();
			out.println(n % 500 <= a ? "Yes" : "No");
		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}
}



Measured memory_bytes: 25172
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull insigned lon long
///////////////////////////////////////////////////////////
int absolute(int n);
void input(vector<int>& vec);
void print(vector<int> vec);
int sum(vector<int> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    int a;
    cin >> a;
    string s;
    cin>>s;
    if(a<3200){
        cout<<"red"<<endl;
    }else{
        cout<<s<<endl;
    }
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

int sum(vector<int> vec)
{
    int s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 256