akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      int[] a = new int[n];
      int[] b = new int[n];
      int[] axor = new int[2*n-1];
      int[] bxor = new int[n];
      st = new StringTokenizer(br.readLine());
      for(int i = 0; i < n; i++) {
          a[i] = Integer.parseInt(st.nextToken());
          if(i > 0)
        	  axor[i] = a[i] ^ a[i-1];
      }
      axor[0] = a[0] ^  a[n-1];
      for(int i = 0; i < n-1; i++) {
    	  axor[i+n] = axor[i];
      }
      st = new StringTokenizer(br.readLine());
      for(int i = 0; i < n; i++) {
          b[i] = Integer.parseInt(st.nextToken());
          if(i > 0)
        	  bxor[i] = b[i] ^ b[i-1];
      }
      bxor[0] = b[0] ^ b[n-1];
      if(n != 1) {
	      TreeSet<Integer> shift = new TreeSet<Integer>();
	      int[] lps = new int[n];
	      int len = 0;
	      int i = 1;
	      while(i < n) {
	    	  if(bxor[len] == bxor[i]) {
	    		  len++;
	    		  lps[i] = len;
	    		  i++;
	    	  }
	    	  else {
	    		  if(len == 0) {
	    			  lps[i] = 0;
	    			  i++;
	    		  }
	    		  else
	    			  len = lps[len-1];
	    	  }
	      }
	      i = 0;
	      int j = 0;
	      while(i < 2*n-1) {
	    	  if(axor[i] == bxor[j]) {
	    		  if(j == n-1) {
	    			  shift.add(i-j);
	    			  j = lps[j];
	    		  }
	    		  else
	    			  j++;
	    		  i++;
	    	  }
	    	  else {
	    		  if(j != 0) {
	    			  j = lps[j-1];
	    		  }
	    		  else
	    			  i++;
	    	  }
	      }
	      for(int k: shift) {
	    	  out.println(k + " " + (a[k]^b[0]));
	      }
      }
      else
    	  out.println(0 + " " + (a[0] ^ b[0]));
      out.close();
   }
}

Measured memory_bytes: 74592
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut grid = vec![vec![0usize; n+1]; 3];
    for i in 0..2 {
        for j in 0..n {
            grid[i][j] = read();
        }
    }
    let mut dp = vec![vec![0; n+1]; 3];
    dp[0][0] = grid[0][0];
    for i in 0..2 {
        for j in 0..n {
            dp[i+1][j] = max(dp[i][j] + grid[i+1][j], dp[i+1][j]);
            dp[i][j+1] = max(dp[i][j] + grid[i][j+1], dp[i][j+1]);
        }
    }
    println!("{}", dp[1][n-1]);
}


Measured memory_bytes: 2076
N = int(input())
ab = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    ab.append(tmp)

ans = 0
for i in reversed(range(N)):
    if (ab[i][0]+ans) % ab[i][1] != 0:
        a = (ab[i][0]+ans)
        b = ((ab[i][0]+ans)//ab[i][1]+1)*ab[i][1]
        ans += abs(a-b)
print(ans)


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

int main(void)
{
    int n;
    cin >> n;
    cout << n * n / 4 << endl;
}


Measured memory_bytes: 3572
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		String A = nextString();
		String B = nextString();

		String ans ="";
		if(A.length()<B.length()){
			ans="LESS";
		}else if(A.length()>B.length()){
			ans="GREATER";
		}else{
			if(A.compareTo(B)<0){
				ans="LESS";

			}else if(A.compareTo(B)>0){
				ans="GREATER";
			}else{
				ans="EQUAL";
			}
		}

		System.out.println(ans);




	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

void solve(int N, int M, int A, int B)
{
    cout << floor_sum(N, M, A, B) << '\n';
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    for(int i=0; i<T; i++)
    {
        int N, M, A, B;
        cin >> N >> M >> A >> B;
        solve(N, M, A, B);
    }

    return 0;
}


Measured memory_bytes: 3672
import sys
sys.setrecursionlimit(4100000)
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, K, L = map(int,input().split())
    road = UnionFind(N)
    train = UnionFind(N)

    for k in range(K):
        p, q = map(int,input().split())
        p -= 1
        q -= 1
        road.union(p,q)

    for k in range(L):
        r, s = map(int,input().split())
        r -= 1
        s -= 1
        train.union(r,s)


    D = dict()
    P = [0]*N
    for k in range(N):
        t = (10**6)*(train.find(k)+1)+road.find(k)
        P[k] = t
        if t in D:
            D[t] += 1
        else:
            D[t] = 1
    ans = []
    for k in range(N):
        ans.append(D[P[k]])
    print(*ans)


if __name__ == '__main__':
    main()


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

int main() {
	bool judge = true;
	while (judge) {
		int h, w, n;
		cin >> h >> w >> n;
		if (h == 0 && w == 0 && n == 0) {
			judge = false;
			return 0;
		}
		int p[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> p[i][j];
			}
		}
		int dp[1010][1010] = { 0 };
		dp[0][0] = n - 1;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (dp[i][j] % 2 == 0) {
					if (i != h - 1) {
						dp[i + 1][j] += dp[i][j] / 2;
					}
					if (j != w - 1) {
						dp[i][j + 1] += dp[i][j] / 2;
					}
				}
				else {
					if (p[i][j] == 0) {
						if (i != h - 1) {
							dp[i + 1][j] += dp[i][j] / 2 + 1;
						}
						if (j != w - 1) {
							dp[i][j + 1] += dp[i][j] / 2;
						}
					}
					else {
						if (i != h - 1) {
							dp[i + 1][j] += dp[i][j] / 2;
						}
						if (j != w - 1) {
							dp[i][j + 1] += dp[i][j] / 2 + 1;
						}
					}
				}
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (dp[i][j] % 2 == 1) {
					if (p[i][j] == 0) {
						p[i][j] = 1;
					}
					else {
						p[i][j] = 0;
					}
				}
			}
		}
		int a = 0, b = 0;
		while (a < h && b < w) {
			if (p[a][b] == 0) {
				a++;
			}
			else {
				b++;
			}
		}
		cout << a + 1 << ' ' << b + 1 << endl;
	}
}


Measured memory_bytes: 10916
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int a, b;
    cin >> a >> b;
    if((a < 9) && (b < 9)){
        cout << "Yay!" << endl;
        return 0;
    }
    cout << ":(" << endl;
    return 0;
}

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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    
    if(b>a+x) cout << "dangerous";
    else if(b<=a) cout << "delicious";
    else if(b<=a+x) cout << "safe";
}


Measured memory_bytes: 256
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a =int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換


    if op=="?": # opが"?"の時は終了
        break
    else:    #opが"?"以外の時
        if op=="+":
            print(a+b)
        elif op=="-":
            print(a-b) 
        elif op=="*":
            print(a*b)        
        elif op=="/":
            print(int(a/b))


Measured memory_bytes: 5596
#include<stdio.h>
int main(void)
{
	int a,b,c,k,x;
	scanf("%d %d %d",&a,&b,&c);
	x=0;
	k=0;
	while(1){
		x++;
		k=k+a;
		if(x%7==0){
			k=k+b;
		}
		if(k>=c){
			break;
		}
	}
	printf("%d\n",x);
	return 0;
}



Measured memory_bytes: 2148
n = int(input())
h = list(map(int,input().split()))
dp = [9999999999]*n
dp[0] = 0
for i in range(1,n):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i] - h[i-1]))
    if (i > 1):
        dp[i] = min(dp[i],dp[i-2]+abs(h[i] - h[i-2]))
print(dp[-1])


Measured memory_bytes: 13924
n = int(input())
bw = [0] * (n + 1)
uvw = [[] for _ in range (n+1)]

for i in range(0,n-1):
  tmp = list(map(int, input().split()))
  uvw[tmp[0]].append((tmp[1], tmp[2]))
  uvw[tmp[1]].append((tmp[0], tmp[2]))

#print(uvw)

nxt = [1]
bw[1] = 1

while len(nxt) != 0:
  cur = nxt.pop()
  while len(uvw[cur]) > 0:
    tmp = uvw[cur].pop()
    if tmp[1] % 2 == 0:
      jdg = 1
    else:
      jdg = -1

    if bw[tmp[0]] == 0:
#      print ('ADD NXT=' + str(tmp[0]) + ' JUDGE=' + str(jdg))
      bw[tmp[0]] = bw[cur] * jdg
      nxt.append(tmp[0])

for i in range(1,n+1):
  if bw[i] == -1:
    print('0')
  else:
    print('1')


Measured memory_bytes: 72096
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) f(i,0,n)
#define rrep(i,n) rf(i,n-1,0)
#define w(t) ll t; cin>>t; while(t--)
#define vi vector<ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mii map<ll,ll>
#define mci map<char,ll>
using namespace std;

void fast_IO_file()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main()
{
	//fast_IO_file();
	ll n;
	cin >> n;
	string ans = "";
	while (n > 0)
	{
		n--;
		ans += 97 + (n % 26);
		n /= 26;
	}
	reverse(ans.begin(),ans.end());
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			String st=in.next();
			int ans=0;
			int cntJ=0;
			int cntO=0;
			int cntI=0;
			int fo=0;
			for(int i=0;i<st.length();i++)
			{
				if(st.charAt(i)=='O')
					fo=i-1;
				while(i<st.length()&&st.charAt(i)=='O')
				{
					cntO++;
					i++;
				}
				while(i<st.length()&&st.charAt(i)=='I')
				{
					cntI++;
					i++;
				}
				while(fo>=0&&st.charAt(fo)=='J')
				{
					cntJ++;
					fo--;
				}
				if(cntO<=cntI&&cntO<=cntJ)
				{
					ans=Math.max(ans, cntO);
				}
				cntJ=cntO=cntI=0;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    long long count = 0;
    for (int a = 1; a < n; a++) {
        for (int b = 1; b < n; b++) {
            if (a * b >= n) {
                break;
            }
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 3632
n,k=map(int,input().split())
r,s,p=map(int,input().split())
string=list(input())
res=[0]*n
a=['t']*len(string)
for i in range(len(string)):
    if i-k>=0:
        if string[i]=='r' and a[i-k]!='p':
            res[i]=p
            a[i]='p'
        elif string[i]=='s' and a[i-k]!='r':
            res[i]=r
            a[i]='r'
        elif string[i]=='p' and a[i-k]!='s':
            res[i]=s
            a[i]='s'
    else:
        if string[i]=='r':
            res[i]=p
            a[i]='p'
        elif string[i]=='s':
            res[i]=r
            a[i]='r'
        elif string[i]=='p':
            res[i]=s
            a[i]='s'
print(sum(res))

Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int m,d;
    cin >> m >> d;
    vvi a(m, vi(d));
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < d; j++) {
            a[i][j] = j+1;
        }
    }
    int ans = 0;
    for(int i= 0; i< m; i++) {
        for(int j = 0; j < d; j++) {
            int d1 = a[i][j] % 10;
            int d2 = a[i][j] / 10;
            if(d2 != 0 && (d1 >= 2 )&& (d2 >= 2) && (d1 * d2 == i+1)) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

int main(int argc,char** argv){
  string str;
  int S = 0;
  int N = 0;
  cin >> str;
  for(int i = 0 ; i < str.length() ; i++ ){
    S += str[i] - '0';
  }
  N = atoi(str.c_str());
  if( N % S == 0 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

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

int main(){
  	int h,w;
  	char s[100][100];
  	cin>>h>>w;
	for(int i=0;i<h;++i){
      for(int j=0;j<w;++j)
    	cin>>s[j][i];
    }
  	for(int j=0;j<=w+1;++j)cout<<"#";
  	cout<<endl;
  	for(int i=0;i<h;++i){
      	cout<<"#";
  		for(int j=0;j<w;++j)cout<<s[j][i];
      	cout<<"#"<<endl;
    }for(int j=0;j<=w+1;++j)cout<<"#";
  	cout<<endl;
  	return 0;
  
}

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

using namespace std;

int main(){
        string s;
        cin>>s;
        int now=(int)s.length();
        while(now!=0){
                if(now>=7&&s.substr(now-7, 7)=="dreamer"){
                        now-=7;
                }
                else if(now>=6&&s.substr(now-6, 6)=="eraser"){
                        now-=6;
                }
                else if(now>=5&&s.substr(now-5, 5)=="dream"){
                        now-=5;
                }
                else if(now>=5&&s.substr(now-5, 5)=="erase"){
                        now-=5;
                }
                else{
                        cout<<"NO"<<endl;
                        return 0;
                }
        }
        cout<<"YES"<<endl;
        return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j; string s;
	cin>>n>>m;
	cout<<(n-1)*n/2+(m-1)*m/2<<endl; 


}

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

int num(int x, int y) {
  int cnt = 0;
  while(x<y) {
    cnt++;
    x *= 2;
  }
  return cnt;
}

int main() {
  int k;
  double n;
  cin >> n >> k;
  
  double ans = 0;
  for(int i=1; i<=n; i++) {
    ans += 1/n*pow(0.5, num(i,k));
  }
  
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string s;
	cin>>s;
	ll sum=0;
  ll size=s.length();
	for(ll i=0;i<size;i++)
    {
	sum+=(s[i]-'0');
      sum=sum%9;
    }
	if(sum%9==0)
	cout<<"Yes"<<"\n";
	else
	cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n),ans;
    vector<bool> b(n);
    for(int i=0;i<n;i++)    b[i] = true;
    for(int i=0;i<n;i++)    cin >> a[i];
    
    for(int j=0;j<n;j++){
        int cnt=0,t=-1;
        for(int i=0;i<n;i++){
            if(b[i]==true)  cnt++;
            if(cnt==a[i])   t = i;
        }
        if(t==-1){
            cout << -1 << endl;
            return 0;
        }
        else{
            b[t]=false;
            ans.push_back(a[t]);
        }
    }
    for(int i=n-1;i>=0;i--)    cout << ans[i] << endl;
	return 0;
}

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

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define clr(a,b) memset((a),b,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

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

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = 2e5+77;
const ll mod = 1e9+7;

ll fact[N];
ll n,m,k,l,r,ans,c,a,b;
//modular exponentiation for fermat little theorem in order to find modular multiplicative inverse
ll mpow(ll a, ll b){
    ll res=1;
    while(b!=0){
        if(b%2==1) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}

//nCr == C(n,r) call this way
ll C(ll n,ll r){
    if(n<r) return 0;
    if(n==r) return 1;
    if(r==0) return 1;
    ll x,y,ans=fact[n];
    x=mpow(fact[n-r],mod-2);
    y=mpow(fact[r],mod-2);
    ans=(ans*x)%mod;
    ans=(ans*y)%mod;
    return ans;
}

ll ways(ll n, ll r){
    return C(n+r-2,n-1);
}

//precalculate factorial
void factorial(ll n){
    fact[0]=1;
    for(int i=1;i<n;i++){
        fact[i]=(fact[i-1]*i)%mod;
    }
}


int main(){
    fast;
    factorial(N);
    cin>>n>>m;
    if(abs(n-m)>1) return cout<<"0\n", 0;
    if(n>m) swap(n,m);
    ans = fact[n];
    ans = ans*C(m,n-1);
    ans %= mod;
    ans = ans*fact[n-1];
    ans %= mod;
    ans = ans*C(2,m-n+1)*(m-n+1);
    ans %= mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
def c_LiningUp(N, A):
    MOD = 10**9 + 7
    A = sorted(A)
    if N % 2 == 0:
        # Nが偶数なら、人数の差の絶対値はB=[N-1,N-3,...,3,1,1,3,...,N-3,N-1]
        # になっていないといけない。AとBをソートして一致しなければ解は0。
        B = [i for i in range(1, N, 2)]
        B = sorted(B + B)
    else:
        # Nが奇数なら、人数の差の絶対値はB=[N-1,N-3,...,2,0,2,...,N-3,N-1]
        # になっていないといけない。
        B = [i for i in range(2, N, 2)]
        B = sorted([0] + B + B)
    if A == B:
        return 2**(N // 2) % MOD  # 解説どおり
    else:
        return 0
    return None

N = int(input())
A = [int(i) for i in input().split()]
print(c_LiningUp(N, A))

Measured memory_bytes: 13880
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	if (N % 3 != 0 || a.size() == 1) {
		if (cnt[0] == N) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	if (a.size() > 3) {
		cout << "No" << endl;
		return 0;
	}
	if (a.size() == 2) {
		if (a[0] == 0 && cnt[0] == N / 3) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if ((a[0] ^ a[1]) == a[2] && cnt[a[0]] == N / 3 && cnt[a[1]] == N / 3) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n,k,s; cin >> n >> k >> s;
	int deflt = 1000000000;
	if(s==deflt) deflt=1;
	vi a(n,deflt);
	rep(i,k) a[i] = s;
	rep(i,n) cout << a[i] << endl;
}




Measured memory_bytes: 1664
import math

N = int(input())
def checklen(A, B):
    return max(len(str(A)), len(str(B)))

ans = float("inf")
M = round(math.sqrt(N))
for i in range(1, M+1):
    if N % i == 0:
        m = round(N/i)
        ans = min(checklen(i, m), ans)
print(ans)

Measured memory_bytes: 3188
import queue
N,X,Y=map(int,input().split())
X-=1
Y-=1
ans=[0]*N
for i in range(N-1):
  for j in range(i+1,N):
    ans[min(j-i, abs(X-i)+1+abs(Y-j))]+=1
for i in range(1,N):
  print(ans[i])

Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;
int cnt[1000]={0};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
       int n, k;
       cin >> n >> k;
       int d;
       FOR(i, 0, k){
        cin >> d;
        int s;
        FOR(j, 0, d){
            cin >> s;
            cnt[s]++;
        }
       }
       int a=0;
       FOR(i, 1, n+1){
        if(cnt[i])a++;
       }
       cout <<n- a << endl;
    }
}


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

int main()
{
    long long n;
    cin >> n;
    if(n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }
    
    long long s = 10;
    long long ans = 0;
    while(s <= n){
        ans += n/s;
        s *= 5;
    }
    cout << ans << endl;
    return 0;
}

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

int H,W;
string t[100];
map<char,int> mp;

bool solve(){
  if(H%2==0 && W%2==0){
    for(char ch='a';ch<='z';ch++){
      if(mp[ch]%4!=0){
        return false;
      }
    }
    return true;
  }
  /*

   ooooo
   ooooo
   ooooo

   */
  int tmp[4]={};
  for(char ch='a';ch<='z';ch++){
    tmp[ mp[ch]%4 ]++;
  }

  if(H%2==1 &&W%2==1){

    if(tmp[1] + tmp[3]>1)return false;
    if(tmp[2] +tmp[3]> H/2+W/2)return false;
    return true;
  }
  
  if(H%2==1 && W%2==0){
    if(tmp[1]+tmp[3]>0)return false;
    if(tmp[2] >W/2)return false;
    return true;
  }
  if(H%2==0 && W%2==1){
    
    
    if(tmp[1]+tmp[3]>0)return false;
    if(tmp[2] >H/2)return false;
    return true;
  }
  
}
int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
    cin>>t[i];
    for(int j=0;j<W;j++){
      mp[ t[i][j] ]++;
    }
  }
  if( solve() )cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
  return 0;
}


Measured memory_bytes: 256
# YouTube解説
MOD = 1000000007
n, k = [int(x) for x in input().split()]
d = [pow(k // i, n, MOD) if i > 0 else 0 for i in range(0, k + 1)]

for i in range(k, 0, -1):  # 大きいほうから
    for j in range(i * 2, k + 1, i):  # iの倍数
        # d[6] = d'[6] - d[12] - d[18] ...
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i, item in enumerate(d):
    ans += i * item
    ans %= MOD
print(ans)


Measured memory_bytes: 76544
import std.string;
import std.stdio;
import std.conv;
import std.algorithm;
import std.typecons;

void main() {
	int n, q;
	int[][int] map;
	scanf("%d %d\n", &n, &q);
	int[] cnts, checks;
	cnts = new int[n+1];
	checks = new int[n+1];
	foreach(i;0..n-1) {
		int a, b;
		scanf("%d %d\n", &a, &b);
		map[a] ~= b;
	}
	foreach(i;0..q) {
		int p, x;
		scanf("%d %d\n", &p, &x);
		checks[p] += x;
	}
	int[] que = [1];
	for(size_t i; i < que.length; ++i) {
		auto v = que[i];
		cnts[v] += checks[v];
		if (v in map) {
			foreach(child; map[v]) {
				cnts[child] += cnts[v];
				que ~= child;
			}
		}
	}
	foreach (v; cnts[1..$]) {
		write(v, " ");
	}
}


Measured memory_bytes: 27516
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{ 
  int N ,K, e=1;
  cin >> N >> K;
  for (int i=0; i<N; i++)
  {
    if (e <= K) 
    {
      e *= 2;
    }
    else 
    {
      e += K;
    }
  }
  cout << e << endl;
}
  

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll a, b, c, d;
int main(){
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    if(a<c){
        printf("1");
    }else{
        printf("0");
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
const int maxn = 3000+5;
int main()
{
	int i, n, a[maxn];
	scanf("%d", &n);
	for(i=0; i<n; ++i)
	   scanf("%d", &a[i]);
	int s = 0;
    for(i=0; i<n; ++i)
	   s += a[i];
	printf("%d\n", s-n);        
	return 0;
}

Measured memory_bytes: 128
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

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

void Main(){
    int N;
    cin >> N;
    vec<ll> H(N);
    REP(i, N){
        cin >> H[i];
    }
    FOR(i, N, 1){
        if(H[i-1]<H[i]){
            H[i]--;
        }
        if(H[i-1]>H[i]){
            cout << "No" << el;return;
        }
    }
    cout << "Yes" << el;
}



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

using namespace std;

int main(){
	int N, M;
	cin >> N >> M;
	int k[15];
	int s[15][15];
    int p[15];
	rep(i,M){
		cin >> k[i];
		rep(j,k[i]){
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	rep(i,M) cin >> p[i];
	int ans=0;
	for(int bit=0; bit<(1<<N); bit++){
		int num=0;
		rep(i,M){
			int sum=0;
			rep(j,k[i]){
				if(bit&(1<<s[i][j])) sum++;
			}
			if(sum%2==p[i]) num++;
		}
		if(num==M) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
string a;
int n, v[130];
int main() {
	int i, j;
	cin>>a;
	n = a.size();
	for(i=0; a[i]; i++) v[a[i]] = 1;
	for(i='a'; i<='z'; i++) if(!v[i]) a += i;
	if(n<26) cout<<a.substr(0,n+1);
	else {
		next_permutation(a.begin(), a.end()+1);
		if(!a[0]) cout<<-1;
		else for(i=0; a[i]; i++) cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,sum,save;
int A,B;
int x;
int m[111111];
int dist(int x, int y){return x>y?x-y:y-x;}
int main(){
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>m[i];
        sum+=dist(m[i-1],m[i]);
    }
    sum+=dist(m[N],0);
    for(int i=1;i<=N;i++)
        cout<<sum-dist(dist(m[i-1], m[i+1]), 
            dist(m[i-1],m[i])+dist(m[i],m[i+1]))<<'\n';
}


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

#define sc scanf
#define pf printf
#define CIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull unsigned long long int
#define ll  long long int
#define db double
#define fl float
#define vi vector<int>
#define vl vector<ll>
#define qin queue<int>
#define pb push_back
#define pob pop_back
#define ft front
#define bk back
#define mp make_pair
#define pii pair<int,int>
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define pll __builtin_popcountll
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<ll>())



int main()
{
    CIN;

    int n;
    cin>>n;

    int s=n+(n*n)+(n*n*n);


    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = min(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      k--;
      if (k == 0) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
(N, M), P, *E = $<.map{|ln|ln.split.map(&:to_i)}

G = *0..N
ID = lambda{|i|
	next G[i] == i ? i : G[i] = ID[G[i]]
}
E.each{|xy|
	a,b = xy.map(&ID)
	G[a] = b
}

p (1..N).count{|i|
	 ID[i] == ID[P[i-1]]
}


Measured memory_bytes: 24536
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;


int main() {
	speed;
	int a, b, c;
	cin >> a >> b >> c;
	if (a<=c&&a+b>=c)cout << "YES";
	else cout << "NO";
	ed;
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	string s;
	cin >> s;

	int n = s.back() - '0';

	if (n == 2 || n == 4 || n == 5
		|| n == 7 || n == 9) {
		out("hon");
	}
	else if (n == 0 || n == 1
		|| n == 6 || n == 8) {
		out("pon");
	}
	else {
		out("bon");
	}

	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void){

    //読み取ったデータを保存する箱を用意する
    int ab[3][3+1];
    //一番左の列にある数値のうち、最小値を格納する箱を用意する
    int min = 101;
    
    //3行読み込み、値をabに代入する
    for(int i = 0;i<3;i++){
        scanf("%d %d %d",&ab[i][0],&ab[i][1],&ab[i][2]);
        //一番左の列にある数値のうち、最小値をabに代入する
        if(ab[i][0] < min){
            min = ab[i][0];
        }
    }
    //a1~a3、b1~b3を入れる箱を用意する
    int a[3];
    int b[3];
    
    //リセット用のフラグを用意する
    int flag = 0;

    //a1b1の値を0~minであると仮定し、他の値を代入して成り立つか確認する
    //成り立つ場合はYesを出力しプログラムを終了する
    //成り立たない場合はそのままfor文を抜ける
    for(int i = 0;i<=min;i++){
        //配列a,bを初期化する
        memset(&a,0,sizeof(a));
        memset(&b,0,sizeof(b));
        //a[0]に仮定した値を代入し、a[0]~b[2]の値を求める
        a[0] = i;
        b[0] = ab[0][0] - i;
        b[1] = ab[0][1] - i;
        b[2] = ab[0][2] - i;
        a[1] = ab[1][0] - b[0];
        a[2] = ab[2][0] - b[0];
        
        //求めた値a[j]、b[k]をそれぞれ足し合わせ、ab[j][k]と一致するか確認する
        //一致しない場合flagを加算し、for文を抜ける
        for(int j = 0;j<3;j++){
            if(flag != 0){
                break;
            }
            for(int k = 0;k<3;k++){
                if(ab[j][k] != a[j] + b[k]){
                    flag++;
                    break;
                }
            }
        }
        //flagが0ならYesを出力し、プログラムを終了する
        if(flag == 0){
            printf("Yes\n");
            return 0;
        }
        //flagを初期化する
        flag = 0;
    }

    //Yesが出力されなかったので、Noを出力する
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
//57
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int l[256];
    for(int i=0;i<n;i++){
      cin>>l[i];
    }
    double me=1<<30;
    int ms,ma,mc;
    for(int s=0;s<16;s++){
      for(int a=0;a<16;a++){
	for(int c=0;c<16;c++){
	  int oa[256]={};
	  int r=s;
	  for(int i=0;i<n;i++){
	    r=(r*a+c)%256;
	    oa[(r+l[i])%256]++;
	  }
	  double ce=0;
	  for(int i=0;i<256;i++){
	    if(oa[i]){
	      ce-=oa[i]*1./n*log(oa[i]*1./n);
	    }
	  }
	  if(ce<me-1e-9){
	    me=ce;
	    ms=s;
	    ma=a;
	    mc=c;
	  }
	}
      }
    }
    cout<<ms<<' '<<ma<<' '<<mc<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextInt();
        int k = in.nextInt() - 1;
        in.nextLine();
        char[] arr = in.nextLine().toCharArray();
        arr[k] = Character.toLowerCase(arr[k]);
        System.out.println(new String(arr));
    }
}


Measured memory_bytes: 21840
dict = Hash.new{|h,k| h[k] = 0}
n = gets.to_i
(1..n).each do
  str = gets.chomp
  dict[str] += 1
end

max = dict.max_by {|k, v| v}
filtered = dict.select {|k, v| v == max[1]}
strings = filtered.map {|arr| arr[0]}.sort

strings.each do |str|
  puts str
end


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

stations = []
for _ in range(n-1):
  stations.append(list(map(int, input().split())))

me = 0
for i in range(n-1):
  remain = n - i - 1
  time = 0
  for r in range(remain):
    c, s, f = stations[r+i]
    if time < s:
      time = s
    elif time % f == 0:
      pass
    else:
      time = time + f - (time % f)
    time += c
  print(time)
  
print(0)
  

Measured memory_bytes: 3188
S = input()
T = input()

def rotate(s):
  rotate_list = []
  for _ in range(len(s)):
    # 最後の文字を取り出す
    tmp = s[-1]
    # 残りとくっつける
    tmp = tmp + s[0:-1] 
    rotate_list.append( tmp )
    s = tmp
  return rotate_list

l = rotate(S)

if T in l:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
var
	i,j,a,b:Longint;
begin
	read(a,b);
	dec(a);
	dec(b);
	writeln('40 100');
	for i:=1 to 10 do begin
		for j:=1 to 50 do begin
			if a>0 then begin
				dec(a);
				write('#.');
			end else write('##');
		end;
		writeln;
		writeln('####################################################################################################');
	end;
	for i:=1 to 10 do begin
		writeln('....................................................................................................');
		for j:=1 to 50 do begin
			if b>0 then begin
				dec(b);
				write('#.');
			end else write('..');
		end;
		writeln;
	end;
end.

Measured memory_bytes: 128
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadIntArray();

            WriteAnswer(a[0] % a[1] == 0 ? 0 : 1);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int counter=0;
	for( int i=0 ; i<n ; i++ ){
		int x;
		cin >> x;
		if( x%2 == 1 )
			counter++;
	} 
	if( counter%2 == 0)
		cout<<"YES"<<endl;
	else 
		cout <<"NO"<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    char ch;
    int str[26] = {};

    while( cin >> ch ){
        ch = tolower(ch);
        if(isalpha(ch)){
            str[ch-'a']++;
        }
    }

    for( int i=0; i<26; i++){
        printf("%c : %d\n",i+'a',str[i]);
    }

    return 0;
}


Measured memory_bytes: 3172
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (r, g, b) = get!(i32, i32, i32);
    println!("{}", if (r*100+g*10+b) % 4 == 0 { "YES" } else { "NO" });
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for(int i = L; i <= R; i++) {
        if(i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<int> a(n);
    bool res = true;
    rep(i,n) cin >> a[i];
    rep(i,n) {
        if (a[i] %2 ==0){
            if (a[i] %3 != 0 and a[i] %5 !=0) {
            res = false;
            break;
        }
    }
    }
    if(res) cout << "APPROVED"<< endl;
    else cout << "DENIED"<< endl;
}


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


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

    if (A == 0) {
        cout << 0 << endl;
        return 0;
    }

    long long res = A * (N / (A + B));
    N %= (A + B);
    res += (N >= A) ? A : N % A;

    cout << res << endl;
    return 0;
}

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

static const int N = 1000;

int lcs(string x,string y){
    int c[N+1][N+1];
    int m = x.size(),n = y.size();
    int maxl = 0;
    x = " " + x;
    y = " " + y;
    for(int i = 0;i <= m;i++){
        c[0][i] = 0;
    }
    for(int j = 1;j <= n;j++){
        c[j][0] = 0;
    }
    for(int i = 1;i <= m;i++){
        for(int j = 1;j <= n;j++){
            if(x[i] == y[j])c[i][j] = c[i - 1][j - 1] + 1;
            else c[i][j] = max(c[i - 1][j],c[i][j - 1]);
            maxl = max(maxl,c[i][j]);
        }
    }
    return maxl;
}

int main(){
    string s1,s2;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
    return 0;
}


Measured memory_bytes: 7128
#include <stdio.h>

#define WIDTH_MAX 50
#define HEIGHT_MAX 50

int field[ WIDTH_MAX + 2 ][ HEIGHT_MAX + 2 ];
const int dx[ 8 ] = { -1, 0, 1, -1, 1, -1, 0, 1 }, dy[ 8 ] = { -1, -1, -1, 0, 0, 1, 1, 1 };

void del( int x, int y );

int main( void ) {
	int w, h, x, y, sum;

	for ( ; scanf( "%d %d", &w, &h ), w + h; printf( "%d\n", sum ) ) {
		for ( y = 1; y <= h; y++ )
			for ( x = 1; x <= w; x++ )
				scanf( "%d", field[ x ] + y );

		sum = 0;
		for ( y = 1; y <= h; y++ )
			for ( x = 1; x <= w; x++ )
				if ( field[ x ][ y ] == 1 ) {
					del( x, y );
					sum++;
				}

	}

	return 0;
}

void del( int x, int y ) {
	int i;

	field[ x ][ y ] = 0;

	for ( i = 0; i < 8; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( field[ nx ][ ny ] == 1 )
			del( nx, ny );
	}
}	

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

int main() {
	vector<vector<int>> A(3, vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A.at(i).at(j);
		}
	}

	int N;
	cin >> N;

	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b.at(i);
	}
	

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < N; k++) {
				if (A.at(i).at(j) == b.at(k)) {
					A.at(i).at(j) = 0;
				}
			}
		}
	}

	for (int i = 0; i < 3; i++) {
		int j = 0;
			if (A.at(i).at(j) == 0 && A.at(i).at(j + 1) == 0 && A.at(i).at(j + 2) == 0) {
				cout << "Yes" << endl;
				return 0;
		}
	
	}

	for (int j = 0; j < 3; j++) {
		int i = 0;
		if (A.at(i).at(j) == 0 && A.at(i + 1).at(j) == 0 && A.at(i + 2).at(j) == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	if (A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0) {
		cout << "Yes" << endl;
		return 0;
	}

	if (A.at(0).at(2) == 0 && A.at(1).at(1) == 0 && A.at(2).at(0) == 0) {
		cout << "Yes" << endl;
		return 0;
	}

	int count = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if(A.at(j).at(i) == 0){
				count++;
			}
		}
	}
	if (count == 9) {
		cout << "Yes" << endl;
		return 0;
	}

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

Measured memory_bytes: 256