akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int H,W,M;
    cin >> H >> W >> M;
    vector<int> h(H),w(W);
    set<P> s;
    rep(i,M) {
        int r,c;
        cin >> r >> c;
        --r; --c;
        h[r]++;
        w[c]++;
        s.emplace(r,c);
    }
    int mh = 0, mw = 0;
    rep(i,H) mh = max(mh,h[i]);
    rep(i,W) mw = max(mw,w[i]);
    vector<int> is,js;
    rep(i,H) if(mh==h[i]) is.push_back(i);
    rep(i,W) if(mw==w[i]) js.push_back(i);
    int ans = mh+mw;
    for(int i : is){
        for(int j : js){
            if(s.count({i,j}))continue;
            cout << ans << endl;
            return 0;
        }
    }
    cout << --ans << endl;



    
    return 0;
}

Measured memory_bytes: 23764
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	String b = stdIn.next();
	String[] B={"A","C","G","T"};
	String[] T={"T","G","C","A"};
	for(int i=0;i<4;i++){
	    if(b.equals(B[i])){
		System.out.println(T[i]);
	    }
	}
    }
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(A, (a, b) => b.CompareTo(a));
        long sum = 0;
        for (int i = 1; i < N; ++i) { sum += A[i / 2]; }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 43440
import java.util.HashMap;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		HashMap<Integer,Integer> hs=new HashMap<Integer,Integer>();
		for(int i=0;i<n;i++){
			int buf=sc.nextInt();
			if(hs.containsKey(buf)){
				hs.put(buf, hs.get(buf)+1);
			}
			else{
				hs.put(buf, 1);
			}
		}
		boolean is=true;
		int m=sc.nextInt();
		int[] t=new int[m];
		for(int i=0;i<m;i++){
			int buf=sc.nextInt();
			if(hs.containsKey(buf)){
				int b=hs.get(buf);
				if(b==1){
					hs.remove(buf);
				}else{
					hs.put(buf, b-1);
				}
			}
			else{
				is=false;
			}
		}

		if(is){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 134812
n = int(input())
s = [list(input()) for i in range(n)]
s += s

def ok(array):
    for i in range(1,n):
        for j in range(i):
            if array[i][j] != array[j][i]:
                return False
    return True
ans = 0
for i in range(n):
    if ok(s[i:i+n]):
        ans += n
print(ans)


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i ,n) cin >> l[i];

  int d = 0;
  int c = 1;
  rep(i, l.size()) {
    d += l[i];
    if(d<=x) {
      ++c;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a, b, c}) << " " << max({a, b, c}) << endl;
    return 0;
}




Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int l[2*n];
	for( int i=0;i<2*n;i++)
		cin>>l[i];
	sort(l,l+2*n);
	long int count=0;
	for( int i=0;i<2*n;i=i+2)
	{
		count+=l[i];
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair <string, int>
using namespace std;

int main() 
{
	int n, m;
	cin >> n >> m;
	int sw[10][10], num[m], p[m];
	for (int i = 0; i < m; i++)
	{
		cin >> num[i];
		for (int j = 0; j < num[i]; j++) {cin >> sw[i][j]; sw[i][j]--;}
	}
	for (int i = 0; i < m; i++) cin >> p[i];
	
	int count = 0;
	for (int i = 0; i < (1 << n); i++)
	{
		int temp[n] = {}, tcount = 0, mew = i;
		
		for (int j = 0; j < n; j++, mew /= 2)
			temp[n - 1 - j] = (mew & 1);
		
		for (int j = 0; j < m; j++)
		{
			int tc = 0;
			for (int k = 0; k < num[j]; k++) if (temp[sw[j][k]]) tc++;
			if (tc % 2 == p[j]) tcount++;
		}
		
		if (tcount == m) count++;
	}
	cout << count;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,j,t,flag=1,count=0,N,A[100]={};

	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	while(flag){
		flag=0;
		for(j=N-1;j>0;j--){
			if(A[j]<A[j-1]){
				t=A[j];
				A[j]=A[j-1];
				A[j-1]=t;
				count++;
				flag = 1;
			}
		}
	}

	for(i=0;i<N-1;i++) printf("%d ",A[i]);
	printf("%d\n",A[N-1]);
	printf("%d\n",count);	
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll f = 0;
    vec a(2, 0);
    DESC(A);
    REP(i,0,N-1) {
        if(A[i] == A[i+1]) {
            a[f] = A[i];
            ++f;
            ++i;
            if(f == 2) break;
        }
    }
    PR(a[0]*a[1]);
    

    return 0;
}

/*



*/

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

ans = 0
hyou = [0] * H
for i in range(H):
    hyou[i] = input()

for h in range(1 << H):
    for w in range(1 << W):
        count = 0
        for i in range(H):
            if(h >> i) % 2 == 1:
                continue
            for j in range(W):
                if(w >> j) % 2 == 1:
                    continue
                count += hyou[i][j] == "#"
        ans += count == K

print(ans)


Measured memory_bytes: 9152
#include<stdio.h>
#define N 100
main(){
  int n,A[N],i,j,l,key;
  scanf("%d",&n);
  for(i = 1; i <= n; i++)scanf("%d",&A[i-1]);
  for(i = 1; i <= n; i++){
    for(l = 1; l < n; l++)printf("%d ",A[l-1]);
    printf("%d\n",A[n-1]);
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<vector>
#include<iostream> //c++
#include<algorithm>
/*
int main(){
	int a=0;
	char A[5];
	for (int i = 0; i < 5; i++) {
		scanf("%c\n", &A[i]);
	}
	
	for(int i = 0; i < 5; i++) {
		if (A[i] =='A' &&A[i + 1]=='C') {
			a = 1;
		
		}
	}
	if (a == 1) {
		printf("Yes");

	}
	else {
		printf("No");
	}
}*/

using namespace std;
/*int main() {
	int g;
	int  N,Num=0;
	vector<int>a;
	cin >> N;
	for (int i = 0; i < N;i++) {

		cin >> g;

		a.push_back(g);
	

	}
	int t,p=0;
	while (true) {
		t=a[p] ;
		a[p] = -1;
		p = t;
		if (p == -1) {
			Num = -1;
			break;
		}
			Num++;
			if (p == 2) {
				break;
			}
			p = p - 1;
	}
	cout << Num;
	

}*/

int main() {
	long long N,g;
	vector<int>a;
	cin >> N;
	for (int i = 0; i< N; i++) {
		cin >> g;
		a.push_back(g);
	}
	sort(a.begin(), a.end());
	long long Num1=0,Num2=0,Num;
	for (int i = 0; i < N; i++)
	{
		if (a[i] == a[i + 1] && a[i] >= Num1&&i!=N-1) {
			Num2 = Num1;
			Num1 = a[i];
			i++;
		}
	}
	Num = Num1 * Num2;
	cout << Num;
	return 0;
}

Measured memory_bytes: 892
N, K = map(int, input().split())

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

is_first_visit = [True for i in range(N)]

now_city = 1
visited_history = []
num_to_visit = K

is_finished = False

while is_first_visit[now_city-1]:
    is_first_visit[now_city-1] = False
    visited_history.append(now_city)
    now_city = A[now_city-1]
    num_to_visit -= 1
    
    if num_to_visit == 0:
        is_finished = True
        break

if is_finished:
    print(now_city)
else:
    loop_route = visited_history[visited_history.index(now_city):]
    loop_length = len(loop_route)

    print(loop_route[loop_route.index(now_city) + (num_to_visit % loop_length)])

Measured memory_bytes: 32404
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int W = nextInt();
        int dp[] = new int[100001];
        Arrays.fill(dp, 1000000001);

        int ans = 0;
        for (int i = 1; i <= N; i++) {
            int wi = nextInt();
            int vi = nextInt();
            for (int j = 100000; j >= 0; j--) {
                if (j <= vi) {
                    dp[j] = Math.min(dp[j], wi);
                } else {
                    dp[j] = Math.min(dp[j], dp[j-vi]+wi);
                }

                if (dp[j] <= W) {
                    ans = Math.max(ans, j);
                }
            }
        }
        System.out.println(ans);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
}


Measured memory_bytes: 23124
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;




#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);


ll N, K, C[100005];
ll best[100005];
int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		cin >> N >> K;
		F0R(i, N) cin >> C[i + 1];


		for (int i = 1; i <= N; i++) best[i] = INF;

		best[1] = 0;
		for (int i = 1; i <= N; i++) {
				for (int j = 1; j <= K; j++) best[i + j] = MIN(best[i + j], best[i] + abs(C[i + j] - C[i]));
		}
		cout << best[N] << endl;
}


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

int main() {
  int A , B ; 
  cin >> A >> B ; 
  int outlet = 1; 
  int cnt = 0 ; 

  while( B > outlet  ){
	outlet-- ;
    outlet += A ; 
    cnt++ ; 
  }

  cout << cnt << endl ;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int imos[10000];
int main() {
  int A,B,C,D,ans = 0;
  cin >> A >> B >> C >> D;
  imos[A]++;
  imos[B]--;
  imos[C]++;
  imos[D]--;
  for(int i = 1;i < 1000;i++)imos[i] += imos[i-1];
  for(int i = 0;i < 1000;i++)if(imos[i] == 2)ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

ll dp[110000];

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    rep(i, m-1) {
        if(a[i] + 1 == a[i+1]) {
            cout << 0 << endl;
            return 0;
        }
    }
    dp[0] = 1;
    int no = 0;
    rep(i, n) {
        if(no < m && a[no] == i+1) {
            dp[i+2] += dp[i];
            dp[i+2] %= MOD;
            no++;
            i++;
        }
        else {
            dp[i+2] += dp[i];
            dp[i+2] %= MOD;
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
        }
    }
    cout << dp[n] << endl;
}

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

int main(){
	string player[] = {"First","Second"};
	string s;
	cin >> s;
	if(s[0] == s[s.length() - 1]) cout << player[(s.length()) % 2] << endl;
	else cout << player[(s.length() + 1) % 2] << endl;
	return 0;
}

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

int main() {
  ll MOD = 1000000007;
  ll N;
  cin >> N;
  vector<ll> A(N);
  sort(A.begin(),A.end());
  ll sum = 0;
  for (auto &e : A) {
    cin >> e;
    sum += e;
  }
  ll ans = 0;
  for (auto e : A) {
    sum -= e;
    ans = ((sum)%MOD * e + ans) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

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

Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
ll c[26];
ll d[400][26];

ll calc(vector<int> contest){
	ll last[26];
	
	memset(last,-1,sizeof(last));
	
	ll res=0;
	rep(x,0,n){
		res+=d[x][contest[x]];
		last[contest[x]]=x;
		
		rep(y,0,26) res-=c[y]*(x-last[y]);
	}
	
	return res;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	//freopen("sample1.in","r",stdin);
	
	auto begin_time=chrono::steady_clock::now().time_since_epoch().count();
	
	cin>>n;
	rep(x,0,26) cin>>c[x];
	
	rep(x,0,n){
		rep(y,0,26) cin>>d[x][y];
	}
	
	vector<int> curr;
	rep(x,0,n){
		curr.push_back(0);
	}
	
	ll val=calc(curr);
	
	while (chrono::steady_clock::now().time_since_epoch().count()-begin_time<1900000000){
		auto nc=curr;
		
		rep(x,0,3){ //hmmm make 3 changes
			nc[rng()%n]=rng()%26;
		}
		
		if (calc(nc)>val) curr=nc;
	}
	
	rep(x,0,n) cout<<curr[x]+1<<endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define READ      freopen("input.txt", "r", stdin);
#define WRITE     freopen("output.txt", "w", stdout);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mint map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
const ll MAX = 1000004;
const ll INF = 1e18L + 5;

int main() {

	_cin
	// READ
	// WRITE
	ll n, W;
	cin >> n >> W;
	ll s_v = 0;
	ll w[n], v[n];
	rep(i, 0, n) {
		cin >> w[i] >> v[i];
		s_v += v[i];
	}
	vll dp(s_v + 1, INF);
	dp[0] = 0;
	// dp[i]--min weight having value i
	rep(i, 0, n) {
		repd(j, s_v - v[i], 0) {
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);

		}
	}
	ll ans = 0;
	rep(i, 0, s_v + 1) {
		if (dp[i] <= W) {
			ans = max(ans, i);
		}
	}
	cout << ans << endl;





}

Measured memory_bytes: 3912
#include<iostream>

using namespace std;

int main(void)
{
  double a,b,t; cin>>a>>b>>t;
  double sum_a=0;
  t+=0.5;
  double sum=0;
  
  for(;;){
    if((int)(sum_a*10)<(int)(t*10)){sum+=b; sum_a+=a;}
    else{break;}
  }
  
  cout<<(int)(sum-b)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n; cin >> n;
	if(n >= 400 && n <= 599)
		cout<<"8";
	else if(n >= 600 && n <= 799)
		cout<<"7";
	else if(n >= 800 && n <= 999)
		cout<<"6";
	else if(n >= 1000 && n <= 1199)
		cout<<"5";
	else if(n >= 1200 && n <= 1399)
		cout<<"4";
	else if(n >= 1400 && n <= 1599)
		cout<<"3";
	else if(n >= 1600 && n <= 1799)
		cout<<"2";
	else if(n >= 1800 && n <= 1999)
		cout<<"1";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


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

using namespace std;

int main(void)
{
  	int n;
  	string s;
  	cin >> n >> s;
  	if(n%2) {
    	cout<<"No";
  	}
  	else
    {
      	for(int i=0;i<(n/2);i++)
          	if(s[i]!=s[i+n/2])
            {
                cout<<"No";
                return 0;
            }
      	cout<<"Yes";
    }
    return 0;
}


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

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

  ll M[N];
  M[0] = 1;
  M[1] = 2;
  for (ll i = 2; i < N; i++) {
    M[i] = ((M[i-1] + M[i-2]) * i) % MOD;
  }

  cout << M[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
const ll MAX = 2020200;
ll fac[MAX], finv[MAX], inv[MAX];
void cinit() { // O(nlogn)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    reps(i, 2, MAX){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll c(int n, int k){ // 二項係数計算
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll wawa(ll rr,ll cc){
    ll res=0;
    reps(i,1,rr+2){
        res+=c(cc+i,i);
        res%=MOD;
    }
    /*
    reps(i,1,cc+1){
        res+=c(rr+i,i);
        res%=MOD;
    }
    */
    return res;
}
//--MAIN-----------------------------------
void Main() {
    ll r1,c1,r2,c2; cin>>r1>>c1>>r2>>c2;
    cinit();
    ll ans=0;
    ans+=wawa(r2,c2);
    ans+=wawa(r1-1,c1-1);
    ans-=wawa(r2,c1-1);
    ans-=wawa(r1-1,c2);
    //de(wawa(r2,c2));
    //de(wawa(r1-1,c1-1));
    //de(wawa(r2,c2));
    //de(wawa(r2,c2));
    ans+=MOD;
    ans+=MOD;
    ans%=MOD;
    cout<< ans <<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 47616
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int64_t A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K % 2 == 0){
        cout << A - B << endl;
    }
    else {
        cout << B - A << endl;
    }
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int[] l = new int[N];
  int[] r = new int[N];
  int sum = 0;
  for(int i = 0;i < N;i++){
    l[i] = sc.nextInt();
    r[i] = sc.nextInt();
    sum += r[i] - l[i] +1;
  }
  System.out.println(sum);
}
}
  


Measured memory_bytes: 25320
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    int N;cin >> N;
    long long M;cin >> M;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);retu.at(i)/=2;
    }
    vector<int> beki2Count(N);
    for(int i = 0;i<N;i++){
        int count = 0;
        long long div = 2;
        while(true){
            if(retu.at(i) % div == 0){
                beki2Count.at(i)++;
            }
            else{
                break;
            }
            div *= 2;
        }
    }
    bool ok = true;
    for(int i = 0;i<N-1;i++) if(beki2Count.at(i) != beki2Count.at(i+1)) ok = false;
    if(!ok){
        cout << 0 << endl;
        return 0;
    }
    long long LCM = 1;
    for(int i = 0;i<N;i++){
        LCM = lcm(retu.at(i),LCM);
        if(LCM >= 1000000000){
            cout << 0 << endl;
            return 0;
        }
    }
    long long multi = 1;
    int ans = 0;
    while(true){
        if(LCM*multi <= M){
            ans++;
            multi += 2;
        }
        else{
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4524
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
ll dp[2000][2000];
vector<pair<ll,int>> vec(2000);
int n;
ll go(int i,int l,int r){
	if(i==n) return 0;
	if(dp[l][r]!=-1) return dp[l][r];
	ll a=go(i+1,l+1,r)+vec[i].f*Abs(vec[i].se-l);
	ll b=go(i+1,l,r-1)+vec[i].f*Abs(vec[i].se-r);
	return dp[l][r]=max(a,b);
}
void solve(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>vec[i].f;
		vec[i].se=i;
	}
	RSort(vec);
	memset(dp,-1,sizeof(dp));
	ll ans=go(0,0,n-1);
	cout<<ans<<endl;
	
	
	
	
	
	
	
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    
 

Measured memory_bytes: 35008
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 1e6 + 100;
int n;
char s[maxn], t[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  scanf("%s", s);
  scanf("%s", t);
  return true;
}

vector<int> pos[300];

void solve() {
  {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        ok = false;
      }
    }
    if (ok) {
      printf("0\n");
      return;
    }
  }
  for (int i = 0; i < 300; i++) {
    pos[i].clear();
  }
  for (int i = 0; i < n; i++) {
    pos[s[i]].pb(i);
  }
  vector<int> xs;
  vector<int> want;
  for (int i = n - 1; i >= 0; i--) {
    if (i == 0 || t[i] != t[i - 1]) {
      int mx = sz(xs) ? xs.back() : inf;
      mx = min(mx, i);
      int j = (int) (upper_bound(pos[t[i]].begin(), pos[t[i]].end(), mx) - pos[t[i]].begin());
      j--;
      if (j == -1) {
        printf("-1\n");
        return;
      }
      xs.pb(pos[t[i]][j]);
      want.pb(i);
    }
  }
  reverse(xs.begin(), xs.end());
  reverse(want.begin(), want.end());
  vector<int> magic;
  for (int i = 0; i < sz(xs); i++) {
    magic.pb(xs[i] - i);
  }
  magic.pb(want.back() - sz(xs) + 1);
  int ans = 1;
  for (int i = 0; i < sz(xs); i++) {
    int j = (int) (lower_bound(magic.begin(), magic.end(), want[i] - i) - magic.begin());
    ans = max(ans, 1 + j - i);
  }
  printf("%d\n", ans);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 22824
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1) << endl;
  return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;
var yx=[];
var zero=[];
for(var i=0;i<n+1;i++)zero.push(0);
yx.push(zero);
for(var i=0;i<n;i++)yx.push(("0 "+arr.shift()).split(" ").map(Number));
n=n+1;
var sum=[];
for(var i=0;i<n;i++){
   sum[i]=[];
   sum[i][0]=yx[i][0];
}
for(var i=0;i<n;i++){
   for(var j=1;j<n;j++){
      sum[i][j]=sum[i][j-1]+yx[i][j];
   }
}
for(var i=1;i<n;i++){
   for(var j=0;j<n;j++){
      sum[i][j]=sum[i-1][j]+sum[i][j];
   }
}
var max=-Infinity;
for(var i=0;i<n;i++){
   for(var j=0;j<n;j++){
      for(var y=i+1;y<n;y++){
         for(var x=j+1;x<n;x++){
            var S=sum[y][x]-sum[i][x]-sum[y][j]+sum[i][j];
            if(max<S)max=S;
         }
      }
   }
}
console.log(max);

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

int main(){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>>data(n);
    rep(i,n){
        cin >> data[i].first.first >> data[i].first.second;
        data[i].second = i+1;
        data[i].first.second *= -1;
    }
    sort(all(data));
    rep(i,n)cout << data[i].second << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

M1 = False
M2 = False
if int(S[0]) <= 1:
    if S[0] == '0' and S[1] != '0':
        M1 = True
    elif S[0] == '1':
        if 0 <= int(S[1]) <= 2:
            M1 = True

if int(S[2]) <= 1:
    if S[2] == '0' and S[3] != '0':
        M2 = True
    elif S[2] == '1':
        if 0 <= int(S[3]) <= 2:
            M2 = True

if M1 and M2:
    print("AMBIGUOUS")
elif M1 and (not M2):
    print("MMYY")
elif (not M1) and M2:
    print("YYMM")
elif (not M1) and (not M2):
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
	vector<int> table;

	for(int hight; cin >> hight; table.push_back(hight));

	sort(table.begin(), table.end());

	for(int i = 9; i > 6; i --) cout << table[i] << endl;

	return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
const int sz = 500;
int id(int i, int j){
    return i * sz + j;
}
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int n;
bool ok(int i,int j){
    return 0<= i and i < n and 0 <= j and j < n;
}
int dist[sz * sz];
bool not_used[sz * sz];
void update(int x, int y){
    int temp = dist[id(x, y)] + not_used[id(x, y)];
    for(int i = 0; i < 4; i++){
        int xx = x + dx[i];
        int yy = y + dy[i];
        if(!ok(xx, yy))continue;
        if(dist[id(xx,yy)] > temp){
            dist[id(xx, yy)] = temp;
            update(xx, yy);
        }
    }
}
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            dist[id(i, j)] = min({i, j, n - 1- i, n - 1 - j});
            not_used[id(i, j)] = true;
        }
    }
    ll ans = 0;
    for(int tt = 0; tt < n * n; tt++){
        int p;
        cin >> p;
        p--;
        int x = p / n;
        int y = p % n;
        ll temp = dist[id(x, y)];
        ans += temp;
        not_used[id(x, y)] = false;
        update(x, y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 23712
#include <bits/stdc++.h>
using namespace std;
int main() {


	long long n,x,t; cin >> n >> x >> t; 

	long long ans = (n%x == 0)?n/x:n/x+1;
	long long ans_actual = ans*t;

	cout << ans_actual << endl;
		
		
  return 0; 
}

Measured memory_bytes: 3588
from itertools import combinations
import numpy as np

# スペース区切りの整数の入力
n, d = map(int, input().split())
vals = [[int(i) for i in input().split()] for _ in range(n)] 

result=0
for i, j in combinations(vals, 2):
    a = np.array(i)
    b = np.array(j)
    dist = (abs(sum((a-b)**2)))**0.5
    if dist.is_integer():
        result+=1
    
# 出力
print("{}".format(result))

Measured memory_bytes: 12440
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
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; }
const long long INF = 1LL << 60;

int main(){
    ll r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  map<ll, ll> em, om;
  rep(i, n) {
    ll a;
    cin >> a;
    if (i & 1)
      om[a]++;
    else
      em[a]++;
  }
  vP ev, ov;
  for (P p : em) ev.push_back({p.second, p.first});
  for (P p : om) ov.push_back({p.second, p.first});
  rSort(ev), rSort(ov);

  ll ans;
  if (ev[0].second != ov[0].second) {
    ans = (n + 1) / 2 - ev[0].first;
    ans += n / 2 - ov[0].first;
  } else {
    ans = INF;
    ll tmp;
    if (ov.size() > 1) {
      tmp = (n + 1) / 2 - ev[0].first;
      tmp += n / 2 - ov[1].first;
      chmin(ans, tmp);
    }
    if (ev.size() > 1) {
      tmp = (n + 1) / 2 - ev[1].first;
      tmp += n / 2 - ov[0].first;
      chmin(ans, tmp);
    }
    tmp = (n + 1) / 2 - ev[0].first;
    tmp += n / 2;
    chmin(ans, tmp);
    tmp = (n + 1) / 2;
    tmp += n / 2 - ov[0].first;
    chmin(ans, tmp);    
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11776
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++) cin>> A[i];
  vector<int> ans(N,0);

  int sum =0;
  for(int i=0;i<N;i++) sum +=A[i];
  int sum_tmp =0;
  for(int i=0;i<=N-3;i=i+2) sum_tmp +=A[i];
  int last_ans = sum - 2*sum_tmp;
  ans[0] = 2*A[N-1]-last_ans;
  for(int i=1;i<=N-1;i++){
    ans[i] = 2*A[i-1]-ans[i-1];
  }

  for(int i=0;i<N;i++){cout << ans[i] << " ";}
  cout << endl;
}





Measured memory_bytes: 2048
<?php



while(fscanf(STDIN, "%d %d", $a, $b)){

//?????§??¬?´???°
$x = GCD($a, $b);

//????°???¬?????°
$y = LCM($a, $b);


echo $x." ".$y."\n";

}

function GCD($m, $n){

while ($m % $n != 0)
{
	$temp = $n;
	$n = $m % $n;
	$m = $temp;

}
return $n;

}

function LCM($l, $k){

return $l*$k / GCD($l, $k);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    vi sum;
    for (int i = 0; ; i++) {
        if (i*(i+1)/2 > ll(1e9)) break;
        sum.pb(i*(i+1)/2);
    }

    ll X; cin >> X;

    int lb = lower_bound(all(sum),X)-sum.begin();

    cout << lb << "\n";
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main(){
    int N,X;
    int arrayL[100];
    cin>>N>>X;
    uint64_t tempsum =0;
    int outnum =1;

    for(int i=0;i<N;++i){
        cin>>arrayL[i];

        tempsum += arrayL[i];
        if(tempsum <= X){
            ++outnum;
        }
    }

    cout<<outnum<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    int a[m],b[m],vis[n+1];
    vector<int>adj[n+1];
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        a[i]=u;
        b[i]=v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans=0;
    for(int i=0;i<m;i++)
    {
        queue<int>q;
        memset(vis,0,sizeof(vis));
        q.push(1);
        vis[1]=1;
        while(!q.empty())
        {
            u=q.front();
            q.pop();
            for(int j=0;j<adj[u].size();j++)
            {
                v=adj[u][j];
                if(u==a[i]&&v==b[i])
                    continue;
                if(u==b[i]&&v==a[i])
                    continue;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
        bool flag=true;
        for(int j=1;j<=n;j++)
        {
            if(!vis[j])
            {
                //cout<<i<<endl;
                flag=false;
                break;
            }
        }
        if(!flag)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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



int main()
{
	int n[26]={};
	string s,ans;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		n[s[i]-'a']++;
	}
	for(int i=0;i<26;i++)
	{
		if(n[i]==0)
		{
			ans='a'+i;
			cout<<ans<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}


Measured memory_bytes: 512
// by syu
package main

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

var in = NewScanner(os.Stdin, 0)

func main() {
	N := in.Int()
	a, b := in.ArrayInt(N), in.ArrayInt(N)
	t := 0
	ans := 0
	c := make([]int, N)
	for i := 0; i < N; i++ {
		c[i] = b[i] - a[i]
		if c[i] > 0 {
			t += c[i]
			ans++
		}
	}
	sort.Ints(c)
	for i := 0; i < N; i++ {
		if c[i] < 0 && t > 0 {
			t += c[i]
			ans++
		}
	}
	if t > 0 {
		Pln(-1)
	} else {
		Pln(ans)
	}
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}

type ByteSlice []byte
type IntSlice []byte


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

int main()
{
    int a, b, c, x;
    int i, j, now, ans = 0;
    
    cin >> a >> b >> c >> x;
    
    for(i = 0; i <= a; i++) {
        for(j = 0; j <= b; j++) {
            
            now = x-(500*i+100*j);
            
            if((now >= 0) && ((now / 50) <= c)) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        String s = String.valueOf(h);
        for(int i = 0;i < s.length(); i++){
            if(s.charAt(i) == '7'){System.out.println("Yes");return;}
        }
        System.out.println("No");
    }
}

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


int main() {
    int N; cin >> N;
    vector<pair<int, int>> A;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        A.push_back(make_pair(a, i + 1));
    }
    sort(A.begin(), A.end());

    for (int i = 0; i < N; i++) {
        cout << A[i].second << " ";
    }

    return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong k, x;

int main() {
    cin >> k >> x;

    if (k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int a[20000];
int dp[2][10001][3];
             //切った: A: B

int main()
{
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n - 1; i++){
		scanf("%d", &a[i]);
	}
	
	for (int i = 0; i < 2; i++){
		for (int j = 0; j <= 10000; j++){
			for (int k = 0; k <= 2; k++){
				dp[i][j][k] = INF;
			}
		}
	}
	
	dp[0][0][0] = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= i; j++){
			for (int k = 0; k <= 2; k++){
				dp[(i + 1) % 2][j][k] = INF;
			}
		}
		
		for (int j = 0; j <= min(i, n / 2); j++){
			dp[(i + 1) % 2][j][0] = min(dp[(i + 1) % 2][j][0], dp[i % 2][j][0] + a[i]);
			dp[(i + 1) % 2][j + 1][0] = min(dp[(i + 1) % 2][j + 1][0], dp[i % 2][j][0] + a[i]);
			dp[(i + 1) % 2][j + 1][0] = min(dp[(i + 1) % 2][j + 1][0], dp[i % 2][j][1] + a[i]);
			dp[(i + 1) % 2][j][0] = min(dp[(i + 1) % 2][j][0], dp[i % 2][j][2] + a[i]);
			
			dp[(i + 1) % 2][j + 1][1] = min(dp[(i + 1) % 2][j + 1][1], dp[i % 2][j][0]);
			dp[(i + 1) % 2][j + 1][1] = min(dp[(i + 1) % 2][j + 1][1], dp[i % 2][j][1]);
			
			dp[(i + 1) % 2][j][2] = min(dp[(i + 1) % 2][j][2], dp[i % 2][j][0]);
			dp[(i + 1) % 2][j][2] = min(dp[(i + 1) % 2][j][2], dp[i % 2][j][2]);
		}
	}
	
	printf("%d\n", dp[n % 2][n / 2][0]);
	
	return 0;
}

Measured memory_bytes: 1464
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    map<string,int> mp;
    REP(i,N) {
        string S; cin >> S;
        mp[S]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	long L[]=new long[87];
	L[0]=2;L[1]=1;
	for(int i=2;i<=a;i++) {
		L[i]=L[i-1]+L[i-2];
	}
	System.out.println(L[a]);
}
}

Measured memory_bytes: 23252