akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);++i)
using namespace std;

int main() {
	int k, x;
	cin >> k >> x;
	if (500 * k >= x) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a,b,i;
ll c[100005],ans;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n;for(i=1;i<=n;++i)cin>>a>>b,c[i]=a+b,ans-=b;
	sort(c+1,c+n+1);
	for(i=n;i;--i)ans+=(n-i)&1?0:c[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <cstring>
#include <map>
#include <stack>
using namespace std;

#define SZ (8)
map< long long , int> dp[2];
int A[110];
int D[110];
int N;

int main(){
	cin >> N;
	for(int i = 0 ; i < N ; i++) cin >> D[i];
	for(int i = 0 ; i < N ; i++) cin >> A[i];
	
	//cout << dfs(0,0) << endl;
	dp[0][0] = 0;
	int answer = -1;
	for(int pos = 0 ; pos <= N ; pos++){
		dp[(pos+1)%2].clear();
		for( map< long long , int>::iterator it = dp[pos%2].begin(); it != dp[pos%2].end() ; ++it ){
			long long slot_ = it->first;
			int cost = it->second;
			
			int sz = min(pos,SZ);
			if( pos >= N ){
				int sum = 0;
				for(int i = 0 ; i < sz ; i++){
					int id1 =  slot_ >> (i*7) & 127;
					for(int k = i+1 ; k < sz ; k++){
						int id2 =  slot_ >> (k*7) & 127;
						if( id1 - D[id1] <= id2 && id2 <= id1 + D[id1] ){
							sum += A[id1];
						}
					}
				}
				answer = max(sum+cost,answer);
				continue;
			}
			int ans = 0;	
			int sum = 0;
			// release 
			if( pos >= SZ ){
				int m = pos - SZ;
				for(int i = 0 ; i < sz ; i++){
					int id1 =  slot_ >> (i*7) & 127;
					if( id1 == m ){
						for(int k = 0 ; k < i ; k++){
							int id2 =  slot_ >> (k*7) & 127;
							if( id2 - D[id2] <= id1 ){
								sum += A[id2];
							}
						}
						for(int k = i+1 ; k < sz ; k++){
							int id2 =  slot_ >> (k*7) & 127;
							if( id2 <= id1 + D[id1] ){
								sum += A[id1];
							}
						}
						long long mask1 = (1ll<<(i*7))-1;
						long long mask2 = ~((1ll<<((i+1)*7))-1);
						long long lower = slot_ & mask1;
						long long upper = slot_ & mask2;
						slot_ = lower + ( upper >> 7 );
						sz--;
						break;
					}
				}
			}
			// adding
			for(int i = 0 ; i <= sz ; i++){
				long long t = slot_;
				long long mask1 = (1ll<<(i*7))-1;
				long long mask2 = ~((1ll<<(i*7))-1);
				long long lower = slot_ & mask1;
				long long upper = slot_ & mask2;
				t = lower + ( upper << 7 ) + (((1ll)*pos)<<(i*7));
				dp[(pos+1)%2][t] = max(dp[(pos+1)%2][t],cost+sum);
			}
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 6236
from decimal import Decimal, ROUND_HALF_UP


N = int(input())
a = list(map(int, input().split(' ')))
result = sum(a) / N
r = Decimal(result).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
cost = 0
for i in a:
    cost += (i - r) ** 2
print(cost)

Measured memory_bytes: 5076
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, K;
  cin >> N >> K;
  vll D(K);
  vector<vll> A(K);
  vll result(N, 0);
  REP(i, 0, K) {
    ll d;
    cin >> d;
    D[i] = d;

    vll v(d);
    REP(j, 0, d) {
      ll a;
      cin >> a;
      v[j] = a;
      result[a-1] = 1;
    }
    A[i] = v;
  }

  ll r = 0;
  REP(i, 0, N) {
    if (result[i] == 0) {
      r++;
    }
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

int x;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> x;
    int cur = 100, days = 0;
    while(cur < x)
    {
        cur += cur / 100;
        days++;
    }
    cout << days << "\n";
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  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 <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const int mod = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) {
    a.n += b.n;
    if (a.n >= mod) a.n -= mod;
    return a.n;
}

mint operator-(mint a, mint b) {
    a.n -= b.n;
    if (a.n < 0) a.n += mod;
    return a.n;
}

mint operator*(mint a, mint b) {
    return (long long)a.n * b.n % mod;
}

mint &operator+=(mint &a, mint b) {
    return a = a + b;
}

mint &operator-=(mint &a, mint b) {
    return a = a - b;
}

mint &operator*=(mint &a, mint b) {
    return a = a * b;
}

mint dp[3030][3030];
int A[3000];
int X[3000], Y[3000];
mint tmpX_[3000];
mint tmpY_[3000];
mint tmp_X[3000];
mint tmp_Y[3000];

int main() {
    mint inv2 = (mod + 1) / 2;
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < q; i++) {
        cin >> X[i] >> Y[i];
        X[i]--;
        Y[i]--;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (A[i] < A[j]) {
                dp[i][j] += 1;
            }
        }
    }
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            tmpX_[j] = dp[X[i]][j];
            tmpY_[j] = dp[Y[i]][j];
            tmp_X[j] = dp[j][X[i]];
            tmp_Y[j] = dp[j][Y[i]];
        }
        for (int j = 0; j < n; j++) {
            if (j == X[i] || j == Y[i]) continue;
            dp[j][X[i]] = (tmp_X[j] + tmp_Y[j]) * inv2;
            dp[j][Y[i]] = (tmp_X[j] + tmp_Y[j]) * inv2;
            dp[X[i]][j] = (tmpX_[j] + tmpY_[j]) * inv2;
            dp[Y[i]][j] = (tmpX_[j] + tmpY_[j]) * inv2;
            // dp[j][X[i]] -> dp[j][X[i]]
            // dp[j][X[i]] -> dp[j][Y[i]]
            // dp[X[i]][j] -> dp[X[i]][j]
            // dp[X[i]][j] -> dp[Y[i]][j]
            // dp[X[i]][Y[i]] -> dp[X[i]][Y[i]]
            // dp[X[i]][Y[i]] -> dp[Y[i]][X[i]]
            // dp[Y[i]][X[i]] -> dp[Y[i]][X[i]]
            // dp[Y[i]][X[i]] -> dp[X[i]][Y[i]]
        }
        dp[X[i]][Y[i]] = (tmpX_[Y[i]] + tmpY_[X[i]]) * inv2;
        dp[Y[i]][X[i]] = (tmpX_[Y[i]] + tmpY_[X[i]]) * inv2;
    }
    mint ans;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            ans += dp[i][j];
        }
    }
    for (int i = 0; i < q; i++) ans *= 2;
    cout << ans.n << endl;
}


Measured memory_bytes: 36224
N = int(input())
x = list(input().split())
num = [int(x[i]) for i in range(N)]
num_sorted = sorted(num)
min_center = num_sorted[N // 2 - 1]
max_center = num_sorted[N // 2]

for i in range(N):
    if num[i] <= min_center:
        print(max_center)
    else:
        print(min_center)


Measured memory_bytes: 30208
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-10;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j;
  string l;
  cin>>l;
  int n=l.size();
  ll d[n+1];
  d[0]=1;
  for(ll i=1;i<=n;i++){
    if(l[n-i]=='0')d[i]=d[i-1];
    else d[i]=pow1(3LL,i-1,MOD)+2*d[i-1];
    if(d[i]>=MOD)d[i]%=MOD;
  }
  cout<<d[n]<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

class UnionFind{
  public:
    //親の番号を格納．親の場合は-(その集合のサイズ)
    vector<int> Parent;
    //作るときはParentの値をすべて-1にする
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //親を求める
    int find(int x){
      if(Parent[x] < 0) return x;
      //親の紐づけを変更
      return Parent[x] = find(Parent[x]);
    }

    //xの属する集合のサイズを取ってくる
    int size(int x){
      return -Parent[find(x)];
    }

    //xとyの属する集合を併合
    //併合できたらtrue，すでに併合していたらfalse 
    bool unite(int x, int y){
      //xとyを直接つけない，親同士をつける
      x = find(x);
      y = find(y);
      if(x==y) return false;

      //大きいほうに小さいほうをくっつける
      if(size(x) < size(y)) swap(x,y);

      //xのサイズを更新
      Parent[x] += Parent[y];
      Parent[y] = x;
      return true;
    }

    //xとyが同じ集合に属するか
    bool same(int x, int y){
      return find(x) == find(y);
    }
};

int main(void){
  int N,M;cin >> N >> M;
  vector<int> p(N+1);
  UnionFind uni = UnionFind(N+1);
  int i,j;
  int count = 0;
  REP(i,N+1){
    if(i==0)continue;
    cin >> p[i];
    if(p[i] == i)count++;
  }
  REP(j,M){
    int x,y;cin >> x >> y;
    uni.unite(x,y);
  }
  REP(i,N+1){
    if(i==0)continue;
    if(i!=p[i] && uni.same(i,p[i]))count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x >= r && y >= r && x <= w-r && y <= h-r) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef  int ll;
using namespace std;
int main() {
    ios;
    ll t=1;
    //cin>>t;
    while(t--)
    {
      ll a,b,c,k;cin>>a>>b>>c>>k;
      ll ans=0;
    ans=min(k,a);
    k-=ans;
    if(k>0)
    {
        k-=b;
    }
    if(k>0)
    {
        ans-=min(k,c);
    }
cout<<ans;
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t,u;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  cin>>u;
  if(s==u){
    cout<<a-1<<" "<<b<<endl;
  }
  else if(t==u){
    cout<<a<<" "<<b-1<<endl;

    
  }
}


Measured memory_bytes: 256
//
// Created by pureZer on 2019-07-20.
//
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const int INF = 99999999;
const double eps = 1e-6;
const int maxn = 1e5+5;

int N, D;

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

mod=998244353

N=int(input())
X=input()

import math
xr=math.ceil(math.sqrt(N))

LIST=[]
for i in range(1,xr+1):
    if N%i==0:
        LIST.append(i)
        LIST.append(N//i)

REP=[l for l in set(LIST) if (N//l)%2==1 and l!=N]

REP.sort(reverse=True)


ANS=2*N*(int(X,2)+1)%mod

def invstr(X,r):
    return bin(int(X,2)^((1<<r)-1))[2:].zfill(r)

from collections import defaultdict
score=defaultdict(int)

for r in REP:
    score[r]+=2*r-2*N

    for j in REP:
        if r%j==0 and j<r:
            score[j]-=score[r]
  
for r in REP:
    sc=score[r]

    #print(r,score)

    XSTR=X[:r]

    kosuu=int(XSTR,2)

    if (XSTR+invstr(XSTR,r))*(N//(r*2))+XSTR<=X:
        kosuu+=1

    ANS+=kosuu*sc

print(ANS%mod)

Measured memory_bytes: 3984
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int n;
    cin >> n;

    vector<ll> a(n);

    FOR(i, 0, n){
        cin >> a.at(i);
    }

    sort(ALL(a));
    
    // nCrのnは決まった
    ll max = a[n-1];

    // max/2は小数点以下が消えるので2倍の世界で考える

    // rを探す
    ll minDiff = abs(max - 2 * a[0]);
    ll r = a[0];
    FOR(i, 1, n-1){
        ll diff = abs(max - 2 * a[i]);
        if(diff < minDiff){
            minDiff = diff;
            r = a[i];
        }
    }

    cout << max << " " << r << endl;
    
    return 0;
}

Measured memory_bytes: 1024
while True:
    m, f, r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5592
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2010;
int n,a[N],f[N][N],g[N][N];
inline int Abs(int x){return x>=0?x:-x;}
int main(){
	scanf("%d",&n);n+=2;
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=n;i;--i) 
		for (int j=n;j;--j)
		if (i==n||j==n) f[i][j]=g[i][j]=Abs(a[i]-a[j]);
		else if (i<j){
			f[i][j]=g[j+1][j];
			if (i==1&&j==2) return printf("%d",f[i][j]),0;
			f[i][j]=min(f[i][j],f[i][j+1]);
		}else if (j<i){
			g[i][j]=f[i][i+1];
			g[i][j]=max(g[i][j],g[i+1][j]);
		}
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int a[5];
	
	while (cin >> a[0], a[0]) {
		for_(i,1,5) cin >> a[i];
		int ex[4] = {0};
		for_(i,0,5) ex[a[i]] = 1;
		int sum = accumulate(ex, ex + 4, int());
		
		
		if (sum == 1 || sum == 3) {
			for_(i,0,5) cout << 3 << endl;
		} else {
			int win = (ex[1] && ex[2]) ? 1 : (ex[2] && ex[3]) ? 2 : 3;
			for_(i,0,5) cout << (a[i] == win ? 1 : 2) << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
  long long int a,b,c,d=0;
  cin >> a >> b >> c;
  if(c>a){
    b = max(a + b - c,d);
    a = 0;
  }
  else a -= c;
  cout << a << " " << b;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int sum = 0;
    for(int i=0; i<m; i++){
        int a; cin >> a;
        sum += a; 
    }
    if(n - sum >= 0) cout << n - sum;
    else cout << -1;
    cout << endl;
    return 0;
}

Measured memory_bytes: 3624
from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
    temp = An[i]
    if check[temp-1] == 1:
        dup = temp
        break
    root.append(temp)
    check[temp-1] = 1
    i = temp - 1
    cnt += 1
index = root.index(dup)
if index >= k:
    print(root[k])
elif index == cnt - 1:
    print(dup)
else:
    print(root[(k-index) % (cnt-index) + index])


Measured memory_bytes: 51044
N = int(input())
H = list(map(int, input().split()))
ans = 0
x = 0
for i in range(N - 1):
	if H[i] >= H[i + 1]:
		x += 1
	else:
		ans = max(ans, x)
		x = 0
ans = max(ans, x)
print(ans)

Measured memory_bytes: 14252
#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;};


template<typename T>
struct PrimalDual{
  struct edge{
    Int to;
    T cap,cost;
    Int rev;
    edge(){}
    edge(Int to,T cap,T cost,Int rev):to(to),cap(cap),cost(cost),rev(rev){}
  };
  
  T INF;
  vector<vector<edge> > G;
  vector<T> h,dist;
  vector<Int> prevv,preve;

  PrimalDual(){}
  PrimalDual(Int n,T INF):INF(INF),G(n),h(n),dist(n),prevv(n),preve(n){}
  
  void add_edge(Int from,Int to,T cap,T cost){
    G[from].emplace_back(to,cap,cost,G[to].size());
    G[to].emplace_back(from,0,-cost,G[from].size()-1);
  }

  T flow(Int s,Int t,T f,Int &ok){    
    T res=0;
    fill(h.begin(),h.end(),0);
    while(f>0){    
      struct P{
        T first;
        Int second;
        P(T first,Int second):first(first),second(second){}
        bool operator<(const P&a) const{return first>a.first;}
      };
      
      priority_queue<P> que;
      
      fill(dist.begin(),dist.end(),INF);
      
      dist[s]=0;
      que.emplace(dist[s],s);
      while(!que.empty()){
        P p=que.top();que.pop();
        Int v=p.second;
        if(dist[v]<p.first) continue;
        for(Int i=0;i<(Int)G[v].size();i++){
          edge &e=G[v][i];
          if(e.cap==0) continue;
          if(dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
            dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
            prevv[e.to]=v;
            preve[e.to]=i;
            que.emplace(dist[e.to],e.to);
          }
        }
      }
      if(dist[t]==INF) return ok=0;
      
      for(Int v=0;v<(Int)h.size();v++) h[v]+=dist[v];

      T d=f;
      for(Int v=t;v!=s;v=prevv[v])
        d=min(d,G[prevv[v]][preve[v]].cap);
      
      f-=d;
      res+=d*h[t];
      for(Int v=t;v!=s;v=prevv[v]){
        edge &e=G[prevv[v]][preve[v]];
        e.cap-=d;
        G[v][e.rev].cap+=d;
      }
    }
    ok=1;
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  Int n;
  cin>>n;
  const Int INF2 = 1e9;
  const Int INF3 = 1e15;
  PrimalDual<Int> G(n+1,INF3);
  Int num=0,ans=0;
  for(Int i=0;i<n;i++){   
    Int k;
    cin>>k;
    num+=k;
    map<Int, Int> cnt,dst;
    for(Int j=0;j<k;j++){
      Int t,c;
      cin>>t>>c;
      t--;
      cnt[t]++;
      ans+=c+INF2;
      if(!dst.count(t)) dst[t]=c;
      chmin(dst[t],c);
    }
    
    for(auto p:cnt){
      G.add_edge(i,p.first,cnt[p.first],-INF2);
      G.add_edge(i,p.first,INF2,dst[p.first]);      
    }
      
    G.add_edge(i,n,INF2,0);
  }
  
  Int ok=1;
  ans+=G.flow(0,n,INF2,ok);  
  cout<<ans<<endl; 
  assert(ok);
  return 0;
}




Measured memory_bytes: 7644
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;

	int ans = a * b - 1 * (a + b) + 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
typedef long long ll;
int main()
{
   int l;
   cin >> l ;
   cout << setprecision(20) << (l*1.0/3)*(l*1.0/3)*(l*1.0/3) << endl;

}


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

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;


int main(){

	int n;
	long long x;

	cin >> n >> x;

	vector<long long> arr(n);

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

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

	if (arr[0] > x) {
		cout << 0 << endl;
		return 0;
	}

	int j = 0;
	int count = 0;

	while (j < n) {
		if (x <= 0) break;
		
		x = x - arr[j];

		if (j == n - 1 && x>0 )break;

		if(x>=0)count++;
		
		j++;

	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX;
const long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll P = 1e9 + 7;
	//const ll P = 998244353;

	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(ALL(a));
	ll ans = 0;
	if (n % 2 == 0) {
		for (ll i = 0; i < n; i++) {
			if (i < n / 2) ans -= a[i] * 2;
			else ans += a[i] * 2;
		}
		ans -= a[n / 2];
		ans += a[n / 2 - 1];
	} else {
		for (ll i = 0; i < n; i++) {
			if (i < n / 2 + 1) ans -= a[i] * 2;
			else ans += a[i] * 2;
		}
		ans += a[n / 2];
		ans += a[n / 2 - 1];
		ll subans = 0;
		for (ll i = 0; i < n; i++) {
			if (i < n / 2) subans -= a[i] * 2;
			else subans += a[i] * 2;
		}
		subans -= a[n / 2];
		subans -= a[n / 2 + 1];
		ans = max(ans, subans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3952
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	
	final double EPS=1e-6;
	Scanner sc;
	
	class Vector{
		double x,y;
		double norm(){
			return Math.hypot(x, y);
		}
		Vector(double x,double y){
			this.x=x;
			this.y=y;
		}
	}
	
	Vector sub(Vector a,Vector b){
		return new Vector(a.x-b.x,a.y-b.y);
	}
	
	double ip(Vector a,Vector b){
		return a.x*b.x+a.y*b.y;
	}
	
	double theta(Vector a,Vector b,Vector c){
		Vector v=sub(a,b),u=sub(c,b);
		return Math.acos(ip(v,u)/v.norm()/u.norm());
	}

	boolean inTriangle(Vector[] triangle,Vector p){
		double angle=0;
		for(int i=0;i<3;++i){
			angle+=theta(triangle[i],p,triangle[(i+1)%3]);
		}
		return Math.abs(angle-Math.PI*2)<EPS;
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		int n=ni();
		
		for(int a=0;a<n;++a){
			Vector[] triangle=new Vector[3];
			for(int i=0;i<3;++i){
				triangle[i]=new Vector(ni(),ni());
			}
			Vector k=new Vector(ni(),ni()),s=new Vector(ni(),ni());
			System.out.println(inTriangle(triangle,k)^inTriangle(triangle,s)?"OK":"NG");
		}
		sc.close();
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 65012
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> s(N,0);
  for(int i=0; i<N-1; i++){
    if(S[i]=='A' && S[i+1]=='C'){
      s[i]++;
    }
  }
  vector<int> sum(N+1,0);
  for(int i=0; i<N; i++){
    sum[i+1] = sum[i] + s[i];
  }
  for(int i=0; i<Q; i++){
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    cout << sum[r] - sum[l] << endl;
  }
  return 0;
}


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

ll solve() {
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> c(10);
    vector<vector<ll>> cl(N,vector<ll>(10)), cr(N,vector<ll>(10));
    set<int> sl, sr;
    for ( int i = 0; i < N; i++ ) {
        if ( i > 0 ) {
            for ( int j = 0; j < 10; j++ ) {
                cl[i][j] = cl[i-1][j];
            }
        }
        cl[i][S[i]-'0'] = 1;
    }
    for ( int i = N-1; i >= 0; i-- ) {
        if ( i < N-1 ) {
            for ( int j = 0; j < 10; j++ ) {
                cr[i][j] = cr[i+1][j];
            }
        }
        cr[i][S[i]-'0'] = 1;
    }
    set<int> s;
    for ( int i = 1; i < N-1; i++ ) {
        for ( int a = 0; a < 10; a++ ) {
            if ( cl[i-1][a] == 0 ) continue;
            for ( int b = 0; b < 10; b++ ) {
                if ( cr[i+1][b] == 0 ) continue;
                int d = (int)(S[i] - '0');
                int x = a*100 + d*10 + b;
                s.insert(x);
            }
        }
    }

    ll ans = s.size();
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9344
H,W=map(int,input().split())
s=[[] for _ in range(H+2)]
s[0]="."*(W+2)
for i in range(H):
    s[i+1]="."+input()+"."
s[-1]="."*(W+2)

ans="Yes"

di=[0,0,1,-1]
dj=[1,-1,0,0]

def ch(i,j):
    for k in range(4):
        if s[i+di[k]][j+dj[k]]=="#":
            return True
    return False
            


for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j]=="#":
            if ch(i,j):
                continue
            else:
                ans="No"
                break
                
print(ans)
            
            
    




Measured memory_bytes: 40048
import Control.Applicative ((<$>), (<*>))
import Data.List (intersect, (\\))

main :: IO ()
main = getLine >> solve <$> f <*> f <*> f >>= print
  where f = map read <$> tail <$> words <$> getLine

solve :: [Int] -> [Int] -> [Int] -> Int
solve xs ys zs = length (ys `intersect` zs) + length ((zs \\ ys) \\ xs)



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

namespace Atc_0031
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int B = int.Parse(str.Split(' ')[1]);

            int result = 0;
            int t = 1;

            while (t < B)
            {
                result++;
                t = (t - 1);
                t += A;
            }

            Console.WriteLine(result);

        }
    }
}


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

int main() {
  int N;
  cin >> N;
  
  bool pink, white, green, yellow;
  pink = white = green = yellow = false;
  
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    
    if (s == "P") {
      pink = true;
    } else if (s == "W") {
      white = true;
    } else if (s == "G") {
      green = true;
    } else {
      yellow = true;
    }
  }
  if (pink && white && green && yellow) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

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

int main(){
int N,X;
  int b =0;
  int count =1;
cin >> N >>X;
  vector<int> L(N);
  for(int i=0;i < N;++i)
    cin >> L[i];
for(int i =0;i < N;++i){
b += L[i];
  if(b <= X)
    count++;
}
cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a<=k){
		cout<<"Yay!"<<endl;
	}
	else{
		cout<<":("<<endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int p=1000000007;
  vector<vector<int>> dp(n,vector<int>(n,0));
  vector<vector<int>> dps(n,vector<int>(n+1,0));
  dp[0][0]=1;
  dps[0][1]=1;
  for(int i=1;i<n;i++){
    for(int j=0;j<=i;j++){
      dp[i][j]=(s.at(i-1)=='<'?dps[i-1][j]:dps[i-1][i]-dps[i-1][j]+p)%p;
      dps[i][j+1]=(dps[i][j]+dp[i][j])%p;
    }
  }
  cout<<dps[n-1][n]<<endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  if (n >= 30) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3636
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: i64 = scan(tokens);
    let l: i64 = scan(tokens);
    let s = n * (l + l + n - 1) / 2;
    if l >= 0 {
        println!("{}", s - l);
    } else if l + n - 1 <= 0 {
        println!("{}", s - (l + n - 1));
    } else {
        println!("{}", s);
    }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;

vector<vi> g;
vi a, ans;
vector<bool> used;

void dfs(int v, int sum) {
    used[v] = true;
    sum += a[v];
    ans[v] = sum;
    for (int u : g[v]) {
        if (!used[u]) {
            dfs(u, sum);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    g.resize(n);
    a.resize(n);
    ans.resize(n);
    used.resize(n, false);
    int u, v;
    forn(i, n - 1) {
        cin >> u >> v;
        u--;
        v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    while (q--) {
        int x;
        cin >> u >> x;
        u--;
        a[u] += x;
    }
    dfs(0, 0);
    for (int x : ans) cout << x << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m; cin >> n >> m;
	vector<vector<int>> adj(n);
	queue<pii> bfs;
	vector<int> ans(n);
	vector<bool> visited(n);
	for(int i = 0; i < m; i++)
	{
		int u, v; cin >> u >> v;
		u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i = 0; i < adj[0].size(); i++) bfs.push(make_pair(adj[0][i], 0));
	visited[0] = 1;
	while(!bfs.empty())
	{
		int v = bfs.front().first, p = bfs.front().second; bfs.pop();
		if(visited[v]) continue;
		visited[v] = 1;
		ans[v] = p;
		for(int i = 0; i < adj[v].size(); i++) bfs.push(make_pair(adj[v][i], v));
	}
	cout << "Yes" << endl;
	for(int i = 1; i < n; i++) cout << ans[i] + 1 << endl;

	return 0;
}

Measured memory_bytes: 12244
/*
時計
*/

#include<stdio.h>
int main(void){
  int time;/*秒単位の時間*/
  int h,m,s;/*時間 分 秒*/

  scanf("%d",&time);
  h = time/3600;
  time = time - 3600*h;
  m = time/60;
  s = time - 60*m;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}


Measured memory_bytes: 2760
N=int(input())
D=list(map(int,input().split()))
M=998244353

P=max(D)
L=[0]*(P+1)
for d in D:
    L[d]+=1

if not(L[0]==1 and D[0]==0):
    print(0)
    exit()

K=1
for i in range(P):
    K*=pow(L[i],L[i+1],M)
    K%=M
print(K)

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

int main()
{
  int n, m;
  while (cin >> n >> m, n || m){
    int a[1010] = {0};
    for (int i = 1; i <= n; i++){
      cin >> a[i];
    }

    vector<int> A;

    for (int i = 0; i <= n; i++){
      for (int j = 0; j <= n; j++){
        if (a[i] + a[j] > m) continue;
        A.push_back(a[i] + a[j]);
      }
    }

    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());

    int maxs = 0;
    for (int l = 0, r = A.size() - 1; l <= r; l++){
      while (A[l] + A[r] > m) r--;
      maxs = max(maxs, A[l] + A[r]);
    }

    cout << maxs << endl;
  }
}

Measured memory_bytes: 10676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int X, N;
bool p[101];

int main()
{
    cin >> X>>N;

    int i,j;
    rep0(i,N)
    {
        cin>>j;
       if(!p[j]) p[j]=true;
    }

    int s=0,l=0;
    rep0(i,N+1){
        if(!p[X-s]){cout << X-s << endl;break;}
        if(!p[X+l]){cout << X+l << endl;break;}
        s++; l++;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
  int b;
  scanf("%d",&b);
  int a[b];
  int i = 0;
  while (i < b)
  {
    scanf("%d",&a[i]);
    i++;
  }
  i = 0;
  int j = 0;
  int tmp = 0;
  while (i < b)
  {
    j = i + 1;
    while (j < b)
    {
      if (a[i] > a[j])
      {
      	tmp = a[i];
      	a[i] = a[j];
      	a[j] = tmp;
      }
      j++;
    }
    i++;
  }
  int pmin = a[0];
  int pmax = a[i - 1];
  int c[a[i - 1] - a[0]];
  i = 0;
  int p = pmin;
  while (i <= pmax - pmin)
  {
    c[i] = 0;
    i++;
  }
  i = 0;
  while (p <= pmax)
  {
    j = 0;
    while (j < b)
    {
      c[i] += (a[j] - p) * (a[j] - p);
      j++;
    }
    p++;
    i++;
  }
  i = 0;
  j = 0;
  while (i <= pmax-pmin)
  {
    while (j <= pmax - pmin)
    {
      if (c[i] > c[j])
      {
        tmp = c[i];
        c[i] = c[j];
        c[j] = tmp;
      }
      j++;
    }
    i++;
  }
  printf("%d",c[0]);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();
	double a=1.0*n/3;
	printf("%.6lf\n",a*a*a);
	return 0;
}

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

int main() {

	int A, B;
	cin >> A >> B;

	int max = A + B;

	if ((A - B) > max) max = A - B;
	if ((A*B) > max) max = A*B;

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=998244353;
int n;
ll ans,tmp;
char s[20];
string S[100010];
ll C(ll x) {
	return x*(x-1)/2;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		cin>>S[i];
		sort(S[i].begin(),S[i].end());
		/*
		printf("%s\n",s+1);
		for (int j=1;j<=10;j++)
			S[i][j-1]=s[j];*/
	}
	sort(S+1,S+n+1);
	int lst=1;
	for (int i=2;i<=n;i++)
		if (S[i]!=S[i-1])
			ans+=C(i-lst),lst=i;
	ans+=C(n-lst+1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n;
    cin>>n;
    vector<vector<int> > g(n);
    vector<mp> edge;
    for(int i=0;i<n-1;i++){
	int s,t;
	cin>>s>>t;
	s--,t--;
	g[s].push_back(i);
	g[t].push_back(i);
	edge.push_back( mp(s,t) );
    }
    vector<bool> used(n,false);
    queue<mp> q;
    q.push( mp( 0 , 1 ) );
    vector<int> res(n-1,0);
    int kmax = 0;
    for(int i=0;i<n;i++){
	set<int> st;
	for(auto j:g[i]){
	    st.insert( res[j] );
	}
	//vector<int> cnt;
	int k = 1;
	for(int j=0;j<g[i].size();j++){
	    if( res[ g[i][j] ] == 0 ){
		while( st.find( k ) != st.end() ) k++;
		res[ g[i][j] ] = k++;
		//cnt.push_back( k++ );
	    }
	}
	kmax = max( kmax , k-1 );
    }
    cout<<kmax<<endl;
    for(auto i:res)cout<<i<<endl;
    /*
    while( !q.empty() ){
	mp now = q.front();
	q.pop();
	if( used[now.first] ){
	    continue;
	}
	used[now.first] = true;
	res[now.first] = now.second;
	//set<int> cnt;
	//for(auto i:g[now])cnt.insert( res[i] );
	//int k = 1;
	//while( cnt.find( k ) != cnt.end() )k++;
	int k = 1;
	for(int i=0;i<g[now.first].size();i++){
	    int add = 0;
	    if( k == now.second ){
		k++;
	    }
	    if( !used[ g[now.first][i] ] )q.push( mp( g[now.first][i] , k++ ) );
	}
    }
*/
    //for(auto i:res)cout<<i<<endl;
    
    return 0;
}


Measured memory_bytes: 7920
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int n = s.size();
    if (s[0] == '0' || s[n-1] == '1') { cout << "-1\n"; return 0; }
    for (int i = 0; i < s.size()/2; i++)
        if (s[i] != s[n-i-2]) { cout << "-1\n"; return 0; }

    int root = 1;
    int parent[n+1];
    int i = 2;
    for (int i = 2; i <= n; i++) {
        if (s[i-2] == '1') { parent[root] = i; root = i; }
        else { parent[i] = root; }
    }

    for (int i = 1; i <= n; i++) {
        if (i != root) cout << i << ' ' << parent[i] << endl;
    }
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define maxn 101
#define ll long long
#define INF 0x3f3f3f3f
vector<int>g[5];
int n,w;
int u[maxn],v[maxn];
bool cmp(int x,int y)
{
    return x>y;
}
ll pre[4][maxn];
int main()
{
    while(~scanf("%d%d",&n,&w))
    {
        for(int i=0;i<=3;++i)
        {
            g[i].clear();
            g[i].push_back(INF);
        }
        for(int i=1;i<=n;++i)
        {
            scanf("%d%d",&u[i],&v[i]);
            g[u[i]-u[1]].push_back(v[i]);
        }
        for(int i=0;i<=3;++i) sort(g[i].begin(),g[i].end(),cmp);

        ll ans=0;
        for(int i=0;i<=3;++i)
        {
            pre[i][0]=0;
            for(int j=1;j<(int)g[i].size();++j)
                pre[i][j]=pre[i][j-1]+g[i][j];
        }
        for(int i1=0;i1<(int)g[0].size();++i1)
            for(int i2=0;i2<(int)g[1].size();++i2)
                for(int i3=0;i3<(int)g[2].size();++i3)
                    for(int i4=0;i4<(int)g[3].size();++i4)
                    {
                        if(1LL*i1*u[1]+1LL*i2*(u[1]+1)+1LL*i3*(u[1]+2)+1LL*i4*(u[1]+3)>w) continue;
                        ans=max(ans,pre[0][i1]+pre[1][i2]+pre[2][i3]+pre[3][i4]);
                    }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include<set>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long COM(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;
}

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}


//134 E
int main(void) {
	ll n;
	cin >> n;
	vector<ll> a = vector<ll>(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	multiset<ll> color;
	rep(i, 0, n) {
		auto itr = color.lower_bound(a[i]);
		if (itr == color.begin()) {
			color.insert(a[i]);
		}
		else {
			color.erase(--itr);
			color.insert(a[i]);
		}
	}
	cout << color.size() << endl;
}


Measured memory_bytes: 5760