akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
de_num = list(map(int, input().split()))
ok_num = []
cand_num = []
ans_num = []
#print(de_num)

for i in range(10):
  if i not in de_num:
    ok_num.append(i)
#print(ok_num)

for i in ok_num:
  for j in ok_num:
    for k in ok_num:
      for l in ok_num:
        for m in ok_num:
          if len(str(N)) == 4:
            num = 10000*i + 1000*j + 100*k + 10*l + m
            cand_num.append(num)
            num_s = 1000*j + 100*k + 10* l +m
            cand_num.append(num_s)
          elif len(str(N)) == 3:
            num = 1000*j + 100*k + 10*l + m
            cand_num.append(num)
            num_s = 100*k + 10*l + m
            cand_num.append(num_s)
          elif len(str(N)) == 2:
            num = 100*k + 10*l + m
            cand_num.append(num)
            num_s = 10*l + m
            cand_num.append(num_s)
          elif len(str(N)) == 1:
            num = 10*l + m
            cand_num.append(num)
            num_s = m
            cand_num.append(num_s)
            

for cd in cand_num:
  if cd >= N:
    ans_num.append(cd)

print(min(ans_num))

Measured memory_bytes: 8256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    ll ans = 0;

    ll a = 0;
    ll bc = 0;

    int i = 0;

    while(i<s.size()){
        if(s[i]=='A'){
            a++;
        }else if(s[i]=='B'){
            if(i==s.size()-1){
                break;
            }else{
                if(s[i+1]=='C'){
                    ans += a;
                    i++;
                }else if(s[i+1]=='B'){
                    a = 0;
                    i++;
                }else{
                    a = 1;
                    i++;
                }
            }
        }else if(s[i]=='C'){
            a = 0;
            bc = 0;
        }
        i++;
    }

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


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n;

bool check(int x)
{
    if (x%2!=0) return true;
    else return (x%3==0 || x%5==0);
}

void nhap()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        int x;
        scanf("%d",&x);
        if (!check(x))
        {
            cout<<"DENIED";
            return;
        }
    }
    cout<<"APPROVED";
}

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


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

int main() {
  long A, B, C, K;
  cin >> A >> B >> C >> K;

  long sum = 0;
  if (A < K) {
    for (int i = 0; i < A; i++) {
      sum++;
    }
  } else {
    for (int i = 0; i < K; i++) {
      sum++;
    }
  }

  long count = K - (A + B);
  if (K > A + B) {
    sum = sum - count;
  }
  cout << sum << endl;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    vector<int> vec;

    vec.push_back(A);
    vec.push_back(B);
    vec.push_back(C);
    sort(vec.begin(), vec.end());

    int x = vec[2] - vec[1];
    int y = vec[1] - vec[0];

    if(y % 2 == 0) {
        cout << x + y / 2 << endl;
    } else {
        cout << x + y / 2 + 2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a1, b1, c1, a2, b2, c2;
		a1 = 2 * (x2 - x1);
		b1 = 2 * (y2 - y1);
		c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		a2 = 2 * (x3 - x1);
		b2 = 2 * (y3 - y1);
		c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		double x, y, r;
		x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		r = sqrt((x1 - x)*(x1 - x) + (y1 - y)*(y1 - y));
		cout << fixed << std::setprecision(3) << x << " " << y << " " << r << "\n";
	}

	return 0;
}

Measured memory_bytes: 1288
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int n, k;
    scanf("%d%d",&n,&k);
    printf("%d", n-k+1);
    return 0;
}


Measured memory_bytes: 128
s = input()
n = len(s)
ans = 0
for i in range(2 ** (n-1)):
    tmp = []
    for k in range(n-1):
        tmp.append(s[k])
        if i>>k & 1:
            tmp.append("+")
    tmp.append(s[-1])
    ans += eval("".join(tmp))
print(ans)

Measured memory_bytes: 3060
import math
n,a,b=list(map(int,input().split(" ")))

mod = 1000000007

def choose(n, a):
    x = 1
    y = 1
    if n/2 < a:
        a = n - a
    for i in range(a):
        x *= n - i
        if x > mod:
            x %= mod
        y *= a - i
        if y > mod:
            y %= mod
    val = x * pow(y, mod-2, mod) % mod
    return val

ans=pow(2,n,mod)-choose(n,a)-choose(n,b)-1
ans=ans%(mod)
print(ans)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


int n;

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
 
  while(1) {
     
  int n;
  cin >> n;
  if(n == 0) break;
 
  int w ,h;
  cin >> w >> h;
 
  int mp[101][101];
  for(int i=0;i<=h;i++)
    for(int j=0;j<=w;j++)
      mp[i][j] = 0;
   
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    mp[b-1][a-1] = 1;
  }
 
  int s,t;
  cin >> s >>t;
  int ans = 0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){      
      int cnt = 0;
      for(int k=i;k<i+t;k++)
    for(int l=j;l<j+s;l++){
      if(w<=l || h<=k) break;
      //  cout <<"x="<<l<<" y="<<k<<" ="<<mp[k][l]<<endl;
      if(mp[k][l] == 1) cnt++;
    }
      //     cout << "cnt="<<cnt << endl;
      //cout <<"----------------"<<endl;
      if(cnt > ans) ans = cnt;
    }
 
  cout << ans <<endl;
  }
  return 0;
   
}

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

#prag\
ma GCC optimzie(3)
const int maxn = 2010;
int n, a[maxn], deg[maxn];
vector <int> vec[maxn];
priority_queue <int> q;
bitset <maxn> vis, g[maxn];

void dfs(int u) {
	vis[u] = 1;
	for (int v = 1; v <= n; v++) {
		if (!vis[v] && g[u][v]) vec[u].push_back(v), deg[v]++, dfs(v);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (__gcd(a[i], a[j]) != 1) g[i][j] = g[j][i] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) dfs(i);
	}
	for (int i = 1; i <= n; i++) {
		if (!deg[i]) q.push(i);
	}
	while (!q.empty()) {
		int u = q.top(); q.pop();
		for (int v : vec[u]) q.push(v);
		printf("%d ", a[u]);
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>> balls,dists;
vector<int> bag;
map<pair<int,int>,int> freq;
int main () {
  int n,ans = 0;
  scanf ("%d",&n);
  balls.resize(n);
  for (int x = 0; x < n; x++) {
    scanf ("%d %d",&balls[x].first, &balls[x].second);
  }
  sort (balls.begin(),balls.end());
  for (int x = 0; x < n; x++) {
    for (int y = x-1; y >= 0; y--) dists.push_back({balls[x].first-balls[y].first,balls[x].second-balls[y].second});
  }
  for (auto p : dists) {
    ans = max(ans,max(++freq[p],++freq[{-p.first,-p.second}]));
  }
  printf ("%d\n",n-ans);
  return 0;
}


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

const int INF = 1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	int ans = INF;
	rep(div,(1<<h-1)){
		int g = 0;
		vector<int> id(h);
		rep(i,h){
			id[i] = g;
			if(div>>i & 1) g++;
		}
		g++;
		vector<vector<int>> c(g, vector<int>(w, 0));
		rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j] - '0');
		int num = g-1;
		vector<int> now(g);
		auto add = [&](int j){
			rep(i,g) now[i] += c[i][j];
			rep(i,g) if(now[i] > k) return false;
			return true;
		};
		rep(j,w){
			if(!add(j)){
				num++;
				now = vector<int>(g);
				if(!add(j)){
					num = INF;
					break;
				}
			}
		}
		chmin(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int X, Y;

  std::cin >> X >> Y;

  for (int i = 0; i <= 100; i ++)
    for (int j = 0; j <= 100; j ++)
      if (i + j == X && i * 2 + j * 4 == Y) {
        std::cout << "Yes" << std::endl;

        return 0;
      }

  std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
 
int main()
{
	int n;
	cin>>n;
	vi a(n);
	rep(i,n){
		cin>>a.at(i);
	}
	int x=0,y=0;
	rep(i,n){
		x=max(x,a.at(i));
	}
	int d=INT_MAX;
	rep(i,n){
		if(a.at(i)!=x){
			if(d>abs(x/2-a.at(i))){
				d=abs(x/2-a.at(i));
				y=a.at(i);
			}
		}
	}
	cout<<x<<" "<<y<<endl;
	
	return 0;
}

Measured memory_bytes: 640
n,x,y = gets.chomp.split.map(&:to_i)
ans = Array.new(n,0)
# fin = Array.new(n){Array.new(n,0)}
graph = Array.new(n){Array.new}

(0..n-2).each do |i|
  graph[i] << i + 1
  graph[i+1] << i
end

graph[x-1] << y - 1
graph[y-1] << x - 1

(0..n-1).each do |i|
  queue = [i] 
  dist = Array.new(n,-1)
  dist[i] = 0
  until queue.empty?
    v = queue.shift
    graph[v].each do |nv|
      next if dist[nv] != -1
      dist[nv] = dist[v] + 1
      ans[dist[nv]] += 1
      queue.push(nv)
    end
  end
end
ans.shift
ans.each do |a|
  puts a / 2
end

Measured memory_bytes: 30204
from collections import Counter

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return (x2, y2, n)

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of #(each prime factors) of n,
    '''
    result = []
    app = result.append
    if n < 2:
        return Counter()
    while n % 2 == 0:
        app(2)
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            app(p)
            n //= p
        p += 2
    if n > 1:
        app(n)
    return Counter(result)

MOD = 10**9 + 7

N = int(input())
*A, = map(int, input().split())
ans = 0
lcm = {}
for a in A:
    for x, y in prime_factorization(a).items():
        if x not in lcm.keys():
            lcm[x] = y
        else:
            lcm[x] = max(lcm[x], y)
L = 1
for x, y in lcm.items():
    L *= pow(x, y, MOD)
    L %= MOD
for a in A:
    ans += L * modular_inverse(a, MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
int main()
{
  vector<int>vec;
  int i,index;
  for(i=0; i<5; i++)
  {
    int v;
    cin>>v;
    vec.push_back(v);
    if(v==0)
    {
      index=i+1;
    }
  }
  cout<<index<<"\n";
  return 0;
}


Measured memory_bytes: 3628
n = int(input())

if (400<=n) and (n<600):
  print(8)
elif (600<=n) and (n<800):
  print(7)
elif (800<=n) and (n<1000):
  print(6)
elif (1000<=n) and (n<1200):
  print(5)
elif (1200<=n) and (n<1400):
  print(4)
elif (1400<=n) and (n<1600):
  print(3)
elif (1600<=n) and (n<1800):
  print(2)
elif (1800<=n) and (n<2000):
  print(1)

Measured memory_bytes: 9208
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

int N, K;
string S;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  cin >> S;

  int ans = 0;
  queue<int> q;

  int sum = 0;
  int n = 0; // 連続した同じ値の数
  int k = 0; // 0に変わった数
  bool flag = (S[0] == '0');

  int i = 0;
  while (i < N) {
    char c = S[i];
    while (c == S[i]) {
      n++;
      i++;
    }
    if (c == '0') {
      k++;
      if (k > K) {
        if (!flag) {
          int f1 = q.front();
          q.pop();
          sum -= f1;
        }
        int f2 = q.front();
        q.pop();
        sum -= f2;
        flag = false;
      }
    }

    q.push(n);
    sum += n;
    n = 0;
    ans = max(ans, sum);
  }

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

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
using tsii = tuple<string, int, int>;

bool highestPoint(tsii left, tsii right) {
  if (get<0>(left) != get<0>(right)) {
    return get<0>(left) < get<0>(right);
  }
  else {
    return get<1>(left) > get<1>(right);
  }
}

int main() {
  int n;
  cin >> n;
  
  using tisi = tuple<int, string, int>;

  vector<tisi> vtisi(n);

  for (int i = 0; i < n; i++) {
    string str;
    int num;
    cin >> str >> num;
    vtisi.at(i) = make_tuple(num, str, i + 1);
  }
  sort(vtisi.rbegin(), vtisi.rend());

  vector<tsii> vtsii(n);
  for (int i = 0; i < n; i++) {
    vtsii.at(i) = make_tuple(get<1>(vtisi.at(i)), get<0>(vtisi.at(i)), get<2>(vtisi.at(i)));
  }
  sort(vtsii.begin(), vtsii.end(), highestPoint);
  
  for (int i = 0; i < n; i++) {
    cout << get<2>(vtsii.at(i)) << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  DVector mp(n,Vector(n,INF));
  vector<P> edges;
  rep(i,n)mp[i][i] = 0;
  rep(i,m){
    ll a,b,c;
    cin >> a >> b >> c;
    mp[a-1][b-1] = c;
    mp[b-1][a-1] = c;
    edges.pb(mkp(a-1,b-1));
    edges.pb(mkp(b-1,a-1));
  }

  DVector tmp = mp;
  rep(k,n)rep(i,n)rep(j,n)minch(mp[i][j],mp[i][k]+mp[k][j]);
  vector<vector<bool>> jd(n,vector<bool>(n,false));
  rep(s,n)rep(t,n)each(edge,edges)if(mp[s][edge.fi]+tmp[edge.fi][edge.se]+mp[edge.se][t] == mp[s][t]){
    jd[edge.fi][edge.se] = true;
    jd[edge.se][edge.fi] = true;
  }
  ll sum = 0;
  each(edge,edges)if(!jd[edge.fi][edge.se])sum++;
  cout << sum/2 << endl;
}


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

int main(){
    int n;
    cin >> n;
    bool ans = false;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if (i * j == n)ans = true;
        }
    }
    if (ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3132
#include<iostream>
using namespace std;
const int MAXN = 100 + 5;
char c[MAXN][MAXN];
int cnt[100];
int main()
{
  int h , w;
  cin >> h >> w;
  for(int i = 0;i < h;i ++)
    for(int j = 0;j < w;j ++)
    {
      cin >> c[i][j];
      cnt[c[i][j] - 'a'] ++;
    }

  int all = 0;
  if(h % 2 && w % 2)
    all += h + w - 1;
  else if(h % 2)
    all += w;
  else if(w % 2)
    all += h;

  int all2 = h * w;
  while(all2 > 0)
  {

    int need = 4;
    if(all2 == 1)
      need = 1;
    else if(all2 <= all)
      need = 2;

    bool pos = false;
    for(int j = 0;j < 26;j ++)
      if(cnt[j] >= need)
      {
        cnt[j] -= need;
        pos = true;
        break;
      }
    if(!pos)
    {
      cout << "No" << endl;
      return 0;
    }
    all2 -= need;
  }


  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


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

  map<LL, int> mp;
  LL a, c;
  int b;
  REP(i, n){
    cin>>a;
    ++mp[a];
  }
  REP(i, m){
    cin>>b>>c;
    mp[c] += b;
  }

  LL ans=0;
  int count=0;

  for(auto i = mp.rbegin(); i != mp.rend(); ++i){
    int x = i->second;
    LL y = i->first;
    if(x+count>n){
      ans += y*(n-count);
      break;
    }
    else{
      ans += y*x;
      count += x;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 12800
import numpy as np

n,l=map(int,input().split())
li=[]
for i in range(n):
  li.append(l+i)
s=sum(li)
p=np.array(li)
a=np.abs(p).tolist()
k=min(a)
b=a.index(k)
print(s-li[b])

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define INF (1LL << 60)
#define int long long
#define mod 1000000007
using namespace std;

int A[100];

bool dp[100001];
int32_t main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	for(int i = 0; i <= k; i++){
		if(!dp[i]){
			for(int j = 0; j < n; j++){
				if(A[j] + i <= k)
					dp[i + A[j]] = 1;
			}
		}
	}
	cout << (dp[k] ? "First" : "Second");
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int H = int.Parse(Console.ReadLine());
            int W= int.Parse(Console.ReadLine());

            Console.WriteLine((N - H + 1) * (N - W + 1));
        }
    }
}


Measured memory_bytes: 11220
#include <stdio.h>
int main(void) {

	int S;
	int h;
	int m;
	int s;

	scanf("%d", &S);

	s = S % 60;
	S = S - s;

	m = (S % 3600)/60;
	S = S - m * 60;

	h = S / 3600;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}



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

int main() {
string S;
cin >> S;
  if((S.at(0) == 'A' && S.at(1) == 'A' && S.at(2) == 'A') || (S.at(0) == 'B' && S.at(1) == 'B' && S.at(2) == 'B'))cout << "No" << endl;
  else cout << "Yes" << endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15



int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a+b > c+d)
		cout << "Left" << endl;
	else if(a+b < c+d)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;
	return 0;
}






Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, a[MAXN], b[MAXN], A[MAXN], B[MAXN], bak[MAXN];
bool g[MAXN][2];
int f[MAXN];

void kmpPreprocess() {
    bak[0] = 0;
    FOR(i,1,n-1) {
        int k = bak[i-1];
        while (k > 0 && B[k] != B[i]) k = bak[k-1];
        if (B[k] == B[i]) bak[i] = k+1;
        else k = 0;
    }
}

void kmpSearch(int w) {
    int j = 0;
    FOR(i,0,2*n-2) {
        while (j > 0 && A[i] != B[j]) j = bak[j-1];
        if (A[i] == B[j]) j++;
        else j = 0;
        if (j == n) {
            g[i-n+1][w] = true;
            j = bak[j-1];
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,0,n-1) cin >> a[i];
    FOR(i,n,2*n-2) a[i] = a[i-n];
    FOR(i,0,n-1) cin >> b[i];
    FOR(i,0,n-1) f[i] = 0;
    FORE(bit,29,0) {
        FOR(i,0,2*n-2) A[i] = (a[i] >> bit) & 1;
        FOR(i,0,n-1) B[i] = (b[i] >> bit) & 1;
        FOR(i,0,n-1) g[i][0] = g[i][1] = false;
        // FOR(i,0,2*n-2) cout << A[i] << ' '; cout << endl;
        // FOR(i,0,n-1) cout << B[i] << ' '; cout << endl;
        kmpPreprocess();
        kmpSearch(0);
        FOR(i,0,n-1) B[i] = 1-B[i];
        kmpPreprocess();
        kmpSearch(1);
        // FOR(i,0,n-1) cout << B[i] << ' '; cout << endl;
        // FOR(i,0,n-1) cout << g[i][0] << ' '; cout << endl;
        // FOR(i,0,n-1) cout << g[i][1] << ' '; cout << endl;
        // cout << endl;
        FOR(i,0,n-1)
            if (f[i] != -1) {
                if (!(g[i][0] | g[i][1])) f[i] = -1;
                else if (g[i][1]) f[i] += (1<<bit);
            }
    }
    FOR(i,0,n-1)
        if (f[i] != -1) cout << i << ' ' << f[i] << "\n";
    return 0;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

void solve()
{
	ll n;
	cin>>n;
	vll a(n),fr(10000000,0),done(10000000,0);
	for(ll i=0;i<n;i++)
		cin>>a[i],fr[a[i]]++;
	for(ll i=0;i<10000000;i++)
	{
		
		if(fr[i]>0 && done[i]==0)
		{
			for(ll j=i*2;j<=10000000;j+=i)
				done[j]=1;
			if(fr[i]>=2)
				done[i]=1;
		}
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(done[a[i]]==0)
		{
			ans++;
		}
	}
	cout<<ans;
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 160992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   int n,ans=0;
   cin>>n;
   vector<int>a(n);
   //a[0]=0;
   for(int i=0;i<n;i++) cin>>a[i];
   sort(a.begin(),a.end());
   a.push_back(1e9);
   for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i!=j){
                int pos2=lower_bound(a.begin(),a.end(),a[i]+a[j])-a.begin();
                ans+=pos2-j-1;
                //cout<<pos1<<" "<<pos2<<" "<<a[i]<<" "<<a[j]<<" "<<ans<<endl;
            }
        }
   }
   cout<<ans;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	long double a,b;
	cin>>a>>b;
	ll n=a*b;
	cout <<n;
	// your code goes here
	return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	string S;
	cin>>S;
	int m=0;
	for(auto &i:S){
		m=(m+(i-'0'))%9;
	}

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

}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;

int N;
ll ans, tmp, sq[MAXN];

map<pair<pll, pll>, int> mp1, mp2;
set<pair<pll, pll> > st;

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

pll cal(pll x) {
	ll g = gcd(abs(x.fi), abs(x.se));
	x.fi /= g, x.se /= g;
	if(x.fi < 0) x.fi *= -1, x.se *= -1;
	if(x.fi == 0) x.se = abs(x.se);
	return x;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) {
		pll a, b;
		cin >> a.fi >> a.se;
		if(a == pll(0, 0)) {
			tmp++;
			continue;
		}
		a = cal(a);
		b.fi = a.se, b.se = -a.fi;
		b = cal(b);
		pair<pll, pll> p;
		if(a < b) {
			p = pair<pll, pll>(a, b);
			mp1[p]++;
			st.insert(p);
		}
		else {
			p = pair<pll, pll>(b, a);
			mp2[p]++;
			st.insert(p);
		}
	}

	sq[0] = 1;
	for(int i=1; i<=N; i++) sq[i] = (sq[i-1] * 2) % MOD;

	ans = 1;
	for(auto it : st) {
		ll x = mp1[it], y = mp2[it];
		ll t = (sq[x] + sq[y] - 1 + MOD) % MOD;
		ans = (ans * t) % MOD;
	}
	ans += tmp;
	cout << (ans - 1 + MOD) % MOD;
}

Measured memory_bytes: 52084
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <fstream>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector <int>a(N);
	int ave;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		ave += a[i];
	}
	ave /= N;
	int res1=0;
	int res2=0;
	for (int i = 0; i < N; i++) {
		res1 += (a[i] - ave)*(a[i] - ave);
		res2 += (a[i] - ave-1)*(a[i] - ave-1);
	}
	cout <<min(res1,res2) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int a = in.nextInt();
        if(a>x)
            System.out.println(0);
        else
            System.out.println(10);

    }
}


Measured memory_bytes: 23124
#include<stdio.h>

int main(void){
        int i,j,m,n,a[101][101]={},b[101]={},c[101]={};

        scanf("%d %d",&m,&n);

        for(i=1; i<=m; i++)
                for(j=1; j<=n; j++)
                        scanf(" %d",&a[i][j]);

        for(i=1; i<=n; i++)
                scanf(" %d",&b[i]);

        for(i=1; i<=m; i++)
                for(j=1; j<=n; j++)
                        c[i] += a[i][j] * b[j];

        for(i=1; i<=m; i++)
                        printf("%d\n",c[i]);

        return 0;
}

Measured memory_bytes: 648
#include<iostream>
using namespace std;
int main()
{
    int a,b,s=0;
    cin >> a >>b;
    int arr[b];
    for(int i=1;i<=b;i++){
        cin >> arr[i];
        s=s+arr[i];
    }
    if(s>=a){
        cout << "Yes" << endl;
    }else{
     cout << "No" << endl;
    }
    return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	int d,r;
	double f;
	d = a/b;
	r = a%b;
	f = (double)a/b;
	cout << d << " " << r << " ";
	cout << fixed << setprecision(8) << f << endl;
	return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int sum = 0;
	REP(i,N) {
		int N_ = i + 1;
		int sum_N = 0;
		while (N_ != 0) {
			//cout << " " << N_ << endl;
			int c = N_ % 10;
			sum_N += c;
			if (sum_N > B) {
				sum_N = 0;
				break;
			}
			N_ = N_ / 10;
			//cout << " " << N_ << endl;
		}
		//cout << sum_N << endl;
		if ((A <= sum_N) && (sum_N <= B)) sum += i + 1;
	}
	cout << sum << endl;
	//cin >> N;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int         long long
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); } 
int lcm(int a, int b) { return (a*b)/gcd(a,b); } 
signed main(){
    tezz   
    
    int a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
    
    return 0;
}   


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;

int a[200001];
ll b[200001];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[a[i]] += 1;
	}

	ll ans = 0;

	for (int i = 1; i <= 200000; i++) {
		ans += (ll)(b[i] * (b[i] - 1) / (ll)2);
	}

	for (int i = 0; i < n; i++) {
		ll cnt = (ll)(b[a[i]] * (b[a[i]] - 1) / (ll)2);
		ll cnt2 = (ll)((b[a[i]] - 1) * (b[a[i]] - 2) / (ll)2);
		cout << ans - cnt + cnt2 << '\n';
	}





}




Measured memory_bytes: 3968
#include<stdio.h>
int main(void){
	int H,W,i,j;
	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(i == 0 || i == H-1 || j == 0 || j == W-1){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define llint long long

using namespace std;

struct CoinPair{
	llint id, a, b;
	CoinPair(llint x, llint y, llint z){
		id = x, a = y, b = z;
	}
	bool operator<(const CoinPair &obj)const{
		return a - b < obj.a - obj.b;
	}
	bool operator>(const CoinPair &obj)const{
		return a - b > obj.a - obj.b;
	}
};

llint X, Y, Z, N;
llint A[100005], B[100005], C[100005];
vector<CoinPair> vec;
priority_queue< CoinPair, vector<CoinPair>, greater<CoinPair> > goldQ;
vector<CoinPair> silVec;
llint rev[100005];
bool used[100005];

int main(void)
{
	cin >> X >> Y >> Z;
	N = X + Y + Z;
	for(int i = 1; i <= N; i++){
		 cin >> A[i] >> B[i] >> C[i];
	}
	
	if(X == 0){
		for(int i = 1; i <= N; i++) vec.push_back( CoinPair(i, B[i], C[i]) );
		sort(vec.begin(), vec.end());
		reverse(vec.begin(), vec.end());
		
		llint ans = 0;
		for(int i = 0; i < vec.size(); i++){
			if(i < Y) ans += B[vec[i].id];
			else ans += C[vec[i].id];
		}
		cout << ans << endl;
		return 0;
	}
	
	for(int i = 1; i <= N; i++) vec.push_back( CoinPair(i, A[i], B[i]) );
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	
	llint sum = 0;
	for(int i = 0; i < vec.size(); i++) sum += C[vec[i].id];
	for(int i = 0; i < X; i++){
		goldQ.push(CoinPair(vec[i].id, A[vec[i].id], C[vec[i].id]));
		sum += A[vec[i].id];
		sum -= C[vec[i].id];
	}
	
	for(int i = X; i < vec.size(); i++){
		silVec.push_back(CoinPair(vec[i].id, B[vec[i].id], C[vec[i].id]));
	}
	sort(silVec.begin(), silVec.end());
	reverse(silVec.begin(), silVec.end());
	for(int i = 0; i < Y; i++){
		sum += B[silVec[i].id];
		sum -= C[silVec[i].id];
	}
	for(int i = 0; i < silVec.size(); i++) rev[silVec[i].id] = i;
	llint cur = Y-1;
	
	llint ans = sum;
	for(int i = X; i < vec.size() - Y; i++){
		
		if((goldQ.top().a - goldQ.top().b) < A[vec[i].id] - C[vec[i].id]){
			sum -= A[goldQ.top().id];
			sum += C[goldQ.top().id];
			goldQ.pop();
			goldQ.push(CoinPair(vec[i].id, A[vec[i].id], C[vec[i].id]));
			sum += A[vec[i].id];
			sum -= C[vec[i].id];
		}
		
		used[vec[i].id] = true;
		if(rev[vec[i].id] <= cur){
			sum -= B[vec[i].id];
			sum += C[vec[i].id];
			cur++;
			while(used[silVec[cur].id]) cur++;
			sum += B[silVec[cur].id];
			sum -= C[silVec[cur].id];
		}
		ans = max(ans, sum);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12272
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

struct Edge {
	int to;
	int weight;
};

void helper(vector<vector<Edge>>& nodes, vector<int>& colors, int idx, int prev, Edge* prev_e) {
	if (prev_e) {
		if (prev_e->weight & 1) {
			colors[idx] = (colors[prev] == 0 ? 1 : 0);
		} else {
			colors[idx] = colors[prev];
		}
	} else {
		colors[idx] = 0;
	}
	for (auto& e : nodes[idx]) {
		if (e.to == prev) {
			continue;
		}
		helper(nodes, colors, e.to, idx, &e);
	}
}

int main (int argc, char* argv[]) {
	int n;
	cin >> n;
	vector<vector<Edge>> nodes(n);
	for (int i = 0; i < n - 1; i++) {
		int from, to, w;
		cin >> from >> to >> w;
		from--; to--;
		nodes[from].emplace_back(Edge { to, w });
		nodes[to].emplace_back(Edge { from, w });
	}
	vector<int> colors(n);
	helper(nodes, colors, 0, -1, nullptr);
	for (int c : colors) {
		cout << c << endl;
	}
}


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

class Main{

	public static void main(String[] arg) throws IOException
	{
		double a,b,degree,rad,cx,cy,sq,len;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");

		a = Double.parseDouble(str[0]);
		b = Double.parseDouble(str[1]);
		degree = Double.parseDouble(str[2]);

		rad = Math.toRadians(degree);

		cx = b * Math.cos(rad) * (-1) + a;
		cy = b * Math.sin(rad);

		sq = (a*cy) / 2;
		len = Math.sqrt(cx*cx + cy*cy) + a + b;

		System.out.printf("%.5f %.5f %.5f\n",sq ,len ,cy);
	}
}

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

bool check_bingo(int a[3][3]){
    for(int i=0; i < 3; i++){
        int reach = 0;
        for(int j=0; j < 3; j++){
            if(!a[i][j]){
                reach = 0;
                break;
            }else{
                reach = 1;
            }
        }
        if(reach){
            return true;
        }

        for(int j=0; j < 3; j++){
            if(!a[j][i]){
                reach = 0;
                break;
            }
            else{
                reach = 1;
            }
        }
        if(reach){
            return true;
        }
    }

    int reach = 0;
    for(int i=0; i < 3; i++){
        if(!a[i][i]){
            reach =0;
            break;
        }
        else{
            reach =1;
        }
    }
    if(reach){
        return true;
    }

    for(int i=0; i < 3; i++){
        if(!a[i][2-i]){
            reach =0;
            break;
        }
        else{
            reach =1;
        }
    }
    if(reach){
        return true;
    }

    return false;
}

int show_card(int array[3][3]){
    for(int i=0; i < 3; i++){
        for(int j=0; j < 3; j++){
            cout << array[i][j];
        }
        cout << endl;
    }
}


int main(void){
    
    int a[3][3];
    int card[3][3] = {0};

    for(int i=0; i < 3; i++){
        for(int j=0; j < 3; j++){
            cin >> a[i][j];
        }
    }

    int N;
    cin >> N;

	vector< int > b(N);
	for ( int &bt : b )
	{
		cin >> bt;
	}

    //1で初期化
    for(int i=0; i < 3; i++){
        for(int j=0; j < 3; j++){
            for(int k=0; k < N; k++){
                if(a[i][j] == b[k]){
                    card[i][j] = 1;
                }
            }
        }
    }
    // show_card(card);

    if(check_bingo(card)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

typedef long long LL;
 
const int N = (int) 0, mod = (int) 0;
 
int main() {
	int n, m;
	cin >> n >> n >> m;
	if ((n + m) % 2 == 1) {
		cout << "Borys\n";
	} else {
		cout << "Alice\n";
	}
}

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

int main(){
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for(int x = 0; x <= k; x++){
    for(int y = 0; y <= k; y++){
      int z = s - x - y;
      if(0 <= z && z <= k){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long ans = 0;
        List<Long> num = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            num.add(0L);
        }
        for (int i = 2; i <= n; i++) {
            for (int j = 1; i * j <= n; j++) {
                long temp = num.get((int)i * j);
                num.set((int)i * j, temp + 1);
            }
        }
        for (int i = 2; i <= n; i++) {
            ans += (num.get(i) + 1) * i;
        }
        System.out.println(ans + 1);
    }
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    long long int a, b, c;
    cin >> a >> b >> c;
    REP(i, 1, b + 1)
    {
        if (a * i % b == c)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[]
while n!=1 and n!=0:
  l.append(abs(n)%2)
  if n>0:
    n=-n
    n//=(-2)
    n=-n
  elif n<0:
    n=abs(n)
    n//=(-2)
    n=-n
l.append(n)
l=l[::-1]
ans=str()
for i in l:
  ans+=str(i)
print(ans)


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

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        String str = obj.next();
        boolean flag = false;
        for(int i=0;i<str.length()-1;i++)
            if(str.charAt(i)!=str.charAt(i+1))
            {
                flag = true;
                break;
            }
        System.out.println((flag)?"Yes":"No");
    }
}


Measured memory_bytes: 22356
#include<stdio.h>
int main(void)
{
  int a,b,c,max,min,i,j;
  scanf("%d%d%d",&a,&b,&c);
  max=a;
  min=a;
  if(max<b) max=b;
  if(max<c) max=c;
  if(min>b) min=b;
  if(min>c) min=c;
  printf("%d", max-min);
  
  return 0;
}

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

#define INF 1000000

int n, m;
int cost[32][32];
int x1, x2, y1, y2;

void init() {
	for(int i = 0; i < 32; i++)
		for(int j = 0; j < 32; j++)
			cost[i][j] = INF;
	for(int i = 0; i < 32; i++)
		cost[i][i] = 0;
}

void input() {
	int a, b, c, d;

	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		cost[a - 1][b - 1] = c;
		cost[b - 1][a - 1] = d;
	}
	
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
}

void warshall_floyd() {
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int k = 0; k < n; k++) {
				cost[j][k] = min(cost[j][i] + cost[i][k], cost[j][k]);
			}
		}
	}
}

int solve() {
	warshall_floyd();
	return y1 - (y2 + cost[x1 - 1][x2 - 1] + cost[x2 - 1][x1 - 1]);
}

int main() {
	init();
	input();
	cout << solve() << endl;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	map<char,int> mp;
	for(char c:s)
	{
		mp[c]++;
	}
	for(char c:s)
	{
		if(mp[c]%2==1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

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

    auto gcd = [](int mm, int nn) {
        function<int(int, int)> f = [&f](int m, int n) {
            if (n == 0) {
                return m;
            }
            else {
                return f(n, m % n);
            }
        };
        return f(max(mm, nn), min(mm, nn));
    };
    auto gcd3 = [gcd](int n, int m, int o) { return gcd(n, gcd(m, o)); };
    vector<int> r;
    if (n == 2) {
        int a, b;
        cin >> a >> b;
        const auto s = gcd(a, b);
        for (int i = 1; i <= s; ++i) {
            if (a % i == 0 && b % i == 0) {
                r.push_back(i);
            }
        }
    }
    else {
        int a, b, c;
        cin >> a >> b >> c;
        const auto s = gcd3(a, b, c);
        for (int i = 1; i <= s; ++i) {
            if (a % i == 0 && b % i == 0 && c % i == 0) {
                r.push_back(i);
            }
        }
    }
    for (auto i : r) {
        cout << i << endl;
    }
}


Measured memory_bytes: 3148