akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
	IOS;
	ll n; cin >> n;
	vector<ll> a(n,0);
	for(ll i=0;i<n;i++)
		cin >> a[i];
	ll dp[n+1][n+1];
	ll sum[n+1][n+1];
	memset(dp,0,sizeof(dp));
	memset(sum , 0 , sizeof(sum));
	for(ll i = 0 ; i < n ; i++){
		dp[i][i] = a[i];
		sum[i][i] = 0 ; 
	}
	ll ans = 0;
	for(ll l = 2 ; l <= n ; l++){
		for(ll i = 0 ; i + l -1 < n ; i++){
			ll j = i+l-1;
			dp[i][j] = 1e15;
			sum[i][j] = 1e15;
			for(ll k = i ; k< j ; k++){
				// dp[i][j] = min(dp[i][j] , (dp[i][k]+dp[k+1][j]));
				if(sum[i][j] > sum[i][k] + sum[k+1][j]+dp[i][k]+dp[k+1][j]){
					sum[i][j] = sum[i][k] + sum[k+1][j]+dp[i][k]+dp[k+1][j];
					dp[i][j] = dp[i][k]+dp[k+1][j];
				}
			}
			
		}
	}
	cout << sum[0][n-1];




	return 0;
}




Measured memory_bytes: 2816
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    l,r=map(int,input().split())
    ans=2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans=min(ans,i*j%2019)
            if ans==0:
                print(0)
                sys.exit()
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 38896
N, K = map(int, input().split())
As = list(map(int, input().split()))

cnt = 0
pres = []
for a in As:
    for p in pres:
        if p > a:
            cnt += 1
    pres.append(a)

kcnt = 0
for a in As:
    for p in pres:
        if p > a:
            kcnt += 1

if K == 1:
    print(cnt)
else:
    print(((cnt * K) % (10**9 + 7) + (kcnt * (K - 1) * K // 2) % (10**9 + 7)) % (10**9 + 7))

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

ll f(ll x) {
  ll m = x % 4;
  if (m == 0)
    return x;
  else if (m == 1)
    return 1;
  else if (m == 2)
    return x + 1;
  else
    return 0;
}

int main() {
  ll A, B;
  cin >> A >> B;
  cout << (f(A - 1) ^ f(B)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N, K; cin >> N >> K; ll a[N]; ll plus=0, minus=0;
  rep(i, N){
    cin >> a[i];
    if(a[i]>0) plus+=a[i];
    if(a[i]<0) minus+=a[i];
  }
  ll sum = plus+minus;
  ll suma=0, sumb=0;
  rep(i, K){
    if(a[i]<0) suma+=a[i];
    if(a[i]>0) sumb+=a[i];
  }
  ll tmpa=-longinf, tmpb=longinf;
  rep(i, N-K){
    tmpa = max(tmpa, suma);
    tmpb = min(tmpb, sumb);
    if(a[i]<0) suma-=a[i];
    if(a[i]>0) sumb-=a[i];
    if(a[i+K]<0) suma+=a[i+K];
    if(a[i+K]>0) sumb+=a[i+K];
  }
  tmpa = max(tmpa, suma);
  tmpb = min(tmpb, sumb);
  cout << max(plus+tmpa, sum-(minus+tmpb)) << endl;
}
  

Measured memory_bytes: 1024
import sys

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


n = int(input())
if n==1:
    print(0)
else:
    max_x = int(((2*n-3)**0.5-1)//1)
    list_count = [0]*n
    for x in range(1,max_x+1):
        for y in range(1, max_x+2-x):
            for z in range(1, max_x+2-x-y):
                s = x**2+y**2+z**2+x*y+y*z+z*x
                if s>n:
                    continue
                else:
                    list_count[s-1] += 1
    for i in range(n):
        print(list_count[i])




Measured memory_bytes: 69836
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <cstdio>
#define int long long
#define double long double
using namespace std;

int n;
int x[1002], y[1002], r[1002];
vector<int> et[1002];
vector<double> ec[1002];

void input() {
	int xs, ys, xe, ye;
	cin >> xs >> ys >> xe >> ye;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[0] = xs; y[0] = ys; r[0] = 0;
	x[n+1] = xe; y[n+1] = ye; r[n+2] = 0;
	n += 2;
}

void graph() {
	int i, j;
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i == j) continue;
			
			int dist2 = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
			if (dist2 <= (r[i] + r[j]) * (r[i] + r[j])) {
				et[i].push_back(j);
				ec[i].push_back(0);
			}
			else {
				et[i].push_back(j);
				ec[i].push_back(sqrt((double)dist2) - r[i] - r[j]);
			}
		}
	}
}

double minCost[1002];

typedef pair<double, int> P;
priority_queue<P, vector<P>, greater<P> > que;
void dijkstra(int start) {
	que.push(P(0, start));
	
	for (int i = 0; i < n; i++) minCost[i] = 214514191900;
	
	while (!que.empty()) {
		P now = que.top();
		que.pop();
		
		double cst = now.first;
		int v = now.second;
		
		if (minCost[v] <= cst) continue;
		minCost[v] = cst;
		
		for (int i = 0; i < et[v].size(); i++) {
			que.push(P(cst + ec[v][i], et[v][i]));
		}
	}
}

signed main() {
	input();
	graph();
	dijkstra(0);
	
	printf("%.14Lf\n", minCost[n - 1]);
	return 0;
}

Measured memory_bytes: 57336
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    
    int N;
    vector<int> T,A;
    long long x,y;
    
    cin >> N;
    
    for ( int i = 0; i < N; i++ ) {
        int t,a;
        cin >> t;
        cin >> a;
        
        T.push_back(t);
        A.push_back(a);
    }
    
    x = T[0];
    y = A[0];
    
    if ( N == 1 ) {
        cout << x + y << endl;
        return 0;
    }
    
    for ( int i = 1; i < N; i++ ) {
        
        long long a = (x % T[i] == 0 )  ? static_cast<long long>(x / T[i]) : static_cast<long long>(x / T[i])+1;
        long long b = (y % A[i] == 0 )  ? static_cast<long long>(y / A[i]) : static_cast<long long>(y / A[i])+1;
                
        x = max(a,b) * T[i];
        y = max(a,b) * A[i];
            
        
    }
    
    cout << x + y << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
  ll n,x;
  vector<ll> a,b,c;
  cin >> n;
  FOR(i,n){
    cin >> x;
    a.push_back(x);
  }
  FOR(i,n){
    cin >> x;
    b.push_back(x);
  }
  FOR(i,n){
    cin >> x;
    c.push_back(x);
  }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  ll ans=0;
  FOR(i,n){
    auto itr=upper_bound(c.begin(),c.end(),b[i]);
    auto v=lower_bound(a.begin(),a.end(),b[i]);
    ans+=distance(c.end(),itr)*(distance(v,a.begin()));
    


  }
  cout << ans << endl;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int R,C,K;
long long r[200005],c[200005],v[200005];
long long a[3005][3005];
long long f[3005][3005][4];
int main()
{
	scanf("%d%d%d",&R,&C,&K);
	for(int i=1;i<=K;++i)
	{
		scanf("%lld%lld%lld",&r[i],&c[i],&v[i]);
		a[r[i]][c[i]]+=v[i];
	}
	for(int i=1;i<=R;++i)
	{
		for(int j=1;j<=C;++j)
		{
			for(int k=1;k<=3;++k)
			{
				if(k==1)
				{
				   for(int s=1;s<=3;++s)
				      f[i][j][k]=max(f[i][j][k],f[i-1][j][s]+a[i][j]);
				}
				f[i][j][k]=max(f[i][j][k],f[i][j-1][k]);
				f[i][j][k]=max(f[i][j][k],f[i][j-1][k-1]+a[i][j]);
			}
		}
	}
	long long ans=0;
	for(int i=1;i<=3;++i)
	   ans=max(ans,f[R][C][i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 360536
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)



int main() {
	
	string s;
	int count = 0;
	cin >> s;
	int size = s.size();
	int i;

	if (size % 2 == 0) {

		for (i = 0; i < size / 2; i++) {
			if (s[i] != s[size - 1 - i]) {
				count++;
			}
		}

		cout << count;
		return 0;
	}
	else {

		for (i = 0; i < (size-1) / 2; i++) {
			if (s[i] != s[size - 1 - i]) {
				count++;
			}
		}

		cout << count;
		return 0;


	}

}


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

int to_number(char c) {
    if (c == 'A') return 14;
    if (c == 'K') return 13;
    if (c == 'Q') return 12;
    if (c == 'J') return 11;
    if (c == 'T') return 10;
    return c - '0';
}

bool win(string a, string b, char trump, char led) {
    if (a[1] == trump && b[1] != trump) return true;
    if (a[1] != trump && b[1] == trump) return false;
    if (a[1] == led && b[1] != led) return true;
    if (a[1] != led && b[1] == led) return false;
    if (to_number(a[0]) > to_number(b[0])) return true;
    return false;
}

int main() {
    char trump;
    while (cin >> trump) {
        if (trump == '#') break;

        string card[4][13];
        for (int i=0; i<4; ++i) {
            for (int j=0; j<13; ++j) {
                cin >> card[i][j];
            }
        }

        int last = 0, ns = 0, ew = 0;
        for (int i=0; i<13; ++i) {
            char led = card[last][i][1];
            int k = 0;
            string t = card[0][i];
            for (int j=1; j<4; ++j) {
                if (win(card[j][i], t, trump, led)) {
                    k = j;
                    t = card[j][i];
                }
            }
            if (k == 0 || k == 2) ns ++;
            else ew ++;
            last = k;
        }

        if (ns > ew) cout << "NS " << ns-6 << endl;
        else cout << "EW " << ew-6 << endl;
    }
    return 0;
}


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

vector<pair<long long,long long>> prime_factorize(long long n){
    vector<pair<long long, long long>> res;
    for(long long p = 2; p*p <= n; p++){
        if(n%p!=0)continue;
        int num = 0;
        while(n%p==0){num++;n/=p;}
        res.push_back(make_pair(p,num));
    }
    if(n!=1)res.push_back(make_pair(n,1));
    return res;
}

long long GCD(long long x, long long y){
    return y ? GCD(y,x%y) : x;
}


int main(){
    long long A,B;
    cin >> A >> B;
    long long G = GCD(A,B);
    auto pf = prime_factorize(G);
    cout << pf.size() + 1 << endl;
}

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

int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k;
  int x;
  cin>>k>>x;
  if(500*k>=x){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int INF=0x3f3f3f3f,M=1e5+10;
const double PI=acos(-1.),EPS=1e-10;
int a[M],b[M];
int n,m;
int main()
{
    cin>>n>>m;
    while(m--)
    {
        int x;
        string s;
        cin>>x>>s;
        if(s[0]=='A') b[x]=1;
        else if(!b[x]) a[x]++;
    }
    int acs=0,pen=0;
    for(int i=1;i<=n;i++)
        if(b[i])
            acs++,pen+=a[i];
    printf("%d %d\n",acs,pen);
    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

int n,q;
Ki G(n);
vector<int> cnt(n);
vector<bool> seen(n);

void dfs(int now){
    seen[now]=true;
    for(auto &next:G[now]){
        if(seen[next]) continue;
        cnt[next]+=cnt[now];
        dfs(next);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    cin>>n>>q;
    G.resize(n);
    cnt.resize(n,0);
    seen.resize(n,false);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        cnt[p]+=x;
    }
    dfs(0);
    rep(i,n){
        cout<<cnt[i]<<endl;
    }
}

Measured memory_bytes: 177408
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int[] a = new int[5];
		for(int i=0; i<5; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		int k = Integer.parseInt(sc.next());
		
		if(a[4]-a[0]>k){
			System.out.println(":(");
		}else{
			System.out.println("Yay!");
		}
		
		sc.close();
	}
	
}


Measured memory_bytes: 22228
N=int(input())
p = list(map(int, input().split()))
#p=int(input()).split()
q=[]
q=sorted(p)
#print(p,q)
count=0
for i in range(N):
    if p[i]!=q[i]:
        count+=1

if count>2:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
#i文字目を見て，それより前のAの個数，ABの個数，ABCの個数を持っておく

S=input()
N=len(S)
dp=[0,0,0]

mod=10**9+7

p=[1]*(N+1)
for i in range(N):
    p[i+1]=(p[i]*3)%mod


count=0#?の数
for i in range(N):
    if S[i]=="A":
        dp[0]=(dp[0]+p[count]) %mod
    elif S[i]=="B":
        dp[1]=(dp[1]+dp[0])%mod
    elif S[i]=="C":
        dp[2]=(dp[2]+dp[1])%mod
    else:
        dp[2]=(dp[2]*3+dp[1])%mod
        dp[1]=(dp[1]*3+dp[0])%mod
        dp[0]=(dp[0]*3+p[count])%mod
        count+=1
        
print(dp[2]%mod)   






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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);

 string s;
  cin >> s;
  bool flag=false;
  if(s=="AKIHABARA") flag=true;
  if(s=="KIHABARA") flag=true;
  if(s=="AKIHBARA") flag=true;
  if(s=="AKIHABRA") flag=true;
  if(s=="AKIHABAR") flag=true;
  if(s=="KIHBARA") flag=true;
  if(s=="KIHABRA") flag=true;
  if(s=="KIHABAR") flag=true;
  if(s=="AKIHBRA") flag=true;
  if(s=="AKIHBAR") flag=true;
  if(s=="AKIHABR") flag=true;
  if(s=="KIHBRA") flag=true;
  if(s=="KIHBAR") flag=true;
  if(s=="KIHABR") flag=true;
  if(s=="AKIHBR") flag=true;
  if(s=="KIHBR") flag=true;
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

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

auto main() -> int{
	int M, s, g;
	cin >> M;

	vector<int> a(6), N(M);
	for_each(a.begin(), a.end(), [](int &i){cin >> i; });
	cin >> s >> g;
	s--; g--;
	for (int &i : N){ cin >> i; }

	vector < vector <int> > memo(M, vector <int>(M + 1, -1));
	memo[s][0] = s;
	/*
	for (int i = 0; i < M; i++){
		for (int j = 0; j < 10; j++) cout << memo[i][j] << " ";
		cout << endl;
	}
	*/
	int movetime;

	auto move = [&a, &N, &M](int p, int dc, int dr) -> int {
		int t = p + dr * a[dc];
		if (t > -1 && t < M) t += N[t];
		else t = -1;
		return t;
	};

	for (movetime = 0; movetime < M; movetime++){
//		cout << "movetime, ";
		for (int j = 0; j < M; j++){
//			cout << "j, ";
			if (memo[j][movetime] < 0) continue;
			for (int k = 0; k < 6; k++){
//				cout << "k";
				int m = move(j, k, 1);
				if (m >= 0){
//					cout << "p";
//					cout << m;
					memo[m][movetime + 1] = j;
//					cout << memo[m][movetime + 1];
				}
				if (m == g) goto SEARCH_END;

				m = move(j, k, -1);

				if (m >= 0){
//					cout << "m";
//					cout << m;
					memo[m][movetime + 1] = j;
//					cout << memo[m][movetime + 1];
				}
				if (m == g) goto SEARCH_END;
			}
		}
//		cout << endl;
	}

SEARCH_END:
//	cout << endl;
	movetime ++;
	/*
	for (int i = 0; i < M; i++){
		for (int j = 0; j < movetime + 1; j++) cout << memo[i][j] << " ";
		cout << endl;
	}
	*/

	vector<int> dice(M), direction(M);
	int p = g;

	for (int t = movetime; t > 0; t--){
//		cout << memo[p][t] << ", " << p;
		for (int k = 0; k < 6; k++){
			if (move(memo[p][t], k, 1) == p){
				dice[t-1] = k;
				direction[t-1] = 1;
				break;
			}
			if (move(memo[p][t], k, -1) == p){
				dice[t-1] = k;
				direction[t-1] = -1;
				break;
			}
		}
		p = memo[p][t];
//		cout << "aaa" << endl;
	}

//	for (int i = 0; i < movetime; i++) cout << dice[i] << ", " << direction[i] << endl;

	for (int i = 0; i < movetime; i++){
		while (1){
			int tmp;
			cin >> tmp;
			if (tmp - 1 == dice[i]){
				cout << direction[i] << endl;
				break;
			}
			cout << 0 << endl;
		}
	}
	

	/*
	int position = s, dice, direction;

	auto move = [&a, &N, &M](int p, int dc, int dr) -> int {
	int t = p + dr * a[dc];
	if (t > -1 && t < M) t += N[t];
	else t = 1000000;
	return t;
	};

	while (1){
	int distance = abs(g - position);

	for (int i = 0; i < 6; i++){
	if (distance > abs(g - move(position, i, 1))){
	distance = abs(g - move(position, i, 1));
	dice = i;
	direction = 1;
	}
	if (distance > abs(g - move(position, i, -1))){
	distance = abs(g - move(position, i, -1));
	dice = i;
	direction = -1;
	}
	}
	//		cout << dice << ", " << direction << endl;
	int tmp;
	while (1){
	cin >> tmp;
	if (tmp - 1 == dice) break;
	cout << 0 << endl;
	}
	cout << direction << endl;
	position = move(position, dice, direction);

	if (position == g) break;
	}
	*/
	return 0;
}

Measured memory_bytes: 1524
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

LL n, A, B;
LL a[MaxN + 5];
bool judge(LL x)
{
	LL cnt = 0;
	for(LL i = 1; i <= n; i++)
	{
		if(a[i] > B * x) 
		{
			cnt += (a[i] - B * x) / (A - B);
			if((a[i] - B * x) % (A - B) != 0) cnt++;
		}
	}
	if(cnt > x) return 1;
	else return 0;
}
int main()
{
	while(scanf("%lld %lld %lld", &n, &A, &B) != EOF)
	{
		for(LL i = 1; i <= n; i++)
			scanf("%lld", &a[i]);
		LL l = 1, r = 1e9 + 7;
		LL mid = 0;
		LL ans = 0;
		while(l <= r)
		{
			mid = (l + r) >> 1;
			if(judge(mid)) l = mid + 1;
			else ans = mid, r = mid - 1;
		}
		printf("%lld\n", ans);
		memset(a, 0, sizeof(a));
	}
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <sstream>
using namespace std;

int main() {
  char ABCD[4+1];
  scanf("%s", ABCD);
  for (int i = 0; i < (1 << 3); ++i) {
    ostringstream oss;
    oss << ABCD[0];
    int calc = ABCD[0] & 0xF;
    for (int j = 0; j < 3; ++j) {
      if (i & (1 << j)) {
        oss << '+';
        calc += ABCD[j+1] & 0xF;
      } else {
        oss << '-';
        calc -= ABCD[j+1] & 0xF;
      }
      oss << ABCD[j+1];
    }
    if (calc == 7) {
      oss << "=7";
      printf("%s\n", oss.str().c_str());
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split(" ")))
cnt = 0
minNum = 0
tmp = 0

while True:
    for i in range(h.count(0)):
        if h.index(0) == 0: 
            h.pop(0)
        elif h.index(0) > 0:
            tmp = h.index(0)
            break
    else:
        tmp = len(h)

    if not h:
        break

    if tmp == 1:
        cnt += h[0]
        h.pop(0)
    else:
        minNum = min(h[0:tmp])
        cnt += minNum
        for j in range(tmp):
            h[j] -= minNum

print(cnt)

Measured memory_bytes: 9088
import sys
_ = input()
input_array = [int(e) for e in input().split()]
even = [e for e in set(input_array) if e%2==0]
divided_by_three = [e for e in even if e%3!=0]
divided_by_five = [e for e in divided_by_three if e%5!=0]
if len(divided_by_five) == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
N = int(input())
a, b, bxxa, ab = 0, 0, 0, 0

for i in range(N):
    s = input()
    if s[-1] == 'A':
        a += 1
    if s[0] == 'B':
        b += 1
    if s[0]=='B' and s[-1]=='A':
        bxxa += 1 
    ab += s.count('AB')

if a>b :
    print(ab+b)
elif a!=0 and a==b and bxxa==a:
    print(ab+a-1)
else: 
    print(ab+a)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;


int main (void)
{
	string s,t;
	cin>>s>>t;
	sort (s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	if (s.compare(t)<0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size();i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


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

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

  int m = n % 10;
  if (m==2 || m==4 || m==5 || m==7 || m==9) {
    cout << "hon" << endl;
  }
  else if (m==3) {
    cout << "bon" << endl;
  }
  else
    cout << "pon" << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i]--;

    vector<int> ql(q), qr(q), qi(q);
    rep(i, q) cin >> ql[i] >> qr[i], ql[i]--;
    iota(qi.begin(), qi.end(), 0);

    int width = 1400;
    sort(qi.begin(), qi.end(), [&](int i, int j) {
        if (ql[i] / width != ql[j] / width) return ql[i] < ql[j];
        return qr[i] < qr[j];
    });

    vector<int> cnt(n), ans(q);
    int sum = 0;
    int l = 0, r = 0;

    auto add = [&](int i) { if (cnt[a[i]]++ == 0) sum++;};
    auto del = [&](int i) { if (--cnt[a[i]] == 0) --sum;};
    
    for (int i : qi) {
        while (ql[i] < l) add(--l);
        while (r < qr[i]) add(r++);
        while (l < ql[i]) del(l++);
        while (qr[i] < r) del(--r);
        ans[i] = sum;
    }
    
    rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 15484
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

// i hope i get better

// Task name:
#define Task ""
using namespace std;

// Include
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

// Define
#define reset(x, value) memset((x), (value) ,sizeof((x)))
#define fr(i,a,b) for(int i = (a); i <= (b); i++)
#define FR(i,a,b) for(int i = (a); i < (b); i++)
#define frr(i,a,b) for(int i = (a); i >= (b); i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl "\n"
#define bit(x,i) (x >> i) & 1
#define all(x) (x).begin(), (x).end()
#define optimize(x) (x).resize(unique(all(x)) - (x).begin())
#define Inpf freopen(Task".inp","r",stdin)
#define Outf freopen(Task".out","w",stdout)
#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

// typedef
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const int base = 131;
const int MOD = 1e9 + 7;
const ll MM = 1ll * MOD * MOD;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void AddMOD(int &x, int y)
{
    x += y;
    if (x >= MOD)
        x -= MOD;
}
int Gcd(int x, int y)
{
    if (y == 0)
        return x;
    return Gcd(y, x % y);
}
template <class T> inline void Gmax(T &x,T y)
{
    x = max((x), (y));
}
template <class T> inline void Gmin(T &x,T y)
{
    x = min((x), (y));
}

void exit_with_runtime()
{
    db x = 1.0 * clock() / CLOCKS_PER_SEC;
	cerr << "\n\n---------------------\nTime elapsed: " << x << " s.\n\n";
	if (x > 1) cerr << "TIME LIMIT EXCEEDED!\n\n";
	exit(0);
}

// --------------------------------------------------------------------
const int maxn = 2e5 + 5;
// --------------------------------------------------------------------
void Solve()
{
    ll x;
    int dem = 0;
    cin >> x;
    ll c = 100;
    while (c < x)
    {
        dem ++;
        c = c + c / 100;
    }
    cout << dem;
}

int main()
{
#ifndef ONLINE_JUDGE
    Inpf;
    Outf;
#endif // ONLINE_JUDGE
    fasterIO;
    int test = 1;
//    cin >> test;
    while (test --)
        Solve();

    // Did you check with the special test case n = 0, n = 1??
    exit_with_runtime();
}

// Goodbye, see u again


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n%m);
}

ll lcm(ll n, ll m) {
	return n / gcd(n, m)*m;
}

int main() {
	ll n, m;
	cin >> n >> m;
	cout << lcm(n, m) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

int main(){
  int n;
  cin>>n;
  vector<lint> c(n),a(n);
  rep(i,n)cin>>c[i];
  int q;
  cin>>q;
  int idx=0;
  rep(i,q){
    int t,x,d;
    cin>>t>>x>>d;
    x--;
    if(t==1){
      a[x]+=d;
    }else{
      a[x]-=d;
    }
    if(idx!=0)continue;
    if(a[x]<0||a[x]>c[x]){
      idx=x+1;
    }
  }
  cout<<idx<<endl;
}



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

string image[102];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i=0;i<h;++i){
        cin >> image[i];
    }

    for(int i=0;i<w+2;++i)cout << "#";
    cout << endl;
    for(int i=0;i<h;++i){
        cout << "#";
        for(char c : image[i]){
            cout << c;
        }
        cout << "#" << endl;
    }
    for(int i=0;i<w+2;++i)cout << "#";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
dp: list = [-1] * 50
def fib(n: int) -> int:
    if n == 0 or n == 1:
        dp[n] = 1
        return dp[n]
    elif dp[n] != -1:
        return dp[n]
    else:
        dp[n] = fib(n-1) + fib(n-2)
        return dp[n]

def main():
    n = int(input())
    print(fib(n))

if __name__ == '__main__': main()


Measured memory_bytes: 5604
n = int(input())
SP = []
for _ in range(n):
    SP.append([i for i in input().split()])
for i in range(n):
    SP[i][1] = str(100 - int(SP[i][1])).rjust(3,'0')
SP2 = []
for i in range(n):
    SP2.append(SP[i][0]+SP[i][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Measured memory_bytes: 3064
def shellSort(A):
    cnt = 0
    def insertionSort(A, g):
        nonlocal cnt
        for i in range(g,len(A)):
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v:
                A[j+g] = A[j]
                j = j - g
                cnt += 1
            A[j+g] = v
    i = 0 
    G = [1]
    if len(A) > 1:
        while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
        G = G[-2::-1]
    print(len(G))
    print(*G)
    for i in range(len(G)):
        insertionSort(A, G[i])
    return cnt

if __name__=='__main__':
    n = int(input()) 
    A = [int(input()) for _ in range(n)]
    print(shellSort(A))
    [print(ai) for ai in A]

Measured memory_bytes: 55380
#include <cstdio>

#define N 4

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */

char S[N];
char T[N];

int main () {
	int n = 0;	// 正答数

	// 読込み
	scanf("%s %s", &S, &T);
	// 
	for(int i = 0; i < 3; i++) 
		n += S[i] == T[i];
	
	printf("%d\n", n);
	return 0;
}

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

using namespace std;

int main()

{
    int n;

    cin>>n;

    //if(n%2==0)
   // {
        int r=ceil((n)/1.08);
        //cout<<r<<endl;
        if((int)((r)*1.08)<n+1)// if((r*1.08)<=n)
            cout<<r<<endl;
        else
             cout<<":(\n";
   // }
   /* else
        {
             int r=(int)((n+1)/1.08);
              if((int)((r+1)*1.08)<=n)
            cout<<(r)<<endl;
        else
             cout<<":(\n";
        }
*/

    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())

f = math.floor(N / 1.08)
c = math.ceil(N / 1.08)

if (math.floor(f * 1.08) == N):
    print(f)
elif (math.floor(c * 1.08) == N):
    print(c)
else:
    print(":(")

Measured memory_bytes: 3064
se=[]

n,k,q = map(int,input().split())

for i in range(q):
  se.append(int(input()))

points = [k]
points *= n

for i in range(n):
  points[i] -= q


#正解者idを進めていく
for i in range(q):
  points[se[i]-1] += 1



for i in range(n):
  if points[i]  <= 0:
    print("No")
  else:
    print("Yes")




Measured memory_bytes: 11776
N = int(input())
S = [int(input()) for i in range(N)]

count = 0
def insertionSort(S, N, g):
    global count
    for i in range(g, N):
        v = S[i]
        j = i - g
        while j >= 0 and S[j] > v:
            S[j+g] = S[j]
            j = j - g
            count += 1
        S[j+g] = v

def shellSort(S, N):
    h = 1
    G = []
    while h <= N:
        G.append(h)
        h = 3*h+1
    G.reverse()
    m = len(G)

    for i in G:
        insertionSort(S, N, i)

    print(m)
    print(' '.join([str(j) for j in G]))

shellSort(S, N)
print(count)
for i in S:
    print(i)


Measured memory_bytes: 45512
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=998244353;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=130;
int n=128,m=62;
char c[N];
int Ask(string s){
	cout<<"? "<<s<<endl;
	fflush(stdout);
	return read();
}
void Answer(string ans){
	cout<<"! "<<ans<<endl;
	fflush(stdout);
}
int cnt[N];
string Solve(int L,int R){
	if (L==R)
		return string(cnt[L],c[L]);
	int mid=(L+R)>>1;
	string a=Solve(L,mid),b=Solve(mid+1,R),c="";
	while (a.size()>0&&b.size()>0){
		string now=c+a[0]+b;
		if (Ask(now)==n-(int)now.size())
			c+=a[0],a=a.substr(1);
		else
			c+=b[0],b=b.substr(1);
	}
	return c+a+b;
}
int main(){
	For(i,0,25)
		c[i]='a'+i,c[i+26]='A'+i;
	For(i,0,9)
		c[i+52]='0'+i;
	int s=0;
	For(i,0,m-1)
		cnt[i]=n-Ask(string(n,c[i])),s+=cnt[i];
	n=s;
	Answer(Solve(0,m-1));
	return 0;
}

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

int main(){
  int N,i=1,a[200000],l,j=1,s[200000],k=0,n=0;
  cin >> N;
  s[0] = 0;
  while(cin>>l){
    a[i] = l;
    s[i] = 0;
    i++;
  }
  while(j<N){
    s[a[j]-1]=s[a[j]-1]+1;
    j++;
  }
  while(k<N){
    cout << s[k] <<endl;
    k++;
  }
}

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

int main(){
        std::map<int,bool> mp;
        int n;
        scanf("%d", &n);
        for(int i=0; i<n; i++){
                int a;
                scanf("%d", &a);
                mp[a] ^= 1;
        }

        int ans = 0;
        for(auto p: mp){
                if(p.second) ans ++;
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 4992
let for_range s e step f =
  let rec loop i =
    if i > e then ()
    else
      begin f i;loop (i + step) end
  in loop s;;
let _ =
  let num = 1000000 in
  let p = Array.init (num+1) (fun x -> 1) in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then
          begin
            p.(i*2) <- 0;
            for_range (i*3) num (i*2) (fun x -> p.(x) <- 0);
          end;
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0);
  for_range 4 num 2 (fun x -> p.(x) <- 0);loop 3;
  for i = 1 to num-1 do
    p.(i) <- p.(i) + p.(i-1);
  done;
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" p.(n);
        read ()
    with End_of_file -> ()
  in read ();;

Measured memory_bytes: 10252
n,k=map(int,input().split())
a=list(map(int,input().split()))
me=0 # Aの中の転倒数
right=0 # 自分より右に並んだAの中にある転倒数
for i in range(len(a)):
  for j in range(len(a)):
    if i==j:#自分同士は比較しない
      continue
    elif a[i]>a[j]:#a[i]のほうが大きい時
      right=right+1
      if i<j:
        me=me+1

total=me*k+right*(((k-1)*k)//2)
print(total%(10**9+7))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}


int main(){
	const double pi = acos(-1);
	double a, b, x;
	cin >> a >> b >> x;
	double ans = 0;
	if(a*a*b/2<=x){
		double h = x / (a*a);
		ans = atan2(b-h, a/2) / pi * 180;
	}else{
		double l = x / (a * b / 2);
		ans = atan2(b, l) / pi * 180;
	}
	printf("%.10lf\n", ans);

	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int cnt = 0;
        for(int i = 1; i < s.length(); i++) {
            if(s.charAt(i-1) == s.charAt(i)) continue;
            cnt++;
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 25300
import java.util.*

fun main(args: Array<String>) {
    val inputCount = readLine()!!.toInt()
    val nodeList = mutableListOf<Node>()
    val map = mutableMapOf<Int, MutableMap<Int, Long>>()
    nodeList.add(Node(0))
    (1..inputCount - 1).forEach {
        val inpt = readLine()!!.split(" ")
        val (a,b) = inpt.take(2).map { it.toInt() - 1 }
        listOf(a,b).forEach {
            if(!map.containsKey(it)) {
                map[it] = mutableMapOf()
            }
        }
        val len = inpt.last().toLong()
        map[a]!![b] = len
        map[b]!![a] = len
        nodeList.add(Node(it))
    }

    nodeList[0].col = Col.Black
    val queue = LinkedList<Int>()
    queue.add(0)
    while (queue.isNotEmpty()) {
        val current = queue.pop()
        map[current]!!.forEach {
            if(nodeList[it.key].col == Col.None) {
                if(it.value % 2 == 0.toLong()) {
                    nodeList[it.key] .col = nodeList[current].col
                } else if(nodeList[current].col == Col.Black) {
                    nodeList[it.key].col = Col.White
                } else {
                    nodeList[it.key].col = Col.Black
                }
                queue.add(it.key)
            }
        }
    }
    nodeList.forEach { println(if (it.col == Col.Black) "0" else "1") }
}

class Node(val id:Int) {
    var col = Col.None
}

enum class Col {
    None,
    Black,
    White
}

Measured memory_bytes: 121860
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    int buf;
    cin >> buf;
    A[i] = buf;
  }

  // find min
  int idx = -1;
  int minvalue = 1000000000;
  for (int i = 0; i < N; i++) {
    if (A[i] < minvalue) {
      idx = i;
      minvalue = A[i];
    }
  }
  int ans = 1000000;
  int Km1 = K - 1;
  for (int j = idx;  j < min(idx + K - 1, N); j++) {
      int nl = 0, k = j;
      for (; k > 0; k -= (K - 1)) {
        nl++;
      }
      if (k > 0) nl++;
      int nr = 0;
      k = j;
      for (; k < N - 1; k += (K - 1)) {
        nr++;
      }
      if (k < (N - 1)) nr++;
      if (nl + nr < ans) {
        ans = nl + nr;
      }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 640
//A - Coffee

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string s;

    cin >> s;

    if ((s[2] == s[3]) && (s[4] == s[5])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
price = A * X + B * Y
ma, mi = (X, Y) if X > Y else (Y, X)
ma_p, mi_p = (A, B) if X > Y else (B, A)

for i in range(1, ma+1):
    if i <= mi:
        temp = price - (ma_p + mi_p) + 2 * C
        if price > temp:
            price = temp
    else:
        temp = price - ma_p + 2 * C
        if price > temp:
            price = temp

print(price)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
 
int main()
{
  int d, t, s;
  cin >> d >> t >> s;
  
  string ans;
  if(s*t >= d) ans = "Yes";
  else ans = "No";
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 3616
K = gets.chomp.to_i

memo = [false] * (K + 1)
amari = 7

1.step do |i|
  amari %= K
  if amari.zero?
    puts i
    exit
  end

  if memo[amari]
    puts "-1"
    exit
  end
  
  memo[amari] = true
  amari = amari * 10 + 7
end

Measured memory_bytes: 22028
#include<iostream>
using namespace std ;
#define ll long long int
#define modm  1000000007
#include<map>
#include<algorithm>
#include<vector>

ll pow( ll a , ll b )
{

    if( b==0)
        return 1 ;


    ll   c= pow(a , b/2) ;
    c= (c*c)%modm ;


    if(b%2==1)
    {

        c= (c*a)%modm ;
    }

    return c  ;
}

ll gdc (ll a , ll b)
{

    if(a==0)
        return b ;
    return gdc( b%a , a ) ;
}
pair<ll ,ll> fract( ll a , ll b )
{


    ll d = 1 ;
    if(  (a<0 && b>0 )  ||  (a>0 && b<0) )
    {
        d= -1 ;
    }
        a = abs(a) ;
        b = abs(b) ;

    ll c = gdc( a , b) ;


    return make_pair(d*(a/c) , b/c ) ;
}
int main()
{

    ll n ;
    cin>> n ;
    map<pair<ll, ll> , ll >count ;
    ll zer = 0 ;


    for(ll i =0;i< n ;i++)
    {

        ll a  , b ;
        cin>>a >> b ;

        if(a==0 && b==0)
        {

            zer = (zer+1)%modm ;
            continue ;
        }


        pair<ll ,ll> inp = fract ( a ,b );



        count[inp]++ ;

    }


    ll ans = 1 ;
    for(auto brr : count )
    {





        pair<ll ,ll> arr  , i  ;
        i = brr.first ;




        if( i.first==0  && i.second!=0 )
        {

            arr = make_pair( 1 ,0 )  ;
        }else if( i.second == 0 && i.first!=0  )
        arr = make_pair( 0 ,1 ) ;
        else
        {

            ll sig = 1 ;
            if( i.first  <0 )
                sig = -1 ;

                arr=  make_pair( -1*sig*abs(i.second) , abs(i.first ) )  ;

        }

        ll cnt =( (  (pow( 2 ,brr.second  ) )%modm  +  (pow( 2 , count[ arr] )  )%modm  )%modm -1 +modm    )%modm   ;




         ans = (ans*cnt)%modm ;

if( count.find(arr)!=count.end())
        count.erase ( arr ) ;
count.erase(i) ;





    }
    ans=  (ans+  (zer)%modm )%modm   ;
ans = (ans+ modm -1)%modm ;
    cout<< ans<<endl;



}


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

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<bint,bint>
#define endl              "\n"
#define rep(i,a,b)        for(bint i=a;i<b;i++)
#define repe(i,a,b)       for(bint i=a;i<=b;i++)
#define bac(i,a,b)        for(bint i=a;i>b;i--)
#define bace(i,a,b)       for(bint i=a;i>=b;i--)
#define fast              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//CHANGE IF REQ
#define int               long long int
#define bint              int
//-----------------

#define ld                long double
#define mod1              (bint)(1e9 + (bint)7)
#define mod2              (bint)998244353
#define pi                (float)3.14159265358979323846
#define inf               LLONG_MAX
#define ninf              (bint)-1*LLONG_MAX

#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define RSORT(v)          sort(all(v),greater<bint>())
#define REVERSE(v)        reverse(all(v))

#define trav(a, x)        for(auto& A : x)
#define display(x)        trav(A,x) cout<<A<<endl;
#define pow(i,n)          (bint)pow((bint)i,n)
#define pow2(n)           ((bint)1<<n)
#define sz(x)             (bint)x.size()

typedef std::priority_queue<bint, std::vector<bint>, std::greater<bint> > min_pq;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

inline string inttos(bint a){std::stringstream soso; soso<<a; return soso.str();}
inline bint stoint(const std::string &s) {std::stringstream soso; soso << s; long long x; soso >> x; return x;}
inline std::string inttobin(bint x) {return std::bitset<40>(x).to_string();}
inline void swp(bint &a, bint &b){auto temp=a;a=b;b=temp;}

//pri - 1000000009
//ba  - 937,991,1013,1409,1741

void solve(){
    int n;
    cin>>n;
    DECIMAL(10);
    cout<<2*pi*n<<endl;

}


signed main(){
    fast

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


    int t=1;
    //cin>>t;
    rep(i,0,t){
       solve();
    }
}

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

using namespace std;

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;
  
  

int main(){
  int n; 
  string s;
  cin >> n >> s;
  
  ll ans = 0;
  ll r = 0;
  ll g = 0;
  ll b = 0;
  
  
  for(ll i=0; i<n; i++){
    char c = s.at(i);
    if(c == 'R'){
      r++;
    }
    else if(c == 'G'){
      g++;
    }
    else{
      b++;
    }
  }
  
  ans = r*g*b;
  
  for(ll i=0; i<n; i++){
    for(ll j=i+1; j<n; j++){
        if(2*j-i<n){
          if((s.at(i) != s.at(j)) && (s.at(i) != s.at(2*j-i)) && (s.at(j) != s.at(2*j-i)))
            ans--;
      }
    }
  }
  
  
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
n = int(input())
testimony = []  # 各iの証言
for i in range(n):
    t = []
    for _ in range(int(input())):
        x, y = map(int, input().split())
        t.append((x - 1, y))
    testimony.append(t)
best = 0  # 正直者の最大人数
for honest in range(1 << n):  # 正直者をあらかじめ仮定して破綻を確認する
    for i in range(n):  # 証言者i
        if not (honest >> i) & 1:  # iが不親切な人なら証言を聞かない
            continue
        for j, t in testimony[i]:  # iによるjに対する証言t
            if (honest >> j) & 1 ^ t:  # jに対する仮定とtが食い違えば破綻
                break
        else:
            continue
        break
    else:  # 全ての正直者に話を聞いて破綻が無ければ更新
        best = max(best, bin(honest).count('1'))
print(best)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    long long int n,j,array[110],i,ans=0,dif;

    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>array[i];
        if(i!=0)
        {
            for(j=0; j<i; j++)
            {
                if(array[i]>array[j])
                    dif=array[i]-array[j];
                else
                    dif=array[j]-array[i];
                if(ans<dif)
                    ans=dif;
            }
        }
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256