akhauriyash/Code-Regression huggingface dataset:
/****************************************

			LostMartian

****************************************/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) {
	cout << arg1 << " ";
	pn(args...);
}
template <typename Arg1>
void ps(Arg1&& arg1) {
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) {
	cout << arg1 << " ";
	ps(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
	cin >> arg1;
	read(args...);
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	ll h, w, x, y, xx, yy;
	cin >> h >> w >> x >> y >> xx >> yy;
	x--, y--, xx--, yy--;
	vector<vector<bool > > a(h, vector<bool >(w)), b(h, vector<bool>(w)), c(h, vector<bool>(w));
	rep(i, 0, h) {
		rep(j, 0, w) {
			char k;
			cin >> k;
			a[i][j] = k == '.';
		}
	}
	set<tuple<ll, ll, ll > > q;
	q.emplace(0, x, y);
	while (q.sz) {
		auto [cnt, r, c] = *q.begin(); q.erase(q.begin());
		b[r][c] = true;

		if (r == xx && c == yy) {
			cout<<cnt<<"\n";
			return 0;
		}
		FOR(dr, -2, 3) {
			FOR(dc, -2, 3) {
				if (!dr && !dc) {
					continue;
				}
				ll rr = r + dr, cc = c + dc;
				if (min(rr, cc) < 0 || rr >= h || cc >= w || b[rr][cc] || !a[rr][cc]) {
					continue;
				}
				if ((abs(dr) == 1 && !abs(dc)) || (abs(dc) == 1 && !abs(dr))) {
					q.emplace(cnt, rr, cc);
				}
				else {
					q.emplace(cnt + 1, rr, cc);
				}
			}
		}
	}

	cout << "-1\n";














	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


Measured memory_bytes: 4872
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<char> vc;
typedef map<long long,long long> mpi;
#define vbi vector<bool> 
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
#define ms(x,v) memset(x,v,sizeof(x))
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
const int N = 2e5 + 5;
ll i,j,k;
void solve()

{
  ll a,b,c; cin>>a>>b;
  cout<<(6-(a+b))<<endl;


 return ; 
 
}
signed main(){
    
 //CASET
         solve();
  

 
    return 0;
}



Measured memory_bytes: 256
N = int(input())
a, b, c, d = 0, 0, 0, 0
for i in range(N):
    S = input()
    if S == 'AC':
        a += 1
    elif S == 'WA':
        b += 1
    elif S == 'TLE':
        c += 1
    else:
        d += 1
print('AC', 'x', a, sep=' ')
print('WA', 'x', b, sep=' ')
print('TLE', 'x', c, sep=' ')
print('RE', 'x', d, sep=' ')

Measured memory_bytes: 9216
S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
tenfactor = 1

for i in range(N):
    s = int(S[-i-1])
    now = (now + s*tenfactor)%2019
    tenfactor = tenfactor*10%2019
    C[now] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)


Measured memory_bytes: 9256
#include<iostream>
using namespace std;
#include <stdint.h>
#include <cmath>
int main(){
    string s;
    uint64_t k,n;
    cin >> s;
    cin >> k;
    n = s[0] - '0';
    while(n==1){
        if(k==1){
            break;
        }else{
            k-=1;
            s.erase(s.begin());
            n = s[0] - '0';
        }
    }
    cout << n <<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,q = inpl()
g = [[]for i in range(n)]
c = [0 for i in range(n)]
seen = set()
for i in range(n-1):
    a,b = inpl()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
for i in range(q):
    a,b = inpl()
    c[a-1] += b
def dfs(node):
    for v in g[node]:
        if v in seen:
            continue
        c[v] += c[node]
        seen.add(v)
        dfs(v) 

seen.add(0)
dfs(0)
for i in c:
    print(i)

Measured memory_bytes: 244436
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] List = new int[n];
        for(int i=0;i<n;i++) List[i]=sc.nextInt();
        for(int i=0;i<n;i++){
            /**未ソート部分の先頭要素の選択*/
            int v = List[i];
            int j = i-1;
            /**vを挿入し、大小関係が成り立つまで要素を後ろに移動する*/
            while(j>=0&&List[j]>v){
                List[j+1] = List[j];
                j--;
            }
            List[j+1]=v;
            for(int k=0;k<n;k++){
                System.out.print(List[k]);
                if(k!=n-1) System.out.print(" ");
            }
            System.out.println();
        }
    }
}


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

using namespace std;

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

    vector<vector<int>> s(m);
    int temp;
    int k;
    for (int i = 0; i < m; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> temp;
            s[i].push_back(temp);
        }
    }

    vector<int> p(m);
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    
    bool flag;
    int count;
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        flag = true;
        for (int j = 0; j < m; ++j) {
            if (!flag) break;
            count = 0;
            for (auto sw: s[j]) if ((i>>(sw-1)) & 1) count++;
            if (!(count % 2 == p[j])) {
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<bitset>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define re register
#define LL long long
#define MOD 998244353
#define MAXN 200005
using namespace std;
int n,k,ans,a[MAXN];
LL sum,pre,t[MAXN];
bool fg=0;
LL rd(){
	LL x=0,tp=1;char c;
	c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*tp;
}
int lowbit(int x){return x&-x;}
void add(int x,int val){
	if(x==0)return;
	for(;x<=n;x+=lowbit(x))t[x]+=val;
}
LL query(int x){
	LL res=0;
	for(;x;x-=lowbit(x))res+=t[x];
	return res;
}
int main(){
	// freopen("sb.in","r",stdin);
	// freopen("sb.out","w",stdout);
	n=rd(),k=rd();
	for(int i=1;i<=n;i++)a[i]=rd()+1;
	for(int i=1;i<=k;i++){
		add(a[i],1);
		sum+=i-query(a[i]);
	}
	if(sum==0)fg=1;
	else ans++;
	for(int i=k+1;i<=n;i++){
		int tmp2=query(a[i-k]-1);
		add(a[i-k],-1);
		add(a[i],1);
		int tmp=k-query(a[i]);
		sum+=tmp-tmp2;
		// printf("tmp:%d %d; sum=%d\n",tmp,tmp2,sum);
		if(sum==0){fg=1;continue;}
		if(tmp==0 && tmp2==0)continue;
		ans++;
	}
	// printf("%d %d %d\n",ans,fg,ans+fg);
	printf("%d\n",ans+fg);
	return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#define INF (1e9)
#define T_MAX 30
#define D 100
using namespace std;

int main(){
  int T,t[T_MAX],N,d[D],id,im,dp[D][T_MAX],dmax,ans;
  while(1){
    cin>>T;
    if(!T) break;
    for(int i=0;i<T;i++) cin>>t[i];
    for(int i=0;i<D;i++) d[i]=INF;
    cin>>N;
    dmax=0;
    while(N--){
      cin>>id>>im;
      d[id-1]=min(d[id-1],im);
      dmax=max(dmax,id-1);
    }
    for(int i=0;i<=dmax;i++)
      for(int j=0;j<T;j++) dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=0;i<dmax;i++){
      for(int j=0;j<T;j++){
	if(dp[i][j]==INF) continue;
	if(t[0]<=d[i+1]){
	  dp[i+1][0]=min(dp[i+1][0],dp[i][j]+1);
	  if(j==T-1) dp[i+1][0]=min(dp[i+1][0],dp[i][j]);
	}
	if(j!=T-1&&t[j+1]<=d[i+1]) dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]);
      }
    }
    ans=INF;
    for(int i=0;i<T;i++) ans=min(ans,dp[dmax][i]);
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int x=0;
  int max=0;
  for(int i=0;i<N;i++){
    if(S[i]=='I'){
      x++;
      if(x>max)max=x;
    }
    else x--;
  }
  cout << max;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans,n,a[1000001];
int main(){
    cin>>n;
    for(int i=0;i<n*2;i++){cin>>a[i];}sort(a,a+n*2);
    for(int i=0;i<2*n;i++){ans+=1*i*a[i];}
    printf("%.12lf\n",1.0*ans/(2*n-1));
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    if (n % 1111 == 0 || n / 10 % 111 == 0 || n % 1000 % 111 == 0)
    	cout << "Yes" << endl;
    else
    	cout << "No" << endl;
}

Measured memory_bytes: 256
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005
ll dp[N][3];
ll a[N],b[N],c[N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,i,j,k;
		cin>>n;
		for(i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];

		dp[0][0]=a[0];
		dp[0][1]=b[0];
		dp[0][2]=c[0];

		for(i=1;i<n;i++)
		{
			dp[i][0]=max(dp[i][0],dp[i-1][1]+a[i]);
			dp[i][0]=max(dp[i][0],dp[i-1][2]+a[i]);

			dp[i][1]=max(dp[i][1],dp[i-1][0]+b[i]);
			dp[i][1]=max(dp[i][1],dp[i-1][2]+b[i]);

			dp[i][2]=max(dp[i][2],dp[i-1][0]+c[i]);
			dp[i][2]=max(dp[i][2],dp[i-1][1]+c[i]);
		}

		//for(i=0;i<n;i++){for(j=0;j<3;j++){cout<<dp[i][j]<<" ";} cout<<"\n";}

		cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

	}
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main(){
    int n,sum=0;
    cin >> n;
    vector<int> s(n),d(10,0);
    rep(i,n){
        cin >> s[i];
        d[s[i]%10]++;
        sum+=s[i];
    }
    if(sum%10!=0) cout << sum;
    else{
        if(d[0]==n) cout << 0;
        else{
            sort(s.begin(),s.end());
            rep(i,n){
                if(s[i]%10!=0){
                    sum-=s[i];
                    break;
                }
            }
            cout << sum;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ld xa, ya, xb, yb, xc, yc, xd, yd;
	while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
		if (xa == xb) {
			if (yc == yd) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
			continue;
		}
		if (xc == xd) {
			if (ya == yb) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
			continue;
		}
		ld katamuki[2];
		katamuki[0] = (yb - ya) / (ld)(xb - xa);
		katamuki[1] = (yd - yc) / (ld)(xd - xc);
		if (katamuki[0] * katamuki[1] == -1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3156
def solve(N, Bs):
    ans = []
    while len(Bs):
        failed = True
        for i, b in enumerate(Bs[::-1]):
            i = len(Bs) - i
            if i == b:
                ans.append(Bs.pop(i - 1))
                failed = False
                break
        if failed:
            return "-1"
    return "\n".join(str(a) for a in ans[::-1])

if __name__ == "__main__":
    N = int(input())
    bs = list(map(int, input().split(" ")))
    print(solve(N, bs))


Measured memory_bytes: 3060
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,k;
    cin>>n>>k;
    vector<pi>vec;
    vector< vector<int> >s(2*k+1,vector<int>(2*k+1,0));
    f(i,1,n)
    {
        int x,y;
        char ch;
        cin>>x>>y>>ch;
        if(ch=='B')y-=k;
        x=(x+2*k)%(2*k);
        y=(y+2*k)%(2*k);
        vec.pb(mp(x,y));
        s[x+1][y+1]++;
    }
    auto qry = [&] (int x0,int y0,int x1,int y1)
    {
        return s[y1][x1]-s[y1][x0-1]-s[y0-1][x1]+s[y0-1][x0-1];
    };
    f(i,1,2*k)
    {
        f(j,1,2*k)
        {
            s[i][j]+=s[i-1][j];
            s[i][j]+=s[i][j-1];
            s[i][j]-=s[i-1][j-1];
        }
    }
    int ses=0;
    f(x,1,k)
    {
        f(y,1,k)
        {
            int cnt=0;
            cnt+=qry(x,y,x+k-1,y+k-1);
            cnt+=qry(1,1,x-1,y-1);
            cnt+=qry(1,y+k,x-1,2*k);
            cnt+=qry(x+k,y+k,2*k,2*k);
            cnt+=qry(x+k,1,2*k,y-1);
            ses=max(ses,max(cnt,n-cnt));
        }
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 36688
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define sf(a)		 scanf("%d",&a)
#define sfl(a)		scanf("%lld",&a)
#define sff(a,b)	 scanf("%d %d",&a,&b)
#define sffl(a,b)	scanf("%lld %lld",&a,&b)
#define pb(a)         push_back(a)
#define loop0(i,n)          for(int i=0;i<n;i++)
#define loop1(i,n)          for(int i=1;i<=n;i++)
#define loopab(a,b)       for(int i=a;i<=b;i++)
#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	int i,n,x,r=0;
	cin>>n;
	for(i=0 ; i<n ; i++){
		cin>>x;
		r = r^x;
		}
	if(r)cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	c, min := 0, 1<<63-1
	for i := 0; i < n; i++ {
		x := nextInt()
		if x <= min {
			min = x
			c++
		}
	}

	fmt.Println(c)
}


Measured memory_bytes: 3072
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

T = input()

for t in T:
    if t == '?':
        print('D', end='')
    else:
        print(t, end='')

print()


Measured memory_bytes: 79988
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long Q = scan.nextLong();
        long H = scan.nextLong();
        long S = scan.nextLong();
        long D = scan.nextLong();
        int N = scan.nextInt();

        H = Math.min(H,Q*2);
        S = Math.min(S,H*2);
        D = Math.min(D,S*2);
        System.out.println((N/2)*D + (N%2)*S);


    }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


struct modint {
	unsigned v;
	static unsigned M;
	static vector<modint> tb_fact;
	static vector<modint> tb_ifact;

	modint() : v(0) {}
	modint(ULL val) : v(val % M) {}

	operator bool() const { return (bool)v; }
	bool operator==(const modint &r)const { return v == r.v; }
	bool operator!=(const modint &r)const { return v != r.v; }
	modint operator+(const modint &r) const { return modint(v + r.v); }
	modint &operator+=(const modint &r) { return *this = *this + r; }
	modint operator-(const modint &r) const { return modint(v + M - r.v); }
	modint &operator-=(const modint &r) { return *this = *this - r; }
	modint operator*(const modint &r) const { return modint(ULL(v) * ULL(r.v) % M); }
	modint &operator*=(const modint &r) { return *this = *this * r; }
	modint inverse() const {
		vector<modint> d = { M / v };
		modint pa = v, pb = M % v;
		while (pb.v) { d.push_back(pa.v / pb.v); pa.v %= pb.v; swap(pa, pb); }
		pa = 1; pb = 0;
		while (d.size()) { swap(pa, pb); pb -= pa * d.back(); d.pop_back(); }
		return pb;
	}
	modint operator/(const modint &r) const { return *this * r.inverse(); }
	modint &operator/=(const modint &r) { return *this *= r.inverse(); }
	static modint Fact(unsigned n) {
		if (n >= M) return 0;
		tb_fact.reserve(n + 1);
		while (tb_fact.size() <= n)
			tb_fact.push_back(tb_fact.back() * modint(tb_fact.size()));
		return tb_fact[n];
	}
	static modint InvFact(unsigned n) {
		if (tb_fact.size() >= n) return Fact(n).inverse();
		while (tb_ifact.size() <= n)
			tb_fact.push_back(tb_ifact.back() / modint(tb_ifact.size()));
		return tb_ifact[n];
	}
	static modint Comb(unsigned n, unsigned r) {
		return Fact(n) * InvFact(r) * InvFact(n - r);
	}
};

unsigned modint::M = 1000000007;
vector<modint> modint::tb_fact = { 1 };
vector<modint> modint::tb_ifact = { 1 };


void solve() {
	int x, y; cin >> x >> y;
	if ((x + y) % 3) { cout << 0 << endl; return; }
	int xx = x - (x + y) / 3, yy = y - (x + y) / 3;
	if (xx < 0 || yy < 0) { cout << 0 << endl; return; }
	unsigned n = xx + yy, r = yy;
	modint::Fact(1000000);
	cout << (modint::Comb(n, r)).v << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>

/*
 *変数
 */
int n,k;

/*
 *解 
 */
void solve(){
    printf("%d",n%k!=0);
}

/*
 *入力 
 */
int main(){
       std::cin.tie(0);
       std::ios::sync_with_stdio(false);
       std::cin>>n>>k;
       solve();
       return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const VI prm= {
	2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	VI sk(n+2);
	for(int i=2; i<=n; i++) if(binary_search(all(prm),i)){
		for(int w=n;w>0;w/=i) sk[i] += w/i;
	}
	int dp[78] ={};
	dp[1] = 1;
	rep(i,n+1){
		int np[78] ={};
		rep(j,76) rep(k, sk[i]+1){
			if((k+1)*j <= 75) np[(k+1)*j] += dp[j];
		}
		swap(dp, np);
	}
	
	cout << dp[75] <<"\n";
	//for(auto x :dp) printf("%d ",x); puts("");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int num[] = {1, 1};

  for (num[0] = 1; num[0] <= 9; num[0]++) {
    for (num[1] = 1; num[1] <= 9; num[1]++) {
      printf("%dx%d=%d\n", num[0], num[1], num[0] * num[1]);
    }
  }

  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    int A = N;
    int B = 0;
    while (A > 0) {
        B += A % 10;
        A /= 10;
    }
    if (N % B == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int H, W;

	while(1) {
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;
		for(int j = 0; j < W; j++){
			printf("#");
		}
		printf("\n");
		for (int i = 0; i < H-2; i++){
			printf("#");
			for (int j = 0; j < W-2; j++)
			{
				printf(".");
			}
			printf("#\n");
		}
		for(int j = 0; j < W; j++){
			printf("#");
		}
		printf("\n\n");
	}

	return 0;
}


Measured memory_bytes: 2052
import sys
import numpy as np
N, M, C = map(int, sys.stdin.readline().rstrip().split())
B = np.array(list(map(int, sys.stdin.readline().rstrip().split())))
ans = 0
for _ in range(N):
    A = np.array(list(map(int, sys.stdin.readline().rstrip().split())))
    if np.dot(A, B) + C > 0:
        ans += 1
print(ans)

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

int main()
{
	int n,k,digit,x;
	cin>>k>>n;
	
	
	int a[n+1];
	for(int i=1;i<=n;i++)  cin>>a[i];
	
	if (a[n]<=k/2 ||a[1]>=k/2)
	cout<<a[n]-a[1]<<endl;
	
	else 
	   x=a[2]-a[1];
	   for(int i=2;i<=n-1;i++)
	     {
	     	digit=a[i+1]-a[i];

	     	if(digit>x) x=digit;
	     	
	     }
	     if(k-x<a[n]-a[1])
	     cout<<k-x<<endl;
	     else
	     cout<<a[n]-a[1]<<endl;
	
	
	return 0;
}


Measured memory_bytes: 1024
N,*A=map(int,open(0).read().split())

def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a

pairwise=True
sw=set()
swd=prime_factorize(A[0])
for a in A:
    s=prime_factorize(a)
    swd&=s
    if pairwise:
        if not sw.isdisjoint(s):
            pairwise=False
    sw|=s
setwise=not pairwise and len(swd)==0
if pairwise:
    print('pairwise coprime')
elif setwise:
    print('setwise coprime')
else:
    print('not coprime')

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), M = input();
    vector< int > P(M), Y(M);
    auto y = make_vector(N + 1, 0, 0);
    range(i, 0, M) {
        cin >> P[i] >> Y[i];
        y[P[i]].push_back(Y[i]);
    }

    range(i, 1, N + 1) {
        whole(sort, y[i]);
    }

    range(i, 0, M) {
        Y[i] = whole(lower_bound, y[P[i]], Y[i]) - y[P[i]].begin() + 1;
    }

    range(i, 0, M) {
        string a = to_string(P[i]);
        a = string(6 - a.size(), '0') + a;

        string b = to_string(Y[i]);
        b = string(6 - b.size(), '0') + b;

        cout << a << b << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 7808
def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))

    cnt = 0
    for i, x in enumerate(L[:-2]):
        for j, y in enumerate(L[i+1:-1]):
            for z in L[i+j+2:]:
                if len({x, y, z}) == 3:
                    cnt += int(x + y > z)
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
# Your code here!

#データの読み込み

fline=readlines
input=fline[0].split(" ")

n=input[0].to_i
m=input[1].to_i

k=Array.new(n)
a=Array.new(n,Array.new(n))
dp=Array.new(m+1,0)

for i in 0..n-1 do
    input=fline[i+1].split(" ")
    k[i]=input[0].to_i
    for j in 0..k[i]-1 do
    	a[i][j]=input[j+1].to_i
#    	printf("a[%d][%d]=%d\n",i,j,a[i][j])
    	dp[a[i][j]]=dp[a[i][j]]+1
    end
end

#実際の処理

=begin
for i in 0..n-1 do
	for j in 0..k[i]-1 do
	    p a[i][j]
		dp[a[i][j]]=dp[a[i][j]]+1
	end
end
=end

ans=0
for i in 1..m do
#    printf("dp[%d]=%d\n",i,dp[i])
	if dp[i]==n then
		ans=ans+1
	end
end


#出力

printf('%d', ans)



Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define IL inline
#define RG register
#define LL long long
#define Upd(a) (a)>=mod?(a-=mod):1
using namespace std;
template <class T>
IL char gc () {
	static char buf[1<<6], *p1=buf, *p2=buf;
	return (p1==p2) && (p2=(p1=buf)+fread(buf,1,1<<6,stdin), p1==p2) ?EOF:*p1++;
}
template <typename T>
IL void read (T&data) {
	data=0;
	RG char ch=0;
	while (ch<'0' || ch>'9') ch=getchar();
	while (ch<='9' && ch>='0') data=(data<<1)+(data<<3)+(ch&15), ch=getchar();
}
const int mod = 1e9+7;
const int _ =2011;
int n, k;
LL dp[2][_], jc[_*_], jcn[_*_];
IL int poww (RG int a, RG int b) {
	RG int ret=1, Base=a;
	for (;b;b>>=1, Base=1LL*Base*Base%mod) if (b&1) ret=1LL*ret*Base%mod;
	return ret;
}
IL int C (RG int a, RG int b) {
	if (a<b) return 0;
	return jc[a]*jcn[b]%mod*jcn[a-b]%mod;
}
int main (/*int aa, int bb*/) {
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	//n=aa, k=bb;
	read(n), read(k);
	if (k<=1) {puts("1"); return 0;}
	jc[0]=jcn[0]=1;
	RG int i, j, pre=1, cur=0;
	for (i=1; i<=n*k; ++i) jc[i]=jc[i-1]*i%mod, jcn[i]=poww(jc[i], mod-2);
	dp[0][0]=1;
	for (i=1; i<=n*2; ++i) {
		swap(cur, pre);
		for (j=0; j<min(i,n+1); ++j) dp[cur][j]=0;
		for (j=1; j<=min(i,n); ++j) {
			if ((i-j)%2) continue;
			if (n*2-i+1<j) break;
			RG int a=(i+j-2)>>1, b=(i-j)>>1;
			dp[cur][j]=1LL*dp[pre][j-1]*C(a*(k-1)+b+k-1-1,k-1-1)%mod;
			dp[cur][j]+=dp[pre][j+1];
			Upd(dp[cur][j]);
		}
		if (cur%2==0) dp[cur][0]=dp[pre][1];
	}
	//return 1LL*dp[cur][0]*jc[n]%mod;
	printf("%lld",1LL*dp[cur][0]*jc[n]%mod);
}


Measured memory_bytes: 63104
mi, ma, num = map(int,input().split())
ans = []
if num <= ma-mi+1:
  for i in range(mi,mi+num):
    ans.append(i)
  for j in range(ma-num+1,ma+1):
    if j not in ans:
      ans.append(j)
  for k in ans:
    print(k)
else:
  for l in range(mi,ma+1):
    print(l)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	ll n;
	cin >> n;
	string s[n];
	f(i,0,n){
		cin >> s[i];
	}

	sort(s,s+n);

	ll sum=1;
	f(i,1,n){
		if(s[i]!=s[i-1]){
			sum++;
		}
	}

	cout << sum;
}

Measured memory_bytes: 9876
N, M, X, Y = list(map(int, input().split()))
X_list = list(map(int, input().split()))
Y_list = list(map(int, input().split()))

for Z in range(X + 1, Y + 1):
    if max(X_list) < Z and Z <= min(Y_list):
        print("No War")
        exit()

print("War")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

const int MAX_N = 1000000;
bool ifprime[MAX_N + 1];
bool used[MAX_N + 1];
int sum [MAX_N + 1];

int main() {
    fill(used, used + MAX_N + 1, false);
    fill(ifprime, ifprime + MAX_N + 1, false);
    for(int i = 2; i <= MAX_N; i++) {
        if(!used[i]) {
            used[i] = true;
            ifprime[i] = true;
            for(int j = 1; i * j <= MAX_N; j++) {
                used[i * j] = true;
            }
        }
    }

    sum[0] = 0;
    rep(i, MAX_N) {
        sum[i + 1] = sum[i];
        if(ifprime[i + 1]) sum[i + 1]++;
    }

    int n;
    while(cin >> n) {
        cout << sum[n] << endl;
    }
}



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

namespace ABC103
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a);
            Console.WriteLine(a[n - 1] - a[0]);
        }
    }
}


Measured memory_bytes: 11348
#include <stdio.h>
int main(){
    int a, b, c, k;
    scanf("%d%d%d%d", &a,&b,&c,&k);
    
    while( a >= b ){
        b *= 2;
        k--;
    }
    while( b >= c ){
        c *= 2;
        k--;
    }
    if( k >= 0 ){ printf("Yes\n"); }
    else        { printf("No\n");  }
    return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d %d %d",&a,&b,&c);
  if(a > b){
    d=a;
    a=b;
    b=d;
  }if(b > c){
    d=b;
    b=c;
    c=d;
  }if(a > b){
    d=a;
    a=b;
    b=d;
  }printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	ios::sync_with_stdio(false);
 cin.tie(0);
 int x; cin >> x;
 if(x) cout << 0 ;
 else cout << 1;
return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		double a[6],matrix[4],ans[2];
		scanf("%lf %lf %lf %lf %lf %lf",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]);
		matrix[0] = 2*(a[0]-a[2]);
		matrix[1] = 2*(a[1]-a[3]);
		matrix[2] = 2*(a[0]-a[4]);
		matrix[3] = 2*(a[1]-a[5]);
		ans[0] = a[0]*a[0]+a[1]*a[1]-a[2]*a[2]-a[3]*a[3];
		ans[1] = a[0]*a[0]+a[1]*a[1]-a[4]*a[4]-a[5]*a[5];
		double t = matrix[0]*matrix[3]-matrix[1]*matrix[2];
		double x = matrix[3]*ans[0]/t-matrix[1]*ans[1]/t;
		double y = matrix[0]*ans[1]/t-matrix[2]*ans[0]/t;
		printf("%.3lf %.3lf %.3lf\n",x,y,sqrt((a[0]-x)*(a[0]-x)+(a[1]-y)*(a[1]-y)));
	}
}

Measured memory_bytes: 0
n = int(input())
s = input()
e = 0
for i in s:
    if i == 'E':
        e += 1
        
w = 0
a = []
for i in range(n):
    if i == 0:
        if s[i] == 'E':
            e -= 1
    else:
        if s[i] == 'E':
            e -= 1
        if s[i-1] == 'W':
            w += 1
    a.append(w+e)

print(min(a))
        

Measured memory_bytes: 15520
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int n = Integer.parseInt(input());
		Dice dice = new Dice(input());
		boolean flag = true;

		for (int i = 0; i < n - 1; i++) {

			if (dice.match(input())) {

				flag = false;
				break;

			}
		}

		if (flag) {

			System.out.println("Yes");

		} else {

			System.out.println("No");
		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

class Dice {

	private int top;
	private int front;
	private int right;
	private int left;
	private int back;
	private int bottom;

	public Dice(String num) {

		String[] partsNum = num.split(" ");

		top = Integer.parseInt(partsNum[0]);
		front = Integer.parseInt(partsNum[1]);
		right = Integer.parseInt(partsNum[2]);
		left = Integer.parseInt(partsNum[3]);
		back = Integer.parseInt(partsNum[4]);
		bottom = Integer.parseInt(partsNum[5]);

	}

	public boolean match(String num) {

		String[] numList = num.split(" ");

		for (int i = 0; i < 7; i++) {

			if (i == 4) {

				this.roll("E");

			}

			if (Integer.parseInt(numList[1]) == this.front) {

				break;

			} else {

				this.roll("N");

			}
		}

		for (int j = 0; j < 4; j++) {

			if (Integer.parseInt(numList[0]) == this.top) {

				break;

			} else {

				this.roll("W");

			}
		}

		return (Integer.parseInt(numList[2]) == right &&
				Integer.parseInt(numList[3]) == left &&
				Integer.parseInt(numList[4]) == back &&
				Integer.parseInt(numList[5]) == bottom);

	}

	public void roll(String direction) {

		int temp;

		for (int i = 0; i < direction.length(); i++) {

			switch (direction.charAt(i)) {

			case 'E':

				temp = top;
				top = left;
				left = bottom;
				bottom = right;
				right = temp;
				break;

			case 'N':

				temp = top;
				top = front;
				front = bottom;
				bottom = back;
				back = temp;
				break;

			case 'S':

				temp = top;
				top = back;
				back = bottom;
				bottom = front;
				front = temp;
				break;

			case 'W':

				temp = top;
				top = right;
				right = bottom;
				bottom = left;
				left = temp;
				break;

			}
		}
	}
}

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

int main()
{
	int x, y;
	scanf("%d%d", &x, &y);
	for(int i = 0; i <= x; i++)
		if(y - x - 3*i == x - i)
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 3672
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""


# ABC 200点問題
import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  # Maximum Sum
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  # Exponential
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


def prob098():  # Cut and Count
    N = getInt()
    S = input()
    dmp((N, S))
    maxChCount = 0
    for i in range(1, N):
        before = S[:i]
        after = S[i:]
        dmp((before, after))
        chCount = 0
        for j in range(26):
            ch = chr(ord('a')+j)
            if ch in before and ch in after:
                chCount += 1
        maxChCount = max(maxChCount, chCount)
    return maxChCount


def prob099():  # Stone Momument
    a, b = getIntList()
    height = 0
    for i in range(b-a+1):
        height += i
    height -= b
    return height


def prob103():  # String Rotation
    S = input()
    T = input()
    for i in range(len(S)):
        S = S[1:] + S[0]
        dmp(S)
        if S == T:
            return 'Yes'
    else:
        return 'No'


def prob110():  # 1 Dimensional World's Tale
    N, M, X, Y = getIntList()
    cX = getIntList()
    cY = getIntList()
    dmp((N, M, X, Y))
    dmp(cX)
    dmp(cY)
    NW = 'No War'
    WA = 'War'
    if Y <= X:
        return WA
    cX.sort()
    cY.sort()
    dmp(cX)
    dmp(cY)
    if cX[-1] < cY[0] and \
            X < cY[0] and \
            cX[-1] < Y:
        return NW
    else:
        return WA


def prob109():  # Shiritori
    N = getInt()
    W = []
    for i in range(N):
        W.append(input())
    dmp(W)
    ALPHABET = [chr(i+ord('a')) for i in range(26)]
    NO = 'No'
    dmp(ALPHABET)
    used = set([W[0]])
    for i in range(1, N):
        dmp(used)
        if W[i] in used:
            return NO
        used.add(W[i])
        if W[i-1][-1] != W[i][0]:
            return NO
    return 'Yes'


def prob100():  # 
    return 0


debug = False  # True False
print(prob109())


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

int main() {
	int a, b, c; cin >> a >> b >> c;
	bool ok = false;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)ok = true;
	cout << (ok ? "Possible" : "Impossible") << endl;

	return 0;
}

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

using namespace std;

int main() {
      string S;
      cin >> S;
      if (S[0] != 'A'){
            cout << "WA" << endl;
            exit(0);
      }
      int count = 0;
      for (int i = 2; i < S.length() -1; i++)
            if (S[i] == 'C'){
                  count ++;
                  S[i] = 'a';
            }
      if (count != 1){
            cout << "WA" << endl;
            exit(0);
      }
      for (int i = 1; i < S.length(); i++)
            if (S[i] < 97 || 122 < S[i]) {
                  cout << "WA" << endl;
                  exit(0);
            }
      
      cout << "AC" << endl;
      exit(0);
}


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

int main() {
  int s,w;
  cin >> s >> w;

  if(w>=s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
const int MOD = 998244353;
const int BASE = 27;
const int N = 100002;
const ll oo = 1e18;
const double EPS = 1e-9;

int r , g , b , n;

int main() {
	cin >> r >> g >> b >> n;
	int ans = 0;
	for(int i = 0; i <= n;++i){
		for(int j = 0 ; j <= n ; ++j){
			int rem = n-i*r-j*g;
			if(rem >= 0 && rem%b == 0){
				//cout << i << " "<< j << " "<< (rem/b) << endl;
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      Deque<Character> que = new ArrayDeque<>();
      StringBuilder buf = new StringBuilder();
      while(true) {
        line = in.readLine();

        if(line.charAt(0) == '.') break;

        boolean isBalanced = true;
        for (char ch : line.toCharArray()) {
          if(ch == '(' || ch == '[') {
            que.push(ch);
          }
          else if(ch == ')' || ch == ']') {
            if(que.isEmpty()) {
              isBalanced = false;
              break;
            }
            else {
              char ec = que.pop();
              if(ec == '(' && ch == ')') continue;
              else if(ec == '[' && ch == ']') continue;
              else {
                isBalanced = false;
                break;
              }
            }
          }
        }

        if(!que.isEmpty()) {
          isBalanced = false;
          que.clear();
        }

        buf.append(isBalanced ? "yes\n" : "no\n");
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 29144
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
int main(){  
    int n;
    cin>>n;
    int array[n];
    for (int i = 0; i < n; i++)
    {
        cin>>array[i];
    }
    int ans=1000;
    for (int i = 0; i < n; i++)
    {
        int sum1=0;
        int sum2=0;
        for (int j = 0; j <i; j++)
        {
            sum1+=array[j];
        }
        for (int k = i; k < n; k++)
        {
            sum2+=array[k];
        }
        if( abs(sum2-sum1)<ans){
            ans=abs(sum2-sum1);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256