akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()

typedef unsigned long long ll;


int main(){ 
int N,Q; cin >> N >> Q;
string X; cin >> X;
vector<int> s(N+1,0);
rep(i,N) {
    if(i+1 < N && X[i] == 'A' && X[i+1] == 'C'){
        s[i+1] = s[i] + 1;
    }
    else{
        s[i+1] = s[i];
    }
}
rep(i,Q){
    int left,right;
    cin >> left >> right;
    --left; --right;
    cout << s[right] - s[left] << endl;
}

}



Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int N, K;
VI G[2111];

int rec(int v, int p, int d) {
    int r = 0;
    if (d > K / 2) r++;
    EACH (e, G[v]) if (*e != p) r += rec(*e, v, d + 1);
    return r;
}

int main() {
    scanf("%d%d", &N, &K);
    REP (i, N-1) {
	int a, b;
	scanf("%d%d", &a, &b);
	a--; b--;
	G[a].push_back(b);
	G[b].push_back(a);
    }


    int ans = N;
    if (K & 1) {
	REP (i, N) EACH (e, G[i]) {
	    amin(ans, rec(i, *e, 0) + rec(*e, i, 0));
	}
    } else {
	REP (i, N) amin(ans, rec(i, i, 0));
    }
    printf("%d\n", ans);

    return 0;
}



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

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    
    int A, B, T;
    
    cin >> A >> B >> T;
    
    cout << (T/A ) * B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

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

	ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') cnt1++;
		if (S[i] == 'G') cnt2++;
		if (S[i] == 'B') cnt3++;
	}

	ll ans = cnt1 * cnt2 * cnt3;

	for (int d = 1; d <= N; d++) {
		for (int m = d; m < N; m++) {
			if (m + d >= N) continue;
			if ((S[m - d] != S[m + d]) && (S[m] != S[m + d]) && S[m - d] != S[m]) ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N,M;
vector<int> g[1000];
int visit[1000] = {};
int depth[1000] = {};
deque<int> dq(2000,0);
bool dfs(int v){
    bool flag = false;
	visit[v]++;
	for(int u:g[v]){
        if(visit[u] == 0){
            depth[u] = depth[v] + 1;
            if(dfs(u)) flag = true;
        }else if(visit[u] == 1){
            flag = true;
            if(depth[v] - depth[u] > dq.size()) continue;
            set<int> st; int cnt = 0;
			rep(i,0,N)if(visit[i] == 1 && depth[i] >= depth[u]) st.insert(i);
			for(int s:st)for(int t:g[s])if(st.count(t)) cnt++;
			if(cnt > st.size()) continue;
			dq.clear();
            rep(i,0,N)if(visit[i] == 1 && depth[i] >= depth[u]) dq.push_back(i+1);
		}
	}visit[v]++;
    return flag;
}
int main(){
	cin>>N>>M;
	int a,b; int deg[N] = {};
	rep(i,0,M){
		cin>>a>>b; a--; b--;
		g[a].push_back(b);
	}
	rep(i,0,N){
        if(visit[i] == 0){
            rep(j,0,N) depth[j] = 0;
            dfs(i);
        }
    }
	if(dq.size() == 2000) cout<<-1<<endl;
	else{
		cout<<dq.size()<<endl;
		rep(i,0,dq.size()) cout<<dq[i]<<endl;
	}
}

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

int main(int argc, char const *argv[])
{
	int h,w;
	cin>>h>>w;
	int d[10][10],c;
	for (int i = 0; i < 10; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			cin>>c;
			d[i][j]=c;
		}
	}
	for (int i = 0; i < 10; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			for (int k = 0; k < 10; ++k)
			{
				d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
			}
		}
	}
	long long ans=0LL;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin>>c;
			if (c==-1)
			{
				continue;
			}
			ans+=(long long)d[c][1];
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	string s;
    cin >> s;
    if (s == "RRR") {
    	cout << 3 << endl;
    }else if (s[1] == 'R' && (s[0] == 'R' || s[2] == 'R')) {
    	cout << 2 << endl;
    } else if (s[1] == 'R' || (s[0] == 'R' || s[2] == 'R')) {
    	cout << 1 << endl;
        } else {
        cout << 0 << endl;
        }
	return 0;
};

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<ll, pair<ll,ll>>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

string n;
int sum = 0;

int main() {
    cin >> n;
    rep(i,n.size()){
        sum += (int)(n[i]-'0');
    }
    if (sum%9) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>
#define N 110
#define INF 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2



int main(){
  int n,keep[N][N];
  int i,j,num,min,sum=0,u;
  int d[N],p[N],color[N];
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[1]=0;
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&num);
      if(num==-1) keep[i][j]=INF;
      else keep[i][j]=num;
    }
  }

  while(1){
    min=INF;
    u=-1;
    for(i=1;i<=n;i++){
      if(min>d[i]&&color[i]!=BLACK){
	u=i;
	min=d[i];
      }
    }
    
    if(u==-1) break;
    color[u]=BLACK;

    for(j=1;j<=n;j++){
      if(color[j]!=BLACK&&keep[u][j]!=INF){
	if(d[j]>keep[u][j]){
	  d[j]=keep[u][j];
	  p[j]=u;
	  color[j]=GRAY;
	}
      }
    }
  }

  for(i=1;i<=n;i++){
    if(p[i]!=-1)sum+=keep[i][p[i]];
  }
  printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
#include<utility>
#include<queue>
#include<vector>
#include<algorithm>
#define MAX_N 10000
#define INF 100000000
using namespace std;

typedef pair<int,int>P;

typedef struct edge
{
	int t,dist,cost;
} edge;

struct StructGreater {
	bool operator() (edge a, edge b) {
		return a.dist==b.dist?a.cost>b.cost:a.dist>b.dist;
	}
};

vector<edge>G[MAX_N];

int N,M,mincost[MAX_N],mindist[MAX_N];

int prim()
{
	int flg[MAX_N];
	priority_queue<edge,vector<edge>,StructGreater>que;
	for(int i=0;i<N;i++)
	{
		mindist[i]=INF;
		mincost[i]=INF;
		flg[i]=0;
	}
	mincost[0]=0;
	edge t1={0,0,0};
	que.push(t1);
	int res=0;
	while(!que.empty())
	{
		edge tmp=que.top();
		que.pop();
		if(!flg[tmp.t])
		{
			res+=tmp.cost;
			mindist[tmp.t]=tmp.dist;
			mincost[tmp.t]=tmp.cost;
			flg[tmp.t]=1;
			for(int u=0;u<G[tmp.t].size();u++)
				if(mindist[G[tmp.t][u].t]>G[tmp.t][u].dist&&mincost[G[tmp.t][u].t]>G[tmp.t][u].cost)
				{
					edge t2={G[tmp.t][u].t,mindist[tmp.t]+G[tmp.t][u].dist,G[tmp.t][u].cost};
					que.push(t2);
				}
		}
	}
	return res;
}

int main()
{
	for(;scanf("%d%d",&N,&M);)
	{
		if(N==0&&M==0)
			break;
		for(int i=0;i<M;i++)
		{
			int a,b,c,d;
			scanf("%d%d%d%d",&a,&b,&c,&d);
			a--,b--;
			edge t1={b,c,d};
			edge t2={a,c,d};
			G[a].push_back(t1);
			G[b].push_back(t2);
		}
		printf("%d\n",prim());
		for(int i=0;i<N;i++)
			G[i].clear();
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
	int x; cin >> x;
    if(x>=400 && x<600) 
    cout << '8' << "\n";
    else if(x>=600 && x<800) 
    cout << '7' << "\n";
    else if(x>=800 && x<1000) 
    cout << '6' << "\n"; 
    else if(x>=1000 && x<1200) 
    cout << '5' << "\n";
    else if(x>=1200 && x<1400) 
    cout << '4' << "\n";
    else if(x>=1400 && x<1600) 
    cout << '3' << "\n"; 
    else if(x>=1600 && x<1800 )
    cout << '2' << "\n";
    else 
    cout << '1' << "\n";





}


Measured memory_bytes: 3564
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    A = LI()
    dct = defaultdict(int)
    for a in A:
        dct[a] += 1
    # print(sorted(dct.items(), key=lambda x: x[0], reverse=True))
    # ans = 0
    left = 2
    pre = 0
    for n, c in sorted(dct.items(), key=lambda x: x[0], reverse=True):
        # print(n, c)
        if c >= 4:
            if left == 2:
                print(n ** 2)
                return
            elif left == 1:
                print(pre * n)
                return
        elif c >= 2:
            if left == 2:
                pre = n
                left -= 1
                continue
            elif left == 1:
                print(pre * n)
                return
    print(0)


if __name__ == '__main__':
    solve()



Measured memory_bytes: 26880
use std::process;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u64, 
        a: [u64; n],
        b: [u64; n],
        c: [u64; (n-1)],
    }   
    
    let mut sum = 0;

    for i in 0..n as usize {
        sum += b[(a[i]-1) as usize];
        if  i != 0 && a[i]-1 == a[i-1] {
            sum += c[(a[i-1]-1) as usize];
        }
    }

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


Measured memory_bytes: 4352
//    ŦĦ€Ř€'Ş ŇØŦĦƗŇǤ ĦØŁĐƗ'Ň Μ€ βΔĆҜ ΔŁŴΔ¥Ş ΔŇĐ ₣ØŘ€V€Ř 😈🤩😇😈💪🤜👊🤛🤟😉🤩:

#include<bits/stdc++.h>

#define mod 1000003
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define B(a) a.begin()
#define E(a) a.end()
#define For(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define M_P make_pair
#define P_B push_back
#define endd "\n"

using namespace std;

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

    ll t;cin>>t;
    vll a(t),b(t),c;

    For(i,0,t)
    cin>>a[i]>>b[i];

    For(i,0,t-1)
    {
       ll cnt=0;

        if(a[i]==b[i])
        {
            while(a[i]==b[i] && i<t)
            {
                cnt++;
                i++;


            }

          if(cnt>=3)
            c.P_B(cnt);

          cnt=0;

        }



    }

    if(c.empty())
        cout<<"No";

    else
        cout<<"Yes";







    return 0;
}


Measured memory_bytes: 3656
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
 		int b_num = (int)(x-a)/b;
        int result = x - a - b * b_num;
        System.out.print(result);
    }
}

Measured memory_bytes: 35244
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int a, b;
  cin >> a >> b;
  cout << (a-1) * (b-1) << endl;
  return 0;
}


Measured memory_bytes: 256
/*
	Solved!
	Time: 05:23:26 PM
	Date: 05-04-2020
*/
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long  ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                5000005
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
    /*#ifndef ONLINE_JUDGE
        double start = clock(); READ(); WRITE();
    #endif*/
        string s; cin >> s;
        int ans = 0;
        if(s[2] == s[3] && s[4] == s[5]) ans = 1;
        puts(ans ? "Yes" : "No");


    /*#ifndef ONLINE_JUDGE
        printf("\n>>Runtime: %.10fs\n", (double)(clock() - start) / CLOCKS_PER_SEC);
    #endif*/

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	long long int n, mod = 1e9 + 7, ans = 1;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace A___CF
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var cIn = int.MaxValue;
            var fIn = int.MinValue;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == 'C')
                {
                    cIn = i;
                }
                if (s[i] == 'F')
                {
                    fIn = i;
                }
            }
            if (cIn < fIn)
                Console.WriteLine ("Yes");

            else
                Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] firstP = new int[n];
		for(int i=0;i<n;i++){
			p[i] = sc.nextInt();
		}
		sc.close();
		
		for(int i=0;i<n;i++){
			firstP[i] = p[i];
		}
		
		Arrays.sort(p);
		
		int count = 0;
		
		for(int i=0;i<n;i++){
			if(p[i]!=firstP[i]){
				count++;
			}
		}
		if(count==0||count==2){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


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

int main(void) {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a), greater<ll>());
    using P = pair<ll, ll>;
    priority_queue<P> que;
    que.push({a[0], a[0]});
    ll score = 0;
    rep1(i,n-1){
        P t = que.top(); que.pop();
        score += t.first;
        que.push({a[i], t.first});
        que.push({a[i], t.second});
    }
    cout << score << endl;
    return 0;
}


Measured memory_bytes: 8904
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	string s;
	cin>>s;
	bool ok=false;
	if(s[0]==s[1]&&s[1]==s[2])ok=true;
	if(s[2]==s[3]&&s[1]==s[2])ok=true;
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	long long* dp = new long long[s.length() + 1];
	dp[0] = 0;
	for (int i = 1;i <= s.length();i++) {
		dp[i] = 0;
		for (int j = 1;j <= i ;j++) {
			if (i == j) {
				dp[i] += stoll(s.substr((signed)s.length() - i, j).c_str()) + dp[i - j];
			}
			else {
				dp[i] += stoll(s.substr((signed)s.length() - i, j).c_str()) * (long long)pow(2, i - j - 1) + dp[i - j];
			}
			
		}
	}
	cout << dp[s.length()] << endl;
}

Measured memory_bytes: 3144
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS
int arr[13][13];
int cost[13];
int n,m,x;

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS

cin>>n>>m>>x;

FOR(i,0,n) {
    cin>>cost[i];
    FOR(j,0,m) cin>>arr[i][j];
}
int ans = 1200001;
FOR(i,0,1<<n){
    vector<int> nw(m,0);
    int ncost = 0;
    FOR(j,0,n) {
        if((1<<j)&i){
            FOR(k,0,m) nw[k] += arr[j][k];
            ncost+=cost[j];
        }
    }
    int flag = 1;
    FOR(j,0,m) if(nw[j]<x ) flag = 0;
    if(flag)  ans = min(ans,ncost);
}
if(ans == 1200001) cout<<-1;
else cout<<ans;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3604
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=1,n,x,d=0;
    cin >>n>>x;
    for(int i=0;i<n;i++){
        ll c;
        cin >>c;
        d+=c;
        if(d<=x){
            ans++;
        }else{
            break;
        }
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    cout << (n+110)/111*111 << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){
  int N;
  cin >> N;
  cout << "ABC" << N << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {

  ll n,k;
  cin >> n>>k;
  
  vector<ll> p(n);
  rep(i,n){
  cin>>p[i];  
  }
  
  vector<bool> q(n,false);
  vector<bool> r(n,false);
  ll now=1;
  q[0]=true;
  
  ll cnt = 0;  
  bool ok = false;
  ll memo;
  ll ans;
  
  while(1){
  now=p[now-1];
  cnt++;
    if(q[now-1]) {
      if(r[now-1]) {
      ans=cnt-memo;
      break;
      }
      else if(!ok){
      memo=cnt;
      r[now-1]=true;
      ok=true;
      }
    }
    else q[now-1]=true;
  }
  
  now=1;
  if(k<=memo) {
    rep(i,k){
      now=p[now-1];
    }
  }
  else{
    rep(i,(k-memo)%ans+memo){
      now=p[now-1];
    }
  } 
  
  
  cout << now << endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, h, w;
    cin >> n >> h >> w;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];

    vector<ll> v(w*n);
    REP(i, n) {
        ll l, r;
        if(i%2==0) {
            l = w*i + x[i];
            r = w*(i+1) + x[i];
        } else {
            l = w*i - x[i];
            r = w*(i+1) - x[i];
        }

        FOR(j, l, r) v[j] = 1;
    }

    ll ret = 0;
    REP(i, w*n) if(v[i]==0) ret++;
    cout << ret*h << endl;

    return 0;
}


Measured memory_bytes: 3292
def main():
    strings = input().split(' ')
    N = int(strings[0])
    K = int(strings[1])
    p_raw = input().split(' ')
    exp = []
    for i in p_raw:
        exp.append((int(i)+1)/2.)
    max = 0
    exp_prev = sum(exp[0:0 + K -1])
    for i in range(N-K+1):
        
        sum_exp = exp_prev + exp[i + K-1]
        exp_prev = sum_exp - exp[i]
        if sum_exp > max:
            max = sum_exp
            
    
    print(max)
    return 0

main()

Measured memory_bytes: 24676
ai = lambda: list(map(int, input().split()))

h,w,d = ai()
ph = [0 for _ in range(h*w + 1)]
pw = [0 for _ in range(h*w + 1)]

for i in range(h):
    a = ai()
    for j in range(w):
        ph[a[j]] = i
        pw[a[j]] = j


score = [0 for _ in range(h*w + 1)]
for i in range(d+1, h*w+1):
    score[i] = score[i-d] + abs(ph[i]-ph[i-d]) + abs(pw[i]-pw[i-d])


q = int(input())
for _ in range(q):
    l,r = ai()
    print(score[r]-score[l])



Measured memory_bytes: 9460
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}

	ans := "Yes"
	for k, v := range s {
		if (k+1)%2 == 0 {

			if string(v) == "R" {
				ans = "No"
				break
			}
		} else {

			if string(v) == "L" {
				ans = "No"
				break
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){

	int n,a,b;
	int sum =0;
	
	scanf("%d %d %d",&n,&a,&b);
	
	for(int i=1;i<=n;i++){
		int x = 0;
		int idx = i;
		do{
			x += (idx%10);
			idx = idx / 10;
		}
		while(idx != 0);
		
		if(x >= a && x <= b){
		sum += i;
	}
}

	printf("%d",sum);
	

	
    return 0;
}

Measured memory_bytes: 1684
<?php
$fp = fopen('php://stdin', 'r');
$num = 1;
$first = true;

while (feof($fp) == false) {
  $line = fgets($fp);
  //Nはとばす
  if ($first == true) {
    $first = false;
    continue;
  }
  if ($line == "") break;   //最終行の空行をとばす

  $nums = explode(' ', $line);
  $nums[2] = trim($nums[2]);
  $max_num = max($nums);
  $sum = 0;
  $igindex = array_search($max_num, $nums);
  for ($i=0; $i<3; $i++) {
    if ($igindex == $i) {
      continue;
    }   
    $sum += pow($nums[$i], 2); 
  }
  if (pow($max_num, 2) == $sum) {
    echo "YES".PHP_EOL;
  } else {
    echo "NO".PHP_EOL;
  }
}

Measured memory_bytes: 6636
s=gets.gsub(/[^KUPC]/,'').split(//).sort.join
a=s.index('C')
b=s.index('K')
c=s.index('P')
d=s.index('U')
e=s.rindex('U')
if !a||!b||!c||!d
  puts "0"
else
  puts [b-a,c-b,d-c,e+1-d].min
end

Measured memory_bytes: 5304
# AOJ ITP1_9_C

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    SCORE_taro = 0
    SCORE_hanako = 0
    n = int(input())
    for i in range(n):
        words = input().split()
        if words[0] > words[1]: SCORE_taro += 3
        elif words[0] < words[1]: SCORE_hanako += 3
        else:
            SCORE_taro += 1; SCORE_hanako += 1
    print(str(SCORE_taro) + " " + str(SCORE_hanako))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int mini=1000000000;
  for(char c='a';c<='z';c++)
  {
    int maxi=0;
    int cnt=0;
    for(int i=0;i<s.size();i++)
    {
      if(s[i]==c)maxi=max(maxi,cnt),cnt=0;
      else cnt++;
    }
    maxi=max(maxi,cnt);
    mini=min(mini,maxi);
  }
  printf("%d\n",mini);
}

Measured memory_bytes: 256
#include <stdio.h>

#include<stdio.h>
#include<iostream> 
#include<string>
#include<vector>
using namespace std;
int main()
{
	int a,b;
	cin>>a;
	cin>>b;
	
	if(b%a==0){
		printf("%d",a+b);}
		else{
		printf("%d",b-a);
		}
	
	
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        var ans = int.MaxValue;
        for (int i = 1; i < N; i++) {
            var s1 = i.ToString();
            var sum1 = 0;
            for (int j = 0; j < s1.Length; j++) {
                sum1 += int.Parse(s1[j].ToString());
            }
            var s2 = (N - i).ToString();
            var sum2 = 0;
            for (int j = 0; j < s2.Length; j++) {
                sum2 += int.Parse(s2[j].ToString());
            }
            ans = Math.Min(ans, sum1 + sum2);
        }
        WriteLine(ans);
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 15168
/*
**id: aizu1370
**tag: hash
*/

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

#define oo 0x3f3f3f3f
#define mp make_pair
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define FO(i,a,b) for(int i=a;i<=b;++i)
#define FD(i,a,b) for(int i=a;i>=b;--i)
#define FE(i,G,x) for(int i=G.h[x];i!=-1;i=G.v[i].nxt)
typedef long long LL;
typedef pair<short, short> PII;

template <class T> inline bool chkmin(T& x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T& x, T y) { return x < y ? x = y, true : false; }

template <class T> T reads() {
    T x = 0;
    static int f;
    static char c;
    for (f = 1; !isdigit(c = getchar()); ) if (c == '-') f = -1;
    for (x = 0; isdigit(c); c = getchar()) x = x * 10 + c - 48;
    return x * f;
}
#define read   reads<int>
#define readll reads<LL>

char str[4005], str1[4005];
int  m, ans1, ans, n, a[4005][26], b[4005][26], cnt;
char ch1;

#define MO 20000007
template<typename T>
struct Graph {
    enum { maxn = MO, maxm = 4000 * 4000 + 5 };
    struct {
        int nxt;
        T w;
    } v[maxm];
    int h[maxn], cnt;
    Graph() { memset(h, -1, sizeof(h)); }
    void add(int x, const T& w) {
        v[cnt].nxt = h[x];
        v[cnt].w = w;
        h[x] = cnt++;
    }
};
Graph<PII> G;

int hash1(int a[4005][26], int x, int y) {
    int ans = 0, r = 1;
    FO(ch1, 0, 25) {
        ans = (ans + (LL)r * (a[y][ch1] - a[x - 1][ch1])) % MO; if (ans < 0) ans += MO;
        r = (LL)r * 26 % MO;
    }
    return ans;
}

int main(void) {
    scanf("%s", str + 1); n = strlen(str + 1);
    scanf("%s", str1 + 1); m = strlen(str1 + 1);
    FO(i, 1, n) FO(ch1, 'a', 'z') a[i][ch1 - 'a'] = a[i - 1][ch1 - 'a'] + (ch1 == str[i]);
    FO(i, 1, m) FO(ch1, 'a', 'z') b[i][ch1 - 'a'] = b[i - 1][ch1 - 'a'] + (ch1 == str1[i]);
    FO(i, 1, m) FO(j, i, m) G.add(hash1(b, i, j), mp(i, j));
    FO(i, 1, n) FO(j, i, n) {
        ans1 = hash1(a, i, j);
        FE(z, G, ans1) {
            bool flag = true;
            PII t = G.v[z].w;
            FO(ch, 0, 25) if (a[j][ch] - a[i - 1][ch] != b[t.se][ch] - b[t.fi - 1][ch]) { flag = false; break; }
            if (flag) {
                chkmax(ans, j - i + 1);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 207160
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)

template <typename String> 
vector < int > Z_Algorithm (String &S) {
    vector < int > A(S.size(), 0);
    for (int i = 1, p = 0; i < S.size(); i++) {
        if (i + A[i - p] < p + A[p]) {
            A[i] = A[i - p];
        } else {
            int j = max(0, p + A[p] - i);
            while (i + j < S.size() && S[j] == S[i + j]) j++;
            A[i] = j;
            p = i;
        }
    }
    A[0] = (int) S.size();
    return A;
}

int N;
string S;

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

    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        string St = S.substr(i, S.size() - i);
        vector < int > len = Z_Algorithm(St);
        for (int j = 0; j < len.size(); j++) {
            if (j >= len[j]) {
                ans = max(ans, len[j]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
(n,),*axy = [list(map(int, s.split())) for s in open(0)]

from itertools import product
from collections import defaultdict
d = defaultdict(defaultdict)

i = 0
for elm in axy:
    if len(elm) == 1:
        i += 1
    else:
        x,y = elm
        d[i][x] = y
del i

ans = 0
for flgs in product([0,1], repeat=n):
    honest = [i for i, v in zip(range(1, n+1), flgs) if v]
    valid = True
    for i in honest:
        if not valid:
            break
        if not i in d:
            continue
        for j in d[i]:
            if (j in honest and not d[i][j]) or (j not in honest and d[i][j]):
                valid = False
                break
    if valid:
        ans = max(ans, len(honest))

print(ans)

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

int main()
{
    string s;
    getline(cin, s);

    string re;
    for (int i = 0; i < s.size(); ++i)
    {
        if (islower(s.at(i)))
        {
            re.push_back(toupper(s.at(i)));
        }
        else
        {
            re.push_back(tolower(s.at(i)));
        }
    }
    cout << re << endl;
    return 0;
}


Measured memory_bytes: 3172
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Pair> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new Pair(i + 1, sc.next(), sc.nextInt()));
		}
		Collections.sort(list, new MyComparator());
		for (int i = 0; i < n; i++) {
			System.out.println(list.get(i).index);
		}
	}
}
class Pair {
	public int index;
	public String s;
	public int p;
	public Pair(int index, String s, int p) {
		this.index = index;
		this.s = s;
		this.p = p;
	}
}

class MyComparator implements Comparator<Pair> {
	@Override
	public int compare(Pair sort1, Pair sort2) {
		if ((sort1.s).compareTo(sort2.s) == 0) {
			return sort2.p - sort1.p;
		} else {
			return (sort1.s).compareTo(sort2.s);
		}
	}
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)

	result := ""
	result += strings.ToUpper(s1[0:1])
	result += strings.ToUpper(s2[0:1])
	result += strings.ToUpper(s3[0:1])
	fmt.Println(result)

}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    int N,Q;
    std::cin >> N;
    Ints A(10e+5+1, 0);
    LL sum = 0;

    for(int i=0;i<N;i++){
        int a;
        std::cin >> a;
        A[a]++;
        sum+=a;
    }

    std::cin >> Q;
    LLs res;

    for(int i=0;i<Q;i++){
        int b, c;
        std::cin >> b >> c;

        if(A[b] == 0){
            res.push_back(sum);
            continue;
        }
        sum += (c - b) * A[b];
        int tmp = A[b];
        A[b] = 0;
        A[c] += tmp;

        res.push_back(sum);
    }

    for(auto r : res){
        std::cout << r << std::endl;
    }

    return 0;
}

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

int main(){
  
  	long long n, k; cin >> n >> k;
    double res = 0.0;
    for(long long i=1; i<n+1; ++i){
        double tmp = 1.0;
        long long d = i;
        while (d < k) d *= 2, tmp /= 2.0;
        res += tmp;
    }
    res /= n;
    cout << fixed << setprecision(10) << res << endl;
  
    /*long long n, k; cin >> n >> k;
    double res = 0.0;
    for(long long i=1; i<n+1; ++i){
        double tmp = 1.0;
        long long d = i;
        while(i<k){i *= 2; tmp /= 2.0;}
        res += tmp;
    }
    res /= n;
    cout << fixed << setprecision(15) << res << endl;*/
    return 0;
}

Measured memory_bytes: 3760
n = int(input())
a = list(map(int, input().split( )))
a.sort()

l1 = a[-1]
i=-2
try:
    while a[i]!=l1:
        l1 = a[i]
        i-=1
    i-=1
    l2 = a[i]
    i-=1
    while a[i]!=l2:
        l2 = a[i]
        i-=1
except:
    print(0)
    exit()
print(l1*l2)
    

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] rain = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
            if(i % 2 == 0){
                rain[0] += a[i];
            }else{
                rain[0] -= a[i];
            }
        }
        
        StringBuilder sb = new StringBuilder();
        sb.append(rain[0]).append(" ");
        for(int i = 1; i < n; i++){
            rain[i] = a[i-1] * 2 - rain[i-1];
            sb.append(rain[i]).append(" ");
        }
        
        System.out.println(sb);
    }
}

Measured memory_bytes: 47784
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string S;

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

  int ans = 0;
  if (S == "SUN") {
    ans = 7;
  } else if (S == "MON") {
    ans = 6;
  } else if (S == "TUE") {
    ans = 5;
  } else if (S == "WED") {
    ans = 4;
  } else if (S == "THU") {
    ans = 3;
  } else if (S == "FRI") {
    ans = 2;
  } else if (S == "SAT") {
    ans = 1;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

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

int n, cap;
ll dp[109][100009], weight[109], val[109];

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

    cin >> n >> cap;
    for (int i = 1; i <= n; i++)
    {
        cin >> weight[i] >> val[i];
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= cap; j++)
        {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j != 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]);

            if (j >= weight[i])
                dp[i][j] = max(dp[i - 1][j - weight[i]] + val[i], dp[i][j]);
        }
    }

    cout << dp[n][cap] << "\n";
}

Measured memory_bytes: 79360
var
	i,n,input:longint;
    arr: array [1..200005] of integer;
begin
	readln(n);
    for i:=1 to n do arr[i]:=0;
    for i:=1 to n-1 do begin
    	read(input);
        inc(arr[input]);
    end;
    for i:=1 to n do writeln(arr[i]);
end.

Measured memory_bytes: 1384
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
int main()
{
	int d,t,s; si(d),si(t),si(s);
	int at=d/s+(d%s!=0);
	if(at<=t) puts("Yes");
	else puts("No");
	return 0;
}

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

ll nn;
char n[100];
int len;
int ans=0;

void dfs(int pos,int now,bool f,ll a)
{
    if(a>nn)return ;
    if(pos==len)
    {
        ans=max(ans,now);
        return;
    }
    if(f)
    {
        dfs(pos+1,now+9,1,a*10+9);
    }
    else if(n[pos]=='0')
    {
        dfs(pos+1,now+n[pos]-'0',0,a*10+n[pos]-'0');
    }
    else
    {
        dfs(pos+1,now+n[pos]-'0',0,a*10+n[pos]-'0');
        dfs(pos+1,now+n[pos]-'0'-1,1,a*10+n[pos]-'0'-1);
    }
}

int main()
{
    cin>>nn;
    sprintf(n,"%lld",nn);
    len = strlen(n);
    dfs(0,0,0,0);
    cout<<ans;
    return 0;
}


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

using namespace std;

int main(void)
{
    int n;
    vector<int> a;
    int d[3] = {-1,0,1};


    cin>>n;
    for(int i = 0;i < n;i++)
    {
        int temp;
        cin>>temp;
        a.push_back(temp);
    }

    long long int sum = 1;
    for(int i = 0;i < n;i++)
    {
        sum *= 3;
    }

    int even = 0;
    for(int i = 0;i < n;i++)
    {
        if(a[i]%2 == 0)
        {
            even++;
        }
    }

    if(even == 0)
    {
        sum--;
    } else {
        int sub = 1;
        sub <<= even;
        sum -= sub;
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

main(){
  int i,j,k,l,f,a[100],c=0, min;

  scanf("%d", &k);
  for(i = 0;i < k;i++)scanf("%d", &a[i]);
  
  for(i = 0;i <= k - 1;i++){
    min = i;
    for(j = i;j <= k - 1;j++){
      if(a[j] < a[min]){
	min = j;
      }
    }
    l = a[i];
    a[i] = a[min];
    a[min] = l;
    if(i != min)c++;
  }
  for(i = 0;i < k-1;i++)printf("%d ", a[i]);
  printf("%d\n", a[i]);
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 600
(N, K), Xs = readlines.map{|l| l.split.map(&:to_i)}

puts (0 .. N - K).map{|l| [l, l + K - 1]}.flat_map{|l, r| [Xs[l].abs + (Xs[r] - Xs[l]).abs, Xs[r].abs + (Xs[l] - Xs[r]).abs]}.min

Measured memory_bytes: 13316
#define _GLIBCXX_DEBUG

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

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

    int rain = 0;
    int tmp = 0;
    rep(i, S.length())
    {
        if(S[i] == 'R'){
            tmp += 1;
        }else{
            tmp = 0;
        }
        if(tmp > rain) rain = tmp;
    }
    cout << rain << endl;
    return 0;
}

Measured memory_bytes: 3624
($n, $k, $q) = split(/ /, <>);

while(<>){
	chomp;
	$point{$_}++;
}

for $i (1 .. $n){
	$point{$i} = 0 unless (defined $point{$i});
	if($k - ($q - $point{$i}) > 0){
		print "Yes\n";
	}else{
		print "No\n";
	}
}

Measured memory_bytes: 12288
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int n, m,k=0;
	char str[5];
	scanf("%s", str);

	if (str[0] == '1') { k++; }
	else {  }

	if (str[1] == '1') { k++; }
	else {  }
	if (str[2] == '1') { k++; }
	else {  }
	
	printf("%lld", k);
}


Measured memory_bytes: 128