akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int M[10];
  int N; const int ALL = (1<<7)-1;
  M[0] = ALL-(1<<6);
  M[1] = (1<<1)+(1<<2);
  M[2] = ALL-(1<<2)-(1<<5);
  M[3] = ALL-(1<<4)-(1<<5);
  M[4] = (1<<1)+(1<<2)+(1<<5)+(1<<6);
  M[5] = ALL-(1<<1)-(1<<4);
  M[6] = ALL-(1<<1);
  M[7] = ALL-(1<<3)-(1<<4)-(1<<6);
  M[8] = ALL;
  M[9] = ALL-(1<<4);
  while(cin >> N && (N!=-1)) {
    int S = 0;
    for(int i=0; i<N; i++) {
      int x; cin >> x;
      S ^= M[x];
      for(int j=6; j>=0; j--) {
        cout << (S >> j & 1);
      }
      S = M[x];
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MX 105

int sum[MX];

int get(int sc)
{
    if (sc>=1&&sc<=399) return 1;
    if (sc>=400&&sc<=799) return 2;
    if (sc>=800&&sc<=1199) return 3;
    if (sc>=1200&&sc<=1599) return 4;
    if (sc>=1600&&sc<=1999) return 5;
    if (sc>=2000&&sc<=2399) return 6;
    if (sc>=2400&&sc<=2799) return 7;
    if (sc>=2800&&sc<=3199) return 8;
    return 0; // ziyou
}

int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        sum[get(x)]++;
    }
    int a=0,b=0;
    for (int i=1;i<=8;i++)
    {
        if (sum[i])
        {
            a++;
            b++;
        }
    }
    a+=sum[0];
    if (b==0&&sum[0]!=0) b=1;

    printf("%d %d\n",b,a);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cmath>
#include <map>
using namespace std;

void func150c() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];
  vector<int> a(n);
  for (int i = 0; i < n; i++) a[i] = i+1;
  
  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(), a.end()));
  int ans = abs(mp[p]-mp[q]);
  cout << ans << "\n";
}



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

Measured memory_bytes: 5248
def rotleft(dx,dy):
  return -dy, dx

s = input().split()
x1 = int(s[0])
y1 = int(s[1])
x2 = int(s[2])
y2 = int(s[3])

dx = x2 - x1
dy = y2 - y1

dx,dy = rotleft(dx,dy)

x3 = x2 + dx
y3 = y2 + dy

dx,dy = rotleft(dx,dy)

x4 = x3 + dx
y4 = y3 + dy

print("%d %d %d %d" % (x3,y3,x4,y4))
   

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x,a,b;
    cin>>x>>a>>b;
    
    if(a>=b){
        cout1("delicious")
    }else if(a+x>=b){
        cout1("safe")
    }else{
        cout1("dangerous")
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<int> v(n-1);
   for(int i=0;i<n-1;i++)cin >> v[i];
   long sum = v[0] + v[n-2];
   for(int i=1;i<n-1;i++){
       sum += min(v[i-1],v[i]);
   }
   cout << sum << endl;
}

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    long long N;
    cin >> N;
    ll ans_min = 1;
    ll ans_max;
	for (ll i = 2; i*i <= N; i++) {
        if(N % i == 0){
            if(i*i <= N){
                ans_min = i;
                ans_max = N/i;
                // sosuu
                for(ll j=2;j*j<ans_max;++j){
                    if(ans_max%j == 0){
                        break;
                    }
                    // is sosuu
                    break;
                }
            }else{
                break;
            }
        }
	}
    ans_max = N  / ans_min;
    out(ans_min + ans_max - 2);
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD =  1000000007;
const ll INF = 1LL << 60;


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

    if(a < b && b < c){
        cout << "Yes" << endl;
        return 0;
    }

    while(0 < k){
        if(b <= a){
            b *= 2;
            k--;
        }
        if(a < b) break;
    }

    if(a < b && b < c){
        cout << "Yes" << endl;
        return 0;
    }

    while(0 < k){
        if(c <= b){
            c *= 2;
            k--;
        }
        if(b < c) break;
    }

    if(a < b && b < c){
        cout << "Yes" << endl;
        return 0;
    }


    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int count = 0;
    int res;
    for (int i = 100; i > 0; --i)
    {
        if (A % i == 0 && B % i == 0)
        {
            count++;
            if (count == K)
            {
                res=i;
                break;
            }
        }
    }
    cout << res << endl;
}

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

namespace AtCoder.Minpro2019_2_9
{
    class D
    {
        public static void Solve()
        {
            var l = int.Parse(Console.ReadLine());
            ulong[] a = new ulong[l];
            ulong[,] dp = new ulong[l, 5];

            for (int i = 0; i < l; i++)
            {
                a[i] = ulong.Parse(Console.ReadLine());
            }


            for (int j = 0; j < 5; j++)
            {
                dp[0, j] = DPUpdate(0, j, a[0]);
            }

            for (int i = 1; i < l; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    dp[i, j] = int.MaxValue;
                }
                for (int j = 0; j < 5; j++)
                {
                    for (int c = j; c < 5; c++)
                    {
                        var u = DPUpdate(dp[i - 1, j], c, a[i]);
                        if (u < dp[i, c])
                            dp[i, c] = u;
                    }
                }
            }
            /*
            for(int i = 0; i < l; i++)
            {
                for(int j = 0; j < 5; j++)
                {
                    Console.Write(dp[i, j]);
                }
                Console.Write("\n");
            }*/
            var min = ulong.MaxValue;
            for(int i = 0; i < 5; i++)
            {
                min = min > dp[l - 1, i] ? dp[l - 1, i] : min;
            }
            Console.WriteLine(min);
        }

        /// <summary>
        /// dpの更新
        /// </summary>
        /// <param name="now">現在の最小値</param>
        /// <param name="t">更新先の状態</param>
        /// <param name="ai">着目してるコスト</param>
        /// <returns></returns>
        private static ulong DPUpdate(ulong now,int t,ulong ai)
        {
            if (t == 0 || t == 4)
            {
                return now + ai;
            }
            else if (t % 2 == 1)
            {
                return now + (ai == 0 ? 2 : ai % 2);
            }
            else
            {
                return now + (ai == 0 ? 1 : (ai + 1) % 2);
            }
        }
    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Minpro2019_2_9.D.Solve();
        }
    }
}


Measured memory_bytes: 24412
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for(int i = 0; i < n; i++)
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)

int main()
{
    int D; cin >> D;
    if (D == 25) {
        cout << "Christmas" << endl;
    } else if (D == 24) {
        cout << "Christmas Eve" << endl;
    } else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
def counter_one(A):
    cnt = 0
    for i,ai in enumerate(A):
        cnt += sum(a < ai for a in A[i+1:])
    return cnt
def counter_two(A):
    cnt = 0
    for i,ai in enumerate(A):
        cnt += sum(a < ai for a in A)
    return cnt
  

N,K = map(int,input().split())
A = list(map(int,input().split()))

one_a = counter_one(A)
two_a = counter_two(A)

ans = (one_a*K)+((two_a)*(K*(K-1)//2))
print(int(ans%((10**9)+7)))  


Measured memory_bytes: 3188
#include<cstdio>
using namespace std;
#define N 25050
#define K 405
#define mod 1000000007
int n,m,k,s[N],dp[N][K],su[N][K],as,l,r,s1[N][K],fr[K],ifr[K],vl[N][K];
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
bool check(int l,int r){for(int i=l;i<=r;i++)for(int j=i+1;j<=r;j++)if(s[i]==s[j])return 0;return 1;}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;i++)scanf("%d",&s[i]);
	fr[0]=ifr[0]=1;for(int i=1;i<=m;i++)fr[i]=1ll*fr[i-1]*i%mod,ifr[i]=pw(fr[i],mod-2);
	for(int i=1;i<=k;i++){if(check(1,i))l=i;if(check(k-i+1,k))r=i;}
	for(int i=1;i+m-1<=k;i++)if(check(i,i+m-1)){printf("%d\n",1ll*pw(m,n-k)*(n-k+1)%mod);return 0;}
	if(l==k)
	{
		su[1][1]=dp[1][1]=m;if(l==1)vl[1][1]=s1[1][1]=m;
		for(int i=2;i<=n;i++)
		for(int j=m-1;j>0;j--)dp[i][j]=(su[i-1][j]+1ll*dp[i-1][j-1]*(m-j+1))%mod,su[i][j]=(su[i][j+1]+dp[i][j])%mod,vl[i][j]=(s1[i-1][j]+1ll*vl[i-1][j-1]*(m-j+1)+(j>=l?dp[i][j]:0))%mod,s1[i][j]=(s1[i][j+1]+vl[i][j])%mod;
		printf("%d\n",(1ll*pw(m,n-k)*(n-k+1)%mod-1ll*s1[n][1]*ifr[m]%mod*fr[m-k]%mod%mod+mod)%mod);return 0;
	}
	dp[0][l]=1;for(int j=1;j<=l;j++)su[0][j]=1;
	for(int i=1;i<=n;i++)
	for(int j=m-1;j>0;j--)dp[i][j]=(su[i-1][j]+1ll*dp[i-1][j-1]*(m-j+1))%mod,su[i][j]=(su[i][j+1]+dp[i][j])%mod;
	vl[0][r]=1;for(int j=1;j<=r;j++)s1[0][j]=1;
	for(int i=1;i<=n;i++)
	for(int j=m-1;j>0;j--)vl[i][j]=(s1[i-1][j]+1ll*vl[i-1][j-1]*(m-j+1))%mod,s1[i][j]=(s1[i][j+1]+vl[i][j])%mod;
	for(int i=1;i+k-1<=n;i++)as=(as+1ll*su[i-1][1]*s1[n-(i+k-1)][1])%mod;
	printf("%d\n",(1ll*pw(m,n-k)*(n-k+1)%mod-as+mod)%mod);
}

Measured memory_bytes: 158720
# -*- coding: utf-8 -*-
N = int(input())
Wi = []

for i in range(N):
    Wi.append(input())

#1
Wi_set = set(Wi)
if len(Wi) != len(Wi_set):
    print('No')
    exit()

#2
tail = ""
for W in Wi:
    if tail != "":
        if tail != W[0]:
            print('No')
            exit()
    tail = W[-1]

print('Yes')


Measured memory_bytes: 3060
N,M=map(int,input().split())
S=[]
C=[]
for i in range(M):
  s,c=map(int,input().split())
  S+=[s]
  C+=[c]
tf=1
ans=[]
for i in range(N):
  ans+=[-1]
for i in range(M):
  if ans[S[i]-1] ==-1:
    ans[S[i]-1]=C[i]
  else:
    if ans[S[i]-1]!=C[i]:
      tf=0
      break
    else:
      continue
for i in range(N):
  if ans[i]==-1:
    if i!=0 or (i==0 and N==1):
      ans[i]=0
    else:
      ans[i]=1
  elif ans[i]==0 and i==0 and N!=1:
    tf=0
    break
if tf==0:
  print('-1')
else:
  ansnum=''
  for i in range(N):
    ansnum+=str(ans[i])
  print(ansnum)

Measured memory_bytes: 3064
#include<cstdio>
#include<queue>
using namespace std;
short mati[5001][5000],lim[5001];
short mati2[5001][5000],lim2[5001];
typedef pair<int,int> P;
int main(void)
{
	int ryo[5001],r[5001],flg[5001];
	int i,j,n,k;
	int x,y,rr,nn,ans;
	priority_queue<P,vector<P>,greater<P> > qu;

	P ppp;
	scanf("%d %d",&n,&k);
//	printf("aaa\n");
	for(i=1;i<=n;i++)	{
		scanf("%d %d",&ryo[i],&r[i]);
		lim[i]=0;	lim2[i]=0;
	}
	for(i=0;i<k;i++)	{
		scanf("%d %d",&x,&y);
		mati[x][lim[x]]=y;
		lim[x]++;
		
//		printf("count i=%d %d\n",x,lim[x]);	
		
		mati[y][lim[y]]=x;
		lim[y]++;
//		printf("count i=%d %d\n",y,lim[y]);
	}
	
//		printf("bbb\n");
	for(i=1;i<=n;i++)	{
		queue<P> qq;
//		printf("i=%d\n",i);
		for(j=1;j<=n;j++)	{
			flg[j]=0;
		}
		qq.push(P(i,0));
		flg[i]=1;
		while(qq.size()!=0)	{
			ppp=qq.front();
			qq.pop();
			nn=ppp.first;
			rr=ppp.second;
			if(rr>=r[i])	break;
			for(j=0;j<lim[nn];j++)	{
				x=mati[nn][j];
				
//				printf("i=%d x=%d rr=%d\n",i,x,rr);
				
				if(flg[x]==0)	{
					flg[x]=1;
					mati2[i][lim2[i]]=x;
					lim2[i]++;
					qq.push(P(x,rr+1));
//					printf("2:i=%d x=%d rr=%d\n",i,x,rr+1);
				}
			}
		}
	}

	for(i=1;i<=n;i++)	flg[i]=0;
	qu.push(P(0,1));
	while(1)	{
		ppp=qu.top();
		qu.pop();
		nn=ppp.first;
		rr=ppp.second;
		
//		printf("nn=%d rr=%d\n",nn,rr);
		
		if(flg[rr]==0)	{
			flg[rr]=1;
			if(rr==n)	{
				ans=nn;	break;
			}
//			printf("rr=%d lim2=%d\n",rr,lim2[rr]);
			
			for(i=0;i<lim2[rr];i++)	{
				if(flg[mati[rr][i]]==0)	{
					qu.push(P(nn+ryo[rr],mati2[rr][i]));
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 229300
#include <iostream>
#include <vector>

int main() {
  using namespace std;

  int N;
  cin >> N;
  vector<int> A(N + 1);
  for (auto i = 2; i <= N; ++i)
    cin >> A[i];

  vector<int> buka(N + 1);
  for (auto i = N; 1 <= i; --i) {
    ++buka[A[i]];
  }

  for (auto i = 1; i <= N; ++i)
    cout << buka[i] << "\n";

  return 0;
}


Measured memory_bytes: 4844
#include<stdio.h>
int main(void){
   int a,b,d,r;
   double f;

   scanf("%d %d",&a,&b);

   d=a/b;
   r=a%b;
   f=(double)a/(double)b;

   printf("%d %d %lf\n",d,r,f);

   return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  int cnt=0;
  while(!s.empty()){
    if(s.front()==s.back()){
      s.erase(s.begin());
      if(s.empty()) break;
      auto itr=s.end();
      --itr;
      s.erase(itr);
    }

    else if(s.front()!='x' && s.back()!='x'){
      cout<<-1;
      return 0;
    }

    else if(s.front()=='x'){
      s+="x";
      cnt++;
    }
    else{
      s="x"+s;
      cnt++;
    }
  }
  cout<<cnt;
}

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

using namespace std;

int main(){
  int N; cin >> N;
  string S; cin >> S;
  
  int left = 0; int right = 0;
  
  int l = 0; int r = 0;
  for(int i = 0; i < N; i++){
    if(S[i] == ')'){ l++;}
    else{ l--;}
    
    left = max(left,l);
  }
  for(int i = N-1; i >= 0; i--){
    if(S[i] == '('){ r++;}
    else{ r--;}
    
    right = max(right,r);
  }
  
  for(int i = 0; i < left; i++){
    S = '('+S;
  }
  for(int i = 0; i < right; i++){
    S = S+=')';
  }
  
  cout << S << endl; return 0;
} 
    

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

int c = 0;
int N, M;
vector<int> a(28), b(28), v(8, false);
int dfs(int current, vector<int> visited)
{
  int result = 0;
  bool all_visited = true;
  for (int i = 0; i <N; i++)
  {
    if (visited[i] == false)
    {
      all_visited = false;
      break;
    }
  }
  if (all_visited)
  {
    c++;
    return 0;
  }

  for (int i = 0; i < M; i++)
  {
    if (a[i] == current && visited[b[i]-1] == false)
    {
      visited[b[i]-1] = true;
      result += dfs(b[i], visited);
      visited[b[i]-1] = false;
    }
    if (b[i] == current && visited[a[i]-1] == false)
    {
      visited[a[i]-1] = true;
      result += dfs(a[i], visited);
      visited[a[i]-1] = false;
    }
  }
  return 0;
}

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

  for (int i = 0; i < M; i++)
  {
    cin >> a[i] >> b[i];
  }
  v[0] = true;
  dfs(1, v);
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

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

        Integer[] a = new Integer[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(a, Collections.reverseOrder());

        int alice = 0;
        int bob = 0;
        for(int i=0; i<n; i++) {
            if(i % 2 == 0) {
                alice += a[i];
            } else {
                bob += a[i];
            }
        }
        System.out.println(alice-bob);
    }
}


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

using namespace std;

typedef long long ll;

void solve(){
    int n;
    string s;
    cin >> n >> s;
    if(n<=3){
        cout << 0;
        return;
    }
    ll res = 0;
    int r, g, b;
    r=g=b=0;
    for(auto c : s){
        if(c=='R')
            r++;
        if(c=='G')
            g++;
        if(c=='B')
            b++;
    }
    if(s[0]=='R')
        --r;
    if(s[0]=='G')
        --g;
    if(s[0]=='B')
        --b;
    for(int i=1; i<n; i++){
        if(s[i]=='R'){
            //Gb,Bg
            --r;
            for(int j=0; j<i; j++){
                if(s[j]=='G'){
                    res+=b;
                    res-=(s[i+(i-j)]=='B');
                }
                else if(s[j]=='B'){
                    res+=g;
                    res-=(s[i+(i-j)]=='G');
                }
            }
        }
        else if(s[i]=='G'){
            //Br,Rb
            --g;
            for(int j=0; j<i; j++){
                if(s[j]=='R'){
                    res+=b;
                    res-=(s[i+(i-j)]=='B');
                }
                else if(s[j]=='B'){
                    res+=r;
                    res-=(s[i+(i-j)]=='R');
                }
            }
        }
        else{
            --b;
            for(int j=0; j<i; j++){
                if(s[j]=='G'){
                    res+=r;
                    res-=(s[i+(i-j)]=='R');
                }
                else if(s[j]=='R'){
                    res+=g;
                    res-=(s[i+(i-j)]=='G');
                }
            }
        }
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1, i = 1;
    //cin >> t;
    while(t--){
        solve();
        ++i;
    }
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int n, a, b;
    n = s.size();
    a = (n-1)/2;
    b = (n+3)/2;
    string first, second, third, fourth;
    for(int i=0; i<a; i++) first.push_back(s[i]);
    for(int i=b-1; i<n; i++) second.push_back(s[i]);

    third = first;
    reverse(third.begin(), third.end());
    fourth = second;
    reverse(fourth.begin(), fourth.end());

    string fifth = s;
    reverse(fifth.begin(), fifth.end());

    if(s == fifth and first == third and second == fourth) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

vi f(string s, int a, int n){
    int x = 0;
    vi ret;
    rep(i,n){
        x *= 10;
        x += s[i] - '0';
        if(a&(1<<i)){
            ret.push_back(x);
            x = 0;
        }
    }
    x *= 10;
    x += s[n] - '0';
    ret.push_back(x);
    return ret;
}

int main(void) {
  int i,j;
  int t;
  string s;
  while(cin >> t >> s, t){
      int n = s.size()-1;
      vector<pii> ans;
      rep(i,1<<n){
          vi x = f(s,i,n);
          int sum = 0;
          rep(j,x.size())sum += x[j];
          if(sum <= t){
              ans.push_back(pii(sum,i));
          }
      }
      int sz = ans.size();
      if(sz==0){
          cout << "error" << endl;
          continue;
      }
      sort(all(ans));
      if(ans[sz-1].first == ans[sz-2].first){
          cout << "rejected" << endl;
          continue;
      }
      cout << ans[sz-1].first;
      vi x = f(s,ans[sz-1].second,n);
      rep(i,x.size())cout << " " << x[i];
      cout << endl;
  }
}



Measured memory_bytes: 3164
#include<stdio.h>
#include<math.h>
#include <string.h>



int main() {
	int i, j, k, l;
	int m, g, n;
	long long int f = 0;
	int a, b;

	scanf("%d", &n);

	for (i = 1;i < n;i++) {
		f = f + i;
	}
	








	printf("%lld", f);

	return 0;
}

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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> l(q), r(q);
  rep(i, q) {
    cin >> l[i] >> r[i];
    --l[i];
    --r[i];
  }
  vector<int> cum(n);
  cum[0] = 0;
  for (int i = 1; i < n; ++i) {
    cum[i] = cum[i-1];
    if (s[i-1] == 'A' && s[i] == 'C') ++cum[i];
  }

  rep(qi, q) {
    int ans = cum[r[qi]] - cum[l[qi]];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	scanf("%d",&n);
	if(n==1)
	{
		printf("Hello World\n");
		return 0;
	}
	scanf("%d %d",&a,&b);
	printf("%d\n",a+b);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        int[][] dp = new int[s.length()+1][t.length()+1];

        for(int i = 0 ; i < s.length() ; i++){
            for(int j = 0 ; j < t.length() ; j++){
                if(s.charAt(i) == t.charAt(j)){
                    dp[i+1][j+1] = dp[i][j] + 1;
                }else{
                    if(dp[i+1][j] >= dp[i][j+1]){
                        dp[i+1][j+1] = dp[i+1][j];
                    }else{
                        dp[i+1][j+1] = dp[i][j+1];
                    }
                }
            }
        }

        StringBuilder ans = new StringBuilder();
        int[] pos = {s.length(), t.length()};
        while(dp[pos[0]][pos[1]] > 0){
            if(dp[pos[0]][pos[1]] == dp[pos[0]][pos[1] - 1]){
                pos[1]--;
            }else if(dp[pos[0]][pos[1]] == dp[pos[0]-1][pos[1]]){
                pos[0]--;
            }else{
                ans.append(s.charAt(pos[0]-1));
                pos[0]--;
                pos[1]--;
            }
        }

        System.out.println(ans.reverse().toString());
    }
}


Measured memory_bytes: 80972
a = int(input())
b = int(input())
c = int(input())
x = int(input())

combination = []
for A in range(a+1):
  for B in range(b+1):
    for C in range(c+1):
      total = A*500 + B*100 + C*50
      combination.append(total)

count = combination.count(x)
print(count)

Measured memory_bytes: 14048
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = new String[26];
		s[22] = "Christmas Eve Eve Eve";
		s[23] = "Christmas Eve Eve";
		s[24] = "Christmas Eve";
		s[25] = "Christmas";
		int n = saori.saori_hayami();
		System.out.println(s[n]);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23380
/*
	author - sekai_no_owari
	date   - 22.01.2020
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define amaterasu ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int
main ()
{
  amaterasu 
  ll n;
  cin >> n;
  ll arr[n];
  ll res = 1;
  for(ll i=0;i<n;i++)cin >> arr[i];
  ll t=arr[0];
  for(ll i=1; i<n;i++){
  	t = min(t, arr[i]);
  	if(arr[i] <= t)res++;
  }
  cout << res;
  return 0;
}


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

int main(){
  long long N, Z, W;
  cin >>N >>Z >>W;
  vector<long long> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  
  if (N==1){
    cout << abs(A[0]-W) << endl;
  }
  else{
    cout << max(abs(A[N-2]-A[N-1]), abs(A[N-1]-W)) << endl;
  }
}

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

using namespace std;
int main(){
	string s1,s2,s3;
  	int a,b;
  	cin>>s1>>s2>>a>>b>>s3;
  	if(s3==s2){b-=1;}
  else if(s3==s1){a-=1;}
  cout<<a<<" "<<b<<endl;
}

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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 1e2 + 5;
const int VAL = 1e5 + 5;
int n , k , mod = 1e9 + 7;
int a[N];
int dp[N][VAL] , dp1[N][VAL];

int add(int a , int b)
{
    return (a + b) % mod;
}

int sub(int a , int b)
{
    return ((a - b) % mod + mod) % mod;
}

main()
{
    //freopen("M.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    FOR(i , 1 , n)
        cin >> a[i];
    dp[0][0] = 1;
    FOR(j , 0 , k)
        dp1[0][j] = 1;
    FOR(i , 1 , n)
    {
        FOR(j , 0 , k)
        {
            dp[i][j] = dp1[i - 1][j];
            if(j - a[i] - 1 >= 0)
                dp[i][j] = sub(dp[i][j] , dp1[i - 1][j - a[i] - 1]);
        }
        dp1[i][0] = dp[i][0];
        FOR(j , 1 , k)
            dp1[i][j] = add(dp1[i][j - 1] , dp[i][j]);
    }
    cout << dp[n][k];
}


Measured memory_bytes: 160000
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q;
    cin >> n >> q;
    dsu d(n);
    
    rep(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t==0) {
            d.merge(u, v);
        }
        else {
            int ans = d.same(u, v);
            pr(ans);
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
// #define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
template<typename T> using Graph = vector<vector<T>>;

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

    int n;
    cin >> n;
    vi c(3);
    rep(i, n) {
        int a;
        cin >> a;
        c[a%3]++;
    }

    int ans = 1;
    if (c[1] > 0) {
        // 1??????????????¨???
        int c1 = c[1], c2 = c[2];
        int t = c[0] + 1; c1--;
        int x = min(c1, c2);
        t += 2 * x; c1 -= x; c2 -= x;
        t += max(min(c1, 2), min(c2, 1));
        ans = max(ans, t);
    }
    if (c[2] > 0) {
        // 2??????????????¨???
        int c1 = c[1], c2 = c[2];
        int t = c[0] + 1; c2--;
        int x = min(c1, c2);
        t += 2 * x; c1 -= x; c2 -= x;
        t += max(min(c2, 2), min(c1, 1));
        ans = max(ans, t);
    }

    cout << ans << endl;

}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int sum = 0;
    vec<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    int cnt = 0;
    for(int i=0;i<N;i++){
        cnt += (4*M*A[i]>=sum);
    }
    cout << (cnt>=M? "Yes\n":"No\n");
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math

N,A,B = (int(x)for x in input().split())

if A*N<=B:
    print(A*N)
else: print(B)






"""""""""""""""""""""""""""""""""""""""""""""""""""""
            提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
"""""""""""""""""""""""""""""""""""""""""""""""""""""


Measured memory_bytes: 3060
/*input
100
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

vector<int> p;
bool isp[105];

int cnt[30];

int main()
{
	IOS;
	int n;
	cin>>n;
	for(int i=2;i<105;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<105;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}

	for(int i=1;i<=n;i++){
		int tmp=i;
		REP(j,SZ(p)){
			while(tmp%p[j]==0){
				tmp/=p[j];
				cnt[j]++;
			}
		}
	}
	ll ans=0;
	REP(i,SZ(p)) for(int j=i+1;j<SZ(p);j++) for(int k=j+1;k<SZ(p);k++){
		if(cnt[i]>=4&&cnt[j]>=4&&cnt[k]>=2) ans++;
	}
	REP(i,SZ(p)) for(int j=i+1;j<SZ(p);j++) for(int k=j+1;k<SZ(p);k++){
		if(cnt[i]>=4&&cnt[j]>=2&&cnt[k]>=4) ans++;
	}
	REP(i,SZ(p)) for(int j=i+1;j<SZ(p);j++) for(int k=j+1;k<SZ(p);k++){
		if(cnt[i]>=4&&cnt[j]>=2&&cnt[k]>=4) ans++;
	}
	REP(i,SZ(p)) if(cnt[i]>=74) ans++;

	REP(i,SZ(p)) REP(j,SZ(p)) if(i!=j){
		if(cnt[i]>=24&&cnt[j]>=2) ans++;
	}
	REP(i,SZ(p)) REP(j,SZ(p)) if(i!=j){
		if(cnt[i]>=14&&cnt[j]>=4) ans++;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w,h,c,a,b,d,n;
	scanf("%d %d %d",&w,&h,&c);
	if(w<=h){
		a=h;
		b=w;
	}
	else{
		a=w;
		b=h;
	}
	while(1){
		if(a%b==0){
			n=(w/b*h/b)*c;
			printf("%d\n",n);
			break;
		}
		else{
			d=b;
			b=a%b;
			a=d;
		}
	}
	return 0;
}



Measured memory_bytes: 2752
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll x, y,ans=0;
	cin >> x >> y;
	if (x * y == 0) {
		ans = abs(x) + abs(y);
		if (y < x)ans++;
	}
	else if (x * y < 0) {
		ans = abs(abs(x) - abs(y)) + 1;
	}
	else if (0 < x * y) {
		ans = abs(abs(x) - abs(y));
		if (y < x)ans += 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2166>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll T;
vector<ll> t(50);
ll N;
vector<ll> M(115);
ll dp[115][50];

template<class Type>
Type solve(Type res = Type()){
    while(cin >> T,T){
        for(int i = 0; i < T;i++) cin >> t[i];
        cin >> N;
        fill(M.begin(),M.end(),INF);
        for(int i = 0; i < N;i++){
            ll D,m; cin >> D >> m;
            M[D-1] = min(M[D-1],m);
        }
        
        // dp[i日目][j番目の睡眠時間] := 最小カフェイン数
        fill(*dp,*dp+110*50,INF);
        dp[0][0] = 0;
        for(int i = 0; i < 110;i++){
            for(int j = 0; j < T;j++){
                if(dp[i][j] == INF) continue;
                if(t[j] <= M[i]){
                    dp[i+1][(j+1)%T] = min(dp[i+1][(j+1)%T],dp[i][j]);
                    dp[i+1][0] = min(dp[i+1][0],dp[i][j]+1);
                }
            }
        }
        cout << *min_element(dp[100], dp[100]+50) << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



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


void dump(vector<int> v) {
  if(v.empty()) {
    cout << endl;
    return;
  }
  vector<int>::iterator it = v.begin();
  cout << *it;
  it++;
  while(it!=v.end()){
    cout << " " << *it;
    it++;
  }
  cout << endl;
}

// void clear(vector<T> v) {
//   if(v.empty()) {
//     cout << endl;
//     return;
//   }
//   v.clear()
//   while(!v.empty()) {

//   }
// }

void  solve() {
  int n, q; cin >> n >> q;
  vector<vector<int> > v(n);
  while(q--){
    int type; cin >> type;
    switch(type){
      case 0:
        int t, a; cin >> t >> a;
        v[t].push_back(a);
        break;
      case 1:
        int t1; cin >> t1;
        dump(v[t1]);
        break;
      case 2:
        int t2; cin >> t2;
        v[t2].clear();
        break;
      default: 
        cout << "Error" << endl;      
    }
  }
}

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



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

const int MOD = 1e9 + 7;
vector<long long> fact, fact_inv;

// x^n の高速べき乗計算 O(logn)
long long pow_mod(long long x, long long n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;  cin >> N;
    long long ans = pow_mod(10, N) - 2 * pow_mod(9, N);
    while (ans < 0) ans += MOD;  ans %= MOD;
    ans += pow_mod(8, N);
    while (ans < 0) ans += MOD;  ans %= MOD;
    cout << ans << endl;
}


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

#define INF 2147483647
#define LINF 9223372036854775807
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int, int> P;

int n;
vector<int> g[100000];
int da[100000],db[100000];

void dijkstra1() {
	priority_queue<P,vector<P>,greater<P> > pq;
	fill(da,da+n,INF);
	da[0]=0;
	pq.push(P(0,0));
	while (!pq.empty()) {
		P p=pq.top(); pq.pop();
		int v=p.second;
		REP(i,g[v].size()) {
			int e=g[v][i];
			if(da[e]>da[v]+1) {
				da[e]=da[v]+1;
				pq.push(P(da[e],e));
			}
		}
	}
	return;
}

void dijkstra2() {
	priority_queue<P,vector<P>,greater<P> > pq;
	fill(db,db+n,INF);
	db[n-1]=0;
	pq.push(P(0,n-1));
	while (!pq.empty()) {
		P p=pq.top(); pq.pop();
		int v=p.second;
		REP(i,g[v].size()) {
			int e=g[v][i];
			if(db[e]>db[v]+1) {
				db[e]=db[v]+1;
				pq.push(P(db[e],e));
			}
		}
	}
	return;
}

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

	cin>>n;
	REP(i,n-1) {
		int a,b; cin>>a>>b; a--; b--;
		g[a].push_back(b); g[b].push_back(a);
	}

	dijkstra1();
	dijkstra2();

	int ca=0,cb=0;
	FOR(i,1,n-1) {
		if(da[i]>db[i]) cb++;
		else ca++;
	}
	if(ca>cb) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;

	return 0;
}


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

function main()
	a = ["Sunny", "Cloudy", "Rainy"]
	s = readline() |> chomp
	for i in 1:3
		if a[i]==s
			println(a[i%3+1])
		end
	end
end

main()

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

int main() {
  string str;
  cin >> str;
  int result = 0;
  for(int i = 0; i < str.size() / 2; ++i) {
    char a = str[i];
    char b = str[str.size() - 1 - i];
    if(a == '(' && b != ')') {++result; continue;}
    if(a == ')' && b != '(') {++result; continue;}
    if(a != '(' && a != ')' && a != b) ++result;
  }
  if(str.size() % 2 && (str[str.size() / 2] == '(' || str[str.size() / 2] == ')')) ++result;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1180
main(){
  int w,n,a,b,t,i;
  scanf("%d",&w);
  scanf("%d",&n);
  int d[w+1];
  for(i=0;i<=w;i++)d[i]=i;
  for(i=0;i<n;i++){
    scanf("%d,%d",&a,&b);
    t=d[a];
    d[a]=d[b];
    d[b]=t;
  }
  for(i=1;i<=w;i++)printf("%d\n",d[i]);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int k; cin >> k;
  cout << (k / 2) * ((k + 1) / 2) << '\n';
}

Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)
h = n.times.map {gets.to_i}.sort_by{|e| -e}

l = 1
r = (h[0] + b - 1) / b

while l != r
    m = (l + r) / 2

    t = 0
    h.each do |e|
        break if e <= b * m || t > m
        t += (e - m * b + a - b - 1) / (a - b)
    end

    t > m ? l = m + 1 : r = m
end

p l

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

int main(){
	while(1){
	int x, y;
	cin >> x >> y;
	if( x == 0 && y == 0) break;
	if( x > y ){ cout << y << " " << x << endl; }else{ cout << x << " " << y << endl; }
	}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
using namespace std;
int n,k;
vector<vector<int> > adj;
int parent[2001][11];
int dep[2001]={0,};
void dfs2(int here,int dad,int d){
    parent[here][0]=dad;
    dep[here]=d;
    for(int i=0;i<adj[here].size();i++){
        int there=adj[here][i];
        if(there==dad)
            continue;
        dfs2(there,here,d+1);
    }
}
int dfs(int here,int dad,int d,int mx){
    int ans=1;
    if(mx==d)
        return ans;
    for(int i=0;i<adj[here].size();i++){
        int there=adj[here][i];
        if(there==dad)
            continue;
        ans+=dfs(there,here,d+1,mx);
    }
    return ans;
}
int getLca(int u,int v){
    if(dep[u]>dep[v])
        swap(u,v);
    int d=dep[v]-dep[u];
    int i=0;
    while(d){
        if(d&(1<<i)){
            d-=(1<<i);
            v=parent[v][i];
        }
        i++;
    }
    if(u==v)
        return u;
    for(int i=10;i>=0;i--){
        if(parent[u][i]!=parent[v][i])
            u=parent[u][i],v=parent[v][i];
    }
    return parent[u][0];
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>k;
    adj.resize(n+1);
    for(int i=0;i<n-1;i++){
        int from,to;
        cin>>from>>to;
        adj[from].push_back(to);
        adj[to].push_back(from);
    }
    int ans=0;
    //dfs2(1,-1,0);
   /* for(int i=1;i<11;i++){
        for(int j=1;j<=n;j++){
            if(parent[j][i-1]<0)
                parent[j][i]=-1;
            else
                parent[j][i]=parent[parent[j][i-1]][i-1];
        }
    }
    */
    if(k%2==0){
        for(int i=1;i<=n;i++)
            ans=max(ans,dfs(i,-1,0,k/2));
    }
    else{
        for(int i=1;i<=n;i++){
            for(int s=0;s<adj[i].size();s++){
                int j=adj[i][s];
                ans=max(ans,max(ans,dfs(i,j,0,k/2)+dfs(j,i,0,k/2)));
            }
        }
    }
    cout<<n-ans;
    return 0;
}

Measured memory_bytes: 512
n,y = map( int, input().split() )

yukichi = 0
ichiyo = 0
hideyo = 0

complete = False

if yukichi != -1:
    for i in range(n+1):
        for j in range(n-i+1):
            if 10000*i+5000*j+1000*(n-i-j) == y:
                yukichi = i
                ichiyo = j
                hideyo = n-i-j
                complete = True
                break
        if complete:
            break

if complete == False:
    yukichi = -1
    ichiyo = -1
    hideyo = -1


print(str(yukichi)+" "+str(ichiyo)+" "+str(hideyo))

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long T = sc.nextInt();
        long ans = 0;
        long t = 0;
        for(int i = 0;i < N;i++){
            long ti = sc.nextLong();
            ans += Math.min(ti-t, T);
            t = ti;
            if(i == N-1)    ans += T;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 61176
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  map<char, int> mp;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char c;
      cin >> c;
      mp[c]++;
    }
  }

  priority_queue<int> que;
  for(auto it = mp.begin(); it != mp.end(); it++){
    que.push(it->second);
  }

  //必要なペアの数
  int p1, p2, p4;
  if(H % 2 == 1 && W % 2 == 1){
    p1 = 1;
    p2 = (H + W - 2) / 2;
    p4 = (H * W - H - W + 1) / 4;
  }
  else if(H % 2 == 0 && W % 2 == 1){
    p1 = 0;
    p2 = H / 2;
    p4 = (H * W - H) / 4;
  }
  else if(H % 2 == 1 && W % 2 == 0){
    p1 = 0;
    p2 = W / 2;
    p4 = (H * W - W) / 4;
  }
  else if(H % 2 == 0 && W % 2 == 0){
    p1 = 0;
    p2 = 0;
    p4 = H * W / 4;
  }

  //cout << p1 << " " << p2 << " " << p4 << endl;
  //p4=============================
  while(p4 > 0){
    int x = que.top();
    que.pop();
    if(x >= 4){
      p4--;
      x -= 4;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
    if(x > 0) que.push(x);
  }

  //p2============================
  while(p2 > 0){
    int x = que.top();
    que.pop();
    if(x >= 2){
      p2--;
      x -= 2;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
    if(x > 0) que.push(x);
  }

  //p1===========================
  while(p1 > 0){
    int x = que.top();
    que.pop();
    if(x >= 1){
      p1--;
      x -= 1;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
    if(x > 0) que.push(x);
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256