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

using namespace std;

int main(){
int a[3][3];
int ans[3][3];
bool kuma = false;

for(int i = 0;i < 3;i++){
	for(int j = 0;j < 3;j++){
		cin >> a[i][j];
	}
}


for(int i = 0;i < 3;i++){
	for(int j = 0;j < 3;j++){
		ans[i][j] = 0;
	}
}


int n;
cin >> n;
int b[11];
for(int k = 0;k < n;k++){
	cin >> b[k];

for(int i = 0;i < 3;i++){
	for(int j = 0;j < 3;j++){
	if(a[i][j] == b[k]){
		ans[i][j] = 1;
	}
	}
}

}

for(int i = 0;i < 3;i++){
	if(ans[1][i]*ans[2][i]*ans[0][i] == 1){
kuma = true;
	}
}

for(int i = 0;i < 3;i++){
	if(ans[i][0]*ans[i][1]*ans[i][2] == 1){
kuma = true;
	}
}


if(ans[0][0]*ans[1][1]*ans[2][2] == 1){
	kuma = true;
}

if(ans[0][2]*ans[1][1]*ans[0][2] == 1){
	kuma = true;
}

if(kuma)cout << "Yes" <<endl;
else cout << "No" <<endl;
return 0;


}
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	ll n,m;
	vll a;
	cin >> n;
	rep(i,n){
		cin >> m;
		a.pb(m);
	}
	ll ans=a[0];
	rep(i,n) ans=gcd(ans,a[i]);
	cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
struct ed{
    int w, x, y;
};
struct Comp{
    bool operator()(const ed& a, const ed& b){
        return a.w>b.w;
    }
};
int r, c, sx, sy, ex, ey;
char a[1001][1001];
int dis[1001][1001];
vector<pair<int,int>> cords = {{0,1}, {0,-1}, {-1, 0}, {1, 0}};
priority_queue<ed, vector<ed>, Comp> q;
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> r >> c >> sx >> sy >> ex >> ey;
    for(int i = 1; i <= 1000; i++)for(int j = 1; j <= 1000; j++)dis[i][j] = 1e9;
    for(int i = 1; i <= r; i++){
        string line; cin >> line;
        for(int j = 1; j <= c; j++){
            a[i][j] = line[j-1];
        }
    }
    q.push((ed){0, sx, sy}); dis[sx][sy] = 0;
    while(!q.empty()){
        int wt = q.top().w, cx = q.top().x, cy = q.top().y; q.pop();
        if(cx == ex && cy == ey)break;
        for(auto i : cords){
            int tx = cx+i.f, ty = cy+i.s;
            if(tx >= 1 && tx <= r && ty >= 1 && ty <= c && a[tx][ty] == '.' && wt < dis[tx][ty]){
                dis[tx][ty] = wt; q.push((ed){dis[tx][ty], tx, ty});
            }
        }
        int lx = max(1, cx-2), ly = max(1, cy-2), rx = min(r, cx+2), ry = min(c, cy+2);
        for(int i = lx; i <= rx; i++){
            for(int j = ly; j <= ry; j++){
                if(a[i][j] == '.' && wt+1 < dis[i][j]){
                    dis[i][j] = wt+1; q.push((ed){dis[i][j], i, j});
                }
            }
        }
    }
    cout << (dis[ex][ey] == 1e9 ? -1 : dis[ex][ey]) << '\n';
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



i64 n, a,b;
void solve(){
	cin >> n >> a >> b;
	
	cout << n/(a+b)*a + min(a,n%(a+b)) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main() {
    long long N,K;
    cin >> N >> K;
    vector< pair<int,int> > v(N);
    for(int i=0;i<N;i++) cin >> v.at(i).first >> v.at(i).second;

    sort(v.begin(),v.end());
    int j=-1;
    while(K>0){
        j++;
        K -= v.at(j).second;
    }
    cout << v.at(j).first << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define llint long long
using namespace std;
int main(){
	llint a,d;
	cin>>a>>d;
	int ans=0;
	while(a--){
		llint x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)ans++;
	}
	cout<<ans<<endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<int> vi;

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

    int mn = 1001;
    int sm = 0;
    REP(i, N)
    {
        int m;
        cin >> m;
        sm += m;
        mn = min(mn, m);
    }

    cout << N + (X - sm) / mn << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

/*
下辺にどれ、上辺にどれ、を列挙,間の点をカウント、xをソートしてK幅の最小値

->N^3logN

->2500*2500
*/

int main() {

    int N, K; cin >> N >> K;
    vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    
    ll res = 5e18;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int s = min(x[i],x[j]), t = max(x[i],x[j]);
            vector<ll> z = {};
            for (int k = 0; k < N; k++) {
                if (s <= x[k] && x[k] <= t) z.push_back(y[k]);
            }
            if (z.size() < K) continue;
            sort(z.begin(),z.end());
            for (int k = 0; k < z.size()-K+1; k++) {
                chmin(res, (t-s)*(z[k+K-1]-z[k]));
            }
            
        }
    }
    cout << res << endl;


}


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

using namespace std;
#define int long long int
constexpr int INF = std::numeric_limits<int>::max();

void solve() {
    int N;
    cin >> N;

    vector<int> w(N);

    for(auto &x: w) {
        cin >> x;
    }

    int ret = INF;

    for (int i = 0; i < N; i++) {
        int a = 0;
        int b = 0;
        for (int x = 0; x <= i; x++) {
            a += w[x];
        }
        for (int x = i + 1; x < N; x++) {
            b += w[x];
        }
        ret = min(ret, abs(a - b));
    }
    cout << ret << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=12,MAX_M=12;
ll N,M,X,C[MAX_N],A[MAX_N][MAX_M];
ll und[MAX_M];
int main(){
	cin>>N>>M>>X;
	REP(i,N){
		cin>>C[i];
		REP(j,M){
			cin>>A[i][j];
		}
	}
	ll ans=-1;
	REP(bt,1<<N){
		fill(und,und+M,0);
		ll tmp=0;
		REP(i,N){
			if((bt>>i)&1){
				tmp+=C[i];
				REP(j,M){
					und[j]+=A[i][j];
				}
			}
		}
		bool f=true;
		REP(j,M){
			if(und[j]<X){
				f=false;
			}
		}
		if(f){
			if(ans==-1){
				ans=tmp;
			}else{
				ans=min(ans,tmp);
			}
		}
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 3636
// AOJ 1519: Room of Time and Spirit
// 2017.12.3 bal4u@uu

#include <stdio.h>
#include <string.h>

// <????????????Union Find>
#define MAX 100003

int power[MAX];
int par[MAX], ws[MAX];

int find(int x)
{
	int p;
	if (par[x] < 0) return x;
    p = find(par[x]), ws[x] += ws[par[x]];
    return par[x] = p;
}
    
int weight(int x)
{
    find(x); 
    return ws[x];
}
    
int unite(int x, int y, int w)  // x <-(w)- y (x + w = y)
{
	int tmp;

//  w += weight(x), w -= weight(y);
    w += power[x] + weight(x), w -= power[y] + weight(y);
    x = find(x), y = find(y);
    if (x == y) return 0;
    if (par[y] < par[x]) // ???????????????????????????????????????????????????.
        tmp = x, x = y, y = tmp, w = -w;
    
    par[x] += par[y], par[y] = x;
    ws[y] = w;
    return 1;
}
    
int same(int x, int y)
{
	return find(x) == find(y);
}

// *ans = x - y. ?????????????????? return 0.
int diff(int *ans, int x, int y)
{
    if (find(x) != find(y)) return 0;
	*ans = ws[x] - ws[y];
	return 1;
}
// </????????????Union Find>


char buf[40], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int n, q, a, b, c;

	fgets(p=buf, 40, stdin);
	n = getint(), q = getint();
	memset(par, 0xff, (n+1)*sizeof(int));

	while (q--) {
		fgets(p=buf, 40, stdin);
		if (*p == 'I') {
			p += 3, a = getint(), b = getint(), c = getint();
			power[a] += c, power[b] += c;
			unite(a, b, c);
		} else {
			p += 8, a = getint(), b = getint();
			if (find(a) != find(b)) puts("WARNING");
			else printf("%d\n", (power[b]+ws[b]) - (power[a]+ws[a]));
		}
	}
	return 0;
}

Measured memory_bytes: 2848
from collections import deque

N = int(input())
A = [int(i) for i in input().split()]

A.sort(reverse=True)
q = deque()
for i in range(N):
    q.append(A[i])

s = []
w = True
while q:
    if len(q) == 1:
        break
    else:
        i = q.popleft()
        j = q.popleft()
        if i == j:
            s.append(i)
        else:
            q.appendleft(j)
        if len(s) == 2:
            print(s[0] * s[1])
            w = False
            break
if w:
    print(0)


Measured memory_bytes: 20592
#include <stdio.h>

int main(void) {
	int a, b, d, r = 0;
	double f, p = 0.0;
	scanf("%d %d", &a, &b);
	d = a/b;
	r = a%b;
	f = (double)a/(double)b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main()
{
  double l,vol;
  cin>>l;
  vol=(l*l*l)/27;
  cout<<fixed<<setprecision(12)<<vol;
  return 0;
}

Measured memory_bytes: 256
cp = 0
def m(L,R):
    global cp
    j = 0
    for l in L:
        while j < len(R) and R[j] < l:
            yield R[j]
            j += 1
        yield l
    while j < len(R):
        yield R[j]
        j += 1
    cp += len(L) + len(R)
def merge(A):
    global cp
    if len(A) == 1:
        return A
    if len(A) == 2:
        cp += 2
        a, b = A
        return A if a < b else (b, a)
    mid = len(A) // 2
    A[:] = m(merge(A[:mid]), merge(A[mid:]))
    return A
n=int(input())
A=[int(i) for i in input().rstrip().split(" ")]
B = merge(A)
print(*B)
print(cp)


Measured memory_bytes: 63692
# -*- coding: utf-8 -*-
"""
C - Go to School
https://atcoder.jp/contests/abc142/tasks/abc142_c

"""
import sys


def solve(N, students):
    res = sorted([(s, i) for i, s in zip(range(1, N+1), students)])
    ans = [i for _, i in res]
    return ans


def main(args):
    N = int(input())
    students = [int(s) for s in input().split()]
    ans = solve(N, students)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
int main()
{
  int n,x,y;
  cin>>n>>x>>y;
  map<int,int>m;
  ffor(i,1,n+1)
  {
      ffor(j,i+1,n+1)
      {
           //cout<<i<<" "<<j<<endl;
          if((x<=j&&x>=i)&&(y<=j&&y>=i))
           {
               m[(j-i)-(y-x)+1]++;
              //cout<<(j-i)-(y-x)+1<<endl;
           }
           else if((i<=y&&i>=x)&&(j<=y&&j>=x)&&(i-x+y-j+1<j-i))
           {
             m[i-x+y-j+1]++;
           }
           else if((x<=j&&x>=i)&&( y-j+1<=j-x ))
           {
             m[x-i+1+y-j]++;
             //cout<<x-i+1+y-j<<endl;
           }
           else if((y<=j&&y>=i)&&( abs(x-i)+1<=abs(i-y) ))
           {
             m[abs(x-i)+1+j-y]++;
             //cout<<abs(x-i)+1+j-y<<endl;
           }
          else 
          {m[j-i]++;
           //cout<<j-i<<endl;
          }
        
      }
  }
  ffor(i,1,n)
  cout<<m[i]<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;int s=n;string ar[n];map<string,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        if(m[ar[i]])s--;
        m[ar[i]]++;
    }
    pair<int,string> p[s];
    sort(ar,ar+n);
    int pos=0;
    for(int i=0;i<n;i++)
    {
        if(ar[i]!=ar[i-1] or !i)
        {
            p[pos].first=m[ar[i]];
            p[pos].second=ar[i];
            pos++;
        }
    }
    sort(p,p+s);
    for(int i=0;i<s;i++)
    {
        if(p[i].first==p[s-1].first)
        {
            cout<<p[i].second<<endl;
        }
    }
}



Measured memory_bytes: 33312
#include<cstdio>

int n;
int wtf[1000006];
int ans;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    wtf[a]++;
  }
  for (int i = 1; i <= 1000000; i++) {
    if (wtf[i] == 1) {
      ans++;
    }
    if (wtf[i]) {
      for (int j = i + i; j <= 1000000; j += i) {
        wtf[j] = 0;
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 5636
#include <iostream>
using namespace std;
int main(){
        int n;
        int i,j;
        cin >> n;
        int a[n];
        int s;
        s=0;
        for (i=0;i<n;i++){
                cin >> a[i];
        }
        for (i=0;i<n-1;i++){
                for (j=i+1;j<n;j++){
                        s = s + a[i]*a[j];
                }
        }
        cout << s;
}



Measured memory_bytes: 256
use io::*;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let k: usize = sc.next();
    let aa: Vec<usize> = sc.next_vec(n);

    let minv = *aa.iter().min().unwrap();

    let mut ans = 0;
    let mut l = 0;
    while l < n {
        while l < n && aa[l] == minv {
            l += 1;
        }

        if l < n {
            let mut r = l;
            let mut cnt = 0;
            while r < n && r - l < k && cnt < k - 1 {
                if aa[r] != minv {
                    cnt += 1;
                }
                r += 1;
            }

            l = r;
            ans += 1;
        }
    }

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

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

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


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

typedef struct node_
{
    int parent;//親
    int sibling;//兄弟
    int degree;//子の数
    int depth;//深さ
    int height;//高さ
    int lf; //左ノード
    int rh; //右ノード
} node;

void init_x(node *X,int no)
{
    X[no].parent = -1;
    X[no].sibling = -1;
}

void input_x(node *X,int no,int rh,int lf)
{
    X[no].lf = lf;
    X[no].rh = rh;
}

void degree_sibling(node *X,int no)
{
    if(X[no].lf==-1&&X[no].rh==-1){
        X[no].degree = 0;
        }else if(X[no].lf>=0&&X[no].rh>=0){
            X[no].degree = 2;
            X[X[no].lf].sibling = X[no].rh;
            X[X[no].rh].sibling = X[no].lf;
        }else {
            X[no].degree = 1;
        }
}

void parent_x(node *X,int No)
{
    switch(X[No].lf){
        case -1:
            break;
        default:
            X[X[No].lf].parent = No;
            //fprintf(stderr,"%d lf=%d chk\n",No,X[No].lf);
            break;
    }
    switch(X[No].rh){
        case -1:
            break;
        default:
            X[X[No].rh].parent = No;
            //fprintf(stderr,"%d rh=%d chk\n",No,X[No].rh);
            break;
    }
}

int depth_chk(node *X,int no)
{
    int cnt=0;
    while(X[no].parent != -1)
    {
        no = X[no].parent;
        cnt ++;
    }
    //fprintf(stderr,"No.%d cnt=%d\n",no,cnt);
    return cnt;
}

int main()
{
    int n,d1=0,d2=0,No,dep=0,cnt;
    scanf("%d",&n);
    node *X = malloc(sizeof(node)*n);
    //fprintf(stderr,"\nchk start\n");
    for(int i=0;i<n;i++) init_x(X,i);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&No,&d1,&d2);
        input_x(X,No,d1,d2);
        degree_sibling(X,No);
        parent_x(X,No);
        //fprintf(stderr,"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d\n",i,X[No].parent,X[No].sibling,X[No].degree,X[No].depth,X[No].height);
    }
    for(int i=0;i<n;i++){
        X[i].depth = depth_chk(X,i);
        if(X[i].depth > dep) dep = X[i].depth;
    }
    for(int j=dep;j>=0;j--)
    {
        for(int i=0;i<n;i++)
        {
            cnt = 0;
            if(X[i].depth==j)
            {
                if(X[i].lf!=-1)
                {
                    if(cnt<X[X[i].lf].height+1) cnt = X[X[i].lf].height+1;
                }
                if(X[i].rh!=-1)
                {
                    if(cnt<X[X[i].rh].height+1) cnt = X[X[i].rh].height+1;
                }
                X[i].height = cnt;
                //fprintf(stderr,"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d\n",i,X[i].parent,X[i].sibling,X[i].degree,X[i].depth,X[i].height);
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d",i,X[i].parent,X[i].sibling,X[i].degree,X[i].depth,X[i].height);
        if(X[i].parent == -1||X[i].degree != 0)
        {
            if(X[i].sibling==-1&&X[i].parent == -1)    printf(", root");
            else    printf(", internal node");
           
        }else    printf(", leaf");
        printf("\n");
    }
    //fprintf(stderr,"chk end");
    free(X);
}


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

long long sum(long long n) {
	return (n * (n + 1)) / 2;
}

int main() {
	long long n;
	cin >> n;
	long long x = sum(n) - 3 * sum(n / 3) - 5 * sum(n / 5) + 15 * sum(n / 15);
	cout << x;


}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
int main()
{
  string s;
  cin >> s;
  Rep(i,s.size()) {
    if(s[i] == ',')cout << " ";
    else cout << s[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

template<typename T>
void _dump(const char* s, T&& head)
{
  cerr << s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail)
{
  while (*s != ',')
    cerr << *s++;
  cerr << "=" << head << ",";
  _dump(s + 1, tail...);
}

template<typename T>
void _dumpv(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << *it << " ";
  }
  cerr << endl;
}

// #define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__)
// #define dumpv(...) _dumpv(#__VA_ARGS__, __VA_ARGS__)
#define dump(...)
#define dumpv(...)

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  int N, W;
  cin >> N >> W;
  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
  vector<ll> weight(N + 1);
  vector<ll> value(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> weight[i] >> value[i];
  }
  for (int i = 1; i <= N; i++) {
    for (int w = 0; w <= W; w++) {
      if (weight[i] <= w) {
        dp[i][w] = max(dp[i - 1][w - weight[i]] + value[i], dp[i - 1][w]);
      } else {
        dp[i][w] = dp[i - 1][w];
      }
    }
  }
  for (int i = 0; i <= N; i++) {
    dumpv(dp[i]);
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 80256
N = int(input())
A = list(map(int, input().split()))
x2 = 0
for i in range(N):
    if i%2 == 0:
        x2 += A[i]
    else:
        x2 -= A[i]
ans = [0]*N
ans[0] = x2//2
for i in range(N-1):
    ans[i+1] = A[i]-ans[i]
for i in range(N):
    ans[i] *= 2
print(' '.join(map(str, ans)))


Measured memory_bytes: 19100
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n;
  cin>>n;
  int tmp;
  deque<int>ans; 
  rep0(i,n){
    cin>>tmp;
    if(i % 2 == 0)ans.push_back(tmp);
    else ans.push_front(tmp);
  }
  if(n % 2 == 0){for(auto j : ans){
    cout<<j<<" ";
  }
  }
  else{
    vector<int>anser(n);
    int size = 0;
    for(auto k : ans){
      anser[size] = k;
      size++;
    }
    reverse(all(anser));
    rep0(i,n)cout<<anser[i]<<" ";
  }
  return 0;
}

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

const long MOD = 998244353;
using B = bitset<30>;
const B b_mod = MOD - 2;

long my_pow(int n, B b) {
    long m = 1;
    long c = n;
    for (int i = 0; i < b.size(); i++) {
        if (b.test(i)) {
            m *= c;
            m %= MOD;
        }
        c *= c;
        c %= MOD;
    }
    return m;
}

long inv(int n) {
    return my_pow(n, b_mod);
}



int main() {
    /*
    k = 0, 1, ... Kにおける
    (N-1) C k * M * (M-1)^(N-1-k)
    の総和を求める
    */

    int N, M, K;
    cin >> N >> M >> K;
    //k = 0 のとき 1 * M * (M-1)^(N-1)
    B b_n = N-1;
    long p = (my_pow(M-1, b_n) * M) % MOD;
    long inv_m = inv(M-1);
    long ans = p;
    long comb = 1;

    //k > 1のとき
    for (int i = 1; i <= K; i++) {
        comb = (((comb * (N-i)) % MOD) * inv(i)) % MOD;
        p = (p * inv_m) % MOD;
        ans += (p * comb) % MOD;
        ans %= MOD;
    }

    if (N-1 == K && K > 0 && M == 1) {
        ans++;
    }
    cout << ans << endl;
}


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

int main(void) {
	// your code goes here
	int n,v[100001],o[100001],e[100001],i,j;
	cin >> n;
	for(i=0;i<n;i++) {
		cin >> v[i];
		if(i%2==0) e[i/2]=v[i];
		else o[(i-1)/2]=v[i];
	}
	sort(o,o+n/2);
	sort(e,e+n/2);
	int a=1,omax=1,oo=o[0];
	for(i=0;i<n/2;i++){
		if(o[i]==0) continue;
		if(o[i+1]==o[i]) {
			a++;
		} else {
			if(omax<a) {
				omax=a;
				oo=o[i];
			}
			a=1;
		}
	}
	a=1;
	int emax=1,ee=e[0];
	for(i=0;i<n/2;i++){
		if(e[i]==0) continue;
		if(e[i+1]==e[i]) {
			a++;
		} else {
			if(emax<a) {
				emax=a;
				ee=e[i];
			}
			a=1;
		}
	}
	if(ee!=oo) {
		cout << n-emax-omax << endl;
		return 0;
	}
	if(emax+omax==n) {
		cout << n/2 << endl;
		return 0;
	}
	for(i=0;i<n/2;i++) {
		if(e[i]==ee) e[i]=0;
		if(o[i]==oo) o[i]=0;
	}
	a=1;
	int omax1=1;
	for(i=0;i<n/2;i++){
		if(o[i]==0) continue;
		if(o[i+1]==o[i]) {
			a++;
		} else {
			if(omax1<a) {
				omax1=a;
			}
			a=1;
		}
	}
	a=1;
	int emax1=1;
	for(i=0;i<n/2;i++){
		if(e[i]==0) continue;
		if(e[i+1]==e[i]) {
			a++;
		} else {
			if(emax1<a) {
				emax1=a;
			}
			a=1;
		}
	}
	if(omax+emax1>=omax1+emax) cout << n-omax-emax1 << endl;
	if(omax+emax1<omax1+emax) cout << n-omax1-emax << endl;
	return 0;
}


Measured memory_bytes: 1024
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
import java.util.*;

public class Main
{
	public static void main(String[] args) {
	    
	    Scanner sc = new Scanner(System.in);
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    int op = sc.nextInt();
	    
	    for(int i=0; i<op; i++){
	        if ( i % 2 == 0 ){ b += a / 2 ; a /= 2 ;}
	        else{
	          a += b / 2 ;
	          b /= 2 ;  
	        } 
	    }
	    System.out.println(a);
	    System.out.println(b);
	}
}


Measured memory_bytes: 23764
package main
import "fmt"

func main(){
    var w, h, x, y, r int
    fmt.Scan(&w,&h,&x,&y,&r)
    if x-r>=0 && x+r<=w && y-r>=0 && y+r<=h{
        fmt.Println("Yes")
    }else{
        fmt.Println("No")
    }
}


Measured memory_bytes: 1160
import math
h,w = list(map(int,input().split()))

w1 = math.ceil(w/2)
w2 = math.floor(w/2)

h1 = math.ceil(h/2)
h2 = math.floor(h/2)

if h==1 or w==1:
    print(1)
    exit(0)
print((h1*w1) + (h2*w2))

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int i,j,a[5],tmp;
    for(i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<4;i++){
        for(j=4;j>i;j--){
            if(a[j] > a[j-1]){
                tmp=a[j];
                a[j]=a[j-1];
                a[j-1]=tmp;
            }
        }
    }
    for(i=0;i<5;i++){
        if(i!=4){
            printf("%d ",a[i]);
        }
        else{
            printf("%d\n",a[i]);
        }
    }
    return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}

map<int,map<int,int> > mp;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    
    /*
    FOR(i,1,N+1) {
        const auto &pf = prime_factorize(i);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ans += res*i;
    }
    */

    FOR(i,1,N+1) {
        ans += (LD)i/2 * floor((LD)N/i) * floor(1 + (LD)N/i);
    }
    cout << ans << endl;
    


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc172/abc172_d && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc172/abc172_d && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc172/abc172_d && sh shellscripts/submit_cpp.sh
*/


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll ans = -INF;

  ll N;
  scanf("%lld", &N);

  vector<ll> a_list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    a_list.emplace_back(v);
  }

  ans = 0;
  ll m = 0;
  for (ll i = 0; i < a_list.size(); i++) {
    auto v = a_list[i];
    if (m > v) {
      ans += (m - v);
    }
    m = max(m, v);
  }

  cout << ans << endl;
}


Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int count_error=0;
  int length = s.length();
  for(int i=0;i<length;i++){
    if((i%2&&s[i]=='1')||(i%2!=1&&s[i]=='0')){
      count_error++;
    }
  }
  int ans = (length-count_error<count_error)?length-count_error:count_error;
  cout << ans;
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] a = new int[2][n];
		for(int i=0;i<2;i++) {
			for(int j=0;j<n;j++) {
				a[i][j] = in.nextInt();
			}
		}
		int[][] sum = new int[2][n];
		sum[0][0] = a[0][0];
		sum[1][0] = a[1][0];
		for(int i=1;i<n;i++) {
			sum[0][i] = sum[0][i-1] + a[0][i];
			sum[1][i] = sum[1][i-1] + a[1][i];
		}
		int max = sum[0][0] + sum[1][n-1];
		for(int i=1;i<n;i++) {
			int total = sum[0][i] + sum[1][n-1] - sum[1][i-1];
			if(total>max) {
				max = total;
			}
		}
		System.out.println(max);
		in.close();
	}

}


Measured memory_bytes: 21844
h, w = map(int, input().split())
n = int(input())
a = [[int(j), i + 1] for i, j in enumerate(input().split())]
b = []
for j, i in a:
    b.extend([i] * j)
for i in range(h):
    if i % 2 == 0:
        print(*b[i * w : (i + 1) * w])
    else:
        print(*b[(i + 1) * w - 1: (i) * w - 1:-1])

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=2e5+5;
const int MAXN=2e5+5;
const int M=1e9+7;
void solve()
{
	int n,h,w;
	cin>>n>>h>>w;
	int ans=(n-h+1)*(n-w+1);
	cout<<ans;
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int inf = 1e9;

int dx[4]={0,-1, 0, 1};
int dy[4]={1, 0,-1, 0};
struct cell{
	int y;
	int x;
	int dir;
	int cost;
	cell(int y, int x, int d, int c):
		y(y),x(x),dir(d),cost(c){}
};

namespace std{
	bool operator < (const cell& a, const cell& b){
		return b.cost < a.cost;
	}
}

int main(){
	while(1){
		int w,h;
		cin >> w >> h;
		if(w==0) break;
		
		int map[31][31];
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				cin >> map[i][j];
			}
		}
		int cost[4];
		for(int i=0; i<4; i++){
			cin >> cost[i];
		}
		
		vector<cell> adj[32][32][4];
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				for(int k=0; k<4; k++){
					for(int t=0; t<4; t++){
						int y=i+dy[(k+t)%4];
						int x=j+dx[(k+t)%4];
						int c;
						if(map[i][j]==t) c=0;
						else c=cost[t];
						adj[i][j][k].push_back(cell(y,x,(k+t)%4,c));
					}
				}
			}
		}
		
		priority_queue<cell> q;
		q.push(cell(1,1,3,0));
		int mincost[32][32][4];
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				for(int k=0; k<4; k++){
					mincost[i][j][k] = inf;
				}
			}
		}
		
		mincost[1][1][3] = 0;
		while(!q.empty()){
			int y=q.top().y;
			int x=q.top().x;
			int d=q.top().dir;
			int c=q.top().cost;
			q.pop();
			if(c > mincost[y][x][d]) continue;
			if(y==h && x==w){
				cout << c << endl;
				break;
			}
			for(int i=0; i<(int)adj[y][x][d].size(); i++){
				cell nc=adj[y][x][d][i];
				if(nc.cost+c <mincost[nc.y][nc.x][nc.dir]){
					mincost[nc.y][nc.x][nc.dir] = nc.cost+c;
					nc.cost +=c;
					q.push(nc);
				}
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 3432
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <algorithm>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int maxn = 100010;
ll a[maxn];
int n;

bool check1(ll x)
{
	for(int i = 0;i < n;i++)
	{
		x -= x%a[i];
	}
	return x >= 2;
}

bool check2(ll x)
{
	for(int i = 0;i < n;i++)
	{
		x -= x%a[i];
	}
	return x <= 2;
}

int main()
{
	scanf("%d",&n);
	for(int i = 0;i < n;i++)
		scanf("%lld",&a[i]);

	ll l = 2,r = 1e18;
	while(l < r)
	{
		ll mid = (l+r) >> 1;
		if(!check1(mid)) l = mid+1;
		else r = mid;
	}
	ll mn = l;
	l = 2,r = 1e18;
	while(l < r)
	{
		ll mid = (l+r+1) >> 1;
		if(check2(mid)) l = mid;
		else r = mid-1;
	}
	ll mx = l;
	if(!check1(mx)) printf("-1\n"); 
	else printf("%lld %lld\n",mn,mx);
	return 0;
}


Measured memory_bytes: 1024
a,b = map(int,input().split())
if a<=0 and b>=0:
  print("Zero")
elif a>0 and b>0:
  print("Positive")
elif a<0 and b<0:
  t = b-a
  if t%2==0:
    print("Negative")
  else:
    print("Positive")

Measured memory_bytes: 2940
import math

def calc(N, X):
    P = round(sum(X) / N)
    res = 0
    for x in X:
        res += (P - x) ** 2
    return math.ceil(res)

if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    print(calc(N, X))

Measured memory_bytes: 3060
x=int(input())
value=0
index=0
hashmap=dict()
while value<int(1e18)+1:
    value=pow(index,5)
    hashmap[value]=index
    index+=1

for i in range(1,1000):
    b1=x+int(pow(i,5))
    b2=x+int(pow(-i,5))
#    print(i,b1,b2)
    if hashmap.get(b1)!=None:
        print(hashmap[b1],i)
        break
    if hashmap.get(b2)!=None:
        print(hashmap[b2],-i)
        break  

Measured memory_bytes: 9524
/**
 *    author:  tourist
 *    created: 04.05.2019 15:28:26       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) {
    cin >> grid[i];
  }
  vector<vector<int>> dist(h, vector<int>(w, -1));
  vector<pair<int, int>> que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == '#') {
        que.emplace_back(i, j);
        dist[i][j] = 0;
      }
    }
  }
  for (int b = 0; b < (int) que.size(); b++) {
    for (int dx = -1; dx <= 1; dx++) {
      for (int dy = -1; dy <= 1; dy++) {
        if (dx * dx + dy * dy == 1) {
          int xk = que[b].first + dx;
          int yk = que[b].second + dy;
          if (xk >= 0 && yk >= 0 && xk < h && yk < w && dist[xk][yk] == -1) {
            que.emplace_back(xk, yk);
            dist[xk][yk] = dist[que[b].first][que[b].second] + 1;
          }
        }
      }
    }
  }
  cout << dist[que.back().first][que.back().second] << '\n';
  return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  auto chk = [](string &s, int len) {
    bool ans = true;
    for (int i = 0; i < len / 2; ++i) {
      if (s[i] != s[i + len / 2]) {
        ans = false;
        break;
      }
    }

    return ans;
  };

  int ans;
  for (int i = 2; i < s.size(); i += 2) {
    if (chk(s, s.size() - i)) {
      ans = s.size() - i;
      break;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3612
// Problem : A - Frog 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    vi dp(n+1,inf),h(n+1);
    for(int i=1;i<=n;i++) cin>>h[i];
    for(int i=1;i<=n;i++){
        if(i == 1) dp[i] = 0;
        if(i+1 <= n) dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        if(i+2 <= n) dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout<<dp[n];
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> x(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    if(i % 2)
      x.at(0) -= a.at(i);
    else
      x.at(0) += a.at(i);
  }
  cout << x.at(0) << " ";
  for(int i = 1; i < n; i++) {
    x.at(i) = 2 * a.at(i - 1) - x.at(i - 1);
    cout << x.at(i) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  sort(A.begin(), A.end());
  ll arg, mi = 1LL << 60;
  REP(i, 0, N - 1) {
    if(A.back() % 2 == 0) {
      ll k = (A.back()) / 2;
      if(abs(k - A[i]) < mi) {
        mi = abs(k - A[i]);
        arg = i;
      }
    } else {
      ll k = A[i] <= A.back() / 2 ? A.back() / 2 : (A.back() + 1) / 2;
      if(abs(k - A[i]) < mi) {
        mi = abs(k - A[i]);
        arg = i;
      }
    }
  }
  cout << A.back() << " " << A[arg] << endl;
}


Measured memory_bytes: 1024
s = input()

flag = 0
slen = len(s)

if s == s[::-1]:
  flag += 1
  
s1 = s[::(slen-1)//2]
if s1 == s1[::-1]:
  flag += 1
  
s2 = s[(slen+3)//2-1:]
if s2 == s2[::-1]:
  flag += 1

if flag > 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <map>

const int mod = 1000000007;
//const int mod = 998244353;
int maximum(int a, int b) { return a < b ? b : a; }

int main() {
	long long N, M;
	scanf("%lld %lld", &N, &M);
	auto D = new int[N];
	for (int i = 0; i < N; i++) scanf("%d", D + i);
	auto U = new int[M];
	auto V = new int[M];
	std::map < long long, int>map;
	for (int i = 0; i < M; i++) {
		scanf("%d %d", U + i, V + i);
	}
	auto p = new std::vector<int>[N];
	for (int i = 0; i < M; i++) {
		U[i]--;
		V[i]--;
		p[U[i]].push_back(V[i]);
		p[V[i]].push_back(U[i]);
		map[U[i] * N + V[i]] = i;
		map[V[i] * N + U[i]] = i;
	}
	for (int i = 0; i < N; i++) {
		std::sort(p[i].begin(), p[i].end());
	}
	auto forest = new std::vector<int>[M];
	bool No = false;
	for (int i = 0; i < N; i++) {
		int min = 0;
		for (int j = 0; j < p[i].size(); j++) {
			if (D[p[i][j]] < D[p[i][min]]) {
				min = j;
			}
		}
		if (D[p[i][min]] > D[i]) {
			No = true;
			break;
		}
		forest[i].push_back(p[i][min]);
		forest[p[i][min]].push_back(i);
	}
	if (No) {
		printf("-1");
		return 0;
	}
	auto C = new char[N + 1]{};
	auto cost = new int[M] {};
	std::vector<int>q;
	int r = 0;
	for (int i = 0; i < N; i++) {
		if (C[i])continue;
		C[i] = 'B';
		q.push_back(i);
		while (q.size() > r) {
			for (int j = 0; j < forest[q[r]].size(); j++) {
				if (C[forest[q[r]][j]])continue;
				C[forest[q[r]][j]] = C[q[r]] == 'B' ? 'W' : 'B';
				cost[map[q[r] * N + forest[q[r]][j]]] = maximum(D[q[r]], D[forest[q[r]][j]]);
				q.push_back(forest[q[r]][j]);
			}
			r++;
		}
	}
	for (int i = 0; i < M; i++) {
		if (cost[i] == 0) {
			cost[i] = 1000000000;
		}
	}
	printf(C);
	for (int i = 0; i < M; i++) {
		printf("\n%d", cost[i]);
	}
	return 0;
}

Measured memory_bytes: 44792
//ÕÅ¼ÒÆæÔõÃ´ÓÖAKIOIÁËÑ½£¬ÔõÃ´CSPÒ²Âú·Ö°¡...ÔõÃ´Çå±±ÌìÌì¸øËû´òµç»°°¡...ÔõÃ´»áÓÐÕâÃ´Ç¿µÄÈË°¡
#include<bits/stdc++.h>
#define int long long
#define writeln(x)  write(x),puts("")
#define writep(x)   write(x),putchar(' ')
using namespace std;
inline int read(){
	int ans=0,f=1;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-') f=-1;chr=getchar();}
	while(isdigit(chr)){ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
	return ans*f;
}void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}int ans=LONG_LONG_MAX;
signed main(){
	int n=read();
	for(int i=1;i<=sqrt(n);i++){
		if(n%i==0){
			int a=i,b=n/i;
			ans=min(ans,a+b-2);
		}
	}cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char S[80010];
int i,j,dp[80010][20],t,r,l;
int main()
{
	for(;scanf("%s",S),S[0]!='0';)
	{
		memset(dp,0,sizeof(dp));
		l=strlen(S);
		for(i=r=0;i<l;i++)
		{
			t=S[i]-'0';
			dp[i+1][t]=!!t;
			for(j=0;j<11;j++)
				if(dp[i][j])
					dp[i+1][(10*j+t)%11]+=dp[i][j];
			r+=dp[i+1][0];
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 6876
#include<stdio.h>

int main(void)
{
  int a[3][3],n,i,j,k;

  //ビンゴカードの入力
  for(i=0;i<3;i++)
    for(j=0;j<3;j++)
      scanf("%d",&a[i][j]);

  //bの入力
  scanf("%d",&n);
  int b[n];
  for(k=0;k<n;k++)
    scanf("%d",&b[k]);

  //ビンゴカードに穴をあける
  for(i=0;i<3;i++)
    for(j=0;j<3;j++)
      for(k=0;k<n;k++)
        if(a[i][j]==b[k])
          a[i][j] = 0;

  //ビンゴが達成されているか確認
  for(i=0;i<3;i++){
    if(a[i][0]+a[i][1]+a[i][2]==0){
      printf("Yes\n");
      return 0;
    }
    else if(a[0][i]+a[1][i]+a[2][i]==0){
      printf("Yes\n");
      return 0;
    }
  }
  if(a[0][0]+a[1][1]+a[2][2]==0){
     printf("Yes\n");
     return 0;
  }
  else if(a[0][2]+a[1][1]+a[2][0]==0){
     printf("Yes\n");
     return 0;
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll N,K,Q;
vector<int> A;

ll num[100010];

int main(){
  cin>>N>>K>>Q;
  A.resize(Q);
  rep(i,Q) cin>>A[i];

  for(int i=0;i<Q;i++) A[i]--;

  for(int i=0;i<Q;i++) num[A[i]]++;

  for(int i=0;i<N;i++){
    int p=K-(Q-num[i]);
    if(p>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=4
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
#    a = fractions.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1
#    print(sosu)
    if sosu==set() and a!=1:
        sosu.add(a)
    if sosuhante(a) and a!=1:
        sosu.add(a)
#    print(sosu)
    m=4
    k=1

    count=1
    sosub=set()
#    a = fractions.gcd(a,b)
    if b%2==0:
        sosub.add(2)
        while b%2==0:
            b//=2
    if b%3==0:
        sosub.add(3)
        while b%3==0:
            b//=3
#    print(d)
    c=math.sqrt(b)+1
 #   print(c)
    while m<=c and m!=1:
        if b%m==0:
            sosub.add(m)
            while b%m==0:
                b//=m

        m+=1
#    print(sosu)
    if sosub==set() and b!=1:
        sosub.add(b)
    if sosuhante(b) and b!=1:
        sosub.add(b)
#    print(sosu,sosub)
    for i in sosu:
        if i in sosub:
            count+=1
    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Measured memory_bytes: 5088
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int h,w;cin>>h>>w;
    string s[h];
    rep(i,0,h)cin>>s[i];
    int ko[h][w];
    memset(ko,0,sizeof ko);
    rep(i,0,h){
        int now=0;
        rep(j,0,w){
            if(s[i][j]=='.')now++;
            else now=0;
            ko[i][j]+=now;
        }
    }
    rep(i,0,w){
        int now=0;
        rep(j,0,h){
            if(s[j][i]=='.')now++;
            else now=0;
            ko[j][i]+=now;
        }
    }
    rep(i,0,h){
        int now=0;
        rrep(j,w-1,0){
            if(s[i][j]=='.')now++;
            else now=0;
            ko[i][j]+=now;
        }
    }
    rep(i,0,w){
        int now=0;
        rrep(j,h-1,0){
            if(s[j][i]=='.')now++;
            else now=0;
            ko[j][i]+=now;
        }
    }
    int ans=0;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='.')ko[i][j]-=3;
            ans=max(ans,ko[i][j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 19968