akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    string S;
    cin >> S;

    vector<int> count_white(N + 1, 0);
    vector<int> count_black(N + 1, 0);

    for (int i = 1; i <= N; i++)
    {
        if (S[i - 1] == '.')
        {
            count_white[i] = count_white[i - 1] + 1;
            count_black[i] = count_black[i - 1];
        }
        else
        {
            count_white[i] = count_white[i - 1];
            count_black[i] = count_black[i - 1] + 1;
        }
    }

    int ans = N;
    for (int i = 0; i <= N; i++)
    {
        ans = min(ans, count_black[i] + (count_white[N] - count_white[i]));
    }
    cout << ans << endl;
}

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

int main(){
  int s;
  cin >> s;
  set<int> st;
  int x = s;
  while(st.count(x)==0){
    st.insert(x);
    if(x % 2 == 0){
      x /= 2;
    }
    else {
      x = 3*x +1;
    }
  }
  cout << st.size()+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    for(ll i=2; i<=n; i++){
        ans *= i;
        ans  = ans % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << '\n';
    return 0;
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
S = sum(a)
f, m = 0, 10**20
for i in range(N - 1):
    f += a[i]
    m = min(abs(S - 2 * f), m)
print(m)

Measured memory_bytes: 71632
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
bool st[10]; 
int main()
{
	for(int i=1;i<=5;i++)
	{
		int x;
		cin>>x;
		st[x]=1;
	}
	for(int i=1;i<=5;i++)
	{
		if(st[i]==0)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3604
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, K = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort()
    cur = 0
    for a, b in AB:
        if cur+b < K:
            cur += b
            continue
        else:
            return print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55244
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
int main()
{
    int i,k;
    string a,b;
    int  f=0;
    cin>>a>>b;
    if(a.size()==b.size())
    {
        if(a==b)
        cout<<"Yes"<<endl;
        else
        {
            k=a.size();
            while(k--)
            {
                char p=a[a.size()-1];
                for(i=a.size()-1;i>=0;i--)
                {
                    a[i+1]=a[i];
                }
                a[0]=p;
                if(a==b)
                {
                    f=1;
                    break;
                }
            }
            if(f==1)
            cout<<"Yes"<<endl;
            else
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int a[100010];
int sum[200010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    int normal = 0;
    rep(i, n - 1) normal += ((a[i + 1] + m - a[i]) % m);
    rep(i, n - 1) {
        if (a[i] > a[i + 1])
            sum[a[i] + 1]++;
        sum[a[i]+m + 1]++;
        sum[a[i + 1]+m + 1] += ((a[i + 1] + m - a[i]) % m) - 1;
        sum[a[i + 1]+m] -= ((a[i + 1] + m - a[i]) % m);
    }
    rep(j, 2) rep(i, m * 2) sum[i + 1] += sum[i];
    //rep(i, m * 2 + 1) cout << i << " " << sum[i] << endl;
    int ans = 0;
    REP(i, m, 2 * m) ans = max(ans, sum[i]);
    cout << normal - ans << endl;


    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  if(A>=13){
    cout<<B<<endl;
  }
  else if(6<=A && A<=12){
    cout<<B/2<<endl;
  }
  else if(5>=A){
    cout<<0<<endl;
  }
  return 0;
}


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

int main() {
  int64_t K,N;
  cin>>K>>N;
  vector<int64_t> a(2*N);
  for(int i=0;i<N;i++) {
    cin>>a[i];
    a[i+N]=a[i]+K;
  }
  int64_t ans=K;
  for(int i=0;i<N;i++)
    ans=min(ans,a[i+N-1]-a[i]);
  cout<<ans<<endl;
}
    

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>

typedef struct{
	double x,y;
} Point;

int koch(int n,Point p1,Point p2){
	Point s,t,u;
	double degree = M_PI / 3;
	if(n==0) return;
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x)*cos(degree) - (t.y - s.y)*sin(degree) + s.x;
	u.y = (t.x - s.x)*sin(degree) + (t.y-s.y)*cos(degree) + s.y;
	koch(n-1,p1,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,p2);
}


int main(){
	int n;
	Point p1,p2;
	
	scanf("%d",&n);
	
	p1.x = 0;
	p1.y = 0;
	p2.x = 100;
	p2.y = 0;
	
	printf("%.8f %.8f\n",p1.x,p1.y);
	koch(n,p1,p2);
	printf("%.8f %.8f\n",p2.x,p2.y);
	
	return 0;
}

Measured memory_bytes: 644
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int[] memo = new int[60];
	public void run(){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		calc(a, b, c);
	}
	public void calc(int a, int b, int c){
		int sum = c;
		int okita = 0;
		memo[okita] = 1;
		int neta = a;
		
		while(true){
			if(okita <= sum && sum <= neta){
				break;
			}
			else{
				okita += a+b;
				neta += a+b;
				if(memo[okita % 60]==1) {
					sum = -1;
					break;
				}
				else{
					if(okita > sum) sum += 60;
					memo[okita % 60] = 1;
				}
			}
		}
		System.out.println(sum);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

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

int main() {
    int H, W;
    cin >> H >> W;
    string A = "";
    for (int j = 0; j < W + 2; j++) {
        A += ".";
    }
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        A += S;
        A += ".";
    }
    for (int j = 0; j < W + 1; j++) {
        A += ".";
    }
    
    for (int i = 0; i < H; i++) {
        
        for (int j = 0; j < W; j++) {
            int cnt = 0;
            if (A.at((W+1)*(i+1)+j+1) == '.') {
                if (A.at((W+1)*i+j) == '#') cnt++;
                if (A.at((W+1)*i+j+1) == '#') cnt++;
                if (A.at((W+1)*i+j+2) == '#') cnt++;
                if (A.at((W+1)*(i+1)+j) == '#') cnt++;
                if (A.at((W+1)*(i+1)+j+1) == '#') cnt++;
                if (A.at((W+1)*(i+1)+j+2) == '#') cnt++;
                if (A.at((W+1)*(i+2)+j) == '#') cnt++;
                if (A.at((W+1)*(i+2)+j+1) == '#') cnt++;
                if (A.at((W+1)*(i+2)+j+2) == '#') cnt++;
                
                cout << cnt;
               
            }else cout << '#';
            
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
       
       //入力準備
       Scanner sc = new Scanner(System.in);
       
       //入力値の受け取り
       int x = sc.nextInt();
       
       //計算して出力
        System.out.println(x*x*x);
    }
}


Measured memory_bytes: 26140
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
s=max(x)
t=min(y)
if s<X and X+1<=Y and Y<t:
  print("No War")
elif X<s and s+1<=t and t<Y:
  print("No War")
elif s<X and X+1<=t and t<Y:
  print("No War")
elif X<s and s+1<=Y and Y<t:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
(let* ((s (reverse (cdr (reverse (concatenate 'list (read-line))))))
       (len (length s)))

  (defun f (l)
    (let ((lst1 (subseq l 0 (truncate (length l) 2)))
          (lst2 (subseq l (truncate (length l) 2))))

      (if (equal lst1 lst2)
        (length l)
        (f (reverse (cdr (reverse l)))))))

  (format t "~A~%"
          (f s)))



Measured memory_bytes: 25020
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("YES") if fl else print("NO")
import collections
import math
import itertools
import heapq as hq
import sys

n = ni()
def factorize(n):
    b = 2
    fct = [(1,1)]
    while b * b <= n:
        cnt =0
        while n % b == 0:
            n //= b
            cnt +=1
        if cnt >=1:
            fct.append((b,cnt))
        b = b + 1
    if n > 1:
        fct.append((n,1))
    return fct

co = collections.Counter()
for i in range(2,n+1):
    fct = factorize(i)
    for num,cnt in fct:
        if num>1:
            co[num]+=cnt
f4 = 0
f2 = 0
f14 = 0
f24=0
f74=0
for cnt in co.values():
    if cnt>=74:
        f74+=1
    if cnt>=24:
        f24+=1
    if cnt>=14:
        f14+=1
    if cnt>=4:
        f4+=1
    if cnt>=2:
        f2+=1



ans = f74 + f24*(f2-1) +f14*(f4-1)+f4*(f4-1)//2*(f2-2)

print(ans)


Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100000;

int N;
int A[MaxN + 5];
int pre[MaxN + 5], suf[MaxN + 5];

int main()
{
	while(scanf("%d", &N) != EOF)
	{
		memset(pre, 0, sizeof(pre));
		memset(suf, 0, sizeof(suf));
		for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
		pre[1] = A[1];
		for(int i = 2; i <= N; i++) pre[i] = __gcd(pre[i - 1], A[i]);
		suf[N] = A[N];
		for(int i = N - 1; i >= 1; i--) suf[i] = __gcd(suf[i + 1], A[i]);
		int ans = 0;
		for(int i = 1; i <= N; i++)
			ans = max(ans, __gcd(pre[i - 1], suf[i + 1]));
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s;
    cin >>s;
    //R, U, or D.L, U, or D
    int flag=0;
   for(int i=0;i<s.length();i++){
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D')
                continue;
            else {
                flag=1;
                break;
            }
        }
        else if(i%2){
            if(s[i]=='L'||s[i]=='U'||s[i]=='D')
                continue;
            else {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
   }
   if(flag)
    cout<<"No"<<endl;
   else
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
int M;
string S;
enum Color
{
  RED,
  BLUE,
  NONE,
};
map<pair<string, string>, int> cnt1, cnt2;
int main()
{
  cin >> N;
  cin >> S;
  M = S.size();
  for (int bit = 0; bit < (1 << N); bit++)
  {
    string red1, blue1;
    red1 = blue1 = "";
    string red2, blue2;
    red2 = blue2 = "";
    for (int i = 0; i < N; i++)
    {
      if (((bit >> i) & 1))
      {
        red1 += S[i];
        red2 += S[i + N];
      }
      else
      {
        blue1 += S[i];
        blue2 += S[i + N];
      }
    }
    reverse(blue2.begin(), blue2.end());
    reverse(blue1.begin(), blue1.end());
    cnt2[mp(red2, blue2)]++;
    cnt1[mp(red1, blue1)]++;
  }

  ll res = 0;
  for (const auto &val : cnt1)
  {
    string s1 = val.first.first;
    string s2 = val.first.second;
    int cnt1 = val.second;
    res += (ll)cnt1 * cnt2[mp(s2, s1)];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 103424
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 

#define int long long 

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


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

	n %=10;

	switch(n) {
		case 0 : cout << "pon"; break;
		case 1 : cout << "pon"; break;
		case 2 : cout << "hon"; break;
		case 3 : cout << "bon"; break;
		case 4 : cout << "hon"; break; 
		case 5 : cout << "hon"; break;
		case 6 : cout << "pon"; break;
		case 7 : cout << "hon"; break;
		case 8 : cout << "pon"; break;
		case 9 : cout << "hon"; break;
	}
}	

int32_t main() {
 

    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3652
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> ip(N);
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x; --x;
		ip[x] = i;
	}
	int cont = 1, ans = 1;
	for (int i = 1; i < N; ++i) {
		if (ip[i - 1] < ip[i]) {
			++cont;
			ans = max(ans, cont);
		}
		else {
			cont = 1;
		}
	}
	cout << N - ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int INF=1e9;
int e,v,r;
int to[100000],from[100000],w[1000000],d[1000000];
bool relax(int e){
	if(d[to[e]]>d[from[e]]+w[e] && d[from[e]]!=INF){
		d[to[e]]=d[from[e]]+w[e];
		return 1;
	}
	return 0;
}
int main(){
	cin>>v>>e>>r;
	fill(d,d+v,INF);
	for(int i=0;i<e;i++){
		cin>>from[i]>>to[i]>>w[i];
	}
	d[r]=0;
	for(int i=0;i<v;i++){
		for(int j=0;j<e;j++){
			bool o=relax(j);
			if(i==v-1 && o==true){
				cout<<"NEGATIVE CYCLE"<<endl;
				return 0;
			}
		}
	}
	for(int i=0;i<v;i++){
		if(d[i]!=INF){
			cout<<d[i]<<endl;
		}
		else{
			cout<<"INF"<<endl;
		}
	}
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ll N, P; cin >> N >> P;

    string S; cin >> S;
    ll ans = 0;

    if(P == 2 || P == 5){
        rep(i, N){
            if((S[i]-'0') % P == 0) ans += i+1;
        }
    }
    else{
        reverse(S.begin(), S.end());
        ll pmod[10][N];
        rep(i, 10) pmod[i][0] = i % P;
        for(int i = 0; i < 10; i++){
            for(int j = 1; j < N; j++){
                pmod[i][j] = pmod[i][j-1]*10 % P;
            }
        }

        map<int, ll> mp;
        ll A[N];
        A[0] = (S[0]-'0') % P;
        for(int i = 1; i < N; i++){
            int val = S[i]-'0';
            A[i] = (A[i-1] + pmod[val][i]) % P;
        }
        rep(i, N){
            if(mp.count(A[i])) mp[A[i]]++;
            else mp[A[i]] = 1;
        }
        if(mp.count(0)) ans += mp[0];
        rep(i, N){
            ans += mp[A[i]]-1;
            mp[A[i]]--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18180
#D
#モジュール
import numpy as np

#入力
N,K=map(int,input().split())
P=np.array(list(map(int,input().split())))

#諸関数
def pront(X):
    #デバッグ用プリント
    #環境変数としてdebugを確保して、それが1なら内容を出力
    if debug==0:
        print(X)

#デバッグ用
debug=1#0:本番,1:デバッグ中



#処理
pront(P)
#関数
def d_1(p):
    #1~pまででるサイコロの期待値を返す
    return((p+1)/2)
#ここまで

P=list(d_1(P))

pront(P)

X=[0]
for i in range(N):
    if i==0:
        X.append(P[i])
    else:
        X.append(P[i]+X[-1])
result=-1
pront(X)
for i in range(N-K+1):
    cal=X[i+K]-X[i]
    if result<cal:
        result=cal
print(result)
    

Measured memory_bytes: 33992
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    a = makeInt(input_string[0])
    return 180 * (a - 2)


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


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

ll dp[3005][3005][4];

int main(){
    rep(i,3005) rep(j,3005) rep(k,4) dp[i][j][k] = 0;
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<ll>> v(3005, vector<ll>(3005));
    rep(i,k){
        int r, c;
        ll k;
        cin >> r >> c >> k;
        v[r][c] = k;
    }

    rep(i,r+1) rep(j,c+1){
        rep(l,4) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][l]);
        rep(l,4) dp[i][j+1][l] = max(dp[i][j+1][l], dp[i][j][l]);
        if(v[i][j] != 0){
            rep(l,3) dp[i][j+1][l+1] = max(dp[i][j+1][l+1], dp[i][j][l]+v[i][j]);
        }
        if(v[i][j] != 0){
            rep(l,3) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][l]+v[i][j]);
        }
    }
    ll ans = 0;
    rep(i,4) ans = max(ans, dp[r][c+1][i]);
    rep(i,4) ans = max(ans, dp[r+1][c][i]);
    cout << ans << endl;
}

Measured memory_bytes: 356140
#include<bits/stdc++.h>
#define ll long long

using namespace std;



	

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

	int n;cin>>n;
	while(n)
	{
		if(n % 10 == 7)
		{
			cout<<"Yes";
			break;
		}
		n /= 10;
		
	
	}

	if(n == 0)
		cout<<"No";

	return 0;
	
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < (int)t.size(); i++) cout << s[i] << t[i];
  if (s.size() > t.size()) cout << s.back();
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[10];
	int n, ac = 0, wa = 0, tle = 0, re = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> s;
		if (strcmp("AC", s) == 0)
			ac++;
		else if (strcmp("WA", s) == 0)
			wa++;
		else if (strcmp("TLE", s) == 0)
			tle++;
		else if (strcmp("RE", s) == 0)
			re++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);
	return 0;
}

Measured memory_bytes: 3760
from collections import deque
import sys
input = sys.stdin.readline

class Graph(): #non-directed
    def __init__(self,n,edge):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.deg = [0 for _ in range(n)]
        for e in edge:
            self.graph[e[0]-1].append(e[1]-1)
            self.graph[e[1]-1].append(e[0]-1)
            self.deg[e[0]-1] += 1
            self.deg[e[1]-1] += 1
    def BFS(self,s):
        dist = [None for _ in range(self.n)]
        dist[s] = 0
        queue = deque([s])
        self.par = [None for _ in range(self.n)]
        while queue:
            node = queue.popleft()
            for adj in self.graph[node]:
                if dist[adj] is not None:
                    continue
                dist[adj] = dist[node]+1
                self.par[adj] = node
                queue.append(adj)
        return dist

N, M = map(int, input().split())
E = [tuple(map(int, input().split())) for _ in range(M)]

G = Graph(N, E)

G.BFS(0)
res = list()

print('Yes')

for i in range(N):
    if i == 0:
        continue
    res.append(G.par[i] + 1)

print('\n'.join(map(str, res)))

Measured memory_bytes: 135584
n=int(input())
t=list(map(int,input().split())) #かかる時間
m=int(input())
a=0
for i in range(m):
    p,x=map(int,input().split()) #pは問題番号,xは時間
    a=t[p-1]
    t[p-1]=x
    print(sum(t))
    t[p-1]=a

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int dp[270000],n,q,r,x,y,i;
int m(int l,int r,int k){
	if(x<=l&&r<=y)return dp[k];
	if(y<=l||r<=x)return 2147483647;
	return min(m(l,(l+r)/2,k*2+1),m((l+r)/2,r,k*2+2));
}
int main(){
	cin>>n>>q;
	r=2;while(r<n)r*=2;n=r,r*=2;
	while(r--)dp[r]=2147483647;
	while(q--){cin>>r>>x>>y;
		if(r){y++;cout<<m(0,n,0)<<endl;}
		else{
			i=x+n-1,dp[i]=y;
			while(i)i=(i-1)/2,dp[i]=min(dp[i*2+1],dp[i*2+2]);
		}
	}
	return 0;
}

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

int main() {
    string S;
    ll K;
    cin >> S >> K;
    int cnt1;
    rep(i,S.size()) {
        if (S.at(i) != '1') {
            cnt1 = i;
            break;
        } else if (i == S.size() - 1) {
            cnt1 = S.size();
        }
    }
    if (K <= cnt1) {
        cout << 1 << endl;
    } else {
        cout << S.at(cnt1) << endl;
    }
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int dp[50010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<int> c(m); rep(i, 0, m) { cin >> c[i]; }
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	rep(i, 0, m) {
		rep(j, 0, n + 1) {
			if (j + c[i] > n)continue;
			chmin(dp[j + c[i]], dp[j] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

void input(int& rnDivisor)
{
  cin >> rnDivisor;
}

int calcDigit(int nDivisor)
{
  set<int> seRemain;

  int nDividend = 7;
  int nDigit = 1;
  int nRemain = nDividend % nDivisor;

  while ( seRemain.count(nRemain) == 0 )
  {
    seRemain.insert(nRemain);
    if (!nRemain)
      return nDigit;

    nDividend = nRemain * 10 + 7;
    nRemain = nDividend % nDivisor;
    nDigit++;
  }
  return -1;
}
 
int main()
{
  int nDivisor;

  input(nDivisor);
  cout << calcDigit(nDivisor) << endl;

  return 0;
}

Measured memory_bytes: 50460
#include <time.h>
 
#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;
const ll mod = 1000000007;
int main(){
	string s;
	cin>>s;
	bool ans=false;
	for(ll i1=0;i1<3;i1++){
		char t = s[i1];
		if(t=='7'){
			ans=true;
		}
	}
	if(ans){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

int main(){
    int n;
    cin >> n;
    int d[100];
    int count=1;
    for(int i=0;i<n;i++)cin >> d[i];
    sort(d,d+n);
    for(int i=0;i<n-1;i++){
        if(d[i]!=d[i+1])count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main(){
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)cout<<1;
    if(b==0)cout<<2;
    if(c==0)cout<<3;
    if(d==0)cout<<4;
    if(e==0)cout<<5;
}



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

using namespace std;

typedef long long ll;

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

	ll n, k;
	cin >> n >> k;

	// r, s, p
	ll score[3]; 
	cin >> score[0] >> score[1] >> score[2];

	string s;
	cin >> s;

	string spr = "spr";

	ll ans = 0;
	for(int a = 0; a < k; a++){
		ll dp[n / k + 10][3];
		rep(i, n / k + 10) rep(j, 3) dp[i][j] = 0;
		for(int j = 0; j < 3; j++){
			if(s[a] == spr[j]) dp[0][j] += score[j];
		}

		int last = 0;
		int idx = a + k;
		for(; idx < n; idx += k){
			int i = idx / k;
			last = idx;
			for(int j = 0; j < 3; j++){
				for(int l = 0; l < 3; l++){
					if(j == l) continue;
					if(s[idx] == spr[j]) dp[i][j] = max(dp[i][j], dp[i-1][l] + score[j]);
					else dp[i][j] = max(dp[i][j], dp[i-1][l]);
				}
			}
		}

		ans += max({dp[last/k][0], dp[last/k][1], dp[last/k][2]});
	}

	cout << ans << endl;
}


Measured memory_bytes: 2768
def main():
    n = int(input())
    t, a = map(int, input().split())
    ans = 0
    x = 100000
    for i, h in enumerate(map(int, input().split())):
        temp = abs(a - (t - h * 0.006))
        if temp < x:
            x = temp
            ans = i+1

    print(ans)

main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>

using namespace std;


int main(){
	int a,b;
	
	cin >> a >> b;
	
	if(a > b)cout << "safe" << endl;
	else cout << "unsafe" << endl;
	
	return 0;
}

Measured memory_bytes: 3632
H,W = map(int,input().split())

ans = 10**18
#fix H
for w in range(1,W):
    first_area = H*w
    if (W-w)%2 == 0:
        second_area = (W-w)*H//2
        third_area = (W-w)*H//2
    else:
        second_area = (W-w)//2*H
        third_area = (1+(W-w)//2)*H
    diff = max(first_area,second_area,third_area)-min(first_area,second_area,third_area)
    if diff < ans:
        ans = diff
    if H%2 == 0:
        second_area = H//2*(W-w)
        third_area = H//2*(W-w)
    else:
        second_area = H//2*(W-w)
        third_area = (H//2+1)*(W-w)
    diff = max(first_area,second_area,third_area)-min(first_area,second_area,third_area)
    if diff < ans:
        ans = diff
#fix W
for h in range(1,H):
    first_area = W*h
    if (H-h)%2 == 0:
        second_area = (H-h)*W//2
        third_area = (H-h)*W//2
    else:
        second_area = (H-h)//2*W
        third_area = (1+(H-h)//2)*W
    diff = max(first_area,second_area,third_area)-min(first_area,second_area,third_area)
    if diff < ans:
        ans = diff

    if W%2 == 0:
        second_area = W//2*(H-h)
        third_area = W//2*(H-h)
    else:
        second_area = W//2*(H-h)
        third_area = (W//2+1)*(H-h)
    diff = max(first_area,second_area,third_area)-min(first_area,second_area,third_area)
    if diff < ans:
        ans = diff
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<climits>
#include<cmath>

using namespace std;
int fun(vector<int> &a,vector<int> &b,vector<int> &c,int i,char p)
{
    if(i<0)
        return 0;
    
    int x,y,z;
    x=y=z=INT_MIN;
    if(p != 'a')
        x = a[i] + fun(a,b,c,i-1,'a');
    if(p != 'b' )
        y = b[i] + fun(a,b,c,i-1,'b');
    if(p != 'c')
        z = c[i] + fun(a,b,c,i-1,'c');
    
    return max(x,max(y,z));
}

int bottomup(vector<int> &a,vector<int> &b,vector<int> &c,int n)
{
    vector<vector<int>> dp(3,vector<int>(n,0));
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
                dp[j][i] = a[i] +  max(dp[1][i-1],dp[2][i-1]);
            else if(j==1)
                dp[j][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
            else if (j==2)
                dp[j][i] = c[i] + max(dp[0][i-1],dp[1][i-1]);
        }
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=0;j<3;j++)
    //     {
    //         cout<<dp[j][i]<<" ";
    //     }
    //     cout<<"\n";
    // }
    return max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}
int main()
{
    int n{};
    cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    //int ans = fun(a,b,c,n-1,'d');
    //cout<<ans;
    int ans2 = bottomup(a,b,c,n);
    cout<<ans2;
    return 0;
}

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

using namespace std;

int main() {
  int r, D;
  int64_t X;
  cin >> r >> D >> X;
  for (int i = 0; i < 10; i++) {
    X = X * r - D;
    cout << X << endl;
  }

  return 0;
}


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

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a == c-b) puts("YES\n");
    else puts("NO\n");
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>

using namespace std;
vector<string> word;


int main() {
	//input
	int n;
	cin >> n;

	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		string tmp;
		cin >> tmp;
		word.push_back(tmp);
	}

	//重複の確認
	for (int i = 0; i < word.size() - 1; ++i) {
		for (int j = i+1; j < word.size(); ++j) {
			if (word.at(i) == word.at(j)) {
				cout << "No" << endl;
				cnt++;
				return 0;
			}
		}
	}
	//前後の確認
	for (int i = 0; i < word.size() - 1; ++i) {
		string tmp2 = word.at(i);
		char bef = tmp2[tmp2.size() - 1];
		string tmp3 = word.at(i + 1);
		char aft = tmp3[0];
		if (bef != aft) {
			cout << "No" << endl;
			cnt++;
			return 0;
		}
	}


	if (cnt == 0) {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/**
* ============================
* stay hungry stay foolish
* @Author:pubgoso
* @DateTime: 2019-04-06 19:38:04
* ============================
*/
#include<bits/stdc++.h>

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,a[N],k;
int main(){
	ios::sync_with_stdio(false);
	for(int i=1;i<=5;i++)cin>>a[i];
	cin>>k;
	for(int i=1;i<=4;i++){
		for(int j=i+1;j<=5;j++){
			if(a[j]-a[i]>k)return cout<<":(",0;
		}
	}
	cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 256
def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))

    kti = [0] * n
    sm = [0] * (n)
    for i,pp in enumerate(p):
        kti[i] = (pp + 1) / 2
        if i == 0:
            sm[0] = kti[0]
        else:
            sm[i] = sm[i-1] + kti[i]

    ans = sm[k-1]
    j = 0
    for i in range(k,len(sm)):

        tmp = sm[i]-sm[j]
        ans = max(ans,tmp)
        j += 1
    print(ans)
    
if __name__=='__main__':
    main()


Measured memory_bytes: 25060
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <bitset> 

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk

const int MAXN = 105;
const int BTS = 30000;
const int offset = 15000;

int n, m;
int a[MAXN][MAXN];
bitset<BTS> dp[2][MAXN];

int main() { 

  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  int x;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &x);
      a[i][j] = abs(a[i][j] - x);
    }
  }

  int cur = 0, prev = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp[cur][j].reset();
      if (i == 0 && j == 0) {
        dp[cur][j][offset + a[i][j]] = true;
        dp[cur][j][offset - a[i][j]] = true;
      } else {
        if (j > 0) {
          dp[cur][j] |= (dp[cur][j - 1] >> a[i][j]);
          dp[cur][j] |= (dp[cur][j - 1] << a[i][j]);
        }
        if (i > 0) {
          dp[cur][j] |= (dp[prev][j] >> a[i][j]);
          dp[cur][j] |= (dp[prev][j] << a[i][j]);
        }
      }
    }
    cur = 1 - cur; prev = 1 - cur;
  }

  cur = 1 - cur;
  string res = dp[cur][m - 1].to_string();
  reverse(all(res));

  int ans = (int) 1e9;

  for (int i = 0; i < BTS; i++) {
    int cur = i - offset;
    if (cur < 0) {
      cur = -cur;
    }
    if (res[i] == '1') {
      ans = min(ans, cur);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=17;

ll dp[1<<maxn],a[maxn][maxn]; 
int n;

int main(){
	for(int i=0;i<(1<<maxn);i++) dp[i]=0ll;
	cin>>n;
	for(int i=0;i<n;i++) a[i][i]=0ll;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int mask=0;mask<(1<<n);mask++){
		vector <int> v;
		for(int i=0;i<n;i++) if(mask&(1<<i)) v.pb(i);
		for(int i=0;i<v.size();i++) for(int j=i+1;j<v.size();j++)
			dp[mask]+=a[v[i]][v[j]];
	}
//	for(int mask=0;mask<(1<<n);mask++) cout<<dp[mask]<<" "; cout<<endl;
	for(int mask=0;mask<(1<<n);mask++) dp[mask]=max(dp[mask],0ll);
//	for(int mask=0;mask<(1<<n);mask++) cout<<dp[mask]<<" "; cout<<endl;
//	cout<<dp[5]<<" "<<dp[2]<<endl;
	for(int msk=0;msk<(1<<n);msk++){
		int x=-1;
		for(int i=0;i<n;i++) if(msk&(1<<i)){
			x=i; break;
		}
		if(x==-1) continue;
		int msk2=((1<<n)-1)^msk^(1<<x),msk3=0,flag=0;
		for(int i=n-1;i>=0;i--){
			if(!(msk2&(1<<i))) flag=1;
		//	cout<<(msk&(1<<i))<<" "<<flag<<endl;
			if(flag&&(!(msk2&(1<<i)))) msk3|=(1<<i);
		}
	//	cout<<msk2<<" "<<msk3<<endl;
		for(int msk4=msk3;msk4;msk4=(msk4-1)&msk3){
			int msk5=msk4|(1<<x);
			dp[msk]=max(dp[msk5]+dp[msk^msk5],dp[msk]);	
		//	cout<<msk<<" "<<dp[msk]<<" "<<dp[msk5]+dp[msk^msk5]<<endl;
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}



Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
import sys

N,M = list(map(int, input().rstrip().split()))
#-----

divisor = 10**9 + 7

cnt=1
diff = abs(N-M)
if diff >=2:
    print("0")
    sys.exit()
else:
    for num in [N,M]:
        for i in range(1,num+1):
            cnt = (cnt * i) % divisor

    if diff == 0:
        cnt = (cnt * 2) % divisor

print(cnt)


Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int N;
  std::cin >> N;

  const int n3 = N / 100;

  if ((n3 * 111) - N >= 0) {
    std::cout << (n3 * 111) << std::endl;
  } else {
    std::cout << ((n3 + 1) * 111) << std::endl;
  }
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  vector<ll> A(N+1);
  for(int i(1);i<=N;i++) cin>>A[i];
  vector<ll> ans(N+1);
  ll x1(0);
  for(int i(2);i<=N;i++){
    x1 ^= A[i];
  }
  ans[1] = x1;
  for(int i(2);i<N;i++){
    ans[i] = A[i-1]^A[i]^ans[i-1];
  }
  ans[N] = ans[1]^A[1]^A[N];
  for(int i(1);i<=N;i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 6420
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
// gcd: 最大公約数, lcm: 最小公倍数
template<typename T>
T euclidean(T a, T b){
    if(a < b) swap(a, b);
    T r = a % b;
    while(r != 0){
        a = b; b = r; r = a % b;
    }
    return b;
}
template<typename T>
T gcd(T a, T b){
    return euclidean(a, b);
}

template<typename T>
T lcm(T a, T b){
    T g = gcd(a, b);
    return a / g * b;
}
/*************** using variables **************/

/**********************************************/

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

    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3188
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    print(input()[::2])


main()


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

int main(){
    ll N,M;string S,T;cin>>N>>M>>S>>T;
    ll p=N,q=M;
    if(p<q)swap(p,q);
    while(q){
        p%=q;
        swap(p,q);
    }
    ll L=N/p*M;
    for(ll i=0;i<L;i+=L/N){
        if(i%(L/M)==0 and S.at(i/(L/N))!=T.at(i/(L/M))){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<L<<endl;
    return 0;
}

Measured memory_bytes: 512
# AとBに値を、opに"+"か"-"の記号を入力
A,op,B = input().split()
# AとBを整数に変換
A = int(A)
B = int(B)
# 記号が+ならA+B、記号が-ならA-B
if op == "+":
    print(A + B)
else:
    print(A - B)

Measured memory_bytes: 9060
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		int prev = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (prev < x) {
		        count += x - prev;
		    }
		    prev = x;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
fun main(args: Array<String>) {
    // Your code here!
    var input = readLine()!!.split(" ").map{x->x.toDouble()}
    var ans = input[1]
    if(input[0]!=1.0) println((input[1] * Math.pow(ans-1,input[0]-1)).toLong())
    else println(input[1].toInt())
    
}


Measured memory_bytes: 35960
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

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

string X, Y;
string ans;

string Ans() {
  if (X < Y) {
    return "<";
  } else if (X > Y) {
    return ">";
  } else {
    return "=";
  }
}

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

  ans = Ans();

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


Measured memory_bytes: 256
N = int(input())

D={}
L = [0]*N
for i in range(N):
    L[i]=input()
    if D.get(L[i],None)==None:
        D[L[i]]=1
    else:
        D[L[i]]+=1
D = sorted(D.items(),reverse=True,key=lambda x:x[1])
n=D[0][1]
s=""

List=[]
for i in range(len(D)):
    if(D[i][1]==n and D[i][0]!=s):
        List.append(D[i][0])
        s=D[i][0]
List=sorted(List)

for l in List:
    print(l)

Measured memory_bytes: 44884
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.es", "r", stdin);
	string str = "";

	while ( getline (cin, str ) ){

		map <string, int> freq, leng;
		if (str.find('.') != string::npos){
			str = str.erase (str.find('.'), 1);
		} // end if
		stringstream ss(str);
		string s = "";

		while (ss >> s){
			++freq[s];
			leng[s] = s.length();
		} // end while

		if (freq.size() == 2){
			cout << "The two words separated by a space." << endl;
			continue;
		} // end if		
		if (!freq.empty() && !leng.empty() ){ 
			multimap <int, string, greater<int> > rank;
			map <string, int>::iterator itf = freq.begin();
			for (; itf != freq.end(); ++itf){
				rank.insert (make_pair ((*itf).second, (*itf).first ) );
			} // end for
			multimap<int, string, greater<int> > mlen;
			map<string, int>::iterator itl = leng.begin();
			for (; itl != leng.end(); ++itl){
				mlen.insert (make_pair ((*itl).second, (*itl).first ) );
			} // end for
			multimap<int, string, greater<int> >::iterator itr = rank.begin();
			multimap<int, string, greater<int> >::iterator itm = mlen.begin();
			cout << (*itr).second << ' ' << (*itm).second << endl;
		} // end if
	} // end while
		
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
from collections import Counter

n = int(input())
(*a, ) = map(int, input().split())
c = Counter(a)
b = 0
for i in c.keys():
    b ^= i
if sum(a) == 0 or (b == 0 and all(i * 3 == n for i in c.values())):
    print("Yes")
elif len(c) == 2 and c.most_common()[0][1] * 3 == 2 * n and c.most_common(
)[1][0] == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 20648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    char a;
    cin >> a;
    if('a' <= a && a <= 'z'){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
  int w,h,i,j;
  while(1)
       {
  scanf("%d%d",&w,&h);
  if(w==0&&h==0){break;}
 
  for(i=1;i<=w;i++)
    {
      for(j=1;j<=h;j++)
    {
      if(i>1&&i<w&&j<h&&j>1)printf(".");
      else printf("#");
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}
 

  

 



Measured memory_bytes: 2048
import io.StdIn._

object Main extends App {

  val line = readLine.split(" ").map(_.toInt)
  val N = line(0) // >= 1 && <= 10^9
  val K = line(1) // >= 2 && <= 10

  // 2 ^ 40 = 1,099,511,627,776
  val A = Range(1, 41).find { i =>
    N <= math.pow(K, i) - 1
  }

  println(A.get)
}


Measured memory_bytes: 25412
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt();
        scanner.nextLine();
        final String s = scanner.nextLine();
        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void)
{
    while (1) {
        int n, m, p, i, t, s=0;
        scanf("%d%d%d", &n, &m, &p);
        if ((n|m|p)==0) break;

        for(i=1;i<=n;++i) {
            int x;
            scanf("%d", &x);
            s+=x;
            if (i==m) t=x;
        }
        printf("%d\n", t ? (int)(s*100.*(100-p)/100./t) : 0);
    }
    return 0;
}

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

const long mod = 1e9+7;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)

int main() {
    int N;
    int a;
    cin >> N;
    vector<int> A;
    REP(i, N) {
        cin >> a;
        A.push_back(a);
    }
    int init = 0;
    if (N % 2 == 0) {
        init = 1;
    }
    sort(A.begin(), A.end());
    for (int i = init; i <= N; i += 2) {
        if (N==1){
            cout << 1 << endl;
            return 0;
        } else if (i != 0) {
            if (A[i - 1] != A[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    long out = 1;
    REP(i, N / 2) out = out * 2 % mod;
    cout << out << endl;
    return 0;
}

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

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


int main() {
    int a, b;
    cin >> a >> b;
    string p = "Positive", n = "Negative", z = "Zero";
    if (a <= 0 && b >= 0)cout << z << endl;
    else if (a > 0)cout << p << endl;
    else if (a < 0) {
        if (b < 0) {
            if (((abs(a - b)) + 1) % 2 == 0)cout << p << endl;
            else cout << n << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256