akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;static char ch;static bool flag;flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 100010;
const int mod = 1e9+7;
int frac[maxn],inv[maxn];
inline int qpow(int x,int p){
    int ret = 1;
    for(;p;p>>=1,x=1LL*x*x%mod) if(p&1) ret=1LL*ret*x % mod;
    return ret;
}
inline int C(int n,int m){
    if(m > n) return 0;
    return 1LL*frac[n]*inv[m]%mod*inv[n-m]%mod;
}
int last[maxn];
int main(){
    int n;read(n);++ n;
    frac[0] = 1;
    rep(i,1,n) frac[i] = 1LL*i*frac[i-1] % mod;
    inv[n] = qpow(frac[n],mod-2);
    per(i,n-1,0) inv[i] = 1LL*inv[i+1]*(i+1) % mod;
    int x,p1,p2;
    rep(i,1,n){
	read(x);
	if(last[x] != 0){
	    p1 = last[x];
	    p2 = i;
	}
	last[x] = i;
    }
    int num = n - (p2 - p1 + 1);
    rep(k,1,n){
	int ans = C(n,k) - C(num,k-1);
	if(ans < 0) ans += mod;
	printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>
int main(void){
int a,b;
int d,r;
double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}


//for(int i = ; i < ; i++){}

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i = 0; i < n; i++){
    cin>>a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  int sum = 0;
  for(int i = 0; i < k; i++){
    sum+=a[i];
  }
  cout<<sum<<endl;
  return 0;
  }
  



Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=list(input())
c=Counter(s)
c=c.values()
ans=1
mod=10**9+7
for i in c:
    ans*=(i+1)
    ans%=mod
print(ans-1)

Measured memory_bytes: 74280
//問２渡辺彩子
import java.util.Scanner;
public class Main{
    
    public void solve(){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        
        for(int a=0;a<n;a++){
        int x=sc.nextInt();
        int y=sc.nextInt();
        int b=sc.nextInt();
        int p=sc.nextInt();
        
        int kgaku=x*b+y*p;
        
        if(b>=5&&p>=2){
            kgaku=(x*b+y*p)*4/5;
        }else{
            if(b<5){
                b=5;
            }
            if(p<2){
                p=2;
            }
         int waribiki=(x*b+y*p)*4/5;
            
            if(kgaku>waribiki){
                kgaku=waribiki;
            }
        }
     System.out.println(kgaku);
    }
}
public static void main(String[]args){
    Main obj=new Main();
    obj.solve();
}
}

             

Measured memory_bytes: 23292
H,W,A,B=map(int,input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = (10**5)*2+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
w=[]
for i in range(W):
    w.append(cmb(H-A-1+i,i,mod))
#print(w)
w=w[B:]
#print(w)
ans=[]
for i in range(len(w)):
    ans.append(cmb(A-1+(W-B-1-i),W-B-1-i,mod)*w[i])
#print(ans)
print(sum(ans)%mod)

Measured memory_bytes: 81392
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int H,W,h,w;
    scanf("%d%d%d%d",&H,&W,&h,&w);
    printf("%d\n",(H-h)*(W-w));
    return 0 ;
}

Measured memory_bytes: 128
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";

int main() {
	cin >> S;
	ll X = S.size() / 2;
	int i = 0;
	int j = S.size() - 1;
	ll cnt = 0;
	for(int l = 0; l < X; l++) {
		if(S[i] != S[j]) {
			cnt++;
		}
		i++;
		j--;
	}
	printf("%lld", cnt);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    if ((b - a - 1) % 2 == 0) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  if( ((N/100)%10 == 7) or ((N/10)%10 == 7) or ((N %10) == 7)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[200],t[200];
  cin >> s >> t;
  sort(s,s+strlen(s));
  sort(t,t+strlen(t),greater<char>());
  if(strcmp(s,t)<0)cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if(v<=w) {
        cout << "NO" << endl;
        return 0;
    }
    if(a > b) {
        if(b-t*w >= a-t*v) cout << "YES" << endl;
        else cout << "NO" << endl;
    }else {
        if(b+t*w <= a+t*v) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main() {
  char s[20];
  scanf("%[^\n]", s);

  for(int i = 0; s[i] != '\0'; i++) {
    if(s[i] == ',') {
      printf(" ");
      continue;
    }
    printf("%c", s[i]);
  }
  return 0;
}

Measured memory_bytes: 1572
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<vector<ll> > dp(N + 1, vector<ll>(13, 0));

  dp[0][0] = 1;

  int mod = 1;
  for (int i = 1; i <= N; ++i) {
    char ch = S[N - i];
    if (ch == '?') {
      for (int j = 0; j < 13; ++j) {
	for (int d = 0; d <= 9; ++d) {
	  dp[i][(j + d * mod) % 13] += dp[i - 1][j];
	}
      }
    } else {
      int d = ch - '0';
      for (int j = 0; j < 13; ++j) {
	dp[i][(j + d * mod) % 13] += dp[i - 1][j];	
      }
    }

    for (int j = 0; j < 13; ++j) {
      dp[i][j] = dp[i][j] % 1000000007;
    }
    
    mod = (10 * mod) % 13;
  }

  cout << dp[N][5] << endl;
  
  return 0;
}


Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

template<typename T>
struct BIT {
	int n;
	vector<T> d;
	BIT(int n = 0) : n(n), d(n+1) {}
	void add(int i, T x = 0){
		for(i++; i <= n; i += i&-i){
			d[i] += x;
		}
	}
	T sum(int i){
		T x = 0;
		for(i++; i; i -= i&-i){
			x += d[i];
		}
		return x;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<int, int>> p(n);
    for(int i = 0; i < n; i++){
    	cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());
    BIT<long long> bit(n+1);
    long long ans = 0;
    for(int i = 0; i < n; i++){
    	long long x = p[i].first;
    	long long h = p[i].second;
    	h -= bit.sum(i);
    	if(h <= 0) continue;
    	long long num = (h+a-1)/a;
    	ans += num;
    	long long damage = num*a;
    	bit.add(i, damage);
    	int rx = min(x+d*2, 1001001001LL);
    	int j = upper_bound(p.begin(), p.end(), P(rx+1, -1)) - p.begin();
    	bit.add(j, -damage);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main()
{
	int n,i,a[100],max=0,mini=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		
	}
	max = a[0]; mini = a[0];
	for(int i=0;i<n;i++)
	{ 
		if (a[i] > max)max = a[i];
		else if (a[i] < mini)mini = a[i];
	}
	cout << max - mini << endl;
}

Measured memory_bytes: 256
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,k[10010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N && N){
		rep(i,N)cin>>k[i];
		if(*max_element(k,k+N)<2){
			cout<<"NA"<<endl;
			continue;
		}
		int ans=1;
		rep(i,N)ans+=!!k[i];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

string S;





int main()
{
	cin >> S;
	int b = -1;
	int e = -1;
	REP(i,S.size()-1){
		if(S[i] == S[i+1]){
			b = i+1;
			e = i+2;
			break;
		} else if(i != S.size() - 2){
			if(S[i] == S[i+2]){
				b = i+1;
				e = i+3;
				break;
			}
		}
	}



	cout << b << ' ' << e << endl;




}

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

lli n;

int main(void){
	cin >> n;
	int d = 1;
	int r = 1;
	rep(i, n){
		int a;
		cin >> a;
		if(a%2 == 0){
			r*=2;
		}
		d*=3;
	}
	cout << d-r << endl;
	return 0;
}


Measured memory_bytes: 3572
import sys
N=int(input())
H=list(map(int,input().split()))

le=int(len(H))

a=0
for i in range(0,N):
    if a-1>H[i]:
        print("No")
        sys.exit()
    if H[i]>a:
        a=H[i]
print("Yes")


Measured memory_bytes: 14396
#include<set>
#include<map>
#include<cmath>
#include<deque>
#include<stack>
#include<ctime>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
int main(){
	LL n=read(),ans=n-1;
	for(LL i=1;i*i<=n;i++)
		if(n%i==0)
			ans=min(ans,(i-1)+(n/i-1));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
a, b, k = map(int, input().split())

if b - a + 1 >= 2 * k:
    for i in range(0, k):
        print(a + i)
    for i in range(k - 1, -1, -1):
        print(b - i)
else:
    for i in range(a, b + 1):
        print(i)


Measured memory_bytes: 3060
//  q1.cpp(2014/10/12-)


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;


int main(){
    int p,sum=0;
    
    for(int i=0;i<5;i++){
        scanf("%d",&p);
        if(p<40) p=40;
        sum+=p;
    }
    
    printf("%d\n",sum/5);
    
    
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  bool ans=false;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      int money=4*i+7*j;
      if(N==money) ans=true;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long f[2005][2005],ny[4000005],s[4000005],t[4000005];
long long p(long long n,long long m)
{
	return s[n]*t[m]%mod*t[n-m]%mod;
}
int main()
{
	long long n,k,i,j;
	cin>>n>>k;
	if(k==1)
	{
		puts("1");
		return 0;
	}
	ny[1]=1;
	for(i=2;i<=4000000;i++)
	{
		ny[i]=(mod-mod/i)*ny[mod%i]%mod;
	}
	s[0]=1,t[0]=1;
	for(i=1;i<=4000000;i++)
	{
		s[i]=s[i-1]*i%mod;
		t[i]=t[i-1]*ny[i]%mod;
	}
	for(i=0;i<=n;i++)
		f[i][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			f[i][j]=f[i-1][j]+f[i][j-1]*(n-j+1)%mod*p(n*k-i-1-(j-1)*(k-1),k-2)%mod;
			f[i][j]%=mod;
		}
	}
	cout<<f[n][n]%mod<<endl;
	return 0;
}

Measured memory_bytes: 119980
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int f(int a, int b) {
	string s = to_string(a), t = to_string(b);
	return max(s.size(), t.size());
}
int main() {
	long long n;
	cin >> n;
	for (long long i = sqrt(n);; i--) {
		if (n % i == 0) {
			cout << f(i, n / i) << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int[][][] array = new int [4][3][10];
		Scanner scan = new Scanner(System.in);
		int number = scan.nextInt();
		for(int i = 0; i<number; i++){
			int building = scan.nextInt();
			int floor = scan.nextInt();
			int room_number = scan.nextInt();
			int change = scan.nextInt();

			array[building-1][floor-1][room_number-1] += change;

		}
		for(int j = 0; j<4; j++){
			for(int k = 0; k<3; k++){
				for(int l = 0; l<10; l++){
					System.out.print(" "+array[j][k][l]);
				}
				System.out.println();
			}
			if(j!=3){
				System.out.println("####################");
			}
		}
	}
}


Measured memory_bytes: 29776
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif
const int M = 2005 ;	
int a[M][M][4] , obs[M][M] ;
// 0 L 1 R 2 U 3 D 

void solve()
{
	int n , m ;
	cin >> n >> m ;
	string s[n] ;
	rep(i,n){
		cin >> s[i] ;
		rep(j,m) if(s[i][j] == '#'){
			obs[i][j] = 1; 
		}
	}
	rep(i,n){
		int last = -1; 
		rep(j,m){
			if(obs[i][j]){
				last = j ; 
			}
			a[i][j][0] = last; 
		}
	}
	rep(i,n){
		int last = m; 
		repD(j,m-1,0){
			if(obs[i][j]){
				last = j ; 
			}
			a[i][j][1] = last; 
		}
	}
	rep(j,m){
		int last = -1; 
		rep(i,n){
			if(obs[i][j]){
				last = i ; 
			}
			a[i][j][2] = last; 
		}
	}
	rep(j,m){
		int last = n; 
		repD(i,n-1,0){
			if(obs[i][j]){
				last = i ; 
			}
			a[i][j][3] = last; 
		}
	}
	int res = 0;
	rep(i,n){
		rep(j,m){
			if(obs[i][j]) continue ;
			int ans = (j - a[i][j][0]) + (a[i][j][1] - j) + (i - a[i][j][2]) + (a[i][j][3] - i); 
			ans -= 3;
			// rep(k,4)
			// 	cout << a[i][j][k] << " " ;
			// cout << endl ;
			// cout << i << " " << j << endl ;
			res = max(ans , res); 
		}
	}
	cout << res ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

using namespace std;

int main(){

    string s;
    cin >> s;
    int count = 0;

    if(s[0] == '1') ++count;
    if(s[1] == '1') ++count;
    if(s[2] == '1') ++count;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
	int N;
	cin>>N;
	vec(S)
	fx(N){
		vecp(S)
	}
	vector<int> ans;
	for(int i=N-1;i>=0;i--){
      for(int j=S.size()-1;j>=0;j--){
		if(S.at(j)==j+1){
			pb(ans,S.at(j))
			S.erase(S.begin() + j);
			break;
		}
      }
	}
  

  if(ans.size()!=N){
    ce("-1")
  }else{
  
	reverses(ans)
	fx(N){
		ce(ans.at(x))
	}
  }
 
	
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N;
    int[] a;
    private void solve() {
        N = nextInt();
        a = nextIntArray(N);

        int xor = a[0];
        for(int i = 1;i < N;i++) {
            xor ^= a[i];
        }


        for(int i = 0;i < N;i++) {
            if (i > 0) {
                out.print(" ");
            }
            out.print(a[i] ^ xor);
        }
        out.println();
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] x = new int[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextInt();
        }
        return x;
    }

    public long[] nextLongArray(int n) {
        long[] x = new long[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextLong();
        }
        return x;
    }

    public double[] nextDoubleArray(int n) {
        double[] x = new double[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextDouble();
        }
        return x;
    }
}

Measured memory_bytes: 51436
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();

		Arrays.sort(s);

		if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c') {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, long long> save;
    save[0] = 2;
    save[1] = 1;
    
    if (N == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        for (int i = 2; i <= N; ++i)
        {
            save[i] = save[i - 1] + save[i - 2];
        }
        cout << save[N] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
const int INF = 1e+9;
int main(){
	int N,A;
	int a[100];
	int dp[21][50001];
	scan(A);scan(N);
	rep(i,N){
		scan(a[i]);
	}
	rep(i,N+1){
		rep(j,A+1){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	rep(i,N){
		rep(j,A+1){
			dp[i+1][j] = dp[i][j];
			if(j>=a[i]){
				dp[i+1][j] = min(min(dp[i][j-a[i]]+1,dp[i+1][j-a[i]]+1),dp[i+1][j]);
			}
		}
	}
	prin(dp[N][A]);
	return 0;
}



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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				return;
			}
			int cnt = 0;
			boolean left = false;
			boolean right = false;
			boolean up = false;
			for (int i = 0; i < n; i++) {
				String q = sc.next();
				if (q.equals("lu")) {
					left = true;
				} else if (q.equals("ru")) {
					right = true;
				} else if (q.equals("ld")) {
					left = false;
				} else if (q.equals("rd")) {
					right = false;
				}
				if (!up && left && right) {
					cnt++;
					up = true;
				}
				if (up && !left && !right) {
					cnt++;
					up = false;
				}
			}
			System.out.println(cnt);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 24128
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static System.Math;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int H, W;
        static string[] c;


        public static void Input()
        {
            var cin = new Solve();

            var input = cin.SplitReader();
            H = input[0];
            W = input[1];
            c = new string[H];
            for(var i = 0; i < H; i++)
            {
                c[i] = Console.ReadLine();
            }
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            
            for(var i = 0; i < H; i++)
            {
                Console.WriteLine(c[i]);
                Console.WriteLine(c[i]);
            }




            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }
}

    



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

int main(){
  int input, i = 1, x, n;

  cin >> n;

  for(i = 1; i <= n; i++){
    x = i;
    if(x % 3 == 0) cout << " " << i;
    else{
      while(x){
        if( x % 10 == 3 ){
          cout << " " << i;
          break;
        }
        else x /= 10;
      }
    }
  }
  cout << "\n";
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
const long long M = 1000000007;

int n, k;

long long C[N][N];
void pre()
{
    for (int i = 0; i < N; ++i)
    {
        C[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % M;
    }
}

int main()
{
    cin >> n >> k;
    pre();
    for (int i = 1; i <= k; ++i)
    {
        cout << (C[k - 1][i - 1] * C[n - k + 1][i]) % M << endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  
  int ans = 0;
  for (int i = 1; i < n-1; i++)
  {
    if((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1])) ans++;
  }
  cout << ans << endl;  
}

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

int main() {
	ios_base::sync_with_stdio(false);

	int N, W;
	cin >> N >> W;
	vector<ll> w(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(N, vector<ll> (W + 1, 0));
	for (int i = w[0]; i <= W; i++) {
		dp[0][i] = v[0];
	}
	for (int i = 1; i < N; i++) {
		for (int j = 1; j <= W; j++) {
			if (w[i] > j) {
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			dp[i][j] = max(dp[i - 1][j], v[i] + dp[i - 1][j - w[i]]);
		}
	}
	cout << dp[N - 1][W];

	return 0;
}

Measured memory_bytes: 79488
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define	PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vbl vector<bool>
#define vpll vector<pll>
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define mod 1000000007
#define INF 1000000000000000
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pll;
#define ook order_of_key
#define fbo find_by_order
/*  
	Query 1 - order_of_key(k) : Number of items strictly smaller than k.
	Query 2 - find_by_order(k) : K-th element in the set (counting from zero).
	less<ll> means Query 1 will return numbers strictly less than k.
	greater<ll> means Query 1 will return numbers strictly greater than k.
*/
ll powmod(ll x, ll n){
	ll res = 1;
	while(n){
		if(n & 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		n >>= 1;
	}
	return res;
}
ll invmod(ll a){
	return powmod(a, mod - 2);
}
ll n, t, a;
vector<vll> adj;
vll depth, parent, deepest;
void dfs(ll node, ll pr){
	parent[node] = pr;
	depth[node] = (pr < 0 ? 0 : depth[pr] + 1);
	deepest[node] = 0;
	for(ll neighbor : adj[node]){
		if(neighbor != pr){
			dfs(neighbor, node);
			deepest[node] = max(deepest[node], deepest[neighbor] + 1);
		}
	}
}
int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> n >> t >> a;
	t--, a--;
	adj.assign(n, vll());
	for(ll i = 1; i < n; i++){
		ll u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	depth.resize(n);
	parent.resize(n);
	deepest.resize(n);
	dfs(a, -1);
	ll start = depth[t];
	ll up = (start - 1) / 2;
	for(ll i = 0; i < up; i++){
		t = parent[t];
	}
	cout << depth[t] + deepest[t] - 1 << '\n';
}

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

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

	for (int i = 0; i<100; i++) {
		sum += A;
		sum %= B;
		if (sum == C) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
using ll = long long;

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

    vector<int> p(n);
    vector<ll> c(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for(int i = 0; i < n; i++) cin >> c[i];

    vector<vector<int>> v(n);

    for(int i = 0; i < n; i++) {
        int j = i;
        while(p[j] != i) {
            v[i].push_back(p[j]);
            j = p[j];
        }
        v[i].push_back(i);
    }

    /*
    for(int i = 0; i < n; i++) {
        for(auto x : v[i]) {
            cout << x << " ";
        }
        cout << endl;
    }
     */
    
    ll ans = LONG_LONG_MIN;
    for(int i = 0; i < n; i++) {
        int s = v[i].size();

        ll tmp = 0;
        ll wa = 0;

        int q = k / s;
        int r = k % s;

        vector<ll> mx(s, LONG_LONG_MIN);
        mx[0] = c[v[i][0]];
        wa = c[v[i][0]];

        for(int j = 1; j < s; j++) {
            wa += c[v[i][j]];
            mx[j] = max(mx[j - 1], wa);
        }

        // for(auto x : v[i]) wa += c[x];

        if(wa >= 0 && q >= 1) tmp = wa * (ll)(q - 1);


        if(q == 0) tmp += mx[r - 1];
        if(q != 0 && r == 0) tmp += mx[s - 1];
        if(q != 0 && r >= 1) tmp += max(mx[s - 1], wa + mx[r - 1]);

        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 120988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e3 + 10;

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

int fact[N], invfact[N];

void pre() {
	fact[0] = 1;
	for(int i = 1; i < N; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}
	invfact[N - 1] = modpow(fact[N - 1], mod - 2, mod);
	for(int i = N - 2; i >= 0; i--) {
		invfact[i] = invfact[i + 1] * (i + 1) % mod;
	}
}

int ncr(int x, int y) {
	if(y < 0 || y > x)
		return 0;
	int res = fact[x] * invfact[y] % mod * invfact[x - y] % mod;
	return res;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	pre();
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; ; i++) {
		if(n - 2 * i - 1 >= 0) {
			ans = (ans + ncr(n - 2 * i - 1, i - 1)) % mod;
		}
		else {
			break;
		}
	}
	cout << ans;

	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int flag=1;
  for(int i=0;i<n;i++){
    if(a.at(i)%2==0){
      if(a.at(i)%3!=0&&a.at(i)%5!=0){
        flag=0;
      }
    }
  }
  if(flag==1){
    cout<<"APPROVED";
  }else{
    cout<<"DENIED";
  }
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  long int H[N];
  int i, j;
  for(i=0; i<N; i++)
    cin >> H[i];

  int max = 0;
  int count = 0;
  for(i=N-1; i>0; i=j-1){
    count = 0;
    j = i;
    while(H[j-1] >= H[j] && j>0){
      //   cout << H[j-1] << "&" << H[j] << endl;
      count++;
      j--;
    }
    if(max < count)
      max = count;
    
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100005];
bool used[100005];
deque<int> ans;
int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	int s,e;
	int x,y;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
		s=x;
		e=y;
	}
	
	for(int i=1;i<=n;i++)
		used[i]=false;
	used[s]=true;
	used[e]=true;
	ans.push_front(s);
	ans.push_back(e);
	bool changed1=true,changed2=true;
	while(changed1||changed2)
	{
		changed1=changed2=false;
		for(int i=0;i<v[e].size();i++)
			if(!used[v[e][i]])
			{
				e=v[e][i];
				used[e]=true;
				changed1=true;
				ans.push_back(e);
			}
			
		for(int i=0;i<v[s].size();i++)
			if(!used[v[s][i]])
			{
				s=v[s][i];
				used[s]=true;
				changed2=true;
				ans.push_front(s);
			}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<' ';
}

Measured memory_bytes: 6656
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int order[100000];
int parent[100000];
int num[100000];
int a[100000];
int b[100000];
long long dp[100001] = {0};

int find_root(int num) {
	if (parent[num] == -1) return num;
	return find_root(parent[num]);
}

void unite(int root_a, int root_b) {
	if (order[root_a] >= order[root_b]) {
		parent[root_b] = root_a;
		order[root_a] = max(order[root_a], order[root_b] + 1);
		num[root_a] += num[root_b];
	}
	else {
		parent[root_a] = root_b;
		order[root_b] = max(order[root_b], order[root_a] + 1);
		num[root_b] += num[root_a];
	}
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	for (int i = 0; i < n; i++) {
		order[i] = 1;
		parent[i] = -1;
		num[i] = 1;
	}

	dp[m] = (long long)n * (n - 1) / 2;

	for (int i = m - 1; i >= 0; i--) {
		int root_a = find_root(a[i]);
		int root_b = find_root(b[i]);
		if (root_a == root_b) {
			dp[i] = dp[i + 1];
		}
		else {
			dp[i] = dp[i + 1] - (long long)num[root_a] * num[root_b];
			unite(root_a, root_b);
		}
	}

	for (int i = 1; i <= m; i++) {
		cout << dp[i] << endl;
	}


	return 0;
}

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

int main(int argc, char const *argv[]) {
  int N;
  int L[15];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  sort(L,L+N);
  int c = 0;
  for(int i=0;i<N-1;i++){
    c+=L[i];
  }
  if(L[N-1]<c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
ai = lambda: list(map(int, input().split()))

n = int(input())
a = ai()
d = [a[i]-a[i-1] for i in range(n)]

s = sum(a)
if s % (n*(n+1)//2) != 0:
    print('NO')
    sys.exit()

s //= n*(n+1)//2
d = [i-s for i in d]

if all(i % n == 0 for i in d) and sum(-i//n for i in d if i < 0) == s:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 14260
package main

import (
    "bufio"
    "fmt"
    "os"
    "sort"
    "strconv"
    "strings"
)

func solve(n int, l []int) int {
    nfoods := 0
    sort.Ints(l)
    for i := 0; i < n; i++ {
        nfoods += l[i*2]
    }
    return nfoods
}

func main() {

    bio := bufio.NewReader(os.Stdin)
    s, _ := bio.ReadString('\n')
    n, _ := strconv.Atoi(strings.Trim(s, "\n"))
    s, _ = bio.ReadString('\n')
    valsStr := strings.Split(strings.Trim(s, "\n"), " ")
    vals := []int{}
    for _, s := range valsStr {
        val, _ := strconv.Atoi(s)
        vals = append(vals, val)
    }
    fmt.Printf("%v\n", solve(n, vals))
}

Measured memory_bytes: 640
def North(d):
    d[0], d[1], d[3], d[5] = d[1], d[5], d[0], d[3]
    return int(d[0])

def West(d):
    d[0], d[2], d[4], d[5] = d[2], d[5], d[0], d[4]
    return int(d[0])

def East(d):
    d[0], d[2], d[4], d[5] = d[4], d[0], d[5], d[2]
    return int(d[0])

def South(d):
    d[0], d[1], d[3], d[5] = d[3], d[0], d[5], d[1]
    return int(d[0])

def Right(d):
    d[1], d[2], d[3], d[4] = d[2], d[3], d[4], d[1]
    return int(d[0])

def Left(d):
    d[1], d[2], d[3], d[4] = d[4], d[1], d[2], d[3]
    return int(d[0])

while True:
    n = int(input())
    if n == 0:
        break

    dice = ['1','2','3','5','4','6']
    total = 1
    for i in range(n):
        ss = str(input().split()[0])
        if ss == "North":
            total += North(dice)

        elif ss == "West":
            total += West(dice)

        elif ss == "East":
            total += East(dice)

        elif ss == "South":
            total += South(dice)

        elif ss == "Right":
            total += Right(dice)

        elif ss == "Left":
            total += Left(dice)
    print(total)

Measured memory_bytes: 7856
#include <cstdio>

using namespace std;

int main(){
	int r, g, b;
	scanf("%d", &r);
	scanf("%d", &g);
	scanf("%d", &b);

	if ((10 * g + b) % 4 == 0) {
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >>a >> b >> k;
  int count=0;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0 && b%i==0) {
      --k;
      if(k==0){
        cout << i << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a == b&&a!=c)||(a == c&&a != b)||(b == c&&a != b))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  lines = input.split("\n");
  line = lines[0].split(" ")
  a = line[0] * 1
  b = line[1] * 1
  ans = 0
  ans = Math.ceil((b - 1) / (a - 1)) 
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  long long N,K;
  cin >> N >> K;
  long long t = N / K;
  long long ans = N - t*K;
  long long an = K - ans;
  if(an < ans){
    ans = an;
  }
  cout << ans << endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int n,m; scanf("%d%d",&n,&m);
   printf("%d\n",n*(n-1)/2+m*(m-1)/2);
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
 
ll mymod(ll a, ll b)
{
	return (a%b + b)%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
struct edge
{
	ll src;
	ll to;
	ll val;
	ll index;
};
struct node
{
	vll adj;
	ll parent;
	ll time;
	ll ex_time;
	ll indegree;
};

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	ll tot=0;
	ll A[n];
	REP(i,0,n)
	{
		cin>>A[i];
		tot+=A[i];
	}
	ll min = tot/(4*m) + (tot%(4*m)!=0);
	ll count=0;
	REP(i,0,n)
	{
		if(A[i]>=min)
		{
			count++;
		}
	}
	if(count>=m)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}




Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1]>h[b-1]:
        x[b-1] = 0
    elif h[a-1]<h[b-1]:
        x[a-1] = 0
    else:
        x[a-1] = 0
        x[b-1] = 0
print(x.count(1))



Measured memory_bytes: 20124
#include<iostream>
#define ll long long
#define P pari<int,int>
#define mk make_pair
const int N = 1e5+10;
using namespace std;

int main()
{
    ll h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll ans = h2 * 60 + m2 - h1 * 60 - m1;
    if(ans < 0)
    {
        ans += 24 * 60;
    }
    cout << max(0LL,ans - k );
    return 0;
}


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

 int main() {
   vector<char> S(4);
   for(int i = 0;i < 4;i++){
     cin >> S.at(i);
   }
   
   int a = 0;
   for(int i = 0;i < 4;i++){
    if(S.at(i) == '+'){
      a++;
    }else if(S.at(i) == '-'){
      a--;
    }
   }
   cout << a << endl;
 }

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))


//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a,s;}atai;
atai xx(atai x,atai y){
	atai r;
	if(x.a<y.a)r=y;
	else if(x.a>y.a)r=x;
	else{
		r.a=x.a;
		r.s=max(x.s,y.s);
	}
	return r;
}
atai aid={0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/

ll a[100010];
int idx[100010];
int c(const void*p,const void*q){
	if(a[*(int*)p]<a[*(int*)q])return -1;
	if(a[*(int*)p]>a[*(int*)q])return 1;
	if(*(int*)p>*(int*)q)return -1;
	return 1;
}
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		scanf("%lld",a+i);
		idx[i]=i;
	}
	qsort(idx,n,sizeof(int),c);
	seguse(1<<17);
	rep(i,0,n){
		atai x=segcalc(0,idx[i]);
		x.a++;
		x.s+=a[idx[i]];
		segupdate(idx[i],x);
	}
	printf("%lld\n",segcalc(0,n).s);
}


Measured memory_bytes: 7096