akhauriyash/Code-Regression huggingface dataset:
// ABC177-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll n,mod=pow(10,9)+7,ans=0;
    cin>>n;
    vector<ll> a(n);
    vector<ll> rui(n,0);
    rep(i,n){
        cin>>a[i];
    }
    for(int i=n-1;i>=1;i=i-1){
        rui[i-1]=rui[i]+a[i];
        rui[i-1]%=mod;
    }
    rep(i,n){
        ll cur=rui[i]*a[i];
        cur%=mod;
        ans+=cur;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6336
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
ws = []
for i in range(n):
    ws.append(na())

ws.sort(key=lambda x: x[1])
t = 0
for w in ws:
    t += w[0]
    if t > w[1]:
        print("No")
        sys.exit(0)
print("Yes")


Measured memory_bytes: 53608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

// dijkstra
struct edge{int to, cost;};

struct dijkstra {
    int V;
    vint d;
    vector<vector<edge>> G;

    dijkstra(int n) {init(n);} 

    void init(int n) {
        V = n;
        G.resize(V);
        d.resize(V);
        rep(i,V) d[i] = inf;
    }

    void add_edge(int s, int t, int cost) {
        s--; t--;
        edge e;
        e.to = t; e.cost = cost;
        G[s].push_back(e);
    }

    void run(int s) {
        s--;
        priority_queue<P, vector<P>, greater<P>> q;
        d[s] = 0;
        q.push(P(0,s));
        while (!q.empty()) {
            P e = q.top(); q.pop();
            int v = e.second;
            if (d[v] < e.first) continue;
            for (auto e: G[v]) {
                if (chmin(d[e.to],d[v]+e.cost)) {
                    q.push(P(d[e.to],e.to));
                }
            }
        }
    }
};

int main() {
    int n; cin >> n;
    dijkstra dj_f(n);
    dijkstra dj_s(n);
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        dj_f.add_edge(a,b,1);
        dj_f.add_edge(b,a,1);
        dj_s.add_edge(b,a,1);
        dj_s.add_edge(a,b,1);
    }
    dj_f.run(1); dj_s.run(n);
    int ct_f = 0; int ct_s = 0;
    rep(i,n) {
        if (dj_f.d[i] <= dj_s.d[i]) ct_f++;
        else ct_s++;
    }
    if (ct_f <= ct_s) cout << "Snuke" << endl;
    else cout << "Fennec" << endl;
}

Measured memory_bytes: 13708
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define nep(x) next_permutation(x);
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int min_l = 0, min_r = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            if(S[i] == '0') min_l++;
            if(S[i] == '1') min_r++;
        }else{
            if(S[i] == '1') min_l++;
            if(S[i] == '0') min_r++;
        }
    }
    cout << min(min_l, min_r) << endl;
}


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

typedef long long ll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
typedef pair<ll,ll> pll;

const ll N = 200001;
const ll MOD = 1000000007;
const ll INF = LLONG_MAX;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'

#define COUT(v) for(auto it:v)cout<<it<<space;cout<<nl;
#define CIN(v) for(auto &it:v)cin>>it;

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int t=1,cs=0;
    //cin>>t;
    while(t--)
    {
        ll k,n,i;
        cin>>k>>n;
        vll v(n),d;
        CIN(v);
        d.pb(v[0]+k-v[n-1]);
        for(i=1;i<n;i++)
            d.pb(v[i]-v[i-1]);
        sort(rall(d));
        ll s=accumulate(all(d),0);
        cout<<s-d[0]<<nl;
    }
}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/


int main(){
    int N,L; cin >> N >> L;
    vector<string> s(N);
    for (int i = 0; i < N; i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for (int i = 0; i < N; i++){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N,M;
    cin >> N >> M;
    dsu d(N);
    REP(i,M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a,b);
    }
    set<int> ans;
    REP(i,N){
        ans.insert(d.leader(i));
    }
    cout << (ans.size()-1) << endl;
}

Measured memory_bytes: 7544
def resolve():
  x,k,d=map(int,input().split())
  if x<0:
    x*=-1
  if x//d>k:
    print(x-k*d)
  else:
    m=x//d-k
    if m%2==0:
      print(x%d)
    else:
      print(abs(x%d-d))
    
if __name__ == '__main__':
    resolve()

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N,K);
    vi H(N);VCIN(H);
    sort(all(H));
    int ans=INF;
    rep(i,N-K+1){
        int cur=H[i+K-1]-H[i];
        chmin(ans,cur);
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int seg[10][7]={{0,1,1,1,1,1,1},
				   {0,0,0,0,1,1,0},
				   {1,0,1,1,0,1,1},
				   {1,0,0,1,1,1,1},
				   {1,1,0,0,1,1,0},
				   {1,1,0,1,1,0,1},
				   {1,1,1,1,1,0,1},
				   {0,1,0,0,1,1,1},
				   {1,1,1,1,1,1,1},
				   {1,1,0,1,1,1,1}};
	int change[7];
	int n,a;
	int i,j;
	
	scanf("%d",&n);
	while(n!=-1){
		for(i=0;i<7;i++){	
			change[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d",&a);
			for(j=0;j<7;j++){
				if(seg[a][j]==change[j]){
					printf("0");
				}
				else {
					printf("1");
				}
				change[j]=seg[a][j];
			}
			printf("\n");
		}
		scanf("%d",&n);
	}
	return 0;
}
		

Measured memory_bytes: 1004
#include <bits/stdc++.h>
using namespace std;
const int INFTY = (1<<30);

struct Card{
  char suit;
  int value;
};

int partition(vector<Card> &A, int p, int r) {
  int x = A[r].value;
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j].value <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i + 1;
}

void quickSort(vector<Card> &A, int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

void merge(vector<Card> &A, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  vector<Card> L(n1+1);
  vector<Card> R(n2+1);
  for (int i = 0; i < n1; i++) {
    L[i] = A[left+i];
  }
  for (int j = 0; j < n2; j++) {
    R[j] = A[mid+j];
  }
  L[n1].value = INFTY;
  R[n2].value = INFTY;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].value <= R[j].value) {
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(vector<Card> &A, int left, int right) {
  if (right - left > 1) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  vector<Card> A(n), B(n);
  for (int i = 0; i < n; i++) {
    char s;
    int v;
    cin >> s >> v;
    A[i].suit = s;
    A[i].value = v;
  }
  B = A;
  
  quickSort(A, 0, n - 1);
  mergeSort(B, 0, n);

  bool is_same = true;
  for (int i = 0; i < n; i++) {
    if (!(A[i].suit == B[i].suit && A[i].value == B[i].value)) {
      is_same = false;
      break;
    }
  }

  if (is_same) {
    cout << "Stable" << endl;
  }
  else {
    cout << "Not stable" << endl;
  }
  for (int i = 0; i < n; i++) {
    cout << A[i].suit << " " << A[i].value << endl;
  }
}


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

struct dor {
	dor *l, *r;
	int sd;

	void pp() {
		if(l == NULL && r == NULL);
		else if(l == NULL) sd = r->sd;
		else if(r == NULL) sd = l->sd;
		else sd = max(l->sd, r->sd);
	}
} *rt;

const int LN = -1e9, NR = 1e9, mod = 998244353;

int M(long long l, long long r) {
	int m = (l + r) / 2;
	if(m == r) --m;
	return m;
}

int si, vl;
void rgnk(int l, int r, dor *&t) {
	if(t == NULL)
		t = new dor();
	if(l == r)
		t->sd = vl;
	else if(M(l, r) >= si)
		rgnk(l, M(l, r), t->l);
	else
		rgnk(M(l, r) + 1, r, t->r);
	t->pp();
}

void gnk(int Si, int Vl) {
	si = Si, vl = Vl;
	rgnk(LN, NR, rt);
}

int sl, sr;
int rsgm(int l, int r, dor *&t) {
	if(l > sr || r < sl || t == NULL)
		return LN;
	if(l >= sl && r <= sr)
		return t->sd;
	return max(rsgm(l, M(l, r), t->l), rsgm(M(l, r) + 1, r, t->r));
}

int sgm(int l, int r) {
	sl = l, sr = r;
	return rsgm(LN, NR, rt);
}

int n, x, d;
vector<pair<int, int> > v, ve;
set<pair<int, int> > s;
long long fp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	v.push_back((*new pair<int, int>()));
	ve.push_back((*new pair<int, int>()));
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> x >> d;
		v.push_back({x, x + d - 1});
	}
	sort(v.begin() + 1, v.end());
	reverse(v.begin() + 1, v.end());
	for(int i = 1; i <= n; ++i) {
		int tp = max(v[i].second, sgm(v[i].first, v[i].second));
		gnk(v[i].first, tp);
		ve.push_back({v[i].first, tp});
	}
	for(int i = 1; i <= n; ++i) {
		long long tp = 1;
		while(s.size() && s.begin()->first <= ve[i].second) {
			tp *= s.begin()->second;
			tp %= mod;
			s.erase(s.begin());
		}
		++tp;
		tp = (tp == mod ? 0 : tp);
		s.insert({ve[i].first, tp});
	}
	fp = 1;
	while(s.size()) {
		fp *= s.begin()->second;
		fp %= mod;
		s.erase(s.begin());
	}
	cout << fp << endl;
	return 0;
}


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

int main(void){
  string s, t;
  cin >> s >> t;
  int ans = 1100;
  for(int i = 0; i < s.size()-t.size()+1; i++){
    int cnt = 0;
    for(int j = 0; j < t.size(); j++){
      if(s[i+j] != t[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

string s1, s2;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> s1 >> s2;
    int n = s1.length();
    if (s1.substr(0, n) == s2.substr(0, n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while(1) {
    c -= b;
    if(c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if (k % 2 == 0){
        ans = a - b;
    }else{
        ans = b - a;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) throws Exception {
		Main main = new Main();
		main.run();
	}

	void run() {
		int n = in.nextInt();
		int[] num = in.nextIntArray(n);

		int count = 0;
		for (int i = 0; i < n - 1; i++) {
			int minIndex = i;
			for (int j = i; j < n; j++) {
				if (num[j] < num[minIndex]) {
					minIndex = j;
				}
			}
			if (i != minIndex) {
				count++;
				int temp = num[i];
				num[i] = num[minIndex];
				num[minIndex] = temp;
			}
		}
		System.out.println(Arrays.stream(num).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
		System.out.println(count);
	}
}

class FastReader {
	private InputStream in = System.in;
	private byte[] buf = new byte[1024];
	private int charNum;
	private int charLen;
	private StringBuilder sb = new StringBuilder();

	public int read() {
		if (charLen == -1)
			throw new InputMismatchException();
		if (charNum >= charLen) {
			charNum = 0;
			try {
				charLen = in.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (charLen <= 0)
				return -1;
		}
		return buf[charNum++];
	}

	public String next() {
		int c = read();
		while (isWhitespace(c)) {
			c = read();
		}
		sb.setLength(0);
		do {
			sb.appendCodePoint(c);
			c = read();
		} while (!isWhitespace(c));
		return sb.toString();
	}

	public char[] nextCharArray() {
		return next().toCharArray();
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public int[] nextIntArray(int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++)
			array[i] = nextInt();
		return array;
	}

	public List<Integer> nextIntList(int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++)
			array[i] = nextInt();
		return Arrays.asList(array);
	}

	public int[][] nextIntArray2D(int n, int m) {
		int[][] array = new int[n][m];
		for (int i = 0; i < n; i++)
			array[i] = nextIntArray(m);
		return array;
	}

	public List<int[]> nextIntsList(int n, int m) {
		List<int[]> list = new ArrayList<int[]>(n);
		for (int i = 0; i < n; i++)
			list.add(nextIntArray(m));
		return list;
	}

	public long nextLong() {
		int c = read();
		while (isWhitespace(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isWhitespace(c));
		return res * sgn;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public double[] nextDoubleArray(int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++)
			array[i] = nextDouble();
		return array;
	}

	public boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
}

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

int main()
{
  string s;
    cin>>s;
    int x=s.size();
    bool lower=false;
    for(int i=0;i<x;i++)
    {
        if(islower(s[i]))
           lower=true;
        else
        {
            lower=false;
        }
    }
    if(x==19&&s[5]==','&&s[13]==','&&lower==true)
    {
        replace( s.begin(), s.end(), ',', ' ');
    }
    cout<<s;


    return 0;
}


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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B, C;
    cin >> A >> B >> C;
    if(A+B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))
#define eps 1e-8
const int maxn=1e5+100;

LL a[maxn],w[maxn];
int main()
{
    //freopen("c:\\in.txt","r",stdin);
    int x,y,z;
    cin>>x>>y>>z;
    cout<<(x-z)/(y+z)<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll cnt[1000010] = {};

int main() {

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

    sort(a.begin(), a.end());

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

        if (cnt[a[i]] == 1) continue;

        ll t = a[i] * 2;
        while(t <= 1000000) {
            cnt[t] = 1;
            t += a[i];
        }
    }

    ll ans = 0;
    for (ll i = 0; i < n; ++i) {
        if (cnt[a[i]] == 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12696
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

bool isprime(int n){
    if(n == 2 || n == 3) return true;
    else if(n <= 1 || n % 2 == 0 || n % 3 == 0) return false;
    for(int i = 5; i*i <= n; i += 6) if(n % i == 0 || n % (i+2) == 0) return false;
    return true;
}

int main(){
    int q; cin >> q;
    vector<int> num(1e5+7);
    num[0] = 0;
    for(int i = 1; i<=1e5; i++){
        num[i] = num[i-1];
        if(isprime(i) && isprime((i+1)/2)) num[i]++;
    }
    
    vector<pair<int,int>> p(q);
    rep(i,q){
        int l, r; cin >> l >> r;
        p[i] = make_pair(l,r);
    }
    rep(i,q) cout << num[p[i].second] - num[p[i].first-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#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(){
    int N, l, r;
    int count = 0;
    cin >> N;

    rep(i, N)
    {
        cin >> l;
        cin >> r;
        count += r - l + 1;

    }
    cout << count << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  priority_queue<int> q;
  rep(i,n) {
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i,k) {
    if(q.empty()) continue;
    q.pop();
  }
  long long ans = 0;
  while(!q.empty()) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main()
{
    int i, j, seki;
    for (i = 1; i <= 9; i++) {
        for (j = 1; j <= 9; j++) {
            seki = i*j;
            printf("%dx%d=",i, j);
            printf("%d\n", seki);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<int, int>
#define Pl pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int main()
{
  string S; cin >> S;
  reverse(S.begin(), S.end());
  int sz = S.size(); --sz;
  int index = 0;

  while(index < sz){
    if(S.substr(index, 5) == "maerd") index += 5;
    else if(S.substr(index, 7) == "remaerd") index += 7;
    else if(S.substr(index, 6) == "resare") index += 6;
    else if(S.substr(index, 5) == "esare") index += 5;
    else { cout << "NO" << endl;return 0;}
  }

  cout << "YES" << endl;
}

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

using namespace std;

const int N = 3e5 + 5;
int q;
string s;
char tambah[N][2];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> s >> q;
    int m = 0;
    int ptr1 = 0, ptr2 = 0;
    while(q--){
        int a;
        cin >> a;
        if(a == 1){
            m++;
        } else {
            int k;
            char he;
            cin >> k >> he;
            if(k == 2){
                if(m % 2 == 0){
                    tambah[ptr1][0] = he;
                    ptr1++;
                } else {
                    tambah[ptr2][1] = he;
                    ptr2++;
                }
            } else {
                if(m % 2 == 0){
                    tambah[ptr2][1] = he;
                    ptr2++;
                } else {
                    tambah[ptr1][0] = he;
                    ptr1++;
                }
            }
        }
    }

    if(m % 2 == 0){
        for(int i = ptr2 - 1; i >= 0; i--){
            cout << tambah[i][1];
        }
        cout << s;
        for(int i = 0; i < ptr1; i++){
            cout << tambah[i][0];
        }
        cout << '\n';
    } else {
        for(int i = ptr1 - 1; i >= 0; i--){
            cout << tambah[i][0];
        }
        reverse(s.begin(), s.end());
        cout << s;
        for(int i = 0; i < ptr2; i++){
            cout << tambah[i][1];
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 1104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void judge(char *);
void judge(char *s)
{
    int n=strlen(s);
    if(s[0]!=s[n-1])
    {
        if(n%2==1)
        {
            printf("First\n");
            return;
        }
        else
        {
            printf("Second\n");
            return;
        }
    }
    if(s[0]==s[n-1])
    {
        if(n%2==0)
        {
            printf("First\n");
            return;
        }
        else
        {
            printf("Second\n");
            return;
        }
    }
}
int main()
{
    char a[100005];
    scanf("%s",a);
    judge(a);
    return 0;
}

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


int main(){
    while(1) {
    int n, l, r; cin >> n >> l >> r;
    if(n==0 && l==0 && r==0) return 0;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int count=0;
    for(int i=l; i<=r; i++) {
        int res = -1;
        for(int j=0; j<n; j++) {
            if(i % a[j] == 0) {
                res = j;
                break;
            }
        }
        if(res % 2 == 0) count++;
        else if(n % 2 == 0 && res ==-1) count++; 
    }
    cout << count << endl;
    }
}
   


Measured memory_bytes: 3104
# https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_B
def dp(i, j):
    if dp_list[i][j] != 0:
        return dp_list[i][j]
    if i == len(lists):
        return 0
    if j < lists[i][1]:
        dp_list[i][j] = dp(i + 1, j)
        return dp_list[i][j]
    else:
        dp_list[i][j] = max(dp(i + 1, j), dp(i + 1, j - lists[i][1]) + lists[i][0])
        return dp_list[i][j]


N, W = (int(x) for x in input().split())
# value, weightの順で並んでいる
lists = []
for i in range(N):
    lists.append(list(map(lambda x: int(x), input().split())))
dp_list = [[0 for i in range(W + 1)] for j in range(N + 1)]
print(dp(0, W))



Measured memory_bytes: 24088
fun main(args: Array<String>) {
    val N = nextInt()
    val S = next()
    val deque = java.util.ArrayDeque<Char>()
    var openBracket = 0
    S.forEach { s ->
        when (s) {
            '(' -> {
                deque.addLast('(')
                openBracket += 1
            }
            ')' -> {
                if (openBracket > 0) openBracket -= 1
                else deque.addFirst('(')
                deque.addLast(')')
            }
        }
    }

    repeat(openBracket) {
        deque.addLast(')')
    }
    println(deque.joinToString(""))
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}


Measured memory_bytes: 33600
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        printf("%.9lf\n",sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));

        return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"1"<<endl;
        return 0;
    }
    vector<int>furui(n+1,0);
    for(int i=2;i<=n;i++){
        if(furui[i]==0){
            for(int j=i;j<=n;j+=i)furui[j]=i;
        }
    }
    long long x=1;
    for(int i=2;i<=n;i++){
        vector<int>v;
        int I=i;
        while(furui[I]!=I){//prime
            v.push_back(furui[I]);
            I/=furui[I];
        }
        v.push_back(I);
        long long yakusu=1;
        int s=2;
        for(int j=0;j<v.size()-1;j++){
            if(v[j]==v[j+1])s++;
            else{
                yakusu*=s;
                s=2;
            }
        }
        yakusu*=s;
        x+=yakusu*i;
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 42304
SIZE=2*10**5; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    fac[i] = fac[i-1]*i%MOD
finv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(SIZE-1,0,-1):
    finv[i-1] = finv[i]*i%MOD
    inv[i] = finv[i]*fac[i-1]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0


# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

h,w,a,b = map(int,read().split())


ans = 0
for r in range(0,h-a):
    ans += choose(b-1+r,b-1)*choose(w-b-1+h-r-1,w-b-1)

print(ans%MOD)






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

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

int main(){
    ll A, B, K; cin >> A >> B >> K;
    if(A >= K) cout << A-K << ' ' << B << endl;
    else if(A < K){
        K = K - A;
        A = 0;
        if (B >= K) cout << A << ' ' << B-K << endl;
        else if (B < K) cout << 0 << ' ' << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define db(...) #__VA_ARGS__ << ": " << __VA_ARGS__
using ii=long long;
const int M = 1e9 + 7;
string s;
int MOD;
int pd[1 << 15][2][101];
ii dp[1 << 15][2][101];
ii calc(int x, int f, int m)
{
    if (x == s.size()) return m == 0;
    if (pd[x][f][m]) return dp[x][f][m];
    pd[x][f][m] = 1;
    ii r = 0;
    for (int j = 0; j <= (f ? 9 : s[x]); ++j) {
        r += calc(x + 1, f || (j < s[x]), (m + j) % MOD);
        r %= M;
    }
    return dp[x][f][m] = r;
}
int main()
{
    cin >> s >> MOD;
    for (char &c : s) c -= '0';
    cout << (calc(0, 0, 0) - 1 + M) % M << "\n";;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  int x[n+1];
  for(int i=1; i<=n; i++) cin >> x[i];

  int ans=0;
  for(int i=1; i<=n; i++){
    ans += 2*min(abs(x[i]-0), abs(x[i]-k));
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
  double a, max, min;
  max = 0;
  min = 10000000;
  while (cin >> a){
    if (max < a){
      max = a;
    }
    if (min > a){
      min = a;
    }
  }
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void) {
	int num;
	char str[5];

	scanf("%s", str);


	if (str[0] == '1' && str[1] <= '2' && str[2] == '1' && str[3] <= '2') {
		puts("AMBIGUOUS");
		return 0;
	}

	if (str[0] == '0' && str[1] <= '9' && str[2] == '0' && str[3] <= '9') {
		if (str[1] == '0' && str[3] == '0') {
			puts("NA");
			return 0;
		}else if(str[1] == '0' || str[3] == '0') {
			
		}
		else {
			puts("AMBIGUOUS");
			return 0;
		}
	}

	if (str[0] == '0' && str[1] <= '9' && str[1] != '0' && str[2] == '1' && str[3] <= '2') {
		puts("AMBIGUOUS");
		return 0;
	}

	if (str[2] == '0' && str[3] <= '9' && str[3] != '0' && str[0] == '1' && str[1] <= '2') {
		puts("AMBIGUOUS");
		return 0;
	}

	if ((str[0] == '1' && str[1] <= '2') || (str[0] == '0' && str[1] <= '9' && str[1] != '0')) {
		puts("MMYY");
		return 0;
	}

	if ((str[2] == '1' && str[3] <= '2') || (str[2] == '0' && str[3] <= '9' && str[3] != '0')) {
		puts("YYMM");
		return 0;
	}

	puts("NA");
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
A, B, M = map(int,  input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

sum = []
for i in range(M):
        x, y, c = map(int,  input().split())
        sum.append(a[x-1]  + b[y-1] - c)

a.sort()
b.sort()

sum.append(a[0] + b [0])

sum.sort()

i=0
while sum[i] < 0:
        i+=0
print(sum[i])


Measured memory_bytes: 18608
#include <stdio.h>
const int M = 300;
const int N = 300;

int main()
{
int m, n;


	
	while(scanf("%d %d",&m ,&n))
	{
		if(m == 0 && n == 0)
		{
			break;
		}
	for(int i = 0; i < m; i++)
	{
		for(int j = 0; j < n; j++)
		{
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
	}
	
}



Measured memory_bytes: 2600
import sys
import math


#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def query(self,top_num,front_num):

        self.save_data = [i for i in range(6)]
        #元の値の保存
        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]

        ret = -1

        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break

        #元の値の復元
        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]

        return ret

    def equals(self,another):

        ret = False

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret

num_dice = int(input())
DICE = []

for i in range(num_dice):
    table = list(map(int,input().split()))
    tmp_dice = Dice()
    tmp_dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
    DICE.append(tmp_dice)

FLG = True

for i in range(num_dice-1):
    for k in range(i+1,num_dice):
        if DICE[i].equals(DICE[k]) == True:
            FLG = False
            break


if FLG == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5684
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int arr[n][4];
    int dp[n][4];
    for (int i=0 ; i<n ; i++){
        for (int j=1 ; j<4 ; j++){
            cin >> arr[i][j];
        }
        if (i==0){
            dp[0][1] = arr[0][1];
            dp[0][2] = arr[0][2];
            dp[0][3] = arr[0][3];
        }
        else{
            dp[i][1] = arr[i][1] + max(dp[i-1][2],dp[i-1][3]);
            dp[i][2] = arr[i][2] + max(dp[i-1][1],dp[i-1][3]);
            dp[i][3] = arr[i][3] + max(dp[i-1][1],dp[i-1][2]);
        }
    }
    cout << max(dp[n-1][1],max(dp[n-1][2],dp[n-1][3])) << "\n";
    return 0;
}


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

int main() {
	ll N, M;
	cin >> N >> M;

	vector<int> m;
	for (int i = 1; i * i <= M; ++i) {
		if (M % i == 0) {
			m.push_back(i);
			m.push_back(M / i);
		}
	}
	sort(m.begin(), m.end());

	ll res = 1;
	for (int i = 0; i < m.size(); ++i) {
		ll t = M / m[i];
		if (t >= N) { res = m[i]; }
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
xyz = [list(map(int,input().split())) for i in range(n)]

ans = 0
for x in [-1,1]:
    for y in [-1,1]:
        for z in [-1,1]:
            s = []
            for a,b,c in xyz:
                s.append(a*x+b*y+c*z)
            s.sort(reverse=True)
            ans = max(ans,sum(s[:m]))
print(ans)

Measured memory_bytes: 41200
#include<stdio.h>
int main(void)
{
	int a[7],b[7],c[7],i;
	for(i=0;i<7;i++) {
		scanf("%d %d",&a[i],&b[i]);
		c[i]=a[i]-b[i];
	}
	for(i=0;i<7;i++) {
		printf("%d\n",c[i]);
	}
	return 0;
}

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

struct Point {
  int x;
  int y;
};

int main(void) {
  int W, H ,r;
  Point circle;
  cin >> W >> H >> circle.x >> circle.y >> r;
  int top = circle.y + r;
  int bottom = circle.y - r;
  int left = circle.x - r;
  int right = circle.x + r;
  if(top <= H && bottom >= 0 && left >= 0 && right <= W)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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


typedef pair<ll,ll> pll;


ll n;
ll a[100005], ans[100005];
int main()
{
        cin >> n;
        for(ll i=1;i<=n;i++) cin >> a[i];
        ll sum = a[n];
        for(ll i=1;i<n;i += 2) sum -= a[i];
        for(ll i=2;i<n;i += 2) sum += a[i];
        assert(sum%2 == 0);
        ans[n] = sum / 2;
        ans[1] = a[n] - ans[n];
        ll tt = ans[n];
        for(ll i=1;i<n;i++){
                ans[i+1] = a[i] - ans[i];
        }
        assert(tt == ans[n]);
        for(ll i=1;i<=n;i++) cout << 2*ans[i] << " "; cout << endl;
        return 0;
}


Measured memory_bytes: 2816
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string S;
  cin>>S;
  rep(i,S.size()) {
    cout<<"x";
  }
}

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

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

    int t[5] = {};
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        switch (s[0]) {
            case 'M' : t[0]++; break;
            case 'A' : t[1]++; break;
            case 'R' : t[2]++; break;
            case 'C' : t[3]++; break;
            case 'H' : t[4]++; break;
            default : break;
        }
    }

    long long ans = 0;
    for (int i = 0; i < (1 << 5); i++) {
        long long cnt = 0, tmp = 1;
        for (int j = 0; j < 5; j++) {
            cerr << (i >> j & 1);
            if (i >> j & 1) {
                tmp *= t[j];
                cnt++;
            }
        }
        if (cnt == 3) ans += tmp;
        cerr << " " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

const int MAX_V=5000;
typedef pair<int,int> P;
struct edge{ int to,cap,cost,rev; };
int V=5000;
vector<edge> G[MAX_V];
int h[MAX_V],dist[MAX_V],prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
	G[from].pb((edge){to,cap,cost,G[to].size()});
	G[to].pb((edge){from,0,-cost,G[from].size()-1});
}
pi min_cost_flow(int s,int t,int f){
	int res=0;
	fill(h,h+V,0);
	while(f>0){
		priority_queue<P,vector<P>,greater<P> > q;
		fill(dist,dist+V,inf);
		dist[s]=0;
		q.push(P(0,s));
		while(!q.empty()){
			P p=q.top(); q.pop();
			int v=p.second;
			if(dist[v]<p.first)continue;
			rep(i,G[v].size()){
				edge &e=G[v][i];
				if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
					dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
					prevv[e.to]=v;
					preve[e.to]=i;
					q.push(P(dist[e.to],e.to));
				}
			}
		}
		if(dist[t]==inf)return mp(f,res);
		rep(v,V)h[v]+=dist[v];
		int d=f;
		for(int v=t;v!=s;v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
		f-=d;
		res+=d*h[t];
		for(int v=t;v!=s;v=prevv[v]){
			edge &e=G[prevv[v]][preve[v]];
			e.cap-=d;
			G[v][e.rev].cap+=d;
		}
	}
	return mp(0,res);
}

int n,m[100],x[100][20],y[100][20],c[100][20],g;
int v[100],vy[100][20];
map<int,int> id[100];

int main(){
	while(cin>>n,n){
		rep(i,5000)G[i].clear();
		v[0]=1;
		m[0]=1;
		vy[0][0]=-1;
		int s=4998,t=4999, cur=1;
		for(int i=1;i<n;i++){
			cin>>m[i];
			rep(j,m[i])cin>>x[i][j]>>y[i][j]>>c[i][j], id[i][y[i][j]]=0;
			v[i]=0;
			fr(j,id[i])vy[i][j->second=v[i]++]=j->first;
			
			int nxt=cur+v[i-1];
			rep(j,v[i])add_edge(nxt+j,nxt+j+v[i],1,0);
			rep(j,v[i-1])rep(k,m[i])if(vy[i-1][j]<=x[i][k])
				add_edge(cur+j,nxt+id[i][y[i][k]],1,c[i][k]);
			cur+=v[i-1]+v[i];
		}
		cin>>g;
		add_edge(s,1,g,0);
		rep(i,v[n-1])add_edge(cur+i,t,g,0);
		
		pi ans=min_cost_flow(s,t,g);
		cout<<g-ans.first<<" "<<ans.second<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 3472
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

vll a;
ll k;
bool calc(ll t){
  bitset<5001> b;
  b.set(0);
  for(int i=0;i<a.size();i++){
    if(i==t) continue;
    b = b | (b << a[i]);
  }
  for(int i=max(k-a[t], (ll)0);i<k;i++) if(b[i]) return true;
  return false;
}
int main(int argc, char const *argv[]) {
  ll n, tmp;std::cin >> n >> k;
  for(int i=0;i<n;i++){
    std::cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  ll l = -1, r = n;
  while(r - l > 1){
    ll mid = (l+r)/2;
    if(!calc(mid)) l = mid;
    else r = mid;
  }
  std::cout << r << '\n';
}


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


#define ll long long
#define MOD 1000000007



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

    for(int i=0;i<s.size();i++){
        if(i>=k){
            cout<<"..."<<endl;
            break;
        }else{
            cout<<s.at(i);
        }
    }

}


Measured memory_bytes: 3600
#include <iostream>

int main()
{

    int n;

    std::cin >> n;

    long long int ans = 0;

    for (int i = 1; i <= n; ++i)
    {
        if (i % 3 > 0 && i % 5 > 0)
            ans += i;
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int H,W;
int c[10][10], A[200][200];


void floyd_warshall(){
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
			}
		}
	}
}

void solve(){
	int ans=0;
	floyd_warshall();

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(A[i][j] != -1){
				ans += c[A[i][j]][1];
			}
		}
	}

	cout << ans << endl;
}

int main(){
	cin >> H >> W;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin >> c[i][j];
		}
	}

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> A[i][j];
		}
	}

	solve();
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    map<ll,ll> freq;
    ll n,m,temp;
    cin>>n>>m;
    while(m--)
    {
        cin>>temp;
        freq[temp]++;
    }
    ll arr1[n+1];
    arr1[0]=1;
    arr1[1]=1-freq[1];
    for(ll i=2;i<=n;i++)
    {
        if(freq[i])
        {
            arr1[i]=0;
            continue;
        }
        arr1[i]=(arr1[i-1]+arr1[i-2])%MOD;
    }
    cout<<arr1[n];
    return 0;
}

Measured memory_bytes: 7296