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

int main() {
  string S;
  cin >> S;
  
  if (S.at(2)==S.at(3) && S.at(4)==S.at(5)){
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    k: usize,
  }
  if k > (n - 1) * (n - 2) / 2 {
    println!("-1");
    return;
  }
  let mut edge = vec![];
  for i in 1 .. n {
    edge.push((i, n));
  }
  let mut p = ((n - 1) * (n - 2) / 2 - k) as i32;
  for i in 1 .. n {
    for j in 1 .. i {
      if p > 0 {
        edge.push((i, j));
        p -= 1;
      }
    }
  }
  println!("{}", edge.len());
  for &(i, j) in &edge {
    println!("{} {}", i, j);
  }
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int n, d, x, a;
	int count = 0;

	cin >> n >> d >> x;

	for (int i = 0; i < n; i++) {
		int y = 1;

		cin >> a;
		while (y <= d) {
			count++;
			y += a;
		}
	}


	cout << count + x<< endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = (int)1e9 + 7;

signed main() {
  int N;
  cin >> N;
  vector<int> C(N);
  for(int i=0; i<N; i++) cin >> C[i];
  sort(C.begin(),C.end(), greater<int>());

  vector<int> b(N+1);
  b[0] = 1;
  for(int i=1; i<=N; i++) b[i] = (b[i-1]*2) % MOD;

  int ans = 0;
  for(int i=0; i<N; i++) ans = (ans + (C[i] * (i+2))) % MOD;
  ans = (ans * ((b[N-1] * b[N-1]) % MOD)) % MOD;
  cout << ans << endl;
}


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

int main(){

  int n, q, m, date;
  int cnt[110];

  while(cin >> n >> q, n|q){
    memset(cnt, 0, sizeof(cnt));
    int ans = 0;
    for(int i = 0; i < n; i++){
      cin >> m;
      for(int j = 0; j < m; j++){
        cin >> date;
        cnt[date]++;
      }
    }
    for(int i = 1; i < 110; i++){
      if(cnt[ans] < cnt[i]) ans = i;
    }
    if(cnt[ans] < q) ans = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2992
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; i++)
        L[i] = A[left+i];
    for(int i=0; i<n2; i++)
        R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;
    int i=0, j=0;
    for(int k=left; k<right; k++)
    {
        cnt++;
        if(L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}
void mergeSort(int A[], int n, int left, int right)
{
    if(left+1 < right)
    {
        int mid = (left+right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}
int main()
{
    int A[MAX], n, i;
    cnt = 0;
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> A[i];
    mergeSort(A, n, 0, n);
    for(int i=0; i<n-1; i++)
        cout << A[i] << " ";
    cout << A[n-1] << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 7016
from sys import stdin

s = int(stdin.readline().rstrip())
up = s//100
down = s%100


if (up>=13 or up==0) and (down>=13 or down==0):
  ans = "NA"
elif (up>=13 or up==0):
  ans = "YYMM"
elif (down>=13 or down==0):
  ans = "MMYY"
else:
  ans = "AMBIGUOUS"

print(ans)


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

using namespace std;

int main()
{
    char s[101], *p1, *p2;
    cin.get(s, 101);
    p1=strchr(s, 'C');
    p2=strrchr(s, 'F');
    if(p1==NULL || p2==NULL)
    {
        cout<<"No";
        return 0;
    }
    if(p2-p1>=0)
    {
        cout<<"Yes";
        return 0;

    }
    else{
        cout<<"No";
        return 0;
    }
return 0;
}


Measured memory_bytes: 256
/*input
7
218 786 704 233 645 728 389
*/

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e3 + 10;
vector<long long> freq(MAXN);

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

	int n;
	cin >> n;

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

	long long ans = 0;

	for(int i = 1; i < MAXN; i++) {
		freq[i] += freq[i-1];
	}

	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			long long l = max(a[i], a[j]) - min(a[i], a[j]);
			long long r = a[i] + a[j];
			long long cur = freq[r-1] - freq[l];
			if(a[i] > l and a[j] < r) cur--;
			if(a[j] > l and a[j] < r) cur--;
			ans += cur;
		}
	}

	ans = ans / 3;

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    vector<int> seg = {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
    int n;cin >> n;
    while(n!=-1){
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n){
        if(i!=0){
            cout << bitset<7>(seg[v[i]]^seg[v[i-1]]) << endl;
        }else{
            cout << bitset<7>(seg[v[0]]) << endl;
        }
    }
    cin >> n;
    }
}


Measured memory_bytes: 3108
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

int n, a1, a2;
int pm;
ll cnt;

int main(){
	cin >> n;
	cnt = 1;
	cin >> a2;
	pm = 0;
	lp(n - 1) {
		a1 = a2;
		cin >> a2;
		if (pm == 0 && a2 > a1)pm = 1;
		else if (pm == 0 && a2 < a1)pm = -1;
		else if (pm == 1 && a2 < a1) {
			pm = 0;
			cnt++;
		}
		else if (pm == -1 && a2 > a1) {
			pm = 0;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,ans=1;
  cin>>n>>k;
  int cnt=0;
  while(1)
  {
   if(ans>=k)break;
   ans+=n;                      cnt++;
   ans--;
    
  }

  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 1e5 + 50;
VI e[MAXN];
int cnt[MAXN];
bool first = false;

bool DFS(int x, int p = 0) {
	if(SZ(e[x]) == 1) return true;
	int cnt = 0;
	for(int u : e[x]) {
		if(u == p) continue;
		if(DFS(u, x)) cnt++;
	}
	if(cnt >= 2) first = true;
	if(cnt == 0) return true;
	return false;
}

int main() {
	int N;
	scanf("%d", &N);
	for(int i = 1; i < N; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		e[a].PB(b);
		e[b].PB(a);
	}
	for(int i = 1; i <= N; i++)
		if(SZ(e[i]) > 1) {
			if(DFS(i))
				first = true;
			break;
		}
	puts(first ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 5888
def factorization(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())
prime_factors = factorization(P)
g = 1
for p in prime_factors:
    g *= p[0] ** (p[1] // N)
print(g)

Measured memory_bytes: 3188
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

g = [0]*(N+1)

for i in range(N+1):
    g[i] = abs(A[i]-A[i+1])

s = sum(g)

for i in range(N):
    print(s-g[i]-g[i+1]+abs(A[i]-A[i+2]))

Measured memory_bytes: 20372
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rip(i,n,0){
        cin >> a[i];
    }
    vector<vector<ll>> da(n,vector<ll>(n)); // da[i][j] i番目のjこ後ろまで見る
    rip(i,n,0){
        da[i][0]=a[i];
        rip(j,n,1){
            da[(i+j)%n][j]=min(da[(i+j-1)%n][j-1],a[(i+j)%n]);
        }
    }
    ll ans=LLONG_MAX;
    rip(i,n,0){
        ll memo=0;
        rip(j,n,0){
            memo+=da[j][i];
        }
        memo+=(ll) x*i;
        ans=min(ans,memo);
    }
    cout << ans << endl;
}

Measured memory_bytes: 31616
def main():
    x = int(input())
    answer = 1
    b = 2
    while b <= x:
        p = 2
        while pow(b, p) <= x:
            answer = max(answer, pow(b, p))
            p += 1
        b += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    char str[3];
    scanf("%s", str);

    if (str[0] == 'A' && str[1] == 'A' && str[2] == 'A')
    {
        printf("No\n");
        return (0);
    }
    else if (str[0] == 'B' && str[1] == 'B' && str[2] == 'B')
    {
        printf("No\n");
        return (0);
    }
    else 
    {
        printf("Yes\n");
        return (0);
    }
    return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const int INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};

int main(){
  int n;
  cin >> n;
  vector<vector<int>> point(n,vector<int>(2));
  for(int i=0;i<n;i++){
    cin >> point.at(i).at(0) >> point.at(i).at(1);
  }
  sort(point.begin(),point.end());
  double ans = 0;
  do{
    double tmp = 0;
    for(int i=1;i<n;i++){
      int x1 = point.at(i-1).at(0),y1 = point.at(i-1).at(1);
      int x2 = point.at(i).at(0),y2 = point.at(i).at(1);
      tmp += pow((pow(x1-x2,2) + pow(y1-y2,2)),0.5);
    }
    ans += tmp;
  }
  while(next_permutation(point.begin(),point.end()));
  cout << fixed << setprecision(10) << ans/kaizyou(n) << endl;
}

Measured memory_bytes: 4172
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,a[100000];
    cin >> n;
    for (int i = 0;i < n; i++ ){
        cin >> a[i];
    }
    for(int j = n - 1;j >= 0;j--){
        if(j == n - 1){ 
        cout << a[j];
    }else{
       cout << " " << a[j];
    }
    }
    cout << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

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

    long long dist = 0;
    while (n--) {
        int b;
        cin >> b;

        if (b < (k - b))
            dist += 2* b;
        else
            dist += 2* (k-b);
    }

    cout << dist << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

func main() {
	var n int
	fmt.Scan(&n)

	var t, x, y int
	var ny, nx, nt int
	for i := 0; i < n; i++ {
		fmt.Scan(&t, &x, &y)
		dt, dx, dy := t-nt, abs(nx-x), abs(ny-y)
		if dt-(dx+dy) < 0 || (dt-(dx+dy))%2 != 0 {
			fmt.Println("No")
			return
		}
		nx, ny, nt = x, y, t
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
ll _gcd(ll a, ll b) { return b != 0 ? _gcd(b, a % b) : a; }
map<ll, ll> decompositPrime(ll n) {
  map<ll, ll> res;
  ll a = 2;
  while (n >= a * a) {
    if (n % a == 0) {
      n /= a;
      if (res.count(a) == 0) res[a] = 0;
      res[a]++;
    } else {
      a++;
    }
  }
  if (n > 1) {
    debug("n>1", n);
    if (res.count(n) == 0) res[n] = 0;
    res[n]++;
  }

  return res;
}

int main() {
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  ll g = _gcd(a, b);
  debug(g);
  map<ll, ll> res = decompositPrime(g);
  for (pair<ll, ll> i : res) {
    debug(i.first, i.second);
  }
  cout << SIZE(res) + 1 << endl;
  return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll X, A, B;

int main() {
    cin >> X >> A >> B;
    if(B - A <= 0) {
        cout << "delicious"
             << "\n";
    } else if(B - A <= X) {
        cout << "safe"
             << "\n";
    } else {
        cout << "dangerous"
             << "\n";
    }
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    int cnt = 0;
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, s.size()) {
            if (s[j] == '#') ++cnt;
        }
    }

    if (h + w - 1 == cnt)
        cout << "Possible";
    else
        cout << "Impossible";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
using namespace std;
int a[100100];
int n;
int cnt[10];
int main()
{
//	freopen("A.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2!=0)
			a[i]=1;
		else if(a[i]%4!=0)
			a[i]=2;
		else a[i]=3;
		cnt[a[i]]++;
	}
	if(cnt[1]>cnt[3]){
		if(cnt[2]==0&&cnt[1]-cnt[3]<=1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else printf("Yes\n");
	return 0;
}


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

int main() {
	// your code goes here
	long long int n, x, a, b;
	cin >> n;
	a = n / 100;
	b = n % 100;
	bool ym = false, my = false;
	if(a > 12 || a == 0){
		if(b <= 12 && b > 0){
			ym = true;
			
		}
	}else{
		if(b > 12 || b == 0){
			my = true;
		}else{
			my = true;
			ym = true;
		}
	}
	if(ym && my){
		cout << "AMBIGUOUS" << endl;
	}else if(ym){
		cout << "YYMM" << endl;
	}else if(my){
		cout << "MMYY" << endl;
	}else{
		cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import static java.lang.System.out;

class Collision {
    public static boolean isOutCircleFromRect( int w, int h, int cx, int cy, int cr ) {
        return !(((cx - cr) >= 0) && ((cx + cr) <= w) &&
            ((cy - cr) >= 0) && ((cy + cr) <= h));
    }
}

public class Main {
    public static void main( String... args ) {
        // scan
        Scanner scan = new Scanner( System.in);

        int w = scan.nextInt();
        int h = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();

        out.println(Collision.isOutCircleFromRect(w, h, x, y, r) ? "No" : "Yes");

    }
}

Measured memory_bytes: 26316
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	int res=(n-1)*(n-2)/2;
	if(k>res)return !puts("-1");
	int zhn=res-k;
	printf("%d\n",n-1+zhn);
	for(int i=2;i<=n;i++){
		printf("1 %d\n",i);
	}
	for(int i=2;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(!zhn)return 0;
			zhn--;
			printf("%d %d\n",i,j);
		}
	}
}


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

int main(){
  ll N;cin>>N;
  vll A(N),B(N);rep(i,N)cin>>A[i]>>B[i];
  sort(all(A));sort(all(B));
  ll ans;
  if(N%2==1){
    ll cut = (N-1)/2;
    ll left = A[cut];
    ll right = B[cut];
    ans = right - left + 1;    
  }
  else{
    //to cut+1
    ll cut = N/2-1;
    ll a = A[cut]+A[cut+1];
    ll b = B[cut]+B[cut+1];
    ans = b - a + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6376
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
vector<bool> b(1000001,false);
int main(void) {
	int n, m; cin >> n;
	if (n == 1) cout << 1 << endl;
	else if (n < 4) cout << 2 << endl;
	else if (n < 8) cout << 4 << endl;
	else if (n < 16) cout << 8 << endl;
	else if (n < 32) cout << 16 << endl;
	else if (n < 64) cout << 32 << endl;
	else  cout << 64 << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

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

		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		if (a <= b) {
			if (b <= c) {
				System.out.println(a + b);
			} else {
				System.out.println(a + c);
			}
		} else {
			if (a <= c) {
				System.out.println(a + b);
			} else {
				System.out.println(b + c);
			}
		}
	}
}


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

using namespace std;
using ll = long long;

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

bool judge_kaibun(string S) {
    string S2(S);
    reverse(S2.begin(), S2.end());
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != S2[i]) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    int len = s.size();
    int b1 = (len - 1)/2;
    int b2 = (len + 3)/2;

    if (judge_kaibun(s) && judge_kaibun(s.substr(0, b1)) && judge_kaibun(s.substr(b2-1))) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        int esum = 0, osum = 0;
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
                if (i & 1) {
                        osum += a[i];
                } else {
                        esum += a[i];
                }
        }
        if (n & 1) {
                int lb = 0, ub = 100000000;
                while (ub - lb > 1) {
                        int mid = (lb + ub) / 2;
                        vector<int> b = a;
                        for (int i = 0; i < n - 1; i += 2) {
                                if (b[i] >= mid && b[i + 1] >= b[i]) {
                                        continue;
                                } else {
                                        b[i + 2] += b[i] - b[i + 1];
                                }
                        }
                        if (b[n - 1] >= mid) {
                                lb = mid;
                        } else {
                                ub = mid;
                        }
                }
                printf("%d %d\n", lb + osum, esum - lb);
        } else {
                printf("%d %d\n", max(esum, osum), min(esum, osum));
        }
        return 0;
}



Measured memory_bytes: 2576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int n,a,b,c,d;
string s;

bool A(int from,int to){
    int i;
    for(i=from;i<=to;i++){
        if(i==to) return true;
        if(s[i+1]!='#') continue;
        if(s[i+2]=='#') return false;
        else i++;
    }
    if(i==to) return true;
    return false;
}
bool B(){
    int i;
    for(i=b;i<=d;i++){
        if(i==d) return true;
        if(s[i+1]!='#') continue;
        if(s[i+2]=='#') return false;
        else i++;
    }
    if(i==d) return true;
    return false;
}

int main(){
    cin>>n>>a>>b>>c>>d>>s;
    a--,b--,c--,d--;
    bool ans=true;
    ans&=B();
    if(c<d){
        ans&=A(a,c);
        cout<<(ans?"Yes":"No")<<endl;
    }else{
        bool flg=0;
        for(int i=b;i<=d;i++){
            if(s[i]=='#') continue;
            if(s[i-1]!='#' and s[i+1]!='#'){
                if(A(a,i-1)&&A(i+1,c)){
                    flg=1;
                    break;
                }
            }
        }
        ans&=flg;
        cout<<(ans?"Yes":"No")<<endl;
    }
    return 0;
}


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

using namespace std;

void solve()
{
	int N, K;
	while(cin >> N >> K, N || K)
	{
		vector<int> blood(K);
		for(int i = 0; i < K; ++i)
		{
			cin >> blood[i];
		}
		vector<int> sum(K);
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < K; ++j)
			{
				int require;
				cin >> require;
				sum[j] += require;
			}
		}
		bool flag = true;
		for(int i = 0; i < K; ++i)
		{
			if(sum[i] > blood[i])
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1188
N,C=map(int, input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]
color=[{} for i in range(3)]
for i in range(N):
    for j in range(N):
        x=(i+j)%3
        if c[i][j] in color[x]:
            color[x][c[i][j]]+=1
        else:
            color[x][c[i][j]]=1
ans=10**9
for i in range(C):
    for j in range(C):
        if j==i:
            continue
        for k in range(C):
            if k==j or k==i:
                continue
            s0=sum([D[x-1][i]*color[0][x] for x in color[0].keys()])
            s1=sum([D[x-1][j]*color[1][x] for x in color[1].keys()])
            s2=sum([D[x-1][k]*color[2][x] for x in color[2].keys()])
            ans=min(ans,s0+s1+s2)
print(ans)

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

//#define int long long

signed main() {
	string s;
	cin >> s;
	
	for (int i = 0; i < 4; i++) cout << s[i];
	cout << " ";
	for (int i = 4; i < s.length(); i++) cout << s[i];
	cout << endl;
	return 0;
}

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

void insertionSort(int A[], const int n, const int g, int *cnt)
{
    for( int i = g; i < n; ++i ){
        int tmp = A[i];
        int j = i - g;
        while( -1 < j && tmp < A[j] ){
            //cout << A[j+g] << "<-->" << A[j] << endl;
            A[j+g] = A[j];
            j = j - g;
            ++*cnt;
        }
        A[j+g] = tmp;
    }
}

void shellSort(int A[], const int n)
{
    int cnt = 0;
    int m;
    int G[100];
    for( int i = 0; i < 100; ++i ){
        if( i == 0 ) G[i] = n / 2 + 1;
        else G[i] = G[i-1] / 2 - 1;
        if( G[i] < 0 ){
            G[i-1] = 1;
            G[i] = 0;
            m = i;
            break;
        }
    }

    for( int i = 0; i < m; ++i )
        insertionSort(A, n, G[i], &cnt);

    //??????
    printf("%d\n", m);
    for( int i = 0; i < m; ++i ){
        if( i ) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for( int i = 0; i < n; ++i )
        printf("%d\n", A[i]);
}

int main()
{
    //??\???
    int n;
    scanf("%d", &n);
    int A[n];
    for( int i = 0; i < n; ++i )
        scanf("%d", &A[i]);

    //?????§????????????
    shellSort(A, n);

    return 0;
}

Measured memory_bytes: 7116
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 
#define MO 
ll tmp,op,n,k;
inline void _Sol_()
{
	read(n);read(k);
	if(n==1){
		priE(1);return;
	}
	tmp=0; op=1;
	while(op<=n){
		op*=k;
		tmp++;
	}
	priE(tmp);
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 256
// Problem Code: abc172_d

#include <iostream>
#include <vector>

using namespace std;

long long sum_of_divisors(int N) {
	long long res = 0;
	vector<int> f(N);

	for (int i = 1; i <= N; i++)
		f[i] = 1;
	
	for (int i = 2; i <= N; i++)
		for (int j = i; j <= N; j += i)
			f[j]++;
	
	for (long long i = 1; i <= N; i++)
		res += i * f[i];
	
	return res;
}

int main() {
	int N;
	cin >> N;
	cout << sum_of_divisors(N);
	return 0;
}

Measured memory_bytes: 42308
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    vector<int> odd, even;
    rep(i, 3) {
        int a;
        cin >> a;
        if(a % 2 == 0) even.push_back(a);
        else odd.push_back(a);
    } 
    int ans = 0;
    if(even.size() == 2) {
        ans++;
        rep(i, even.size()) even[i]++;
    }
    if(even.size() == 1) {
        ans++;
        rep(i, odd.size()) odd[i]++;
    }
    int maxv = -1;
    
  
    for(auto x : even) maxv = max(x, maxv);
    for(auto x : odd) maxv = max(x, maxv);
    for(auto x : even) ans += (maxv - x) / 2;
    for(auto x : odd) ans += (maxv - x) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
x=sorted(x,reverse=True)
cnt=0
for i in range(0,n-2):
 l1=x[i]
 for j in range(i+1,n-1):
  l2=x[j]
  for k in range(j+1,n):
   l3=x[k]
   if l1<l2+l3 and l1!=l2 and l2!=l3:
      cnt+=1
print(cnt)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, Q;
const int m_log = 20;
vector<int> G[100010];
int par[m_log][100010];
int depth[100010];

void dfs(int v, int p, int d){
    par[0][v] = p;
    depth[v] = d;

    for(auto& u : G[v]){
        if(p == u) continue;
        dfs(u, v, d + 1);
    }
}

void setting(){
    dfs(0, -1, 0);
    for(int i = 1; i < m_log; i++){
        for(int j = 0; j < N; j++){
            if(par[i - 1][j] < 0) par[i][j] = -1;
            else par[i][j] = par[i - 1][par[i - 1][j]];
        }
    }
}

int lca(int u, int v){
    if(depth[u] < depth[v]) swap(u, v);
    int d = depth[u] - depth[v];

    for(int i = 0; i < m_log; i++){
        if(d >> i & 1) u = par[i][u];
    }
    if(u == v) return u;

    for(int i = m_log - 1; i >= 0; i--){
        if(par[i][u] != par[i][v]){
            u = par[i][u];
            v = par[i][v];
        }
    }
    return par[0][u];
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int c;
            cin >> c;
            G[i].push_back(c);
            G[c].push_back(i);
        }
    }
    setting();

    cin >> Q;
    for(int i = 0; i < Q; i++){
        int u, v;
        cin >> u >> v;
        cout << lca(u, v) << endl;
    }
    return 0;
}


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

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

int judge(int place, int height, int rank){
    if(rank==1){
        if(place==1 && height==0)return 0;
        else return 1;
    }
    if(height<rank && rank<=place)return 0;
    else{
        if(rank<=place)place-=rank;
        if(rank<=height)height-=rank;
        return judge(place, height, rank/2);
    }
}

int main(){
    int n;
    cin>>n;
    int a[1000005]={};
    char c;
    REP(i,n){
        cin>>c;
        a[i]=c-'0';
    }
    int b[1000005]={};
    REP(i,n-1){
        b[i] = abs(a[i] - a[i+1]);
    }
    int two = 1;
    REP(i,n-1){
        if(b[i]==1)two=0;
    }
    if(two){
        REP(i,n-1)b[i]/=2;
    }
    else{
        REP(i,n-1)if(b[i]==2)b[i]=0;
    }
    int ra=0;int val=1;
    while(val<n){
        val*=2;
        ra++;
    }
    int sum=0;
    REP(i,n-1){
        //cout<<i<<" "<<n-2<<" "<<val/2<<" "<<judge(i,n-2,val/2)<<endl;
        if(judge(i, n-2, val/2))sum=sum^b[i];
    }
    if(two)sum*=2;
    cout<<sum<<endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n,k;cin>>n>>k;
    cout<<abs((n+k-1)/k-n/k)<<endl;
    return 0;
}

Measured memory_bytes: 3584
K, A, B = map(int, input().split())

k = K
ans = A
k -= A - 1
if k % 2 == 1:
    k -= 1
    ans += 1
    
if B-A >= 2:
    ans += (k//2) * (B-A)
    
else:
    ans += k

print(ans)

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

const int N = 3000;

int n, z, w;

int a[N], f[N], g[N]; 

// f[i] : X 拿第 i 个的话最终的结果
// g[i] : Y 拿第 i 个的话最终的结果

int main()
{
    scanf( "%d%d%d", &n, &z, &w );

    for( int i = 1; i <= n; i ++ )
        scanf( "%d", &a[i] );

    f[n-1] = g[n-1] = abs( a[n] - a[n-1] );
    f[n] = abs( a[n] - w );
    
    for( int i = n-2; i >= 1; i -- )
    {
        f[i] = g[i] = abs( a[i] - a[n] );
        for( int j = i+1; j < n; j ++ )
        {
            f[i] = min( f[i], g[j] );
            g[i] = max( g[i], f[j] );
        }
    }
    
    int ans = 0;
    for( int i = 1; i <= n; i ++ )
        ans = max( ans, f[i] ); 
    printf( "%d\n", ans );

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def solve(N: int):
    base = 26
    # z 26
    # aa 27
    # ab 28
    if N == 1:
        print("a")
        return
    rans = []
    for i in range(100000):
        if N == 0:
            break
        N -= 1
        if i == 0:
            rans.append(chr(N % base + ord('a')))
            N = N // base
        else:
            rans.append(chr((N) % base + ord('a')))
            N = N // base
    print("".join(reversed(rans)))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65208
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

const int N = 200002;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a, b;
    LL ans = 0;
    cin >> n;
    FOR(i, 1, n){
        ans += 1ll*i*(i+1)/2;
    }
    FOR(i, 1, n-1){
        cin >> a >> b;
        if(a > b) swap(a,b);
        ans -= 1ll*a*(n-b+1);
    }
    cout << ans;
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 3700
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d, area1, area2;
    cin >> a >> b >> c >> d;
    area1 = a * b;
    area2 = c * d;
    if(area1 > area2)
        cout << area1;
    else if(area1 < area2)
        cout << area2;
    else
    cout << area1;


    return 0;
}


Measured memory_bytes: 256
N = input()
N = int(N)
Ws = list(map(int,input().split(" ")))

ans = 10e10
for i in range(1,N):
    if abs(sum(Ws[:i])-sum(Ws[i:])) < ans:
        ans = abs(sum(Ws[:i])-sum(Ws[i:]))
print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    //string S;
    cin >> N;
    vector<ll> A(N),B(N);
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        if(i%2){
            sum -= A[i];
        }else{
            sum += A[i];
        }
    }
    B[0] = sum;
    REP(i,1,N){
        B[i] = (A[i-1] - B[i-1]/2)*2;
    }
    PR(B,N);
}


Measured memory_bytes: 3712
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #define rep(i,a,b) for(ll i=a;i<b;++i)
  #define rrep(i,a,b) for(ll i=a;i>b;--i)
  #define FOR(i,n)  for(ll i=0;i<n;i++)
  #define vi vector<int>
  #define vl vector<ll>
  #define ld long double
  #define vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #define pii pair<int,int>
  #define pll pair<long,long>
  #define vpii vector<pii>
  #define vpll vector<pll>
  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define d1(x) cout<<(x)<<endl
  #define d2(x,y) cout<<(x)<<" "<<(y)<<endl
  #define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
  #define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
  #define PI 3.1415926535897932384626433832795
  #define fix(f,n) fixed<<setprecision(n)<<f
  #define all(x) x.begin(),x.end()
  #define rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
  if(b&1)ans=ans*a%m;
  a=a*a%m;
  b>>=1;
  }

  return ans;
  }



  ll poww(ll a,ll b)
  { 

  ll ans=1;
  while(b)
  {
  if(b&1)ans=ans*a;
  a=a*a;
  b>>=1;
  }

  return ans;

  }

  template<typename T,typename F>
  void chmax( T &a,F b){
  if(b>a)a=b;
  }

  template<typename T,typename F>
  void chmin( T &a,F b){
  if(b<a)a=b;
  }

string tostring(ll x){
  stringstream sss;
  sss<<x;
  string ans=sss.str();
  return ans;
}


  const ll N=1e3+5;



  int main()
  { 

ll n;cin>>n;

vl a(n);
ll c=0;
FOR(i,n)cin>>a[i],c+=a[i];

ll s=0,ans=1e18;

FOR(i,n){
s+=a[i];
if(i<n-1)chmin(ans,abs(2*s-c));
}

cout<<ans;

  return 0;

  }

Measured memory_bytes: 4908
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
A = [int(x) for x in input().rstrip().split()]
A = np.array(A, np.int64)
while len(A) > 1:
    A = A[np.nonzero(A)]
    A = np.sort(A)
    minA = A[0]
    A %= minA
    A[0] = minA
A = A[np.nonzero(A)]
print(A[0])


Measured memory_bytes: 23124
using System;

namespace ABC126_E___1_or_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var union = new UnionFind(NM[0]);
            for (int i = 0; i < NM[1]; i++)
            {
                var xyz = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                union.unite(xyz[0], xyz[1]);
            }
            Console.WriteLine(union.UnionCount);
        }
    }
    public class UnionFind
    {
        private int[] parents;
        // 同じ根に属する枝の数を格納する
        private int[] rootCount;
        public int UnionCount;

        public int RootCount(int branch)
        {
            return rootCount[root(branch)];
        }

        public UnionFind(int count)
        {
            parents = new int[count + 1];
            rootCount = new int[count + 1];
            UnionCount = count;
            for (int i = 0; i < count + 1; i++)
            {
                parents[i] = i;
                rootCount[i] = 1;
            }
        }

        private int root(int N)
        {
            if (parents[N] == N) return N;
            return parents[N] = root(parents[N]);
        }

        //木を併合する際に、枝の数も合算する
        public void unite(int X, int Y)
        {
            int rootX = root(X);
            int rootY = root(Y);
            if (rootX == rootY) return;
            rootCount[rootX] += rootCount[rootY];
            parents[rootY] = rootX;
            UnionCount -= 1;
        }

        public bool sameRoot(int X, int Y)
        {
            return root(X) == root(Y);
        }

    }
}


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

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

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> a(n+1, 0);
    rep(i, m){
        int idx;
        cin >> idx;
        ++a[idx];
    }

    int r = 0;
    for(int i = x; i <= n; ++i) r += a[i];

    int l = 0;
    for(int i = x; i >= 0; --i) l += a[i];

    cout << min(l, r) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <functional>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(var,init,end) for(int var=init;var<end;var++)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main() {
	int N, M;
	cin >> N >> M;
	vector<vector <long long>> xyz(N);
	FOR(i, 0, N) {
		xyz[i] = vector<long long>(3);
		cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2];
	}

	long long max_value = -(1e+300*1e+300);
	
	int idx = 1;
	int sign_x = -1,sign_y=-1,sign_z=1;
	FOR(i,0,8) {
		vector<long long> sum_val(N);
		sign_z *= -1;
		if (i == 0 || i == 1 || i == 4 || i == 5) {
			sign_y = 1;
		}
		else
		{
			sign_y = -1;
		}
		if (i >3) {
			sign_x = 1;
		}
		FOR(m, 0, N) {
			sum_val[m] = xyz[m][0]*sign_x + xyz[m][1]*sign_y + xyz[m][2]* sign_z;
		}
		sort(sum_val.begin(), sum_val.end(), std::greater<long long>());

		long long tmp = 0;
		FOR(m, 0, M) {
			tmp += sum_val[m];
		}
		
		if (tmp > max_value) {
			max_value = tmp;
		}
	}
	
	cout << max_value;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int A,B,C,K;

int main(int argc, char const *argv[])
{
    cin>>A>>B>>C>>K;
    int M=max(A,max(B,C));
cout<<M*pow(2,K)+A+B+C-M<<endl;
return 0;
}


Measured memory_bytes: 384
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    A, B, K = map(int, sys.stdin.readline().split())
    cnt = 0
    i = max(A, B)
    while True:
        if (A % i) == 0 and (B % i) == 0:
            cnt += 1
            if cnt == K:
                print(i)
                exit()
        i -= 1


Measured memory_bytes: 5072