akhauriyash/Code-Regression huggingface dataset:
#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(){
  long long n,m,l;
  cin >> n >> m >> l;

  vector<vector<long long> > A(n, vector<long long>(m, 0));
  vector<vector<long long> > B(m, vector<long long>(l, 0));
  vector<vector<long long> > C(n, vector<long long>(l, 0));
  
  for (long long i=0; i<n; i++){
    for (long long j =0; j<m; j++){
      cin >> A.at(i).at(j);
    }
  }
  for (long long j=0; j<m; j++){
    for (long long k=0; k<l; k++){
      cin >> B.at(j).at(k);
    }
  }

  for (long long i=0; i<n; i++){
    for (long long k=0; k<l; k++){
      long long sum = 0;
      for (long long j=0; j<m; j++){
        sum += A.at(i).at(j) * B.at(j).at(k);
      }
      C.at(i).at(k) = sum;
      cout << sum;
      if (k == l-1) break;
      cout << ' ';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    int n,x=0,ans=0;
    string s;
    cin>>n>>s;
    for (int i = 0; i < n; i++)
    {
        if(s[i]=='I') x++; else x--;
        ans=max(ans,x);
    }
    cout<<ans;
    
	

   return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
vector<int> videos(105);
double now=0;
queue<int> num;
ll n,q;
vi v(100005);
vi w(100005);
int main(int argc,char const* argv[])
{
  cin >> n >> q;
  for(int i=0;i<q;i++)
    {
      cin >> v[i] >> w[i];
    }
  for(int i=0;i<q;i++)
    {
      if(n==1)
	{
	  cout << min(v[i],w[i]) << endl;
	}
      else
	{
	  while(v[i]!=w[i])
	    {
	      if(v[i]>w[i])
		{
		  v[i]=(v[i]+n-2)/n;
		}
	      else
		{
		  w[i]=(w[i]+n-2)/n;
		}
	    }
	  cout << v[i] << endl;
	}
    }
  return 0;
}


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

int main(int argc, char const *argv[])
{
	int x,y;
	scanf("%d", &x);
	y = sqrt(x);
	if (x % 2 == 0 && x != 2)
		x++;
	for (int i = 3; i < y; i++)
	{
		if (x % i == 0)
		{
			x += 2;
			y = sqrt(x);
			i = 2;
		}
	}
	printf("%d", x);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}


int main()
{
    int i, n, t1=0, t2=0;
    char s[100000];
    scanf("%s",s);
    n = strlen(s);
    for(i=0; i<n; i+=2) {
        if(s[i]=='0') {
            t1++;
        } else if(s[i]=='1') {
            t2++;
        }

        if(s[i+1]=='0') {
            t2++;
        } else if(s[i+1]=='1') {
            t1++;
        }
    }
    printf("%d",MIN(t1,t2));

    return 0;
}


Measured memory_bytes: 256
def prob_c():
    n = int(input())
    d_list = [int(a) for a in input().split()]
    d_list.sort()
    return d_list[int(n/2 + 0.1)] - d_list[int(n/2 + 0.1) - 1]


b = prob_c()
print(str(b))

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    bool flag = false;
    for(int i=0;i<N-1;++i){
        if(A[i] == A[i+1]){
            flag = true;
            break;
        }
    }
    if(flag) cout << "NO" << endl;
    else cout << "YES" << endl;
}


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

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

  if(N%(2*D+1)==0){
    cout<<N/(2*D+1)<<endl;
  }
  else{
    cout << N/(2*D+1)+1<<endl;
  }
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int D;
    string s[] = {"Christmas Eve Eve Eve", "Christmas Eve Eve","Christmas Eve","Christmas"};
    cin >> D;
    cout << s[D - 22] << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main{
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B = s.nextInt();
        int C = s.nextInt();
        if(A == B && B != C && A != C){
            System.out.println("Yes");
        }else if(A != B && B == C && A != C){
            System.out.println("Yes");
        }else if(A != B && B != C && A == C){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
		
	}
} 

Measured memory_bytes: 23124
#PypyでもTLE A[:half]のような箇所が遅い？

N = int(input())
A = list(map(int, input().split()))
for i in range(1, N):
    A[i] += A[i - 1]

def calc(lb, ub):
    max_num = A[ub]
    lb -= 1
    if lb == -1:
        min_num = 0
    else:
        min_num = A[lb]
    total = A[ub] - min_num
    # print (total)
    while (ub - lb) > 1:
        mid = (lb + ub)//2
        if A[mid] - min_num > total/2:
            ub = mid
        else:
            lb = mid
    # print ('ub', ub)
    a1, b1 = A[ub] - min_num, max_num - A[ub]
    diff1 = abs(b1 - a1)
    # print ('diff1', diff1)
    a2, b2 = A[ub - 1] - min_num, max_num - A[ub - 1]
    diff2 = abs(b2 - a2)
    # print ('diff2', diff2)
    if diff2 < diff1:
        a1, b1 = a2, b2
    return a1, b1

# print (calc(A, 0))
# half = 2
# P, Q = calc(0, half - 1)
# print (P, Q)

ans = 10 ** 9
for half in range(2, N - 1):
    # print (A[:half], end = ' ')
    # print (A[half:])
    P, Q = calc(0, half - 1)
    R, S = calc(half, N - 1)
    # print (P, Q, R, S)
    tmp = max(P, Q, R, S) - min(P, Q, R, S)
    # print (tmp)
    ans = min(tmp, ans)

# print ('ans', ans)
print (ans)


Measured memory_bytes: 95096
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <vector>

using namespace std;

class c_rmq
{
private:

public:
    c_rmq();
    void f_input();
    int c_min(unsigned int *a, int r1, int r2);
};

c_rmq::c_rmq()
{

}

void c_rmq::f_input()
{
    int n;
    int q;
    int i;
    unsigned int a[100000];
    int c1;
    int c2;
    int c3;
    
    cin >> n >> q;
    
    for ( i = 0; i < n; ++i){
        a[i] = 2147483647;
    }
    
    for ( i = 0; i < q; ++i){
        cin >> c1 >> c2 >> c3;
        if (c1 == 1){
            cout << c_min(a,c2,c3) << endl;
        }else if (c1 == 0){
            a[c2]=c3;
        }
    }
}

int c_rmq::c_min(unsigned int *a, int r1, int r2){
    int temp1;
    int i;
    int temp_min;
    unsigned int *temp_a;
    
    temp_a = &*a;
    
    temp_min = 2147483647;
    
    for (i = r1; i < r2 +1;++i){
        if (temp_min > temp_a[i])temp_min=temp_a[i];
    }
    temp1 = temp_min;
    
    return temp1;
}

int main(){
    
    c_rmq rmq01;
    rmq01.f_input();
    
    return 0;
}

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

ll A;

void solve()
{
	int n=1;
	while(1LL*n*(1+n)<2*A)n++;
	if(n*(n+1) == 2*A){
		for(int i=1;i<=n;++i)cout<<i<<'\n';
		return;
	}else{
		cout<<n<<'\n';
		A-=n;
		for(int i=n-1;i>=1;--i){
			if(A>=i){
				cout<< i <<'\n';
				A-=i;
				if(!A) break;
			}
		}
	}
}

int main()
{
	cin >> A;
	solve();
	return 0;
}

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

int main(){

    int table[]={1,3,1,2,1,2,1,1,2,1,2,1};

    int x,y;
    cin>>x>>y;
    cout<<(table[x-1]==table[y-1]?"Yes":"No")<<endl;






    return 0;
}

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

int main() {
	string S; cin >> S;
	int ret = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '+')ret++;
		else ret--;
	}

	cout << ret << endl;
}

Measured memory_bytes: 256
def rot(x, y, t):
    v = [0.0, 0.0]
    v[0] = ((1-t**2)*x+2*t*y)/(t**2+1)
    v[1] = (2*t*x+(t**2-1)*y)/(t**2+1)
    return v
import sys
v=[0.0,0.0]
for line in sys.stdin:
    ipt = line.split(',')
    x = [float(ipt[i]) for i in range(0,6,2)]
    y = [float(ipt[j]) for j in range(1,6,2)]
    if x[1]!=x[0]:
        v = rot(x[2]-x[0],y[2]-y[0],(y[1]-y[0])/(x[1]-x[0]))
        v[0]+=x[0]; v[1]+=y[0];
    else:
        v = [-x[2], y[2]]
    print "%.6f %.6f"%(0.0+v[0],0.0+v[1])

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 43;

struct drug{
    int a,b,c;
};

signed main(){
    int n,a,b;
    cin >> n>>a >> b;
    drug D[n_max]; 
    REP(i,n){
        cin >> D[i].a >> D[i].b >> D[i].c;
    }
    int dp[405][405];
    REP(i,405) REP(j,405) dp[i][j] = INF;
    dp[0][0] = 0;
    REP(i,n){
        REPR(j,404){
            REPR(k,405){
                if(dp[j][k] == INF) continue;
                if(j + D[i].a <405 and k + D[i].b < 405){
                    chmin(dp[j + D[i].a][k + D[i].b], dp[j][k] + D[i].c);
                }
            }
        }
    }

    int ans = INF;
    int aid = 0,bid = 0;
    while(1){
        aid += a;
        bid += b;
        if(aid >=405 or bid >= 405) break;
        chmin(ans,dp[aid][bid]);
    }
    if(ans == INF){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }


}

Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
	int a, b, c;

	// 整数の入力
	scanf("%d%d", &a,&b);
	// スペース区切りの整数の入力
	
	c = a*b;
	
	if (c%2 == 0) {
		printf("Even");
	}
	if (c%2 == 1) {
		printf("Odd");
	}

	return 0;
}

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


int main()
{
	std::string S, T, U;
	int A, B;
	std::cin >> S >> T >> A >> B >> U;

	if (S == U)
	{
		--A;
	}
	else
	{
		--B;
	}

	std::cout << A << " " << B;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M;
    cin >> N >> M;
    int A[N][M];
    rep(i, N) rep(j, M) {cin >> A[i][j]; A[i][j]--;}
    //(l,r]
    int l = 0, r = N;
    while(r-l > 1){
        int n = (l+r)/2;
        vector<int> cnt(M, 0), now(N, 0);
        vector<bool> used(M, false);
        bool able = true;
        while(true){
            rep(i, N){
                while(now[i] < M && used[A[i][now[i]]]) now[i]++;
                if(now[i] == M) able = false;
                else cnt[A[i][now[i]]]++;
            }
            bool update = false;
            rep(i, M){
                if(cnt[i] > n) update = true, used[i] = true;
            }
            fill(all(cnt), 0);
            if(!update) break;
        }
        if(able) r = n;
        else l = n;
    }
    cout << r << endl;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#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 LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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



int main(void) {
	string s;
	long long int count = LLINF;
	long long int point = 0;

	cin >> s;

	point = 0;
	FOR(i, 0, s.size() - 1) {
		if (i % 2 == 0) {
			if (s[i] == '0') {
				point++;
			}
		}
		else {
			if (s[i] == '1') {
				point++;
			}
		}
		
	}
	count = min(count, point);
	
	point = 0;
	FOR(i, 0, s.size() - 1) {
		if (i % 2 == 0) {
			if (s[i] == '1') {
				point++;
			}
		}
		else {
			if (s[i] == '0') {
				point++;
			}
		}

	}
	count = min(count, point);

	cout << count << endl;


	return 0;
}

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

int main(){
    
    int a, b, c, x, y, ans=0;
    cin>>a >>b >>c >>x >>y;
    if(a+b >= 2*c){
        ans+=min(x, y)*2*c;
        if(x<y){
            ans+=(y-x)*min(b, 2*c);
        }
        if(x>y){
            ans+=(x-y)*min(a, 2*c);
        }
    }else{
        ans+=a*x+b*y;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]

mod = 10**9 + 7

X = 0
Y = 0
for i in range(N - 1):
    X += (A[i + 1] - A[i]) * (i + 1) * (N - 1 - i)
    X %= mod
for j in range(M - 1):
    Y += (B[j + 1] - B[j]) * (j + 1) * (M - 1 - j)
    Y %= mod
print(X * Y % mod)


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

int main()
{
    int N, A;
    cin >> N;
    
    map<int, bool> set;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (set[A] == true) {
            cout << "NO";
            return 0;
        }
        set[A] = true;
    }
    
    cout << "YES";
    
    return 0;
}

Measured memory_bytes: 9600
def factorization(n):
    """素因数分解する

    下記より引用いたしました。
    https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8

    Parameters
    ----------
    n : integer
        対象の数

    Returns
    -------
    list
        素因数分解のリスト
        list[素数][n乗]
    """
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N, P = map(int, input().split())
fact_li = factorization(P)
ans = 1
for i in range(len(fact_li)):
    cnt = fact_li[i][1] // N
    ans *= fact_li[i][0] ** cnt
print(ans)


Measured memory_bytes: 63344
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define ll long long
int main(){
	string s; cin>>s;
	if(s[0]==s[1] or s[1]==s[2] or s[2]==s[3]) cout<<"Bad";
	else cout<<"Good";
}


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

int main() {
    string S; cin >> S;
    int c0=0, c1=0;

    for (int i = 0; i < S.length(); ++i) {
        if(S[i]=='0') c0++;
    }
    c1 = S.length() - c0;

    cout << 2*min(c0, c1) << endl;
    return 0;
}

Measured memory_bytes: 512
n,m = map(int, input().split())
a = list(map(int, input().split()))
tot = sum(a)
b = tot/(4*m)
a.sort()

cnt = 0
for i in range(n):
	if a[-(i+1)] < b:
		break
	cnt += 1

if cnt >= m:
	print('Yes')
else:
	print('No')

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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; ++i) 
			a[i] = sc.nextInt();
		
		Arrays.sort(a);
		int tmp = a[0];
		int cnt = 1;
		int ans = 0;
		for(int i = 1; i < n; ++i) {
			if(tmp != a[i]) {
				tmp = a[i];
				++cnt;
			}
		}
		
		if(k < cnt) {
			int count[] = new int[cnt];
			tmp = a[0];
			int l = 0;
			count[0] = 1;
			for(int i = 1; i < n; ++i) {
				if(tmp != a[i]) {
					tmp = a[i];
					++l;
				}
				++count[l];
			}
			Arrays.sort(count);
			for(int i = 0; i < cnt - k; ++i) {
				ans += count[i];
			}
		}
		sc.close();
		System.out.println(ans);
	}

}


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

int main(void)
{
  int64_t x, k, d;
  std::cin >> x >> k >> d;

  int64_t posi_ans = std::abs(x);
  int64_t k_cnt = std::abs(x / d);

  if (k_cnt > k) {
    posi_ans -= d * k;
  }
  else {
    k -= k_cnt;

    posi_ans -= d * k_cnt;

    if (k&0x01) {
      posi_ans -= d;
    }
  }

  posi_ans = std::abs(posi_ans);
  std::cout << posi_ans << std::endl;

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll x = 0;

    REP(i,n){
        cin >> a[i];
    }

    REP(i,n){
        x += a[i] * ((i%2 == 0)?1:-1);
    }
    cout << x << " ";

    FOR(i,1,n){
        x = 2*a[i-1]- x;
        cout << x << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }






int main(int argc, char* argv[])
{
	for (;;) {
		int N;
		cin >> N;
		if (cin.fail()) break;

		int ans = 0;
		bool swapped = false;
		for (int i = 1; i <= N; i++) {
			int p;
			cin >> p;
			if (!swapped && p == i) {
				ans++;
				swapped = true;
			} else {
				swapped = false;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

ll gcd(ll a, ll b){
    if(a < b){
        swap(a, b);
    }
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int K;
    cin >> K;
    ll total = 0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                int g = gcd(i, j);
                g = gcd(g, k);
                total += g;
            }
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
    string x;
    cin >> x;
    int sz = x . size() , s = 0;
    for (int i = 0; i < x . size();)
    {
        if (x[i] == 'S')
        {
            s ++;
            i ++;
        }
        if (x[i] == 'T')
        {
            while (s)
            {
                if (x [i] == 'T')
                {
                    sz -= 2;
                }
                else
                {
                    break;
                }
                s --;
                i ++;
            }
        }
        if (x[i] == 'T' && s == 0)
        {
            i ++;
        }
    }
    cout << sz;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int dp[5001][5001] = {};

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

    int res = 0;
    for(int i=N-1; i>=0; --i) {
        for(int j=N-1; j>=0; --j) {
            if(S[i] == S[j]) dp[i][j] = dp[i+1][j+1] + 1;
            else dp[i][j] = 0;
            res = max(res, min(dp[i][j], abs(j - i)));
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 97920
#include<iostream>
using namespace std;
int main()
{
  int x,y,p,q;
  cin>>x>>y;
  if(y<=4*x && y>=2*x)
  {
    if(y&1)
      cout<<"No";
    else
      cout<<"Yes";
  }
  else
    cout<<"No";
}

Measured memory_bytes: 3620
import java.util.*;
class Main 
{ 

	
	 
	public static void main(String args[]) 
	{ 
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int k = s.nextInt();
		int count=1;
		for(int i=Math.max(a,b);i>0;i--)
		{
			if(a%i==0 && b%i==0)
			{
				if(count==k)
				{
					System.out.println(i);
					break;
				}
				count++;
			}
		}

		

		
		
		
	}
} 


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if(x == 1&& y == 1){
    cout << 1000000 << endl;
  }else{
    if(x == 1){ans = 300000;}
    else if (x == 2){ans = 200000;}
    else if (x == 3){ans = 100000;}

    if(y == 1){ans += 300000;}
    else if (y == 2){ans += 200000;}
    else if (y == 3){ans += 100000;}

    cout << ans << endl;

  }

}


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

int main() {
	int n, ans = 0;
	cin >> n;
	char str;
	vector<int> c(n);
	rep(i,n) {
		cin >> str;
		if(str == 'W') c[i] = 0;
		else c[i] = 1;
	}
	int x = 0, y = n-1;
	while(x != y) {
		if(c[x] == 0 && c[y] == 1) {
			x++;
			if(x!=y)y--;
			ans++;
		}
		else if(c[x] == 0 && c[y] == 0) y--;
		else if(c[x] == 1 && c[y] == 1) x++;
		else if(c[x] == 1 && c[y] == 0) x++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4020
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

k = ii()

#a>b
dp = [[0]*201 for _ in range(201)]
def gcd(a,b):
    if a < b:
        a,b = b,a
    if dp[a][b] != 0:
        return dp[a][b]
    while b!=0:
        a,b=b,a%b
    dp[a][b] = a
    return a

def gcds(a,b,c):
    d = gcd(a,b)
    e = gcd(d,c)
    return e
ans = 0
for i in range(1,k+1):
    for l in range(1,k+1):
        for t in range(1,k+1):
            ans += gcds(i,l,t)
print(ans)


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

ll f(ll b,ll n){
    ll res=0;
    while(n){
        res+=n%b;
        n/=b;
    }
    return res;
}

int main(){
    ll n;
    ll s;
    cin>>n>>s;
    if(s>n){
        cout<<-1<<endl;
        return 0;
    }
    for(int b=2;b<1e6;b++){
        if(f(b,n)==s){
            cout<<b<<endl;
            return 0;
        }
    }
    // ab+c=n a+c=s
    // b=(n+a-s)/a=(n-s)/a+1
    for(ll a=1e6;a>=1;a--){
        if((n+a-s)%a==0){
            ll b=(n+a-s)/a;
            if(b<2) continue;
            if(f(b,n)==s){
                cout<<b<<endl;
                return 0;
            }
        }
    }
    if(n==s){
        cout<<n+1<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}



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

using namespace std;

int main() {

  char a, b;
  cin>>a>>b;

  if(a=='H'){
    cout<<b<<endl;
  }else {
    if(b=='H') cout<<'D'<<endl;
    else cout<<'H'<<endl;
  }
  
}


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

public class Main {

  public static void main(String[] args) {
    // abc173_a();
    abc173_b();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  public static void abc173_b() {
    try (Scanner sc = new Scanner(System.in)) {
      int num = parseI(sc.next());

      // AC
      // WA
      // TLE
      // RE x 0
      int[] ansCount = new int[4];
      String[] err = { "AC", "WA", "TLE", "RE" };
      Arrays.fill(ansCount, 0);

      for (int i = 0; i < num; i++) {
        String ans = sc.next();
        switch (ans) {
          case "AC":
            ansCount[0]++;
            break;
          case "WA":
            ansCount[1]++;
            break;
          case "TLE":
            ansCount[2]++;
            break;
          case "RE":
            ansCount[3]++;
            break;
        }
      }
      int count = 0;
      for (int answer : ansCount) {
        System.out.println(err[count] + " x " + answer);
        count++;
      }
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }
}


Measured memory_bytes: 59524
N,pi[1000],pj[1000],pk[1000],r[1000],a,b,c,v[301],i,j;
main(){
	for(;scanf("%d%d%d",&a,&b,&c),a|b|c;){
		scanf("%d",&N);
		for(i=0;i<N;i++)
			scanf("%d%d%d%d",pi+i,pj+i,pk+i,r+i);
		for(i=1;i<=a+b+c;i++)
			v[i]=2;
		for(i=0;i<N;i++)
			if(r[i])
				v[pi[i]]=v[pj[i]]=v[pk[i]]=1;
		for(i=0;i<N;i++)
			if(!r[i]){
				if(v[pi[i]]==1&&v[pj[i]]==1)
					v[pk[i]]=0;
				if(v[pj[i]]==1&&v[pk[i]]==1)
					v[pi[i]]=0;
				if(v[pk[i]]==1&&v[pi[i]]==1)
					v[pj[i]]=0;
			}
		for(i=1;i<=a+b+c;i++)
			printf("%d\n",v[i]);
	}
	exit(0);
}

Measured memory_bytes: 0
n = int(input())
c = {}
m = 0
for i in range(n):
    s = input()
    if s in c:
        c[s] += 1
    else:
        c[s] = 1
    if m < c[s]:
        m = c[s]

ans = []

for i in c:
    if m == c[i]:
        ans.append(i)

ans = sorted(ans)

for i in ans:
    print(i)


Measured memory_bytes: 35640
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>

using namespace std;

/*
n円をa_1円,a_2円,...,a_m円のコインを用いて両替する問題
*/
int main(){
	vector< vector<int> > arr;
    vector<int> coin;
    int n, m;
    // int tmp;
    
    // for aoj-dpl_1_a
    // std::cin >> n >> m;
    // 1,6,6**2,...,9**k円をつくる    
    int itr = 0;
    int itr2 = 1;
    while(true){
        coin.push_back((int)(pow(6.0, itr)));
        itr++;
        if ((int)(pow(6.0, itr)) > 100000){
            break;
        }
    }
    while(true){
        coin.push_back((int)(pow(9.0, itr2)));
        itr2++;
        if ((int)(pow(9.0, itr2)) > 100000){
            break;
        }
    }
    
    std::cin >> n;
    m = coin.size();
	arr.resize(m);
	for(int i=0; i<m; i++){
		arr[i].resize(n+1);
	}
    
    coin.resize(m);
    
    /*
    コインの値段が入ってくる
    for(int i=0; i<m; i++){
        std::cin >> tmp;
        coin[i] = tmp;
    }
    */

    // コインの値段が小さい順にソート（値段順じゃない時）
    std::sort (coin.begin(), coin.end());
    
    for (int i=0; i<m; i++){
        for (int j=0; j<=n; j++){
            // arr[i][j] -> a_1, a_2, ..., a_iのコインでj円両替する時の最小枚数
            if (i==0 || j==0){
                arr[i][j] = j;
            }
            else {
                if (j-coin[i] >= 0){
                    arr[i][j] = min(arr[i-1][j], arr[i][j-coin[i]] + 1);
                }
                else {
                    arr[i][j] = arr[i-1][j];
                }
            }
            //std::cout << arr[i][j] << "|";
        }
        //std::cout << endl;
    }
    std::cout << arr[m-1][n] << endl;
	return 0;
}

Measured memory_bytes: 4992
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"


def main():
    S = input()
    print(S.replace("apple", "あ").replace("peach", "apple").replace("あ", "peach"))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6760
k= int(input())
flag= -1
if k%2 ==0 or k%5==0:
    print("-1")
else:
    temp=7
    for i in range(0,k+1):
        if temp%k ==0:
            flag=i
            break
        else:
            temp= (temp*10+7)% k
    if flag==-1:
        print("-1")
    else:
        print(i+1)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int mochi = 1, current = a.at(0);
  for (int i = 1; i < N; i++) {
	if (a.at(i) < current) {
      mochi++;
      current = a.at(i);
    }
  }
  cout << mochi << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  
  vector<int> k(n);
  rep(i,n) k[i] = i;
  
  double l = 0.0;
  do {
    rep(i,n-1) {
      double dx = x[k[i]] - x[k[i+1]];
      double dy = y[k[i]] - y[k[i+1]];
      double dl = pow(dx*dx + dy*dy, 0.5);
      l += dl;
    }
  } while(next_permutation(k.begin(), k.end()));
  
  ll factorial = 1;
  rep(i,n) factorial *= (i+1);
  
  cout << fixed << setprecision(10) << l / factorial << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
    int N, D;
    scanf("%d %d", &N, &D);
    if(N % (D * 2 + 1) == 0){
        printf("%d\n", N / (D * 2 + 1));
    }
    else {
        printf("%d\n", N / (D * 2 + 1) + 1);
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    priority_queue<int> h;
    int dum;
    int cnt =0;
    for(int i=0; i<n;i++){
        cin >> dum;
        h.push(dum);
        if(h.top() == dum) cnt++;
    }
    cout <<cnt<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);

    for (int i =0; i<N; i++) cin >> A.at(i);
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    int points_alice = 0;
    for (int i=0; i<N; i+=2) points_alice += A.at(i);
    int points_bob = accumulate(A.begin(), A.end(), 0) - points_alice;

    cout << points_alice - points_bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  int a,b;
  cin>>a>>b;
  vector <int> n(a);
  vector <int> m(b);
  vector<vector<int>> vee(101, vector<int>(101));
  rep(i,b){
    cin>>m.at(i);
    rep(j,m.at(i)){
      cin>>vee.at(i).at(j);
    }
  }
  rep(k,b){
    rep(h,m.at(k)){
      n.at(vee[k][h]-1)++;
    }
  }
  int ab=0;
  rep(x,a){
   if(n.at(x)==0){
     ab++;
   }
  }
  cout<<ab;
}


Measured memory_bytes: 3716
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut a: usize = iterator.next().unwrap().parse().unwrap();
    let mut b: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    for i in 0..k {
        if i % 2 == 0 {
            if a % 2 == 1 {
                a -= 1;
            }
            a /= 2;
            b += a;
        } else {
            if b % 2 == 1 {
                b -= 1;
            }
            b /= 2;
            a += b;
        }
    }

    return format!("{} {}", a, b);
}


Measured memory_bytes: 2172
use std::io;
use std::collections::HashMap;
use std::mem;
use std::cmp;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.trim().split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

fn f(n : &mut i64)-> Vec<i64>{
    let mut ret = Vec::new();
    
    for i in 0..10{
        ret.push(*n%2);
        *n /= 2;
    }
    
    ret
}

fn main(){
    let n_store = read_ints()[0];
    let mut fss = Vec::new();
    let mut pss = Vec::new();
    let mut ans : i64 = -100000000000;
    
    for i in 0..n_store{
        fss.push(read_ints());
    }
    
    for i in 0..n_store{
        pss.push(read_ints());
    }
    
    for i in 1..1024{
        let mask = f(&mut i.clone());
        let mut benefit : i64 = 0;
        
        for j in 0..n_store as usize{
            let mut cnt = 0;
            
            for k in 0..10{
                if mask[k] == 1 && fss[j][k] == 1{
                    cnt += 1;
                }
            }
            
            benefit += pss[j][cnt];
        }
        
        ans = cmp::max(ans,benefit);
    }
    
    println!("{}",ans);
}







/*
DOCS


let mut h = HashMap::new();
let a = 5;
h.insert(a,true);
match h.get(&a){
    Some(v) => println!("{}",v),
    None    => println!("none"),
}


use std::mem;

let mut x = 5;
let mut y = 1;
mem::swap(&mut x,&mut y);


let v = vec![0;2]; // [0,0]







*/

Measured memory_bytes: 4352
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 998244353
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[SIZE];

int main() {
  int N, S, A[SIZE];

  cin >> N >> S;

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

  ll ans = 0;

  for (int i = 0; i < N; i++) {
    dp[0]++;
    for (int j = S - A[i]; j >= 0; j--) {
      dp[j + A[i]] = (dp[j + A[i]] + dp[j]) % mod;
    }

    ans += dp[S];
  }

  cout << ans % mod << endl;

  return 0;
}

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

int N, a[100005];

int main(void){
  cin >> N;
  int four = 0, two = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(a[i] % 4 == 0){
      four++;
    }
    else if(a[i] % 2 == 0){
      two++;
    }
  }
  if(two > 0){
    if(2 * four >= N - two){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    if(four >= N / 2){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool cant[20][20];
ll mp[20][20];
int a,b,ans;

int main()
{
	while(cin >> a >> b,a)
	{
		REP(i,20)REP(j,20)
		{
			mp[i][j] = 0;
			cant[i][j] = false;
		}
		ans = 0;
		
		int n;
		cin >> n;
		
		REP(i,n)
		{
			int x,y;
			cin >> x >> y;
			cant[x-1][y-1] = true;
		}
		
		REP(i,20)
		{
			if(cant[i][0])break;
			mp[i][0]=1;		
		}
		REP(i,20)
		{
			if(cant[0][i])break;
			mp[0][i]=1;		
		}
		
		
		for(int i = 1;i < a ;i++)for(int j = 1;j < b;j++)
		{
			int tmp = 0;
			if(i > 0)tmp += mp[i-1][j];
			if(j > 0)tmp += mp[i][j-1];
			if(!cant[i][j])
			{
				mp[i][j] = tmp;
			}
			else
			{
				mp[i][j] = 0;
			}
			
		}

		cout << mp[a-1][b-1] << endl;
	}
	
	return 0;
}	

Measured memory_bytes: 3000
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,x,y = get_nums_l()

x,y = (min(x,y), max(x,y))

by_cost = [0] * (n+1)

for i in range(1, n):
    for j in range(i+1, n+1):
        c = j-i
        c = min(c, abs(i-x) + 1 + abs(j-y))
        by_cost[c] += 1

for i in range(1, n):
    print(by_cost[i])


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


int main(){
	long long int a,b,c,k;
	cin >> a >> b >> c >>k;
	if(k<=a){
		cout << 1*k << endl;
	}else if(k<=a+b){
		cout << a << endl;
	}else{
		cout << a -(k-a-b) << endl;
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    if(b < c || a > d) {
        ans = 0;
    } else if(a >= c && a <= d && b > d) {
        ans = d - a;
    } else if(c >= a && c <= b && d > b) {
        ans = b - c;
    } else if(a >= c && b <= d) {
        ans = b - a;
    } else if(c >= a && d <= b) {
        ans = d - c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import os
import time
import re
import math


def main():
    N,M=map(int,input().split())
    A=[int(input()) for  a in range(M)] #a (1段~N-1段)
    start=time.time();#
    memo=[0]*(N+1)
    memo[0]=1
    ban=[False]*(N+1)
    for a in A:
        ban[a]=True
    mod=1000000007
    for a in range(1,N+1):
        if ban[a]:
            memo[a]=0
        else:
            if a>1:
                memo[a]=(memo[a-1]+memo[a-2])%mod
            else:
                memo[a]=1



    print(memo[-1]%mod)
    #print("{}ms".format(math.floor(time.time()*1000-start*1000)))#


main()


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

int main() {
	long long n, k;
	cin >> n >> k;
	vector<long long> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	vector<long long> dp(n + 1);
	for (int i = 1; i <= n; i++) {
		long long x = a[i] + a[i - 1];
		dp[i] = dp[i - 1];
		if (x > k) {
			long long dx = x - k;
			dp[i] += dx;
			if (a[i] >= dx) {
				a[i] -= dx;
			} 
			else {
				a[i] = 0;
			}
		}
	} 
	cout << dp[n];
	return 0;
}

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


int main()
{
	int cnt=0;
	string s,t="CODEFESTIVAL2016";
	cin>>s;
	for(int i=0;i<16;i++)
	{
		if(s[i]!=t[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) {

    int[][] cookingTime = new int[5][3];
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      for (int i = 0; i < 5; i++) {
        BigDecimal tmp = new BigDecimal(br.readLine());

        cookingTime[i][0] = tmp.intValue();
        cookingTime[i][1] = tmp.setScale(-1, RoundingMode.UP).intValue();
        cookingTime[i][2] = cookingTime[i][1] - cookingTime[i][0];
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    Comparator comparator = new Comparator() {
      @Override
      public int compare(Object o1, Object o2) {
        final int index = 2;

        int[] numA = (int[]) o1;
        int[] numB = (int[]) o2;
        return (Integer.compare(numA[index], numB[index]));
      }
    };

    Arrays.sort(cookingTime, comparator);

    int sum = 0;
    for (int i = 0; i < cookingTime.length; i++) {
      if (i < cookingTime.length - 1) {
        sum += cookingTime[i][1];
      } else {
        sum += cookingTime[i][0];
      }
    }
    System.out.print(sum);

  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >>X;
  
  if (X == 7 || X == 5 || X == 3) {
    cout << "YES" << endl;
  }
  
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>

unsigned long int dp[100];

void func(int i){
  dp[i] = dp[i-1] + dp[i-2];
}
void print_list(int n){
  for(int i=0;i<n-1;i++){
    printf("%lu ",dp[i]);
  }
  printf("%lu\n",dp[n-1]);
}

int main(){
  int N;
  scanf("%d",&N);
  dp[0] = 2;
  dp[1] = 1;
  for(int i=2;i<N+2;i++){
    func(i);
  }
  printf("%lu\n",dp[N]);

  return 0;
}

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


int main() {
	
	int a, b;
	cin >> a >> b;
	
	if (a + b == 15) cout << "+\n";
	else if (a * b == 15) cout << "*\n";
	else cout << "x\n";
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		for (int i = 1; i <= 5; i++) {
              int val = sc.nextInt();
			if (val == 0) {
				System.out.println(i);
			}
		}
		}

	}




Measured memory_bytes: 35340
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;

const int N = 310;
int M;

int n, k;
int binom[N][N], dp[N], sum[N], tmp[N];

int norm(int x) { return x >= M ? x - M : x; }

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
#endif

  scanf("%d%d%d", &n, &k, &M);
  ++n;
  for (int i = 0; i <= n; ++i) {
    binom[i][0] = 1;
    for (int j = 1; j <= i; ++j)
      binom[i][j] = norm(binom[i - 1][j - 1] + binom[i - 1][j]);
  }
  sum[1] = 1;
  for (int i = 1; i <= k; ++i) {
    memset(tmp, 0, sizeof(tmp));
    tmp[1] = 1;
    for (int j = 2; j <= n; ++j)
      for (int l = 1; l < j; ++l)
        tmp[j] = (tmp[j] + tmp[l] * (ll)sum[j - l] % M * binom[j - 2][l - 1]) % M;
    for (int j = 1; j <= n; ++j)
      sum[j] = norm(sum[j] + tmp[j]);
   }
  printf("%d\n", tmp[n]);

  return 0;
}


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


using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)



int main() {

    ll n; cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll next_kill = 0;
    ll ans = 0;
    rep(i, n) {
        ll tmp = a[i] - next_kill;
        if(tmp <= 0) {
            next_kill = b[i];
            ans += a[i];
        } else {
            ll tmp2 = tmp - b[i];
            if(tmp2 < 0) {
                ans += a[i];
                next_kill = b[i]-tmp;
            } else {
                ans += b[i]+next_kill;
                next_kill = 0;
            }
        }
    }
    // 最後にn+1の街の文をみる
    ans += min(a[n], next_kill);

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    long double rad=PI*2*((long double)h/12.0+((long double)m/60.0)/12.0-(long double)m/60);
    long double c=(long double)(a*a+b*b)-2*a*b*cos(rad);
    printf("%20.20Lf",sqrtl(c));
    return 0;
}

Measured memory_bytes: 2644