akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int x = ni();
		int y = ni();
		int result = 0;
		if(x == 3) {
			result += 100000;
		} else if (x == 2) {
			result += 200000;
		} else if (x == 1) {
			result += 300000;
		}
		
		if(y == 3) {
			result += 100000;
		} else if (y == 2) {
			result += 200000;
		} else if (y == 1) {
			result += 300000;
		}
		
		if(x == 1 && y == 1) {
			result += 400000;
		}
		System.out.println(result);		
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi a(n);
	map<i64, int> mp;
	i64 cou = 0, sum = 0;
	mp[0]++;
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
		cou += mp[sum];
		mp[sum]++;
	}
	cout << cou << endl;
	return 0;
}

Measured memory_bytes: 13568
#include <stdio.h>
int main(){
	int n;
	char str[n+2];
	
	scanf("%d", &n);
	scanf("%s", str);
	if(n % 2 != 0){
		printf("No");
		return 0;
	}
	for(int i =0; i<n/2; i++){
		if(str[i]!=str[(n/2)+i]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
 
	
	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main(int argc, char const* argv[])
{
  int a, b, c;
  cin>>a>>b>>c;

  map<int,int> m;
  m[a]++;
  m[b]++;
  m[c]++;

  if(m.size()==2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
# ABC141D - Powerful Discount Tickets
from heapq import heapify, heappop, heappush


def main():
    N, M, *A = map(int, open(0).read().split())
    H = [-i for i in A]
    heapify(H)
    pop_max, push_max = lambda: -heappop(H), lambda x: heappush(H, -x)
    for _ in range(M):
        x = pop_max()
        push_max(x // 2)
    ans = -sum(H)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,k;
    cin>>n>>k;
    ll h[n];
    rep(0,i,n){
        cin>>h[i];
    }
    sort(h,h+n);
    if(n<=k){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    rep(0,i,n-k){
        ans+=h[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
a = [0 for i in range(M)]
for i in range(M):
	k, *s = map(int, input().split())
	for j in range(k):
		a[i] = a[i] | (1 << (s[j] - 1))
p = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
	ok = True
	for i in range(M):
		x = a[i] & bit
		if bin(x).count("1") % 2 != p[i]:
			ok = False
			break
	if ok:
		ans += 1
print(ans)
		

Measured memory_bytes: 3064
import heapq

N = int(input())
a = list(map(int, input().split()))

push = heapq.heappush
pop = heapq.heappop
lq = []
l = [0] * (N + 1)
for i in range(N):
  push(lq, a[i])
  l[0] += a[i]
for i in range(N):
  l[i + 1] = l[i]
  x = pop(lq)
  if a[N + i] > x:
    l[i + 1] += a[N + i] - x
    push(lq, a[N + i])
  else:
    push(lq, x)

rq = []
r = [0] * (N + 1)
for i in range(N):
  push(rq, -a[-1 -i])
  r[-1] += a[-1 -i]
for i in range(N):
  r[-2 -i] = r[-1 -i]
  x = pop(rq)
  if a[-N-1 -i] < -x:
    r[-2 -i] -= -x -a[-N-1 -i]
    push(rq, -a[-N-1 -i])
  else:
    push(rq, x)

ans = l[0] - r[0]
for i in range(1, N + 1):
  ans = max(ans, l[i] - r[i])

print(ans)

Measured memory_bytes: 37212
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

void checkStream() {
    #ifndef _DEBUG
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
}

void inMat (vector<vector<int>> &mat, const int &num) {
    bool found {false};
    for (auto &i: mat) {
        for (auto &j: i) {
            if (j == num) {
                found = true;
                j = 0;
                break;
            }
        }
        if (found) break;
    }
}

int main() {
    // checkStream();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // vector<vector<bool>> mat (3, vector<bool> (3, false));
    vector<vector<int>> mat (3, vector<int> (3));
    for (auto &i: mat) {
        for (auto &j: i)
            cin >> j;
    }

    int n {};
    cin >> n;
    while (n--) {
        int num {};
        cin >> num;

        inMat(mat, num);
    }

    bool found {true};
    for (int i {}; i < 3; ++i) {
        if (mat.at(i).at(i)) {
            found = false;
            break;
        }
    }

    if (found) {
        cout<<"Yes"<<endl;
        return 0;
    }
    found = true;
    for (int i {}, j {2}; i < 3; ++i, --j) {
        if (mat.at(i).at(j)) {
            found = false;
            break;
        }
    }
    if (found) {
        cout<<"Yes"<<endl;
        return 0;
    }

    for (int i {}; i < 3; ++i) {
        found = true;
        for (int j {}; j < 3; ++j) {
            if (mat.at(i).at(j)) {
                found = false;
                break;
            }
        }
        if (found) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    for (int i {}; i < 3; ++i) {
        found = true;
        for (int j {}; j < 3; ++j) {
            if (mat.at(j).at(i)) {
                found = false;
                break;
            }
        }
        if (found) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int n,k;
int array[101][101];
int t[101]={};
int flag[101]={};
int a,b,c,d,e;
int i,j;

int dijkstra(int start,int goal){
  for(int i = 0 ; i < 101 ; i++){
    t[i]=100000000;
    flag[i]=0;
  }

  t[start]=0;

  for(int i = 0 ; i < n ; i++ ){
    int min = 100000000;
    int num  = -1;  
    for( j = 0 ; j < n ; j++ ){
      if( flag[j]==0 && t[j] < min ){
	min = t[j];
	num = j;
      }
    }
    if(num==-1)break;
    if(num == goal) {
      return t[num];
    }
    flag[num]=1;
    for( j = 0 ; j < n ; j++ ){
      if( array[num][j]!=1000001 && flag[j]==0 && t[j] > t[num]+array[num][j] ){
	t[j] = t[num]+array[num][j];
      }
    } 

  } 
  return -1;
}

int main(){
  int ans;
  while(1){
    cin >> n >> k;
    if(n==0&&k==0){
      break;
    }
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
	array[i][j]=1000001;
      }
    }
    for(i = 0 ; i < k ; i++){
      cin >> a;
      if(a==1){
	cin >> c >> d >> e;
	c--;
	d--;
	if(array[c][d]!=0 && array[c][d] > e){
	  array[c][d]=e;
	  array[d][c]=e;
	}
      }else{
	cin >> a >> b;
	a--;
	b--;
	ans = dijkstra(a,b);
	cout << ans << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1200
N = int(input())
K = int(input())

X = str(N)

dp = [[[0] * (K+1) for _ in range(2)] for _ in range(len(X)+1)]
dp[0][0][0] = 1

for i in range(len(X)):
    D = int(X[i])
    for j in range(2):
        for k in range(K + 1):
            for d in range((9 if j == 1 else D) + 1):
                if k + int(d != 0) <= K:
                    dp[i + 1][j | (d < D)][k + int(d != 0)] += dp[i][j][k] 
print(dp[-1][0][-1]+dp[-1][1][-1])

Measured memory_bytes: 41072
/* Atcoder abc151a
 * See tasks at: https://atcoder.jp/contests/abc151/tasks/abc151_a
 */
#include <iostream>
#include <vector>
#include <algorithm>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    char c;
    cin >> c;

    cout << ++c;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
ll a[200000];
ll b[200000];
int main()
{
	ll N,K;
	cin>>N>>K;
	for(ll i=0;i<N;i++)
	{
		cin>>a[i];
		a[i]++;
		b[i] = i>0?b[i-1]+a[i]:a[i];
	}
	
	ll sum = 0;
	for(ll i=K-1;i<N;i++)
	{
		if( sum < b[i]-b[i-K] )
			sum = b[i]-b[i-K];
	}
	
	cout << fixed << setprecision(10) << sum/2.0 << endl; 
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
#define MOD 1000000007
using namespace std;

int main() {
	int n;
	int count = 0, m = 100001;
	ll ans = 0;
	bool flag = true;
	cin >> n;
	vector<ll>a(n);
	REP(i, n) {
		cin >> a[i];
		if (a[i] < 0) {
			count++;
			a[i] = abs(a[i]);
		}
		ans += a[i];
	}
	REP(i, n) {
		if (a[i] == 0){
			flag = false;
			break;
		}
	}
	if (count % 2 == 0) {
		flag = false;
	}
	if (!flag) {
		cout << ans << endl;
	}
	else {
		REP(i, n) {
			if (m > a[i]) {
				m = a[i];
			}
		}
		cout << ans - 2 * m << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
s=input()
n=len(s)
a_seq=0
last='x'
ans=0
count=10*6
for i in s:
    if i=='A':
        if last=='A':
            a_seq=a_seq+1
        else:
            a_seq=1
        count=2
        last=i
    elif i=='B':
        count=count-1
        last=i
    else:
        if count==1 and last=='B':
            ans=ans+a_seq
            count=2
            last='A'
        else:
            a_seq=0
            count=count-1
            last='C'
print(ans)
        


Measured memory_bytes: 42076
#include <iostream>
#include <stdint.h>

using namespace std;

#define MOD 1000000007
#define SIZE 100000

static uint32_t nums[SIZE];

int32_t main()
{
  uint32_t N;
  cin >> N;
  for(uint32_t i = 0; i < N; i++){
    uint32_t n;
    cin >> n;
    nums[n]++;
  }

  uint64_t count;
  if(N % 2 == 1){
    if(nums[0] == 1){
      count = 1;
    } else{
      count = 0;
    }
  } else{
    count = 1;
  }

  for(uint32_t i = 1; i < N; i++){
    if(nums[i] == 2){
      count *= 2;
    } else if (nums[i] == 0){
      count *= 1;
    } else{
      count = 0;
    }
    count %= MOD;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 640
# not solved only by myself
N = int(input())

def get_nums(wa,ar):
    ar = sorted(ar,reverse=True)
    tmp = 0
    for a in ar:
        tmp += wa // a
        wa %= a
    return tmp + wa


nines = []
tmp = 9
while tmp <= N:
    nines.append(tmp)
    tmp *= 9

sixes = []
tmp = 6
while tmp <= N:
    sixes.append(tmp)
    tmp *= 6



res = N
for t in range(0,N + 1):
    hoge = get_nums(t,sixes) + get_nums(N - t,nines)
    res = min(res,hoge)

print(res)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
	int H;
	int W;
	int i,j = 0;
	while(1){
		scanf("%d %d",&H,&W);
		if ((H==0)||(W==0))break;
		
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if((j%2)==(i%2)){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
		i++;
	}
	
	return 0;
}



Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B, C, D;
  cin >> N;
  
  D = N % 10;
  C = (N % 100 - D) / 10;
  B = (N % 1000 - C * 10 - D) / 100;
  A = (N - B * 100 - C *10 - D) / 1000;
 
  if (B == C) {
    if (A == B || B == D){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

H, W = map(int, input().split())

m = [[0 for _ in range(W)] for _ in range(H)]
black = []
for i in range(H):
    # m.append(list(map(lambda x: 0 if x=="#" else 1, input()))）
    for j, c in enumerate(input()):
        if c == "#":
            m[i][j] = 1
            black.append((i, j, 0))

# print(m)
# print(root)

queue = deque(black)
ans = 0
while queue:
    p = queue.popleft()
    if ans < p[2]:
        ans += 1
    for i, j in ((-1, 0), (1, 0), (0, 1), (0, -1)):
        next_p = (p[0] + i, p[1] + j)
        if (0 <= next_p[0] < H) and (0 <= next_p[1] < W):
            if not m[next_p[0]][next_p[1]]:
                m[next_p[0]][next_p[1]] = 1
                queue.append((next_p[0], next_p[1], ans+1))
print(ans)


Measured memory_bytes: 138712
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
to = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

count = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    count[p] += x

stack = [0]
visited = [0] * N
while stack:
    v = stack.pop()
    visited[v] = 1
    for next_v in to[v]:
        if visited[next_v] == 1:
            continue
        count[next_v] += count[v]
        stack.append(next_v)
print(*count)

Measured memory_bytes: 55856
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  int n;
  cin >> n;
  ivec a(n);
  REP(i, n) cin >> a[i];

  ll ans = a[0];

  FOR(i, 1, n) { ans = min(ans, gcd(ans, a[i])); }

  print(ans);
  return 0;
}

Measured memory_bytes: 640
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long

using namespace std;

const int N = 2e3 + 7;

int32_t main() {
    speed;
    double n, mx = 1;
    cin >> n;
    mx *= n / 3;
    mx *= n / 3;
    mx *= n / 3;
    cout << fixed << setprecision(10) << mx << '\n';
}   
  

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

const int Maxn = 100005;

int n, k;
char str[Maxn];
int cnt;

int main()
{
    scanf("%d %d", &n, &k);
    scanf("%s", str);
    cnt = 1;
    for (int i = 0; i + 1 < n; i++)
        if (str[i] != str[i + 1])
            cnt++;
    int res = n - cnt;
    for (int i = 2; i <= cnt && k > 0; i += 2) {
        k--;
        if (i < cnt) res += 2;
        else res++;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N;
  vec v(N);
  cout<<N*N<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 
int N;
int K;
string S;
string ans;

int main(){
    cin >> N >> K;
    cin >> S;
    
    if(S[K-1] == 'A') { 
        S[K-1] = 'a';
    }else if(S[K-1] == 'B'){
        S[K-1] = 'b';
    }else if(S[K-1] == 'C'){
        S[K-1] = 'c';
    }
    ans = S;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
N,Y = map(int,input().split()) 
for i in range(N+1):
    for j in range(N+1-i):
        if 10000*i+5000*j+1000*(N-i-j)== Y and 0<=(N-i-j)<=N:
            print(i,j,N-i-j) 
            exit() 

print(-1,-1,-1)

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  long long  n,tmp,cnt=0;
  map<string,long long > mp;
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    mp[s[i]]++;
  }
  for(auto i=mp.begin();i!=mp.end();i++){
    tmp = i->second;
    if(tmp>1){
      cnt += ((tmp-1)*tmp)/2;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 18176
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        k = j*2-i
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt +=1
print(r*g*b - cnt)

Measured memory_bytes: 9136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();

		char[][] C = new char[H][];
		for (int i = 0; i < H; i++) {
			C[i] = sc.next().toCharArray();
		}
		sc.close();

		int[][] cost = new int[H + 1][H + 1];
		int[][] wk = new int[H + 1][H + 1];
		int ans = 0;
		for (int w = 0; w < W - 1; w++) {
			for (int d = -H; d <= H; d++) {
				for (int left = Math.max(1, 1 - d); left <= Math.min(H,
						H - d); left++) {
					cost[left][left + d] = cost[left - 1][left + d - 1]
							+ (C[left - 1][w] == C[left + d - 1][w + 1] ? 1
									: 0);
				}
			}
			for (int i = 1; i <= H; i++) {
				for (int j = 1; j <= H; j++) {
					wk[i][j] = Math.min(wk[i - 1][j], wk[i][j - 1])
							+ cost[i][j];
				}
			}
			ans += wk[H][H];
		}

		System.out.println(ans);
	}
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


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

using namespace std;

long long a[100001];
long long pref[100001];
int d[100001];

int main () {
	int n;
	cin >> n;
	for (int i = 1;i <= n;i ++) cin >> a[i];
	sort (a + 1, a + n + 1);
	for (int i = 1;i <= n;i ++) pref[i] = pref[i - 1] + a[i];
	int ans = 1;
	d[n] = 1;
	for (int i = n - 1;i >= 1;i --) {                                                                          
		if (pref[i] * 2 >= a[i + 1] && d[i + 1]) {
			d[i] = 1;
			ans ++;
		} 
	}
	cout << ans;
	return 0;   	
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
 
using namespace std;

int main(){
 
  int n;
 
  cin >> n;
  
  long a[n+1],b[n],ans=0.0;
  
  //入力を受け取る
  rep(i,0,n)cin >> a[i]; 
  rep(i,0,n-1)cin >> b[i];
  
  rep(i,0,n-1){
    //勇者iが倒せる数が残っていないときは次の勇者へ
    if(b[i]==0)continue;

    //勇者iが倒せる数が残っているモンスターの数より少ないときは倒せるだけ倒す
    //都市iのモンスターを倒しきれないとき
    if(b[i] <= a[i]){
      ans += b[i];
      continue;
    }

    //勇者iが倒せる数が残っているモンスターの数より少ないときは倒せるだけ倒す
    //都市iのモンスターは倒せるが都市i+1のモンスターは倒しきれないとき
    if(b[i] <= a[i] + a[i+1]){
      ans += b[i];
      b[i] -= a[i];
      a[i+1] -= b[i];
      continue;
    }

    //勇者iが都市i, i+1のモンスターをすべて倒しきれるときはすべて倒す
    ans += a[i]+a[i+1];
    //a[i]も0にすべきだが、この変数はこの後使わないので省略
    a[i+1]=0;
  }
 
  cout << ans << endl;
 
  return 0;
 
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            String s = sc.next();

            if (a >= 3200) {
                System.out.println(s);
            } else {
                System.out.println("red");
            }
        }
    }

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	vector<array<int, 2>> a(n);
	int minval = numeric_limits<int>::max(), maxval = numeric_limits<int>::min();
	int minval2 = minval, maxval2 = maxval;
	int minval3 = minval, maxval3 = maxval;
	for(auto i = 0; i < n; ++ i){
		for(auto j = 0; j < 2; ++ j){
			cin >> a[i][j];
		}
		ctmax(maxval, a[i][0] + a[i][1]), ctmin(minval, a[i][0] + a[i][1]);
		ctmax(maxval2, a[i][0] - a[i][1]), ctmin(minval2, a[i][0] - a[i][1]);
		ctmax(maxval3, a[i][1] - a[i][0]), ctmin(minval3, a[i][1] - a[i][0]);
	}
	cout << max({maxval - minval, maxval2 - minval2, maxval3 - minval3}) << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

const int maxn = 100010;
int n, a[maxn], c[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]), c[a[i]]++;
    }
    sort(a + 1, a + n + 1);
    if (a[n - 1] ^ a[n]) {
        printf("Impossible\n"), exit(0);
    }
    c[a[n]] -= 2;
    for (int i = 1; i < a[n]; i++) {
        int d = max(i, a[n] - i);
        if (!c[d]--) printf("Impossible\n"), exit(0);
    }
    for (int i = 1; i <= (a[n] + 1) / 2; i++) {
        if (c[i]) printf("Impossible\n"), exit(0);
    }
    printf("Possible\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n==0) break;
            int[] s = new int[n];
            double ave = 0.0;
            for(int i = 0; i<n; i++){
                s[i] = sc.nextInt();
                ave += s[i];
            }
            ave /= (double)n;
            double v = 0;
            for(int i = 0;i<n;i++){
                v += (s[i] - ave)*(s[i] - ave);
            }
            double ans = Math.sqrt(v/(double)n);
            System.out.printf("%f\n", ans);
        }
        sc.close();
    }
}


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

int main(){
  int N;
  cin >> N;
  float rev = 0;
  float A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    rev += 1.0/A[i];
  }
  float ans = 1.0/rev;
  printf("%.7f\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define inf 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define se second
#define fi first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	string s[n];
	for(int i=0;i<n;++i)
		cin>>s[i];
	int ans[n][m];
	if(s[0][0]=='#')
		ans[0][0]=1;
	else
		ans[0][0]=0;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<m;++j)
		{
			if(i==0&&j==0)
				continue;
			ans[i][j]=inf;
			if(i-1>=0)
			{
				if(s[i-1][j]==s[i][j])
					ans[i][j]=min(ans[i-1][j],ans[i][j]);
				else
				{
					if(s[i][j]=='.')
						ans[i][j]=min(ans[i-1][j],ans[i][j]);
					else
						ans[i][j]=min(ans[i-1][j]+1,ans[i][j]);
				}
			}
			if(i>=0)
			{
				if(s[i][j-1]==s[i][j])
					ans[i][j]=min(ans[i][j-1],ans[i][j]);
				else
				{
					if(s[i][j]=='.')
						ans[i][j]=min(ans[i][j-1],ans[i][j]);
					else
						ans[i][j]=min(ans[i][j-1]+1,ans[i][j]);
				}
			}
		}
	}
	cout<<ans[n-1][m-1];
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

Measured memory_bytes: 384
n = int(input())
 
adj = [None]
for i in range(n):
    adji = list(map(int, input().split()[2:]))
    adj.append(adji)
isSearched = [None] + [False] * n
distance = [None] + [-1] * n
def BFS(u):
    d = 0
    isSearched[u] = True
    distance[u] = d
    edge = [u]
    while edge:
        q = list(edge)
        edge = []
        d += 1
        for ce in q:
            for ne in adj[ce]:
                if not isSearched[ne]:
                    isSearched[ne] = True
                    edge.append(ne)
                    distance[ne] = d
BFS(1)
for i, x in enumerate(distance[1:], start=1):
    print(i, x)

Measured memory_bytes: 7760
h, w = map(int, input().split())
a = [[0 for j in range(w)] for i in range(h)]
b = [0 for i in range(w)]
for i in range(h):
    x = list(map(int, input().split()))
    for j in range(w): a[i][j] = x[j]
for i in range(w): b[i] = int(input())
c = [0 for i in range(h)]
for i in range(h):
    for j in range(w):
        c[i] += a[i][j] * b[j]
for i in range(h):
    print(c[i])



Measured memory_bytes: 5952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readT(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		S = str;
	}

	String S;

	public void readT(String str) {
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			if (S.charAt(i) == str.charAt(i))
				ans++;
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;

int main(){
    
    ll n;
    cin>>n;
    cout<<(n+n*n+n*n*n);
	
	
	
	 
	
}
    


	
	
    



Measured memory_bytes: 3616
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] p = new int[N + 1];
        for (int i = 1; i <= N; i++) p[i] = sc.nextInt();
        int[] x = new int[M];
        int[] y = new int[M];
        for (int i = 0; i < M; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        UnionFind uf = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            uf.union(x[i], y[i]);
        }
        int cnt = 0;
        for (int j = 1; j <= N; j++) {
            if (j == p[j]) {
                cnt++;
                continue;
            }
            if (uf.isConnected(j, p[j])) cnt++;
        }
        System.out.println(cnt);
    }

    static class UnionFind {
        int n;
        int[] id;
        int[] sz;

        public UnionFind(int n_) {
            n = n_;
            id = new int[n + 1];
            sz = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                id[i] = i;
                sz[i] = 1;
            }
        }

        private int find(int p) {
            if (id[p] == p) return id[p];
            while (id[p] != p) {
                id[p] = id[id[p]];
                p = id[p];
            }
            return p;
        }

        public boolean isConnected(int p, int q) {
            return find(p) == find(q);
        }

        public void union(int p, int q) {
            int i = find(p);
            int j = find(q);
            if (i == j) return;
            if (sz[i] < sz[j]) {
                sz[j] += sz[i];
                id[i] = j;
            } else {
                sz[i] += sz[j];
                id[j] = i;
            }
        }
    }
}


Measured memory_bytes: 90460
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

if A == B:
    print(A + B)
elif A > B:
    print(2 * A - 1)
else:
    print(2 * B - 1)


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    vector< P > v;
    for( int i = 0; i < n; ++i ) {
        int x, l;
        cin >> x >> l;
        v.pb(MP(x + l, x - l));

    }
    sort(all(v));

    int en = v[0].F;
    int cnt = 1;
    for( int i = 1; i < v.size(); ++i ) {
        if( en <= v[i].S ) {
            ++cnt;
            en = v[i].F;

        }
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 1400
m,i,j,k,c[],p,d;main(n){for(;scanf("%d%d",&n,&m),n;printf("%d\n",j>m?-1:j)){for(k=3;k--;)for(scanf("%d",&i);i--;c[j]=k)scanf("%d",&j);for(j=k=0;k++<n;p=i%2*2+p&3)j+=pow(3,n-k)*abs(i=p-c[k]);j=fmin(j,pow(3,n)+~j);}}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
 
int main()
{
    ll n, p, q;
    cin>>n>>p>>q;
    ll c[500000];
    P c1[500000];
    ll ans[500001];
    ans[0]=0;
    for(ll i=0; i<n; i++){
        cin>>c[i];
        ans[0]+=c[i];
        c1[i]=P(c[i]+p*i, i);
    }
    sort(c1, c1+n);
    for(ll m=0; m<n; m++){
        ll i=c1[m].second;
        ans[m+1]=ans[m]-c[i];
        ans[m+1]+=(p*(q-i+2*m));
    }
    ll mx=ans[0];
    for(ll m=1; m<=n; m++){
        mx=max(mx, ans[m]);
    }
    cout<<mx<<endl;
    return 0;
}


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

int main(){

    int m,f,r,Sum;

    while(true){
        scanf(" %d %d %d",&m,&f,&r);
        Sum = m+f;
        if(m == -1 && f == -1 & r == -1){
            break;
        }else if(m == -1 || f == -1){
            printf("F\n");
        }else if(80 <= Sum){
            printf("A\n");
        }else if(65 <= Sum){
            printf("B\n");
        }else if(50 <= Sum){
            printf("C\n");
        }else if(30 <= Sum){
            if(50 <= r){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else if(Sum < 30){
            printf("F\n");
        }
    }

    
    

    return 0;
}



Measured memory_bytes: 2548
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 H = sc.nextInt();
		int W = sc.nextInt();
		char[] weather = new char[W];
		int[][] p = new int[H][W];
		
	    
	    for(int i = 0; i < H; i++){
	    	weather = sc.next().toCharArray();
	    	int cnt = -1;
	    	for(int k = 0; k < W; k++){
	    		if(weather[k] == 'c'){
	    			cnt = 0;
	    		}
	    		else if(cnt != -1 && weather[k] == '.'){
	    			cnt++;
	    		}
	    		p[i][k] = cnt;
	    	}
	    }
	    
	    for(int i = 0; i < H; i++){
	    	for(int k = 0; k < W; k++ ){
	    		System.out.print(p[i][k]);
	    		if(k < W-1)System.out.print(" ");
	    		if(k != 0 && k % (W-1) == 0) System.out.println();
	    	}
	    }
	    sc.close();
	}

}

Measured memory_bytes: 36404
#include <stdio.h>
#define M 100
#define INFTY 21
int graph_s[M][M];
int comp[M],count[M],out[M];
int head=0,tail=0,n;


void enqueue(int x){
  out[tail]=x;
  if(tail+1==M)tail=0;
  else tail++;
}

int dequeue(){
  int x;
  x=out[head];
  if(head+1==M) head=0;
  else head++;
  return x;
}

 int empty(){
   if(head==tail) return 1;
   else return 0;
 }


void bfs(){
  int comp[M];
  int count[M];
  int i,x;
  for(i=0;i<n;i++){
    comp[i]=0;
    count[i]=INFTY;
  }
  comp[0]=1;
  count[0]=0;
  enqueue(0);

  while(!empty()){
    x=dequeue();
    for(i=0;i<n;i++){
      if(graph_s[x][i] && comp[i]==0){
        comp[i]=1;
        count[i]=count[x]+1;
        enqueue(i);
      }
    }
    comp[x]=2;
  }
  for(i=0;i<n;i++){
    printf("%d ",i+1);
    if(count[i]==INFTY) printf("-1\n");
    else printf("%d\n",count[i]);
  }
}

int main(){
  int i,j,nu,out,near;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      graph_s[i][j]=0;
    }
  } 
  for(i=0;i<n;i++){
    scanf("%d%d",&nu,&out);
    for(j=0;j<out;j++){
      scanf("%d",&near);
      graph_s[nu-1][near-1]=1;
    }
  }

  bfs();

  
  return 0;
}



Measured memory_bytes: 2124
N = int(input())
B = list(map(int, input().split()))
A = [0] + B + [0]
s = 0
t = 0

for i in range(1,N+2):
    t += abs(s-A[i])
    s = A[i]

for i in range(1,N+1):
    print(t + abs(A[i-1]-A[i+1]) - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]))


Measured memory_bytes: 14044
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln


void main() {
	const int MOD = 1_000_000_007;
	int n;
	scanf("%d", &n);
	int[] cb = new int[n+1];
	cb[0] = 1;
	foreach (i; 2..n+1) {
		if (i&1) continue;
		cb[i] = long(cb[i-2])*(i-1)%MOD;
	}

	int[][] e = new int[][](n);
	foreach (i; 0..n-1) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--; y--;
		e[x] ~= y;
		e[y] ~= x;
	}

	int[][] dfs(int v, int par=-1) {
		int[][] dp = new int[][](2,2);
		dp[0][1] = 1;
		foreach (u; e[v]) {
			if (u == par) continue;
			auto d = dfs(u,v);
			int nv = dp[0].length.to!int;
			int nu = d[0].length.to!int;
			int[][] p = new int[][](2,nv+nu-1);
			swap(dp,p);
			foreach (bi; 0..2) foreach (i; 0..nv) {
				foreach (bj; 0..2) foreach (j; 0..nu) {
					(dp[bi^bj][i+j] += long(p[bi][i])*d[bj][j]%MOD) %= MOD;
				}
			}
		}
		foreach (bi; 0..2) foreach (i; 2..dp[0].length) {
			if (i&1) continue;
			(dp[bi^1][0] += long(dp[bi][i])*cb[i]%MOD) %= MOD;
		}
		return dp;
	}

	auto dp = dfs(0);
	int ans = (dp[1][0]-dp[0][0]+MOD)%MOD;
	writeln(ans);
}

Measured memory_bytes: 6012
/*
g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
./main.exe
*/

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()

#define ll long long int

using namespace std;

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::greater<T>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::less<T>());
    return;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    if(n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) b[i] = a[i] - (i + 1);
    sort(b.begin(), b.end());
    ll ans = 0;

    if (n%2 == 1){
        int med = b[(n - 1) / 2];
        rep(i,n) ans += abs(a[i] - med - (i + 1));
    }

    else{
        ll ans1 = 0, ans2 = 0;
        ll med1 = b[n / 2];
        ll med2 = b[n / 2 - 1];
        rep(i,n) ans1 += abs(a[i] - med1 - (i + 1));
        rep(k,n) ans2 += abs(a[k] - med2 - (k + 1));
        ans = min(ans1, ans2);
    }
    cout << ans << endl;
}

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

int main(){
  string s;
  int count;
  
  cin >> s;
  if (s[0] == '1') ++count;
  if (s[1] == '1') ++count;
  if (s[2] == '1') ++count;
  
  cout << count << endl;
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  
  Int n=s.size();
  Int zero=0;
  for(Int i=0;i<n;i++) zero+=s[i]=='0';
  
  auto inc=
    [&]{
      Int p=n-1;
      while(p>=0){
	zero-=s[p]=='0';
	if(s[p]!='9'){
	  s[p]++;
	  zero+=s[p]=='0';
	  break;
	}
	s[p--]='0';
	zero++;
      }
    };
  
  auto dec=
    [&]{
      Int p=n-1;
      while(p>=0){
	zero-=s[p]=='0';
	if(s[p]!='0'){
	  s[p]--;
	  zero+=s[p]=='0';
	  break;
	}
	s[p--]='9';
      }
    };

  auto sub=
    [&](Int i){
      Int c=s[i]-'0';
      for(Int j=i;j<n;j++){
	zero-=s[j]=='0';
	s[j]-=c;
	zero+=s[j]=='0';
      }
    };

  auto sz=
    [&](Int k){
      zero-=s[k]=='0';
      s[k]='0';
      zero++;
    };
  
  vector<Int> cnt(n+1,0);
  Int ans=0;
  Int j=0;
  for(Int i=0;i<n;i++){
    if(s[i]=='0') continue;
    chmax(j,i);
    Int d=-1;
    while(j+1<n){
      if(d<0&&s[j]!=s[j+1]) d=j;
      if(s[j]>s[j+1]) break;
      j++;
    }
    if(j+1==n){
      ans+=s[i]-'0';
      cnt[i]+=s[i]-'0';
      sub(i);j=-1;
    }else if(s[d]<s[d+1]){
      cnt[i]+=s[i]-'0';
      cnt[d+1]+=s[d+1]-s[d]-1;
      cnt[d+2]+='9'-s[d+1]+1;   
      for(Int k=i;k<=d+1;k++) sz(k);
      ans+=9;
      inc();j--;
    }else{
      cnt[i]+=s[i]-'0'-1;
      cnt[i+1]+='9'-s[i]+1;
      sz(i);
      ans+=9;
      inc();j--;
    }
    //cout<<s<<":"<<ans<<endl;
    for(Int x=i;x>0;x--){
      Int flg=0;
      while(cnt[x]>=10&&zero!=n){
	//cout<<cnt[i]<<endl;
	cnt[x]-=10;
	cnt[x-1]++;
	ans-=9;
	dec();
	flg=1;
      }
      if(!flg) break;
    }
  }
  //for(Int i=0;i<=n;i++) cout<<i<<":"<<cnt[i]<<endl;
  
  //cout<<ans<<endl;
  cout<<(ans+8)/9<<endl;
  return 0;
}


Measured memory_bytes: 4740
#include <iostream>
#include <vector>
#include <set>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    set<int> cnt;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt.insert(a);
    }

    if (cnt.size() % 2 == 0) {
        cout << cnt.size() - 1 << endl;
    } else {
        cout << cnt.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  string s;

  cin >> s;

  ll ans = 0;

  for (ll i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - 1 - i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
    return;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#ifdef _WIN32
#define NOMINMAX
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#define DEBUGBREAK() ::DebugBreak()
#else
#define DEBUGBREAK() static_cast<void>(0)
#endif

#include <iostream>
#include <sstream>
#include <iomanip>
#include <valarray>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <queue>
#include <array>
#include <functional>
#include <stack>
#include <bitset>
#include <random>
#include <algorithm>
#include <unordered_map>

using namespace std;

const int64_t dx4[4] = { 0, -1, 1, 0 };
const int64_t dy4[4] = { -1, 0, 0, 1 };
const int64_t dx5[5] = { 0, -1, 0, 1, 0 };
const int64_t dy5[5] = { -1, 0, 0, 0, 1 };
const int64_t dx8[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int64_t dy8[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int64_t dx9[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
const int64_t dy9[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

#define REP(i, K) for (int64_t i = 0; i < K; ++i)
#define REPYX() for (int64_t y = 0; y < H; ++y) for (int64_t x = 0; x < W; ++x)
#define REPX() REP(x, W)
#define REPY() REP(y, H)
#define INSIDE(x_, y_) (0 <= (x_) && 0 <= (y_) && (x_) < W && (y_) < H)
#define INSIDE_MARGIN(x_, y_, m_) ((m_) <= (x_) && (m_) <= (y_) && (x_) < W - (m_) && (y_) < H - (m_))

int get_assert_level() {
    const char* s = getenv("ASSERT_LEVEL");
    if (s) { return atoi(s); }
    return 0;
}
static int g_assert_level = get_assert_level();

#define LV_1() if (g_assert_level >= 1)
#define LV_2() if (g_assert_level >= 2)
#define LV_3() if (g_assert_level >= 3)
#define ASSERT_1(expr) do { const bool b = bool(expr); if (g_assert_level >= 1 && !b) { std::cerr << "[ASSERT 1] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_2(expr) do { const bool b = bool(expr); if (g_assert_level >= 2 && !b) { std::cerr << "[ASSERT 2] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_3(expr) do { const bool b = bool(expr); if (g_assert_level >= 3 && !b) { std::cerr << "[ASSERT 3] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)

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

    int N;
    cin >> N;

    int64_t all_xor = 0; // 偶数のNなのですべてをXORすると result_i のすべてのXORと一致
    vector<int64_t> As(N);
    REP(i, N) {
        cin >> As[i];
        all_xor ^= As[i];
    }

    REP(i, N) {
        cout << (all_xor ^ As[i]);
        if (i + 1 < N) { cout << " "; }
    }
    cout  << endl;

    return 0;
}



Measured memory_bytes: 4740