akhauriyash/Code-Regression huggingface dataset:
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
M = [list(map(int, input().split())) for i in range(N)]


mod3_1list = []
mod3_2list = []
mod3_0list = []
for i in range(N):
    for j in range(N):
        if (i+j+2) % 3 == 1:
            mod3_1list.append(M[i][j])
        if (i+j+2) % 3 == 2:
            mod3_2list.append(M[i][j])
        elif (i+j+2) % 3 == 0:
            mod3_0list.append(M[i][j])

mod3_0list = [mod3_0list.count(c) for c in range(1, C+1)]
mod3_1list = [mod3_1list.count(c) for c in range(1, C+1)]
mod3_2list = [mod3_2list.count(c) for c in range(1, C+1)]

ans = float("inf")
for c1 in range(1, C+1):
    for c2 in range(1, C+1):
        for c3 in range(1, C+1):
            if c1 != c2 and c2 != c3 and c1 != c3:
                mod3_0diff = [mod3_0list[c] * D[c][c1-1] for c in range(C)]
                mod3_1diff = [mod3_1list[c] * D[c][c2-1] for c in range(C)]
                mod3_2diff = [mod3_2list[c] * D[c][c3-1] for c in range(C)]
                ans = min(ans, sum(mod3_0diff) + sum(mod3_1diff) + sum(mod3_2diff))


print(ans)

Measured memory_bytes: 56156
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

k = ir()
s = 'ACL'
a = [s for i in range(k)]
print(*a, sep='')

Measured memory_bytes: 72744
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=205;
int basis[65],n,a[N],b[N];

void insert(int x){
	for(int i=59;~i;i--) if(x>>i&1){
		if(basis[i]) x^=basis[i];
		else{
			basis[i]=x;
			return ;
		}
	}
}

bool exists(int x){
	for(int i=59;~i;i--) if(x>>i&1){
		if(basis[i]) x^=basis[i];
		else return 0;
	}
	return 1;
}

bool doit(){
	read(n);
	for(int i=0;i<60;i++) basis[i]=0;
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++) scanf("%1d",&b[i]);
	for(int i=n;i;i--){
		if(!b[i]) insert(a[i]);
		else if(!exists(a[i])) return 1;
	}
	return 0;
}

signed main(){
	int t;
	read(t);
	while(t--) write(doit()),puts("");
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int a[N];
int n;
int k;
int dp[N];

int solve(int i)
{
	if(i>=n)
		return 0;
	if(dp[i]!=-1)
		return dp[i];
	int x= INT_MAX;
	rep(j,i+1,min(i+k,n))
	{
		x= min(x,abs(a[j]-a[i])+solve(j));
	}
	dp[i] = x;
	return dp[i];
}

int32_t main()
{
	IOS;
	memset(dp,-1,sizeof(dp));
	cin >> n;
	cin >> k;
	rep(i,1,n)
	{
		cin >> a[i];
	}
	cout << solve(1) << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;

const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    bool flag=true;
    while(flag){
        for(int i=0;i<n;i++){
            if(a[i]%2==1){
                flag=false;
            }
        }
        if(flag){
            for(int i=0;i<n;i++){
                a[i]/=2;
            }
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  vector<int> v(3);
  int sum=0;
  for(int i=0;i<3;i++){
    cin >> v.at(i);
    sum+=v.at(i);
  }
  sort(v.begin(),v.end());
  if(sum-v.back()==v.back()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long n , m;
  scanf("%lld %lld",&n ,&m);


  long long ans;
  if(2*n >= m){
    ans = m/2;
  }
  else{
    long long sa = m - 2*n;
    sa /= 4;
    ans = sa + n;
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	printf("%d",(n+k-3)/(k-1));
	return 0;
}

Measured memory_bytes: 256
#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 x; cin >>x;
  ll sum = 0, t = 0;
  while(sum<x){
    sum += t+1;
    t++;
  }
  cout << t << endl;
  return 0; 
}

Measured memory_bytes: 3608
n,m=map(int,input().split()) 
k=[0]*m
s=[0]*m
p=[0]*m
for i in range(m):
  test=list(map(int,input().split()))
  k[i]=test.pop(0)
  s[i]=test
p=list(map(int,input().split()))

pattern=[]
ans=0
for i in range(2**(n)):
  count=0
  tmp=[0]*n
  for j in range(n):
    if i>>j & 1:
      tmp[j]=1
  pattern.append(tmp)
  #print(pattern[i])
  for j in range(m):
    num=0
    for t in range(k[j]):
      num+=pattern[i][s[j][t]-1]
    if (num%2==p[j]%2):
      count+=1
  if (count==m):
    ans+=1
print(ans)

Measured memory_bytes: 42480
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    llint n, kk;
    cin >> n >> kk;
    vector<pair<llint, llint>> ten(n);
    
    REP(i,n){
        cin >> ten[i].first >> ten[i].second;
    }
    llint xmax, xmin, ymax, ymin,tmpnum,result=linf;
    
    REP(i,n){
        REP(j,n){
            REP(k,n){
                REP(l,n){
                    xmax = max(max(ten[i].first,ten[j].first),max(ten[k].first,ten[l].first));
                    xmin = min(min(ten[i].first,ten[j].first),min(ten[k].first,ten[l].first));
                    ymax = max(max(ten[i].second,ten[j].second),max(ten[k].second,ten[l].second));
                    ymin = min(min(ten[i].second,ten[j].second),min(ten[k].second,ten[l].second));
                    tmpnum = 0;
                    REP(m,n){
                        if(xmin<=ten[m].first&&ten[m].first<=xmax&&ymin<=ten[m].second&&ten[m].second<=ymax){
                            tmpnum++;
                        }
                    }
                    if(tmpnum>=kk){
                        result = min(result, (xmax - xmin) * (ymax - ymin));
                    }
                }
            }
        }
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

ll n, ans;
string s, p1, p2;
map<pair<string, string>, ll> mp;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> s;
	p1 = s.substr(0, n);
	p2 = s.substr(n, n);
	for (int i = 0; i < (1 << n); i++) {
		string red, blue, mask;
		int t = i;
		while (t) {
			if (t & 1)
				mask += '1';
			else
				mask += '0';
			t /= 2;
		}
		while (mask.size() < n)
			mask += '0';
		for (int j = 0; j < n; j++)
			if (mask[j] == '0')
				red += p1[j];
			else
				blue += p1[j];
		mp[make_pair(red, blue)]++;
	}
	for (int i = 0; i < (1 << n); i++) {
		string red, blue, mask;
		int t = i;
		while (t) {
			if (t & 1)
				mask += '1';
			else
				mask += '0';
			t /= 2;
		}
		while (mask.size() < n)
			mask += '0';
		for (int j = 0; j < n; j++)
			if (mask[j] == '0')
				red += p2[j];
			else
				blue += p2[j];
		reverse(red.begin(), red.end());
		reverse(blue.begin(), blue.end());
		ans += mp[make_pair(blue, red)];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 87040
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,ans=3;
    cin>>a>>b>>c;
    if(a==b&&a==c){
        ans=1;
    }
    else if(a==b||b==c||c==a){
        ans=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
list_s = list(input())
list_t = list(input())
n = len(list_s)
for i in range(0, n):
    if "".join(list_s) == "".join(list_t):
        print("Yes")
        exit()
    list_s.insert(0, list_s[n - 1])
    list_s.pop(-1)
print("No")

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

int kotak[55][55], hasil[55][55];

int main() {
	int baris, kolom;
	char tmp;
	cin >> baris >> kolom;
	for (int i = 1; i <= baris; ++i) {
		for (int a = 1; a <= kolom; ++a) {
			cin >> tmp;
			if (tmp ==  '#')
				kotak[i][a] = 1;
			else if (tmp == '.')
				kotak[i][a] = 0;
		}
	}
	for (int i = 1; i <= baris; ++i) {
		for (int a = 1; a <= kolom; ++a) {
			if (kotak[i][a] == 1)
				cout << '#';
			else if (kotak[i][a] == 0) {
				hasil[i][a] = kotak[i - 1][a] + kotak[i + 1][a] + kotak[i][a + 1] + kotak[i][a - 1] + kotak[i - 1][a - 1] + kotak[i - 1][a + 1] + kotak[i + 1][a + 1] + kotak[i + 1][a -1];
				cout << hasil[i][a];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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

yes = "Yes"
no = "No"

def main():
    k,x = mi()
    a = range(x-(k-1),x+(k-1)+1)
    print(*a)


main()




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


int main() {
	int N;
	set<string> sset;
	cin >> N;
	rep(i,N){
		string s;
		cin >> s;
		sset.insert(s);
	}
	cout << sset.size() << endl;
    return 0;
}



Measured memory_bytes: 19152
n=int(input())
a=list(map(int,input().split()))
a.sort()
am=max(a)
dp=[[True,0] for _ in range(am+1)]
count=0
for i in a:
    if dp[i][0]==False:
        continue
    else:
        if dp[i][1]==1:
            dp[i][0]=False
            count-=1
        else:
            dp[i][1]=1
            count+=1
            for j in range(2*i,am+1,i):
                dp[j][0]=False
print(count)

Measured memory_bytes: 106148
n = gets.to_i

list = []
n.times{
  command = gets.split
  case command[0]
  when "insert"
    list.unshift(command[1])
  when "delete"
    tmp = []
    while list.size > 0 do
      it = list.shift
      break if it == command[1]
      tmp.push(it)
    end
    list = tmp + list
  when "deleteFirst"
    list.shift
  when "deleteLast"
    list.pop
  end
}
puts list.join(" ")

Measured memory_bytes: 119076
#include<bits/stdc++.h>
#define llong long long
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 1e5;
const int P = 1e9+7;
llong a[N+3],s[N+3];
llong f[N+3],sf[N+3];
llong fact[N+3],finv[N+3];
int n;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}

int main()
{
	fact[0] = 1ll; for(int i=1; i<=N; i++) fact[i] = fact[i-1]*i%P;
	finv[N] = quickpow(fact[N],P-2); for(int i=N-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%lld",&s[i]);
	for(int i=1; i<=n; i++) a[i] = s[i]-s[i-1];
	for(int i=1; i<=n; i++)
	{
		f[i] = (sf[i-1]*fact[i-1]%P*finv[i]+1ll)%P;
		sf[i] = (f[i]+sf[i-1])%P;
	}
//	printf("f: "); for(int i=1; i<=n; i++) printf("%lld ",f[i]*fact[i]%P); puts("");
	llong ans = 0ll;
	for(int i=1; i<=n; i++) ans = (ans+a[i]*f[i-1])%P;
	printf("%lld\n",ans*fact[n-1]%P);
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		sc.close();
		int N = S.length();
		//S全体が回文であるかチェック
		for (int i = 0; i < (N - 1) / 2; i++) {
			if (S.charAt(i) != S.charAt(N - 1 - i)) {
				System.out.println("No");
				return;
			}
		}

		for (int i = 0; i < (N - 1) / 4; i++) {
			if (S.charAt(i) != S.charAt((N - 3) / 2 - i)
					|| S.charAt((N + 1) / 2 + i) != S.charAt(N - 1 - i)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23508
#include <stdio.h>
#include <stdlib.h>


int main()
{
	//変数宣言
	int N;
	
	
	//初期入力
	scanf("%d",&N);
	
	//最終出力
	N %= 10;
	
	switch(N){
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon");
		break;
	case 3:
		printf("bon");
		break;
	default:
		break;
	}

	
	return 0;
}

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

using namespace std;
typedef long long ll;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const long long INF  = 1e18;
int md = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<ll> pre(n);
    for(int i=0;i<n;i++)
    {   
        if(i==0)
            pre[i] = a[i]%md;
        else
            pre[i] = (pre[i-1]%md + a[i]%md)%md;
    }
    long long ans= 0LL;
    for(int i=1;i<n;i++)
    {
        long long sum = (a[i]%md * pre[i-1]%md)%md;
        ans = (ans%md + sum%md)%md;
    }
    cout<<ans;
}

//https://www.youtube.com/watch?v=ZQqccia8bVo

Measured memory_bytes: 6328
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String text = stdIn.nextLine();
		String[] textArray = text.split(" ");
		String appleIndex = "";
		String peachIndex = "";

		//textArrayの中で、.*apple.*と.*peach.*の格納されているインデックスを取得する
		for(int i = 0;i < textArray.length; i++){

			if(Pattern.compile(".*apple.*").matcher(textArray[i]).find()){
				appleIndex += i + " ";
			}else if(Pattern.compile(".*peach.*").matcher(textArray[i]).find()){
				peachIndex += i + " ";
			}
		}
		String[] appleIndexArray = appleIndex.split(" ");
		String[] peachIndexArray = peachIndex.split(" ");
		for(String i:appleIndexArray){
			if(i.equals(""))break;
			textArray[Integer.valueOf(i)] = textArray[Integer.valueOf(i)].replace("apple", "peach");
		}
		for(String i:peachIndexArray){
			if(i.equals(""))break;
			textArray[Integer.valueOf(i)] = textArray[Integer.valueOf(i)].replace("peach", "apple");
		}
		for(int i = 0;i < textArray.length; i++){
			if(i == textArray.length -1){
				System.out.println(textArray[i]);
			}else{
				System.out.print(textArray[i] + " ");
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

	ld w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << setprecision(10) << fixed << w * h / 2 << ' ' << (x + x == w && y + y == h);
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

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;

//Write From this Line
vector<int> G[10];
int main()
{
	int n , m ;
	cin >>  n >> m ;
	rep(i,m){
		int a , b ;
		cin >>  a >> b ;
		--a , --b ;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> root(n-1);
	rep(i,n-1){
		root[i] = i +1 ;
	}
	ll ans = 0 ;

	do{
		//今見てるrootの順序ですべての頂点を探索できるか。
		int start = 0;
		int count = 0;
		while(1){
			bool no_root = false ;
			for(int i = 0 ; i < G[start].size() ; i++){
				if(G[start][i] == root[count]){
					//ok
					start = root[count];
					count ++ ;
					break;
				}
				if(i==G[start].size()-1){
					no_root = true ;
				}
			}
			if(count == n -1 ){
				ans ++ ; 
				count = 0 ;
				start = 0 ;
				break ;
			}
			if(no_root){
				count = 0 ;
				start = 0;
				break;
			}
		}
	} while (next_permutation(root.begin(),root.end()));
	cout << ans << endl;
}


Measured memory_bytes: 256
int main(){
int a,b,c;
scanf("%d %d %d", &a,&b,&c);
if(a <= b && b <= c){
printf("%d %d %d\n", a, b, c);
}else if(a <= b && a >= c){
printf("%d %d %d\n", c, a, b);
}else if(b <= c && a >= c){
printf("%d %d %d\n", b, c, a);
}else if(a >= b && a <= c){
printf("%d %d %d\n", b, a, c);
}else if(a >= b && b >= c){
printf("%d %d %d\n", c, b, a);
}else if(a <= c && c <= b){
printf("%d %d %d\n", a, c, b);
}
return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;


public class Main {
	int m, n;
	char[][] map;
	Scanner in = new Scanner(System.in);
	
	String remove_zero(String s) {
		int k;
		for (k = 0; k < s.length(); k++) {
			if (s.charAt(k) != '0') break;
		}
		return s.substring(k, s.length()); 
	}
	
	boolean compare(String s1, String s2) {
		if (s1.length() > s2.length()) return true;
		else if (s1.length() < s2.length()) return false;
		else {
			for (int i = 0; i < s1.length(); i++) {
				if (s1.charAt(i) > s2.charAt(i)) return true;
				else if (s1.charAt(i) < s2.charAt(i)) return false;
			}
		}
		return true;
	}
	
	public Main() {
		while (true) {
			int m = in.nextInt();
			int n = in.nextInt();
			if (m == 0 && n == 0) break;
			map = new char[n+1][m+1];
			for (int i = 1; i <= n; i++) {
				String s = in.next();
				for (int j = 0; j < m; j++) {
					map[i][j+1] = s.charAt(j);
				}
			}
			String[][] dp = new String[n+1][m+1];
			for (int i = 0; i <= n; i++) 
				for (int j = 0; j <= m; j++) 
					dp[i][j] = "";
			
			String ans = "";		
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					if (map[i][j] >= 'A' && map[i][j] <= 'Z' || map[i][j] == 0)
						continue;
					else if (map[i][j] == '0' && dp[i][j-1] == "" && dp[i-1][j] == "") 
						continue;
					else {
						dp[i][j] = (compare(dp[i][j-1] + map[i][j], dp[i][j])) ? dp[i][j-1] + map[i][j] : dp[i][j];
						dp[i][j] = (compare(dp[i-1][j] + map[i][j], dp[i][j])) ? dp[i-1][j] + map[i][j] : dp[i][j];
					}
					ans = compare(dp[i][j], ans) ? dp[i][j] : ans;
				}
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

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

using namespace std;

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

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

	int res = 1;
	vector<int> D(N+1);
	D.at(0) = 0;
	for (int i = 1; i <= N; i++)
	{
		D.at(i) = D.at(i - 1) + L.at(i - 1);

		if (D.at(i) <= X)
		{
			res += 1;
		}
		else
		{
			break;
		}
	}

	cout << res << endl;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
         public void solve(int testNumber, InputReader in, PrintWriter out) {
             int n=in.nextInt(),a=in.nextInt(),b=in.nextInt();
             if((a-b)%2==0)out.print("Alice");else out.print("Borys");
         }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21460
<?php
define('MOD', 1000000007);
define('MAX', 666666);

// 繰り返し二乗法
function power($a, $b){
	$res=1;
	while($b>0){
		if($b&1) $res=$res*$a%MOD;
		$a=$a*$a%MOD;
		$b>>=1;
	}
	return $res;
}

function comb($n, $r){
	global $fact, $fact_inv;
	return ($fact[$n]*$fact_inv[$r])%MOD*$fact_inv[$n-$r]%MOD;
}

$n = MAX;
$fact[0]=1;
// 階乗の計算
for ($i = 0; $i < $n; $i++) {
	$fact[$i+1]=$fact[$i]*($i+1)%MOD;
}
$fact_inv[$n]=power($fact[$n], MOD-2);
// 逆元の計算
for($i=$n-1; $i>=0; --$i) {
	$fact_inv[$i]=$fact_inv[$i+1]*($i+1)%MOD;
}

fscanf(STDIN, "%d %d", $X, $Y);

if (($X + $Y) % 3 === 0) {
	$Z = $X + $Y;
	$ZZ = $Z / 3;
	$X -= $ZZ;
	$Y -= $ZZ;
	if ($X < 0 || $Y < 0) {
		echo "0";
	} else {
		echo comb($X + $Y, $X);
	}
} else {
	echo "0";
}


Measured memory_bytes: 64108
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static int LinearSearch(List<long> a, long key)
    {
        int i = 0;
        a.Add(key);
        while (a[i] != key) i++;
        a.RemoveAt(a.Count - 1);
        if (i == a.Count) return -1;
        return i;
    }

    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        List<long> ns = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        int q = int.Parse(Console.ReadLine());
        List<long> qs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        int res = 0;
        for (int i = 0; i < qs.Count; i++) res = (LinearSearch(ns, qs[i]) != -1)? res + 1: res;
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 18248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.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; }

const long long INF = 1LL << 60;

int main(){
  int a, b, x; cin >> a >> b >> x;

  cout << (a<=x && x<=a+b ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
countDiv n p = inner n 0 0
  where inner m k 0 = inner (div m p) (succ k) (mod m p)
        inner m k 1 = pred k

main = interact $ (++ "\n") . show . minimum
  . map ((`countDiv` 2) . read) . readInput . lines
  where readInput (x:y:_) = take (read x) (words y)


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);

  for(int i=0;i<n;i++) {
    cin >> d.at(i);
  }

  sort(d.begin(), d.end());
  
  int ans = d.size();
  for(int i=0;i<n-1;i++) {
    if(d.at(i) == d.at(i+1)) {
      ans--;
    }
  }

  cout << ans << endl;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

const ll MOD = 1000000007;

int main() {
    ll n, k; cin >> n >> k;
    V<ll> A(n);
    loop (n, i) cin >> A[i];

    V<ll> B(n);
    loop (n, i) for (int j = i + 1; j < n; j++) {
        if (A[i] > A[j]) B[i]++;
    }

    int cnt[2010] = {};
    loop (n, i) cnt[A[i]]++;
    loop (2009, i) cnt[i + 1] += cnt[i];
    V<ll> C(n);
    loop (n, i) C[i] = n - cnt[A[i]];

    ll ans = 0;
    loop (n, i) {
        ans += (k * B[i]) % MOD + (C[i] * ((k * (k - 1) / 2) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}



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

using namespace std;

int main(){

   int n, x;
   vector<int> ans;

   cin >> n >> x;

   while(n){
      int cnt = 0;
      for(int i = 1; i <= n; i++){
         for(int j = i + 1; j <= n; j++){
            for(int k = j + 1; k <= n; k++){
               if(i + j + k == x){
                  cnt++;
               }
            }
         }
      }
      ans.push_back(cnt);

      cin >> n >> x;
   }

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

   return 0;
}


Measured memory_bytes: 3108
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n/100*5>=n%100) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9+7;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

int main() {
    using mint = ModInt<MOD>;
    constexpr int MAX = 3030;
    int n;
    string s;
    cin >> n >> s;
    
    mint dp[MAX][MAX];
    for (int i = 0; i < n; i++) dp[1][i] = 1;
    
    for (int i = 2, id = 0; i <= n; i++, id++) {
        mint sum[MAX];
        for (int j = 0; j <= n; j++) sum[j+1] = sum[j] + dp[i-1][j];
        if (s[id] == '<') {
            for (int j = 0; j <= n-i; j++) dp[i][j] = (sum[n-i+2] - sum[j+1]);
        } else {
            for (int j = 0; j <= n-i; j++) dp[i][j] = sum[j+1];
        }
    }
    
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 36096
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            cnt += 1
    else:
        cnt += 1
if cnt == N:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3064
//String Rotation

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    string s,ss;cin>>s>>ss;
    rep(i,0,s.size()+2){
        s=s[s.size()-1]+s;
        s.erase(s.size()-1);
        if(ss==s){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var n, k int
var h []int
var dp []int

func main() {
	n = readInt()
	k = readInt()
	h = make([]int, n)
	for i := range h {
		h[i] = readInt()
	}
	dp = make([]int, n+1)
	for i := 0; i < n+1; i++ {
	}

	for i := 1; i < n; i++ {
		dp[i] = math.MaxInt32
		for j := k; j > 0; j-- {
			if i-j >= 0 {
				dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
			}
		}
	}

	fmt.Println(dp[n-1])
}


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

using namespace std;

template <typename T>
class SparseTable {
 private:
  const std::size_t n = 0;
  std::vector<std::vector<T>> table;
  std::vector<std::size_t> lookup;

 public:
  SparseTable(const std::vector<T>& vec)
      : n(vec.size()),
        table(static_cast<std::size_t>(std::log2(n)) + 1, std::vector<T>(vec)),
        lookup(n + 1, 0) {
    for (std::size_t k = 0; k + 1 < table.size(); k++) {
      for (std::size_t i = 0; i + (1 << k) < n; i++) {
        table[k + 1][i] = std::gcd(table[k][i], table[k][i + (1 << k)]);
      }
    }
    for (std::size_t i = 2; i < n + 1; i++) {
      lookup[i] = lookup[i >> 1] + 1;
    }
  }

  T query(std::size_t l, std::size_t r) const {  // [l, r)
    assert(l < r);
    std::size_t k = lookup[r - l];
    return std::gcd(table[k][l], table[k][r - (1 << k)]);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto&& e : A) {
    cin >> e;
  }
  SparseTable st(A);
  int res = max(st.query(1, N), st.query(0, N - 1));
  for (int i = 1; i < N - 1; i++) {
    res = max(res, gcd(st.query(0, i), st.query(i + 1, N)));
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 11152
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef long double ldb;

int main(void)
{
	ldb pi2 = 6.28318530717958623200;
	int r;
	scanf("%d",&r);
	printf("%.20Lf",pi2*r);
	return 0;
}

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

int main() {
  int n;
  int data[3] = {0, 0, 0};

  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> data[i];
  }

  for ( int i  = 1; i <= 100000000; i++) {
    if ( data[0] % i == 0 && data[1] % i == 0 && data[2] % i == 0 ) {
      cout << i << endl;
    }
  }

  return (0);
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int k,x;
    cin >> k >> x;
    FOR(i,x-k+1,x+k){
        if (i < x+k-1)
        {
            cout << i << " ";
        }
        else
        {
            cout << i << endl;
        }
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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 const INF = 1001001001;


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

int N;
cin >> N;
vl A(N);
rep(i,N) cin >> A[i];

ll sum = 0;
ll cur = 0;
rep(i,N) {
    sum += A[i];
    if(i % 2 == 1) cur += A[i];
}
ll x = sum / 2 - cur;
rep(i,N) {
    if(i == N-1) {
        cout << 2*x << endl;
        return 0;
    }
    cout << 2*x << ' ';
    x = A[i] - x;
}
return 0;
}

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long 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(){
  int s, w;
  cin >> s >> w;
  if(s <= w)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
  return 0;
}


Measured memory_bytes: 3616
n, m = map(int, input().split())
a = []
b = []

for i in range(n):
  a.append(list(map(int, input().split())))
for i in range(m):
  b.append(int(input()))

for i in range(n):
  sum = 0
  for j in range(m):
    sum += a[i][j] * b[j]
  print(sum)


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

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

struct Data {
    int a, b, c, d;
};

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    int ans = 0;
    vector<Data> data(Q);
    for(Data &x : data) {
        cin >> x.a >> x.b >> x.c >> x.d;
        x.a--, x.b--;
    }
    vector<int> A(N);
    recursive([&](auto f, int i) -> void {
        if(i >= N) {
            int cand = 0;
            for(Data x : data) {
                cand += A[x.b] - A[x.a] == x.c ? x.d : 0;
            }
            ans = max(ans, cand);
            return;
        }
        int l = i ? A[i - 1] : 1; // lower bound of A[i]
        for(int k = l; k <= M; k++) {
            A[i] = k;
            f(f, i + 1);
        }
    })(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	const char *SEP = " ";
	int d, t, s;
	char input_str[256];
	char *num_str;

	fgets(input_str, sizeof(input_str), stdin);
	num_str = strtok(input_str, SEP);
	d = atoi(num_str);
	num_str = strtok(NULL, SEP);
	t = atoi(num_str);
	num_str = strtok(NULL, SEP);
	s = atoi(num_str);

	if ( d <= t * s ) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 1580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K, Q;
	cin >> N >> K >> Q;

	vector<Int> poi(N);
	Int temp;
	for (Int i = 0; i < Q; i++) {
		cin >> temp;
		temp--;
		poi[temp]++;
	}

	vector<Int> ans(N);
	for (Int i = 0; i < N; i++) {
		ans[i] = K - (Q - poi[i]);
	}

	for (Int i = 0; i < N; i++) {
		if (ans[i] > 0)printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) > abs(x - b))
		cout << "B" << "\n";
	else
		cout << "A" << "\n";
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}

int main(){
    ll a,b;cin>>a>>b;
    int k;cin>>k;
    rep(i,k){
        if(i%2==0){
            if(a%2==1 && a>0)a--;
            b += a/2;
            a /= 2;
        }
        if(i%2==1){
            if(b%2==1 && b>0)b--;
            a += b/2;
            b /= 2;
        }
    }
    cout<<a<<" "<<b<<endl;
}



Measured memory_bytes: 256