akhauriyash/Code-Regression huggingface dataset:
// @DateTime:    2020-04-26 21:26:48
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast", "-funroll-all-loops", "-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(), (x).end()
#define trav(a, x) for (auto &a : x)
#define close \
    std::ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c)         \
    (sort(c.begin(), c.end()), \
     c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define CASET    \
    int ___T;    \
    cin >> ___T; \
    for (int __CS = 1; __CS <= ___T; __CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6 + 10;
constexpr int mod = 1e9 + 7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base = 2333, P_1 = 19260811, P_2 = 999998639;
void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
void dec(int &a, int b) {
    a -= b;
    if (a < 0) a += mod;
}
char s[maxn];
const int P = 2019;
#define int long long
int n;
int v[5][P + 10];
void up() {
    int ans = 0, la = 0;
    for (int i = 1; i <= n; i++) {
        memset(v[la ^ 1], 0, sizeof v[la ^ 1]);
        for (int j = 0; j < 2019; j++) {
            if ((j * 10 + s[i] - '0') % P == 0) {
                ans += v[la][j];
            }
            // v[la^1][s[i]-'0']++;
            v[la^1][(j * 10 + s[i] - '0') % P] += v[la][j];
        }
        v[la ^ 1][s[i] - '0']++;
        la ^= 1;
    }
    
    cout << ans << endl;
}
int32_t main() {
    cin >> s + 1;
    n = strlen(s + 1);
    up();
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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);

    string t;
    cin >> t;

    string res = "";
    rep(i, t.size()){
        if(t[i] == '?') res += 'D';
        else res += t[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3888
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    bool check = false;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        if (temp % 2 == 0)
        {
            if (temp % 3 && temp % 5)
            {
                check = true;
            }
        }
    }
    if (check)
    {
        cout << "DENIED"
             << "\n";
    }
    else
    {
        cout << "APPROVED"
             << "\n";
    }
}


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

int main() {
  int n;
  cin >> n;
  ll a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  ll cnt = 0;
  ll push = 0;
  for (int i = n - 1; i >= 0; i--) {
    a[i] += cnt;
    push = a[i] % b[i];
    if (push) {
      cnt += b[i] - push;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e15+7;
const ll N = 200003;
ll n,a[N],y=0,x=0;
pair<ll,ll> ans[N];
int main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
	}
	ll x;
	x=1;
	FOR(i,0,n){
		ans[i].second=a[i];
		if(i%2==0){
			x++;
			ans[i].first=x;
		}else{
			x*=-1;
			ans[i].first=x;
			x*=-1;
			x++;
		}
	}
	sort(ans,ans+n);
	FOR(i,0,n){
		if(n%2==0)cout<<ans[i].second<<" ";
		else cout<<ans[n-1-i].second<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int d, i, j, l, dp[10003][2][103] = {}, ans;
    string k;

    cin >> k;
    scanf("%d", &d);

    dp[0][0][0] = 1;
    for (i = 0; i < k.size(); i++) {
        for (j = 0; j < d; j++) {
            dp[i + 1][0][(j + k[i] - '0') % d] += dp[i][0][j];
            dp[i + 1][0][(j + k[i] - '0') % d] %= mod;
        }
        for (j = 0; j < d; j++) {
            for (l = 0; l < k[i] - '0'; l++) {
                dp[i + 1][1][(j + l) % d] += dp[i][0][j];
                dp[i + 1][1][(j + l) % d] %= mod;
            }
        }
        for (j = 0; j < d; j++) {
            for (l = 0; l < 10; l++) {
                dp[i + 1][1][(j + l) % d] += dp[i][1][j];
                dp[i + 1][1][(j + l) % d] %= mod;
            }
        }
    }

    ans = (dp[k.size()][0][0] + dp[k.size()][1][0]) % mod;
    ans = (ans + mod - 1) % mod;

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

    return 0;
}

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

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

    let answer = solve(&buf);

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

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

    let a: i64 = iterator.next().unwrap().parse().unwrap();
    let b: i64 = iterator.next().unwrap().parse().unwrap();
    let c: i64 = iterator.next().unwrap().parse().unwrap();

    return if (c - a - b) > 0 && (4 * a * b) < (c - a - b) * (c - a - b) {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <cstdlib>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  copy_n(istream_iterator<int>(cin), N, x.begin());

  int result = 2 * (x[N - 1] - x[0]);
  for (int i = 0; i < N - K + 1; ++i) {
    int tmp = 0;
    if (0 <= x[i]) tmp = x[i + K - 1];
    else if (x[i + K - 1] <= 0) tmp = -x[i];
    else if (abs(x[i]) <= x[i + K - 1]) tmp = x[i + K - 1] - 2 * x[i];
    else tmp = 2 * x[i + K - 1] - x[i];

    if (tmp < result) result = tmp;
  }

  cout << result << endl;
  return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(V),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll ans = 1;
	REP(i, n) {
		ans = (ans*(i+1))%MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,b;
  cin >>a >>b;
  
  if ((a*b)% 2 == 0){
   cout << "Even" << endl;
  }
  
  else {
   cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

int main() {
  int r,g,b;
  cin>>r>>g>>b;
  int n=100*r+10*g+b;
  if(n%4==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
 
    int i=1;
    int x;
    
    for(;;){
        cin>>x;
        if(x==0)break;
        cout<<"Case"<<" "<<i<<":"<<" "<<x<<endl;
        ++i;
    }
        
            
 
    
   
    
    return 0;
 
}

Measured memory_bytes: 1164
N = int(input())
X = [0,0,0,0]
for n in range(N):
    x = input()
    if x == 'AC':
        X[0] += 1
    elif x == 'WA':
        X[1] += 1
    elif x == 'TLE':
        X[2] += 1
    else:
        X[3] += 1

print('AC x', X[0])
print('WA x', X[1]) 
print('TLE x', X[2]) 
print('RE x', X[3])  

Measured memory_bytes: 9152
require "prime"

n, m = gets.chomp.split.map(&:to_i)
weight = gets.chomp.split.map(&:to_i)
pd1 = Prime.prime_division n
pd2 = Prime.prime_division m
h = Hash.new(0)
[pd1, pd2].each{|pd| pd.each{|p, n| h[p] = n if h[p] < n}}
lcm = 1
h.each{|k, v| lcm *= (k ** v)}
i = j = sum = 0
min, max = 100, 0
lcm.times{
    min = weight[i] if min > weight[i]
    max = weight[i] if max < weight[i]
    if j == m - 1
        sum += (max - min)
        min, max = 100, 0
    end
    i = (i + 1) % n
    j = (j + 1) % m
}
puts sum


Measured memory_bytes: 7048
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let profit = 0;
    let money = 1000;
    
    for (let i = 0; i<N; i++) {
        const possibleProfit = A[i + 1] - A[i];
        profit = Math.max(profit + possibleProfit, profit);
        
        // console.log("possibleProfit:" + possibleProfit)
        
        if(possibleProfit > 0) {
            let cnt = Math.floor(money / A[i]);
            money += (possibleProfit * cnt);
        }
    }
    
    console.log(money);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30772
#include<stdio.h>
#include<stdlib.h>
#define ll long long
const int Inf=1e9+10;
int gi(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9' && ch>='0'){sum=sum*10+ch-'0';ch=getchar();}
	return sum*f;
}
int d;
ll ans;
int main(){
	int i,j,k,n,m;
	scanf("%d",&d);
	if(d%9){
                printf("0\n");
		return 0;
	}
	d/=9;
	ll len=1,ini=0;
	for(i=1;i<=17;i++){
		ll tmp=1,D=d;
		ini=ini*10+1;
		ll base=ini,lten=len,rten=1;
		for(int j=0;j<=(i>>1);j++){
			tmp*=10-abs(D%(rten*10)/rten)-(!j?1:0);
			D-=base*(D%(rten*10)/rten);
			base-=lten+rten;
			lten/=10;rten*=10;
		}
		len*=10;
		if(!D)ans+=tmp;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
import Control.Applicative
import Data.List

readInts :: IO [Int]
readInts = map read . words <$> getLine

getLines :: IO [[Int]]
getLines = do
  xs@[a, b] <- readInts
  if a == 0 && b == 0
     then return []
     else do
       rest <- getLines
       return (xs : rest)

calc :: Int -> Int -> Int
calc n x = length [1 | i <- [1..n], j <- [i+1..n], k <- [j+1..n],
                   i + j + k == x]

main :: IO ()
main = do
  xs <- getLines
  putStrLn $ intercalate "\n" [show $ calc n x | [n, x] <- xs]

Measured memory_bytes: 4428
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const d = input[1].split(" ").map((x: string): number => +x);
const m = +input[2];
const t = input[3].split(" ").map((x: string): number => +x);

const compare = (a: number, b: number) => a - b;

d.sort(compare);
t.sort(compare);

let ii = 0;
for (let i = 0; i < n; i++) {
	if (d[i] == t[ii]) {
		ii += 1;
	}
}

if (ii == m) console.log("YES");
else console.log("NO");


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

int N;
const long long INF = 1LL << 60;
vector<int> A;
vector<long long> S;
vector<vector<long long>> dp;

// 
long long func(int left, int right) {
  if (left == right) return dp.at(left).at(right) = 0;
  if (dp.at(left).at(right) != INF) return dp.at(left).at(right);
  long long res = INF;
  long long cost = S.at(right+1) - S.at(left);
  for (int i = 0; i < right - left; i++) {
    long long tmp = func(left, left + i) + func(left + i + 1, right);
    res = min(res, cost + tmp);
  }
  return dp.at(left).at(right) = res;
}

int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  S.assign(N+1, 0);
  for (int i = 0; i < N; i++) S.at(i+1) = S.at(i) + A.at(i);
  dp = vector<vector<long long>>(N+1, vector<long long>(N+1, INF));
  cout << func(0, N-1) << endl;
}

Measured memory_bytes: 1536
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        String s = inp.next();
        String t = inp.next();
        if (s.length() + 1 == t.length()) {
            if (s.equals(t.substring(0, s.length()))) {
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }
        }
        else System.out.println("No");
    }
}


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

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();

    println!("{}", a * b);
}


Measured memory_bytes: 2108
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int x;
    int tmp_x;
    int ans=1;
    int tmp_ans;
    cin >> x;
    tmp_x = (int)sqrt(x);
    tmp_x++;
    if(x!=1){
        for(int i=2; i<=tmp_x; i++){
            int j=1;
            while(true){
                tmp_ans=1;
                for(int k=0; k<j; k++){
                    tmp_ans*=i;
                }
                if(tmp_ans>x){
                    break;
                }else if(tmp_ans>ans){
                    ans=tmp_ans;
                }
                j++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll M=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % M; }
ll SUB(ll x, ll y) { return (x-y+M) % M; }
ll MUL(ll x, ll y) { return x*y % M; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { return MUL(x, POW(y, M-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }


vector<vector<ll>> ac; // ac[c][i]: iまでのx^cまでの和

void _prep(int j_max=400, int K=400){
    // 0乗〜3乗：j_max=3
    ac.assign(1+j_max, vector<ll>(1+K, 0));
    vector<ll> xi(1+K, 1);
#ifdef DEBUG
    //cout << ac[0] << endl;
#endif
    rep(c, j_max+1) {
        ac[c][0] = 0LL;
        rep1(i, K) {
            ac[c][i] = ADD(ac[c][i-1], xi[i]);
            xi[i] = MUL(xi[i], i);
        }
#ifdef DEBUG
        cout << ac[c] << endl;
#endif
    }
}

inline ll p(int a, int b, int j) {
#ifdef DEBUG
    // assert(1 <= a && a <= b);
    // printf("p(%d,%d,%d) = %lld - %lld\n", a,b,j, ac[j][b], ac[j][a-1]);
#endif
    return SUB(ac[j][b], ac[j][a-1]);
}


ll solve(int N, int C, vector<int>& a, vector<int>& b) {
    int b_max = *max_element(ALL(b));
    _prep(C, b_max);

    vector<ll> dp0(1+C, 0);
    rep(to, 1+C) {
        dp0[to] = p(a[0], b[0], to);
    }

    rep1(n, N-1) {
        vector<ll> dp1(1+C, 0);

        // n人目: a[n] .. b[n]
        // printf("n=%d, [%d %d]\n", n, a[n], b[n]);

        // dp[a] : n-1人で a個消費した場合の合計
        rep(to, 1+C) {
            rep(from, to+1) {
                ll f = p(a[n], b[n], to-from);
                // printf(" f = %lld\n", f);
                dp1[to] = ADD(dp1[to], MUL(dp0[from], f));
            }
        }
        // cout << dp1 << endl;
        dp0 = dp1;
    }
    // cout << "dp:" << dp0 << endl;
    return dp0[C];
}

int main() {
    int N, C; cin >> N >> C;
    vector<int> a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    cout << solve(N, C, a, b) << endl;
    return 0;
}


Measured memory_bytes: 1536
package main

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

func main() {
	io, flush := NewIO()
	defer flush()
	n := io.ScanInt()
	nums := io.ScanInts(n)
	sort.Ints(nums)
	for i := 0; i < len(nums)-1; i++ {
		if nums[i] == nums[i+1] {
			io.Println("NO")
			return
		}
	}
	io.Println("YES")
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}



Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define vectorl vector<int>
int mmin(int &a, int b) {
	a = min(a, b);
	return a;
}
int mmax(int &a, int b) {
	a = max(a, b);
	return a;
}
int sor(vectorl &v) {
	sort(v.begin(), v.end());
	return 0;
}
int nibl(vectorl &v, int tan) {
	int up = v.size() - 1;
	int lo = 0;
	if (v[up] <= tan) return up;
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (v[mi] <= tan) lo = mi;
		if (tan < v[mi]) up = mi;
	}
	return lo;
}
int vmax(vectorl &v) {
	int ans = v[0];
	for (int i = 1; i < v.size(); i++) mmax(ans, v[i]);
	return ans;
}
int vmin(vectorl &v) {
	int ans = v[0];
	for (int i = 1; i < v.size(); i++) mmin(ans, v[i]);
	return ans;
}
int nextza(int &x, int &y, int kai) {
	int d = -1;
	if (kai % 3 == 1) d = 2;
	if (kai < 3) x += d;
	else y += d;
	return 0;
}
signed main() {
	int w, h;
	cin >> w >> h;
	while(h!=0){
	int n; cin >> n;
	vector<int> x(2 * n);
	vector<int> y(2 * n);
	int zx = 1;
	int zy = 1;
	int mx = 1;
	int my = 1;
	for (int i = 0; i < 2*n; i++) {
		cin >> x[i] >> y[i];
		if (x[i] == 0) zx = 0;
		if (x[i] == w) mx = 0;
		if (y[i] == 0) zy = 0;
		if (y[i] == h) my = 0;
	}
	vector<int> qx, qy;
	qx = x;
	qy = y;
	sor(qx); 
	sor(qy);
	vector<int> ranx(2 * n);
	vector<int> rany(2 * n);
	ranx[0] = 0; rany[0] = 0;
	for (int i = 1; i < 2 * n; i++) {
		ranx[i] = ranx[i - 1];
		rany[i] = rany[i - 1];
		if (qx[i] > qx[i - 1]) ranx[i]++;
		if (qy[i] > qy[i - 1]) rany[i]++;
	}
	vector<int> nx(2 * n);
	vector<int> ny(2 * n);
	for (int i = 0; i < 2*n; i++) {
		nx[i] = ranx[nibl(qx, x[i])]+zx;
		ny[i] = rany[nibl(qy, y[i])]+zy;
	}
	int nw = ranx[2 * n - 1]+zx+mx;
	int nh = rany[2 * n - 1]+zy+my;
	vector<vectorl> co(nw + 2, vectorl(nh + 2, 0));
	for (int i = 0; i < n; i++) {
		int x1 = nx[2 * i]+1;
		int x2 = nx[2 * i + 1] + 1;
		int y1 = ny[2 * i]+1;
		int y2 = ny[2 * i + 1] + 1;
		co[x1][y1]++;
		co[x1][y2]--;
		co[x2][y1]--;
		co[x2][y2]++;
	}
	for (int i = 1; i <= nw+1; i++) {
		for (int j = 1; j <= nh+1; j++) {
			co[i][j] = co[i][j] + co[i - 1][j] + co[i][j - 1] - co[i - 1][j - 1];
		}
	}
	for (int i = 0; i <= nw+1; i++) {
		for (int j = 0; j <= nh+1; j++) {
			if (co[i][j] > 0 or i==0 or i==nw+1 or j==0 or j==nh+1) co[i][j] = -2;
			else co[i][j] = -1;
		}
	}
	int nco = 0;
	vector<int> chx(nw*nh);
	vector<int> chy(nw*nh);
	int sta = 0;
	int to = 0;
	int qst, qto;
	for (int i = 1; i <= nw; i++) {
		for (int j = 1; j <= nh; j++) {
			if (co[i][j] == -1) {
				co[i][j] = nco;
				to++;
				chx[sta] = i; chy[sta] = j;
				while (sta < to) {
					int qst = to;
					int qto = to;
					for (int k = sta; k < to; k++) {
						int cx0 = chx[k];
						int cy0 = chy[k];
						for (int kai = 0; kai < 6; kai++) {
							nextza(cx0, cy0, kai);
							if (co[cx0][cy0] == -1) {
								co[cx0][cy0] = nco;
								chx[qto] = cx0; chy[qto] = cy0;
								qto++;
							}
						}
					}
					sta = qst;
					to = qto;
				}
				nco++;
			}
		}
	}
	cout << nco << endl;
	cin >> w>>h;
	}
}



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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll X;
	cin >>X;
	ll S=X/500*1000;
	X %=500;
	S +=X/5*5;
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
dp = [1000000]*(n+1)
dp[0] = 0
#6,9,36,81,216,729,1296,6561,7776,46656,59049
for i in range(1,n+1):
    if i >= 1:
        dp[i] = min(dp[i],dp[i-1]+1)
    if i >= 6:
        dp[i] = min(dp[i],dp[i-6]+1)
    if i >= 9:
        dp[i] = min(dp[i],dp[i-9]+1)
    if i >= 36:
        dp[i] = min(dp[i],dp[i-36]+1)
    if i >= 81:
        dp[i] = min(dp[i],dp[i-81]+1)
    if i >= 216:
        dp[i] = min(dp[i],dp[i-216]+1)
    if i >= 729:
        dp[i] = min(dp[i],dp[i-729]+1)
    if i >= 1296:
        dp[i] = min(dp[i],dp[i-1296]+1)
    if i >= 6561:
        dp[i] = min(dp[i],dp[i-6561]+1)
    if i >= 7776:
        dp[i] = min(dp[i],dp[i-7776]+1)
    if i >= 46656:
        dp[i] = min(dp[i],dp[i-46656]+1)
    if i >= 59049:
        dp[i] = min(dp[i],dp[i-59049]+1)
print(dp[-1])

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli cache[N];
lli a[N], n;

lli dp(lli idx) {

    if(idx > n)
        return inf;

    if(idx == n - 1)
        return 0;

    lli &ans = cache[idx];

    if(ans != -1) {
        return ans;
    }

    ans = min(dp(idx + 1) + abs(a[idx] - a[idx + 1]), dp(idx + 2) + abs(a[idx] - a[idx + 2]));
    return ans;

}

void solve()
{

    memset(cache, -1, sizeof cache);
    cin>>n;
    for(int i = 0; i < n; i ++) {
        cin>>a[i];
    }

    lli ans = dp(0);

    cout<<ans;

    cout<<'\n';
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}



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

long long f[110][20] = {0}, p[110][20] = {0};

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  long long ans = -9999999999;
  for (int i = 1; i < (1 << 10); i++) {
    long long tmp = 0, c[110] = {0};
    for (int j = 0; j < 10; j++) {
      if (i & (1 << j)) {
        for (int k = 1; k <= n; k++) {
          if (f[k][j] == 1) {
            c[k]++;
          }
        }
      }
    }
    for (int j = 1; j <= n; j++) {
      tmp += p[j][c[j]];
    }
    if (tmp > ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S =input()
S += "X"

ans = [0] * len(S)
state = 0
Rnum = 0
Lnum = 0
Li = 0
Ri = 0
cnt = 0

for i in S:

    if state == 0 and i == "R":
        Rnum+= 1
        
    elif state == 0 and i == "L":
        Lnum += 1
        Li = cnt
        Ri = cnt - 1
        state = 1
        

    elif state == 1 and i == "L":
        Lnum += 1

    else:

        if Rnum % 2 == 0:
            ans[Ri] += Rnum // 2
        else:
            ans[Ri] += Rnum // 2 + 1

        ans[Ri] += Lnum // 2

        if Lnum % 2 == 0:
            ans[Li] += Lnum // 2
        else:
            ans[Li] += Lnum // 2 + 1

        ans[Li] += Rnum // 2


        state = 0
        Rnum = 1
        Lnum = 0

        if i == "X":
            break

    cnt += 1

del ans[-1]
print (" ".join(map(str,ans)))


        

        


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < b; i++)
  {
    if (a * i % b == c)
    {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>
#include <stack>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli mod197 = 1000000007LL;
constexpr lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli arr[100];

int main(void) {

	lli N;
	cin >> N;

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

	lli ans = 1000000000;

	for (int i = -100; i <= 100; i++) {
		lli t = 0;
		for (int j = 0; j < N; j++) {
			t += pow(arr[j] - i, 2);
		}
		CHMIN(ans,t);
	}
	COUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

vector<ll> p(50);
ll RepeatSquaring(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2);
        return t*t;
    }
    return N * RepeatSquaring(N, P-1);
}





int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	if (n % 2 == 0){
		n /= 2;
		for(int i = 0; i <= 33; i++) {
			p[i] = RepeatSquaring(5,i);
		}
		for(int i = 1; i <= 25; i++) {
			ans += n/p[i];
		}
	}
	else{
		ans = 0;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
s = input()

f = -1
b = -1
i = 0
n = len(s) - 1

while f == -1:
    if s[i] == 'A':
        f = i
    i = i + 1

while b == -1:
    if s[n] == 'Z':
        b = n
    n = n - 1

print(b - f + 1)


Measured memory_bytes: 3516
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i += 2) {
        if (v[i] % 2 == 1) {
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
import sys
import  math
import fractions
from collections import defaultdict
from functools import reduce
stdin = sys.stdin
         
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
     
INF=10**18
mod=10**9+7
N=int(input())
A=nl()
ans=0
min_bai=1
#for i in range(N):#最大公倍数
#    min_bai=min_bai*A[i]//fractions.gcd(min_bai,A[i])

lcm = reduce(lambda x,y: x//fractions.gcd(x,y)*y, A)
 
#for i in range(N):
#    ans+=lcm//A[i]

ans = sum(lcm//x for x in A)
print(ans%mod)
    

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

typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

char tochr(int n){return (char)('a' + n);}
int tonum(char c){return (int)(c) - 97;}

int main(){
	ll n;
	cin >> n; 
	deque<int> ans;
	while(n){
		n --;
		ll dig = n % 26;
		n /= 26;
		ans.push_front(dig);
	}
	for(int n: ans){
		cout << tochr(n % 26);
	}
}


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

int main(){
    ll N;
    cin >> N;
    ll ans = 1000000000000;
    for(ll i=1;i*i<=N;i++){
        if(N%i!=0) continue;
        ll A = i;
        ll B = N/i;
        ll cntA=0;
        ll cntB=0;
        while(A!=0){
            A/=10;
            cntA++;
        }
        while(B!=0){
            B/=10;
            cntB++;
        }
        ans = min(ans,max(cntA,cntB));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, kol = 0;
    string s;
    cin >> a >> b;
    cin >> s;
    if (s[a] != '-') cout << "No", exit(0);
    for (int i = 0; i <= a + b; i++)
        if (s[i] == '-') kol++;
    if (kol != 1) cout << "No";
    else cout << "Yes";
    return 0;
}



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

#define sc(x) scanf("%d",&x);
#define rep(x ,n) for(int x=0; x<n; x++)
#define ll long long
#define finish(x) return cout << x << endl,0;
#define scarr(a,n) for(int x=0; x<n; x++)scanf("%d",&a[x]);


int main()
{
    int n;
    sc(n)
    vector<int> d(n);
    scarr(d ,n)
    sort(d.begin() ,d.end());
    cout << d[n/2]-d[n/2-1] << endl;
}


Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func nextInt() int {
	i, e := strconv.Atoi(nextString())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	i, e := strconv.ParseInt(nextString(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func putInt64(i int64) {
	wr.WriteString(strconv.FormatInt(i, 10))
	wr.Flush()
}
func putString(s string) {
	wr.WriteString(s)
	wr.Flush()
}

func main() {
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

	var n int
	n = nextInt()

	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	var ans int64

	for i := 0; i < n; i++ {
		ans += int64(a[i])
		if i%2 == 1 {
			ans -= 2 * int64(a[i])
		}
	}

	for i := 0; i < n; i++ {
		putInt64(ans)
		ans = 2*int64(a[i]) - ans
		if i == n-1 {
			fmt.Print("\n")
		} else {
			fmt.Print(" ")
		}
	}
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int main()
{
	int n,m,ans=0;
	cin>>n>>m;
	
	vector<vector<int>> v1(m, vector<int>(2));//どこからどこへ辺が伸びているかを管理する
	for(int i=0;i<m;++i){
		for(int j=0;j<2;++j){
			cin>>v1[i][j];
		}
	}
	
	vector<vector<int>> v2(n+1, vector<int>(n+1));//頂点１→頂点２のとき、頂点２→頂点１のときにそれぞれ１にする
	for(int i=0;i<m;++i){
		for(int j=0;j<(n-1);++j){
			v2[v1[i][0]][v1[i][1]] = v2[v1[i][1]][v1[i][0]] = 1;
		}
	}
	
	vector<int>v3(n-1);
	iota(v3.begin(),v3.end(),0);//for(int i=0;i<n;++i)v[i]=i;と同じ
	
	do{
		if(v2[1][v3[0]+2] == 1){
			if(n==2){
				ans++;
				break;
			}else{
				for(int i=0;i<(n-2);++i){
					if(v2[v3[i]+2][v3[i+1]+2] == 1){
						if(i == n-3) ++ans;
					}else break;
				}
			}
		}
	}while(next_permutation(v3.begin(),v3.end()));
	cout<<ans<<endl;
	return 0;
}

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

uint64_t K, N;

int main()
{
	vector<pair<uint64_t, uint64_t>> s;

	// データ読み込み
	cin >> N >> K;

	uint64_t a, b;

	for (uint64_t i = 0; i < N; i++)
	{
		cin >> a >> b;
		s.push_back(make_pair(b, a));
	}

	// value順に並び替え
	sort(s.begin(), s.end(), greater<>());

	// 暫定topを計算：種類MAXで最大のvalueを選択
	uint64_t c = 0;
	map<uint64_t, uint32_t> eat_kind;
	map<uint32_t, bool> eat;

	// 得点計算用
	uint64_t ans1 = 0;

	for (uint32_t i = 0; i < N; i++)
	{
		// すべて違う種類の寿司を食べる
		if (eat_kind.count(s[i].second) == 0)
		{
			ans1 += s[i].first;
			eat_kind[s[i].second] = 1;
			eat[i] = true;
			c++;
		}

		if (c >= K)
		{
			break;
		}
	}

	// c < Kの場合、価値の高いものをc>=Kとなるまで設定する
	for (uint32_t i = 0; i < N; i++)
	{
		if (c >= K)
		{
			break;
		}

		if (eat.count(i) == 0)
		{
			ans1 += s[i].first;
			eat_kind[s[i].second]++;
			eat[i] = true;
			c++;
		}
	}

	// valueの高いものを採用し、暫定topより高くなれば続ける。高くならなければEND
	uint64_t max_ans = ans1 + eat_kind.size() * eat_kind.size();
	uint64_t tmp_ans;
	for (uint32_t i = 0; i < N; i++)
	{
		if (eat.count(i) == 0)
		{
			ans1 = ans1 - s[eat.rbegin()->first].first + s[i].first;
			eat_kind[s[eat.rbegin()->first].second]--;
			if (eat_kind[s[eat.rbegin()->first].second] == 0)
			{
				eat_kind.erase(s[eat.rbegin()->first].second);
			}

			eat.erase(eat.rbegin()->first);
			eat[i] = true;
			tmp_ans = ans1 + eat_kind.size() * eat_kind.size();
			if (max_ans > tmp_ans)
			{
				break;
			}
			max_ans = tmp_ans;
		}
	}

	cout << max_ans << endl;
	return(0);
}

Measured memory_bytes: 10224
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>


bool can_defeat(const int a, const int b, long long int count, const std::vector<int>& monster) {
	auto lower = count * b;
	for (auto i = std::upper_bound(monster.begin(), monster.end(), lower); i != monster.end(); ++i) {
		count -= (*i - lower + (a - b) - 1) / (a - b);
		if (count < 0) return false;
	}
	return true;
}
int main() {
	int n, a, b; std::cin >> n >> a >> b;
	std::vector<int> monsters(n); for (auto& m : monsters) std::cin >> m;
	std::sort(monsters.begin(), monsters.end());
	long long int upper = 1000000000LL, lower = 0LL;
	while (lower < upper) {
		auto mid = (lower + upper) / 2;
		if (!can_defeat(a, b, mid, monsters)) 
			lower = mid + 1;
		else 
			upper = mid;
	}
	std::cout << upper << std::endl;
}


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

typedef unsigned long long ull;
ull D,G,v[1010],w[1010],sum,cnt,minn=10000000000000ull;
bool flag[1010];

int main()
{
	cin>>D>>G;
	for(int i=0; i<D; ++i)
		cin >> v[i] >> w[i];
	for(int i=0; i<(1<<D); ++i)
	{
		memset(flag,false,sizeof(flag));
		cnt=sum=0ll;
		for(int j=0; j<D; ++j)
			if(i&(1<<j))
			{
				flag[j]=1;
				sum+=v[j]*(j+1ull)*100+w[j];
				cnt+=v[j];
			}
		bool tt=true;
		if(sum>=G)tt=false;
		for(int j=D-1; ~j && tt; --j)
		{
			if(flag[j])continue;
			for(int k=1; k<=v[j]; ++k)
			{
				sum+=(j+1ull)*100ull;
				++cnt;
				if(sum>=G)
				{
					tt=false;
					break;
				}
			}
		}
		minn=min(minn,cnt);
	}
	cout<<minn;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;

	LL minXY=min(X,Y);
	LL c=2*C*max(X,Y);
	cout<<min(min(2*C*minXY+(X-minXY)*A+(Y-minXY)*B,A*X+B*Y),c)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
int main(){
    ll n;
    cin>>n;
    ll a,ans=0;
    rep(i,0,n){
        cin>>a;
        ans^=a;
    }
    if(ans)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
 
using namespace std;
 
double round(double source, int precision) {    // ?????¨?????\
    return floor((fabs(source) * pow(10, (double)precision) + 0.5)) / pow(10, (double)precision) * (source < 0 ? -1 : 1);
}
 
int main() {
    double a, b, c, d, e, f, x, y;
 
    while (cin >> a >> b >> c >> d >> e >> f) {
        x = (c * e - b * f) / (a * e - b * d);
        y = (a * f - c * d) / (a * e - b * d);
 
        cout.precision(3);
        cout << fixed << round(x, 3) << " " << round(y, 3) << endl;
        //cout << fixed << x + 1e-10 << " " << y + 1e-10 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3384
import sys
N, M, X=map(int, sys.stdin.readline().rstrip().split())
A = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(N)]
cost=[]
for i in range(1<<N):	#Bit All Search
	l=[0]*(M+1)
	for j in range(N):
		if((i>>j)&1)==1:
			l=[l[k]+A[j][k] for k in range(M+1)]
	for k in range(M):
		if l[k+1]<X:
			break
	else:
		cost.append(l[0])
cost.sort()
print(-1 if cost==[] else cost[0])


Measured memory_bytes: 9320
#include<bits/stdc++.h>
using namespace std;
int n,x,ans,f[100005];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		f[x]++;
		f[x+1]++;
		f[x+2]++;
	}
	for (int i=0;i<=100002;i++)
		ans=max(ans,f[i]);
	printf("%d",ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;


int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    */
    // #ifndef ONLINE_JUDGE
    //     fread();
    // #endif
    
    int n,k;
    string s,t; 
    while(scanf("%d",&n)==1){
        getchar();
        cin>>s>>t;
        for(int i=0;i<n;i++) printf("%c%c",s[i],t[i]);
        printf("\n");     
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  int sum = 0;
  rep(i,n) {
    cin >> m[i];
    sum += m[i];
  }
  sort(all(m));
  int ans = n + (x-sum) / m[0];
  cout << ans << endl;
}



Measured memory_bytes: 256