akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n=0,a=0,b=0;
  int num1=0,num2=0,big=0;
  cin >> n >> a >> b;
  num1 = min(a,b);
  big = max(a,b);
  num2 = num1 - (n-big);
  cout << num1 << " ";
  cout << max(num2,0) << "\n";    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			cout << i<<"x"<<j<<"="<< i*j<<endl;
		}
	}
}


Measured memory_bytes: 3092
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;

int main() {
	int n;
	int a, b;
	cin >> n >> a >> b;
	vector<int> p;
	int c1, c2, c3;
	c1 = c2 = c3 = 0;
	for (int i = 0; i < n; ++i) {
		int pi;
		cin >> pi;
		p.push_back(pi);
		if (pi <= a) {
			c1++;
		}
		else if (pi <= b) {
			c2++;
		}
		else {
			c3++;
		}
	}
	cout << min(min(c1, c2), c3) << endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

vector<ll> G[101010];
vector<ll> mark(101010, -1);
vector<ll> visited(101010, false);
ll N, M;
ll bi = 0, od = 0, si = 0;

int is_bipartite(ll now, ll now_mark){
	if(mark[now]!=-1) return (mark[now]==now_mark);
	mark[now] = now_mark;
	bool flag = true;
	if(G[now].size() == 0) return -1;
	REP(i, G[now].size()){
		ll next = G[now][i];
		flag &= is_bipartite(next, 1-now_mark);
	}
	return (flag ? 1 : 0);
}

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

    cin >> N >> M;
    REP(i, M){
    	ll u, v;
    	cin >> u >> v;
    	u--;v--;
    	G[u].push_back(v);
    	G[v].push_back(u);
    }
    REP(i, N){
    	if(mark[i] == -1){
    		int tmp = is_bipartite(i, 0);
    		if(tmp == 1) bi++;
    		else if(tmp == 0) od++;
    		else si++;
    	}
    }
    ll res = 0;
    res += (N*N - (N-si)*(N-si));
    res += ((bi+od)*(bi+od) - bi*bi);
    res += (2*bi*bi);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 14208
import java.util.Scanner;

public class Main {
    private static final long MODVAL = 1000000007L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long W = sc.nextLong();
        if(H==1L || W==1L) {
            System.out.println(1L);
            return;
        }
        long md = (H%2==1L && W%2==1L) ? 1L : 0L;
        System.out.println(((H * W) / 2) + md);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   vector<int>s(n);
   for(int i=0;i<n;i++){
       cin>>s.at(i);
   }
   sort(s.begin(),s.end());
   reverse(s.begin(),s.end());
   int m=0;
   for(int i=0;i<n;i++){
       if(i%2==0){
           m += s.at(i);
       }
       else{
           m -= s.at(i);
       }
   }
   cout<<m<<endl;
  
}

Measured memory_bytes: 256
#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(){
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n){
        cin >> l[i];
    }
    int ans = 0;
    int d = 0;
    while (d <= x) {
        d += l[ans];
        ans++;
    }
    if(ans > n){
        ans = n+1;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
eval'A,B,*C=#'+`tr ' ' ,`
z=x=0
C.map{x^=_1}
i=45
i=(x^A^B)[i]>0?(z+=t=[A[0,i],(~B)[0,i]].min+1
A-=t
B+=t
45):i-1until i<0||A<1
p A>0?z:-1

Measured memory_bytes: 14468
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		//String result = "No";
		int[][] grid = new int[h][w];
		int indexH = 0;
		int indexW = 0;
		for(int i = 0; i < n; i++){
		    for(int j = 0; j < a[i]; j++){
		        grid[indexH][indexW] = i+1;
		        if(indexH%2 == 0 && indexW < w-1){
		            indexW++;
		        }else if(indexH%2 != 0 && indexW > 0){
		            indexW--;
		        }else{
		            indexH++;
		        }
		    }
		}
		
		for(int i = 0; i < h; i++){
		    for(int j = 0; j < w; j++){
		        System.out.print(grid[i][j]);
		        if(j < w-1){
		            System.out.print(" ");
		        }else{
		            System.out.print("\n");
		        }
		    }
		}
		// 出力
		//System.out.println(result);
	}
}



Measured memory_bytes: 33100
#include<iostream>
#include<algorithm>
#include<complex>
#include<cstdio>
#include<iomanip>
#include<vector>
#define x real()
#define y imag()
#define dot(A,B)		real(conj((A))*(B))
#define cross(A,B)		imag(conj((A))*(B))
#define PI 3.1415926
#define EPS 1e-9

using namespace std;
typedef double lf;
typedef complex<lf> pt;

pt pivot;

istream& operator >> ( istream& in, pt& p ) {
  lf a,n; in >> a >> n;
  p = pt(a,n); return in;
}

bool cmp(const pt &p, const pt &q) {
    if(p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}



int ccw(pt &p1, pt &p2){
    lf ans = (cross(p1 , p2) );
    if (-EPS <= ans && ans <= EPS)
        return 0;
    else if(ans <= -EPS)
        return -1;
    else
        return 1;
}

int ccw(pt& p1, pt& p2, pt& p3) {
  lf ans = (cross(p1 - p3, p2 - p3));
  if(-EPS <= ans && ans <= EPS)
    return 0;
  else if(ans <= -EPS)
    return -1;
  else
    return 1;
}

lf dist ( pt A, pt B ) { return abs(A-B); }


vector<pt> convex_hull(vector<pt> P){
	int n = P.size(); int k = 0;
	vector<pt> H(2*n);

	sort(P.begin(), P.end(), cmp);

	for (int i = 0; i < n; i++) {
		while (k >= 2 && ccw(H[k-2], H[k-1], P[i]) < 0) k--;
		H[k++] = P[i];
	}

	for (int i = n-2, t = k+1; i >= 0; i--) {
		while (k >= t && ccw(H[k-2], H[k-1], P[i]) < 0) k--;
		H[k++] = P[i];
	}

	if(n>1)
    k--;
	H.resize(k);
	return H;
}


int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef magUNbos
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif // magUNbos
  int n;
  cin>>n;
  vector<pt> p(n);
  for(int i = 0; i < n; i++)
    cin>>p[i];
  vector<pt> hull = convex_hull(p);

  cout<<hull.size()<<endl;
  int index = 0;
  for(int i = 0; i< hull.size(); i++){
    if(hull[i].y < hull[index].y){
        index = i;
    }
    else if(hull[i].y == hull[index].y){
        if(hull[i].x < hull[index].x)
            index = i;
    }
  }
  cout<<hull[index].x<<" "<<hull[index].y<<endl;
  for(int i = (index + 1)% (int)hull.size(); i != index; (i = (i + 1) % (int)hull.size())  ){
    cout<<hull[i].x<<" "<<hull[i].y<<endl;
  }
}

Measured memory_bytes: 9204
k,n = map(int,input().split())

Ai = list(map(int,input().split()))
kyori = []

for x in range(n-1):
  kyori.append(Ai[x+1]-Ai[x])
  
kyori.append(Ai[0]+k-Ai[n-1])

kyori.remove(max(kyori))

print(sum(kyori))


Measured memory_bytes: 32352
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
vi a[N];
ll vis[N][3];
int main()
{
	ios
	ll n,m,i,j,s,t,x,y;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>x>>y;
		a[x].pb(y);
	}
	cin>>s>>t;
	queue<pii>q;
	memset(vis,-1,sizeof vis);
	q.push({s,0});
	vis[s][0]=0;
	while(!q.empty()){
		auto f=q.front();
		q.pop();
		for(auto j:a[f.F]){
			if(vis[j][(f.S+1)%3]==-1){
				q.push({j,(f.S+1)%3});
				vis[j][(f.S+1)%3]=vis[f.F][f.S]+1;
			}
		}
	}
	if(vis[t][0]!=-1)cout<<vis[t][0]/3;else cout<<"-1";
	return 0;
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

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

    static int64_t dp[512][512];
    dp[0][0] = 1;
    for(int i=0; i<=X; i++) for(int j=N-1; j>=0; j--) for(int k=0; k<512; k++) add(dp[j+1][k^i], dp[j][k]);
    
    int64_t ans = 0;
    for(int j=0; j<=N; j++){
        int64_t res = dp[j][X];
        int r = N-j;
        if(r%2) continue;
        r /= 2;
        mul(res, comb_mod(X+r, r));
        add(ans, res);
    }
    cout << ans << endl;
    return 0;
}



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

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

  bool ans = false;
  rep(i, 9){
    rep(j, 9){
      if (n == (i+1) * (j+1)) ans = true;
    }
  }
  if (ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// using namespace std;

int dp[100005];

const int INF = 1001001001;

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

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

void Main() {
  int N;
  std::cin >> N;

  std::vector<int> h(N);
  for (auto &hi : h) {
    std::cin >> hi;
  }

  rep(i, N) { dp[i] = INF; }

  dp[0] = 0;

  for (int i = 0; i < N; ++i) {
    chmin(dp[i + 1], dp[i] + std::abs(h[i] - h[i + 1]));
    chmin(dp[i + 2], dp[i] + std::abs(h[i] - h[i + 2]));
  }
  std::cout << dp[N - 1] << std::endl;
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int m[55],f[55],r[55];
  int i=0;
  while(1){
    cin >> m[i] >> f[i] >> r[i];
    if(m[i]==-1&&f[i]==-1&&r[i]==-1){
      break;
    }
    if(m[i]==-1||f[i]==-1){
      cout << "F" <<endl;
    }else{
      if(r[i]==-1){
	r[i]=0;
      }
      if(80<=m[i]+f[i]){
	cout << "A" << endl;
      }else if(65<=m[i]+f[i]&&m[i]+f[i]<80){
	cout << "B" << endl;
      }else if(50<=m[i]+f[i]&&m[i]+f[i]<65){
	cout << "C" << endl;
      }else if(30<=m[i]+f[i]&&m[i]+f[i]<50){
	if(50<=r[i]){
	  cout << "C" << endl;
	}else{
	  cout << "D" << endl;
	}
      }else if(m[i]+f[i]<30){
	cout << "F" << endl;
      }
    }
    i=i+1;
  }
  return(0);
}



Measured memory_bytes: 3112
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n,m;
  cin>>n>>m;
  vi a(n);
  rep(i,n)cin>>a[i];
  vp v;
  rep(i,m){
    int b,c;
    cin>>b>>c;
    v.pb({c,b});
  }
  sort(all(a));
  sort(all(v));
  reverse(all(v));
  int j=0;
  rep(i,n){
    if(j==v.size())break;
    if(a[i]<v[j].fi){
      a[i]=v[j].fi;
      v[j].se--;
    }
    if(v[j].se==0)j++;
  }
  int ans=0;
  rep(i,n)ans+=a[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 3188
n = int(input())
a = list(map(int,input().split()))
cnt = [0,0,0,0,0,0,0,0]
count = 0
num = 0

for i in a:
    if 1 <= i <= 399:
        cnt[0] += 1
    elif 400<= i <= 799:
        cnt[1] += 1
        
    elif 800<= i <= 1199:
        cnt[2] += 1
        
    elif 1200<= i <= 1599:
        cnt[3] += 1
        
    elif 1600<= i <= 1999:
        cnt[4] += 1
        
    elif 2000<= i <= 2399:
        cnt[5] += 1
        
    elif 2400<= i <= 2799:
        cnt[6] += 1
       
    elif 2800 <= i <= 3199:
        cnt[7] += 1
        
    else:
        count += 1
for i in range(len(cnt)):
    if cnt[i] > 0:
        num +=1
if num == 0:
    num += 1
    print(num,num+count-1)
    exit()
print(num,num+count)
    

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

int main(void ){
	int m, n;
	while(cin >> m >> n) {
		if(m == 0 && n == 0) {
			break;
		}
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < n; j++) {
				cout << "#";
			}
			cout << endl;
	  	}
	  	cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)1e3;
// ===================== MANASH =================== //

int n,m;

void prn(bool ans ) {
	ans ? cout << "Yes\n" : cout << "No\n";
	exit(0);
}

void test() {

	int x,y;
	cin >> x >> y;
	if (y&1) prn(false);
	int a = y/2 - x;
	int b = 2*x - y/2;
	if ( a >= 0 and b >= 0 ) prn(true);
	else prn(false);
}

signed main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
	#endif

	int T = 1;
	//cin >> T;
	while(T--) {
		test();
		cout << "\n";
	}
	return 0;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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 gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, m;
	cin >> n >> m;
	vector<P<int>> task(n);
	rep(i, n) {
		cin >> task[i].first >> task[i].second;
	}
	sort(all(task));
	priority_queue<int> pq;
	ll ans = 0;
	int cnt = 0;
	rep1(i, m) {
		while (cnt != n && task[cnt].first == i) {
			pq.push(task[cnt].second);
			cnt++;
		}
		if (!pq.empty()) {
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int count_sw = 0;

void ss(int A[],int N){
    for (int i = 0; i < N-1; i++) {
        int min = A[i];
        int k = i;
        for (int j = i+1; j < N; j++) {
            if (min > A[j]) {
                min = A[j];
                k = j;
            }
        }
        if (i != k) {
            swap(A[k],A[i]);
            count_sw++;
        }
    }
}

int main(){
    int N;
    cin >> N;
    
    int *A;
    A = (int *)malloc(sizeof(int));
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    ss(A,N);
    
    for(int i = 0; i < N; i++){
        cout << A[i];
        if (i != N-1){
            cout << " ";
        }
    }
    cout << endl;
    
    cout << count_sw << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  int64_t tot=0;
  for (int i=0;i<n;++i) {
    cin>>a[i];
    tot+=a[i];
  }
  tot/=2;
  int64_t othtot=0;
  for (int i=0;i<(n/2);++i) {
    int j=i*2+1;
    othtot+=a[j];
  }
  b[0]=tot-othtot;
  b[0]*=2;
  cout<<b[0];
  cout<<" ";
  for (int j=1;j<n;++j) {
    b[j]=(2*a[j-1])-b[j-1];
    cout<<b[j];
    cout<<" ";
  }
}



Measured memory_bytes: 2048
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  ll ans = 0LL;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n - 1; i++) {
    ans += a[n - 1 - (1 + i) / 2];
  }
  cout << ans << endl;
}

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

int main() {
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; ++i) {
            if (i == 0 || i == H - 1) {
                for (int j = 0; j < W; ++j) cout << '#';
                cout << endl;
            }
            else {
                cout << '#';
                for (int j = 0; j < W - 2; ++j) cout << '.';
                cout << '#' << endl;                
            }
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
import java.util.*;

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

    while (true) {
      int n = sc.nextInt();
      int sum = 0;
      int a[] = new int[n];
      if (n == 0) return;
      for (int i = 0; i < n; i++) {
        a[i] = sc.nextInt();
        sum += a[i];
      }
      Arrays.sort(a);
      sum = sum - (a[0] + a[n-1]);

      System.out.println(sum / (n-2));
    }
  }
}



Measured memory_bytes: 28772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	V<int> a(N);
	rep(i,N) cin >> a[i];
	V<int> l(N+1),r(N+1);
	rep(i,N) l[i+1] = max(l[i],a[i]);
	rep(i,N) r[i+1] = max(r[i],a[N-1-i]);
	rep(i,N) cout << max(l[i],r[N-1-i]) << endl;
}


Measured memory_bytes: 3968
#include <iostream>
#include <stdio.h>

#define MAX_A 100'000

using namespace std;

int A[MAX_A];
int B[MAX_A];

int main() {
  int NA, NB, M;
  cin >> NA >> NB >> M;
  for (int i = 0; i < NA; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < NB; ++i) {
    cin >> B[i];
  }

  int res = 2 * MAX_A + 1;
  for (int i = 0; i < M; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    res = min(A[x - 1] + B[y - 1] - c, res);
  }
  for (int i = 0; i < NA; ++i) {
    for (int j = 0; j < NB; ++j) {
      res = min(A[i] + B[j], res);
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 4000
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <functional>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ld INF = 1e18;
typedef pair< ld, int > P;
const ll mod = 1e9+7;

int main() {
  int Q; cin >> Q;
  priority_queue<ll> pq_l;
  priority_queue<ll, vector<ll>, greater<ll>> pq_r;
  int lsize = 0, rsize = 0;
  ll lsum = 0, rsum = 0, B = 0;
  for (int i = 0; i < Q; i++) {
    int qtype; cin >> qtype;
    if (qtype == 1) {
      int a, b; cin >> a >> b;
      B += b;
      if (lsize <= rsize) {
        if (rsize > 0 && pq_r.top() < a) {
          lsum += pq_r.top();
          rsum -= pq_r.top();
          rsum += a;
          pq_l.push(pq_r.top());
          pq_r.pop();
          pq_r.push(a);
        } else {
          lsum += a;
          pq_l.push(a);
        }
        lsize++;
      } else {
        if (a < pq_l.top()) {
          rsum += pq_l.top();
          lsum -= pq_l.top();
          lsum += a;
          pq_r.push(pq_l.top());
          pq_l.pop();
          pq_l.push(a);
        } else {
          rsum += a;
          pq_r.push(a);
        }
        rsize++;
      }
    } else {
      ll x = pq_l.top();
      if (lsize == rsize) {
        cout << x << " " << -lsum+rsum+B << endl;
      } else {
        cout << x << " " << x-lsum+rsum+B << endl;
      }
    }
  }
}


Measured memory_bytes: 3828
import sys
import fractions
def input(): return sys.stdin.readline().rstrip()
def cunt_multi(a,b,n):
    #区間[c,d]内のnの倍数の個数
    if b%n<=(b-a+1)%n-1:
        return (b-a+1)//n+1
    else:
        return (b-a+1)//n

def lcm(a,b):
    f=a*b//fractions.gcd(a,b)
    return f

def main():
    a,b,c,d=map(int,input().split())
    print(b-a+1-cunt_multi(a,b,c)-cunt_multi(a,b,d)+cunt_multi(a,b,lcm(c,d)))

if __name__=='__main__':
    main()

Measured memory_bytes: 64236
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S],H=0,[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return print(c)
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return print(-1)
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:g(n,E,*p)
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


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


void solve(long long N){
    cout << static_cast<double>(ceil(static_cast<double>(N)/2) / N) << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    bool f = abs(a-c)<=d;
    bool g = abs(a-b)<=d && abs(b-c)<=d;
    bool h = f || g;

    if (h) 
        printf("Yes");
    else 
        printf("No");

    return 0;
}

Measured memory_bytes: 256
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=2e5+5;

int n,m,a[maxn];
int cl(int x){if(x%(m-1) == 0)return x/(m-1);return x/(m-1)+1;}

int main(){
	scanf("%d%d",&n,&m);
	
	int mn=inf,idx;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i] < mn){mn=a[i],idx=i;}
	}
//	printf("%d\n",(n-2)/(m-1)+1);
	if(idx<=m){
		n -= m;
//		while(1);
		printf("%d\n",cl(n)+1);
		return 0;
	}
	if(n-idx+1<=m){
		n -= m;
//		while(1);
		printf("%d\n",cl(n)+1);
		return 0; 
	}
	printf("%d\n",min(cl(idx-1)+cl(n-idx),cl(n-1)));

	return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc153/tasks/abc153_a

#include <bits/stdc++.h>
using namespace std;
int main() {
    int H, N;
    cin >> H >> N;

    int att = 0;
    int ans = 0;
    while(att < H) {
        att += N;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
xs = [1]
i = 1
while N >= 6**i:
    if 9**i <= N:
        xs.append(9**i)
    xs.append(6**i)
    i += 1
X = sorted(xs)
# print(X)

# N円のときの最小回数
dp = [10000000000] * 1008000
dp[0] = 0
for i in range(N):
    for x in X:
        dp[i+x] = min(dp[i]+1, dp[i+x])
print(dp[N])

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (0 <= x - r && 0 <= y - r && x + r <= W && y + r <= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

ll N, A, B;

ll solve() {
    if ((A+B)%2 == 0) {
        return (B-A)/2;
    }
    return (B-A+1) / 2 + min(A-1, N-B);
}

int main() {
    cin >> N >> A >> B;
    cout << solve() << endl;
}

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

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

	int ha, hb, hc; cin>>ha>>hb;
	int a=0, b, c; b = c = abs(ha-hb);

	n -= 2;
	while(n--){
		cin>>hc;
		c = min(a + abs(hc-ha), b + abs(hc-hb));
		a = b; b = c;
		ha = hb; hb = hc;
	}
	cout<< c <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define FREE -1
#define NFREE 1
#define M 8

int row[M],col[M],board[M][M],left_u[2*M-1],right_u[2*M-1];

void initialize();
void put_queen(int );
void print_board();

int main()
{
  int n,i,j,k;

  initialize();
  scanf("%d",&n);

  for(i=0;i<n;i++){
	scanf("%d %d",&j,&k);
	board[j][k]=NFREE;
  }

  put_queen(0);

  return 0;
}

void initialize()
{
  int i,j;
  for(i=0;i<M;i++){
	   for(j=0;j<M;j++){
  	    board[i][j]=FREE;
	     }
     }
  for(i=0;i<M;i++) row[i]=col[i]=FREE;
  for(i=0;i<2*M-1;i++) left_u[i]=right_u[i]=FREE;
}

void put_queen(int x)
{
  int y;

  if(x==M){
	print_board();
	return ;
  }

  for(y=0;y<M;y++){
	if(left_u[x+y]==NFREE || right_u[x-y+M-1]==NFREE || col[y]==NFREE) continue;

	row[x]=y;
	col[y]=left_u[x+y]=right_u[x-y+M-1]=NFREE;

	put_queen(x+1);

	row[x]=col[y]=left_u[x+y]=right_u[x-y+M-1]=FREE;
  }
}

void print_board()
{
  int i,j;

  for(i=0;i<M;i++){
	   for(j=0;j<M;j++){
  	    if(board[i][j]==NFREE){
          if(row[i]!=j)return;
  	     }
	      }
      }

  for(i=0;i<M;i++){
	   for(j=0;j<M;j++){
  	    if(row[i]!=j)printf(".");
  	     else printf("Q");
	      }

	printf("\n");

  }
}



Measured memory_bytes: 2084
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int x, y;
        cin >> x >> y;

        int a = 4 * x - y;
        int b = y - 2 * x; 
        
        if((b % 2 == 0  && b >= 0 && a % 2 == 0 && a >= 0))
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    
    return 0;
}



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;

  int ans = 0;
  rep(i, 0, 3) { ans += S[i] == T[i]; }
  cout << ans << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


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

int main() {
    int n,k;
    cin >> n >> k;
    long long  ans = 0;
    int count = 0;
    if(k%2 == 1){
        ans = pow(n/k,3);
    }
    else{
        ans = pow(n/k,3);
        for(int i=0; i<INT_MAX; i++){
            if((k*i+k/2) <= n){
                count += 1;
            }
            else{
                break;
            }
        }
        ans += pow(count,3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4100
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#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                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int a[M];
 main()

{
    fast
    int n,k;
    cin>>n>>k;
    int val=1;
    f(i,1,k)
    {
        int x;
        cin>>x;
        a[i]=x;
    }
    f(i,k+1,n)
    {
        int x;
        cin>>x;
        if(x>a[i-k])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
        a[i]=x;
    }
    return 0;

}





































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


int main(){   
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    
    sort(p.begin(), p.end());
    
    int ans = 0;
    for(int i=0;i<k;++i){
        ans += p[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <cmath>
#include <iostream>

using namespace std;

const uint64_t R = 1'000'000'007L;

uint64_t dp[100][40'000];
uint64_t idp[100][40'000];

int main()
{
    uint64_t n, k;

    cin >> n >> k;
    uint64_t r = floor(sqrt(n));

    for (uint64_t i = 0; i < k; i++)
    {
        for (uint64_t j = 1; j <= r; j++)
        {
            if (i == 0)
            {
                dp[i][j] = j;
            }
            else
            {
                dp[i][j] = ((j == 1 ? 0 : dp[i][j - 1]) + idp[i - 1][j]) % R;
            }

            //cout << " dp[" << i << "][" << j << "]=" << dp[i][j] << "\t";
        }
        //cout << endl;

        for (uint64_t j = r; j >= 1; j--)
        {
            if (i == 0)
            {
                idp[i][j] = n / j;
            }
            else
            {
                if (j == r)
                {
                    idp[i][j] = (dp[i][r] + (n / j - r) * dp[i - 1][j]) % R;
                }
                else
                {
                    idp[i][j] = (idp[i][j + 1] + (n / j - n / (j + 1)) * dp[i - 1][j]) % R;
                }
            }
            //cout << "idp[" << i << "][" << j << "]=" << idp[i][j] << "\t";
        }
        //cout << endl;
    }

    uint64_t result = idp[k - 1][1];
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 62080
#include<bits/stdc++.h>
#define MAX 100000
#define NIL -1
using namespace std;
struct Node{
  int p;
  int l;
  int r;
};
Node T[MAX];
int D[MAX];
void setDepth(int node,int deep){
    D[node]=deep;
    if(T[node].r!=NIL)
        setDepth(T[node].r,deep);
    if(T[node].l!=NIL)
        setDepth(T[node].l,deep+1);
}
void printChildren(int node){
    int c = T[node].l;
    int i=0;
    while(c!=NIL){
        if(i)
            cout<<", ";
        cout<<c;
        c = T[c].r;
        i++;
    }
}
void print(int node){
    
    cout<<"node "<<node<<": ";
    cout<<"parent = "<<T[node].p<<", ";
    cout<<"depth = "<<D[node]<<", ";
    
    if(T[node].p==NIL){
        cout<<"root, ";
    }else{
        if(T[node].l!=NIL){
            cout<<"internal node, ";
        }else{
            cout<<"leaf, ";
        }
    }
    cout<<"[";
    printChildren(node);
    cout<<"]"<<endl;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        T[i].p=T[i].l=T[i].r=NIL;
    int v,c,k,l;
    for(int i=0;i<n;i++){
        cin>>v>>k;
        for(int j=0;j<k;j++){
            cin>>c;
            if(j==0)
                T[v].l=c;
            else
                T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    int root;
    for(int i=0;i<n;i++){
        if(T[i].p==NIL)
            root=i;
    }
    setDepth(root,0);
    for(int i=0;i<n;i++)
        print(i);
    return 0;
}


Measured memory_bytes: 7776
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}
fn get_vec_by_lines<T : FromStr>(n : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for _i in 0..n {
        let x : T = get_one();
        v.push(x);
    }
    return v;
}


fn main() {
    let kn : Vec<i64> = get_vec();
    let (k,n) = (kn[0], kn[1] as usize);

    let a : Vec<i64> = get_vec();
    let mut b : Vec<i64> = Vec::new();
    for i in 0..(n-1) {
        b.push(a[i+1] - a[i]);
    }
    b.push(k - a[n-1] + a[0]);
    let mut ans = k;
    //println!("{:?}", b);
    for i in 0..n {
        ans = std::cmp::min(ans, k-b[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
N = int(raw_input())
A = map(int, raw_input().split())
 
#N = 200000
#A = [200000]*N
 
count = [0]*(N+2)
for i in range(N):
    id = A[i]
    count[id] = count[id]+1
 
sumN = long(0)
for i in range(N+1):
    sumN = sumN + long(long(count[i]*(count[i]-1))/2)
 
#print answer
for i in range(N):
    id = A[i]
    sumz = sumN - (count[id] - 1)
    print(sumz)

Measured memory_bytes: 55136
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

template <typename T = int>
T in();

int main() {
    int a(in()), b(in()), c(in());
    int x = b / a;
    cout << min(x, c) << endl; 
    return 0;
}

template <typename T = int>
T in() {
    T temp;
    cin >> temp;
    return temp;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long Dp[100000][3];

long long maxhappy(int A[][3],int N,int i,int c)
{
   if(i<N)
   {
         if(c!=-1 && Dp[i][c]!=-1)
         {
             return Dp[i][c];
         }

        long long cost=INT_MIN;
        long long lp;
        for(int j=0;j<3;j++)
        {
            if(j!=c){
                lp = maxhappy(A,N,i+1,j)+A[i][j];
                if(lp>cost)
                {
                 cost = lp;
                }

              }
        }
Dp[i][c] = cost;
return cost;


   }

   return 0;
}
// long long maxhappy_dp(int A[][3],int N)
// {
//   long long *Dp = new long long[N+1];
//   long long maxh = INT_MIN;
//   int pc = -1;
//   long long kl;
//   long long ch=-1;
// for(int i=N;i>=0;i--)
// {
//   if(i==N)
//   {
//     Dp[i] = 0;
//
//   }else
//   {
// for(int j=0;j<3;j++)
// {
//
//     if(j!=pc)
//     {
//       kl = Dp[i+1]+A[i][j];
//       if(kl>maxh)
//       {
//         maxh = kl;
//         ch = j;
//       }
//     }
//
//
// }
// Dp[i] = maxh;
// pc =ch;
//
//   }
// }
//
// return Dp[0];
//
//
//
// }
main()
{
   int N;
   int A[100000][3];

   cin>>N;
   for(int i=0;i<N;i++)
   {
     cin>>A[i][0]>>A[i][1]>>A[i][2];
     Dp[i][0] = Dp[i][1] = Dp[i][2] =-1;
   }

   long long macost = INT_MIN;
   macost = maxhappy(A,N,0,-1);
   cout<<macost;

}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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 Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int mod = 1e9 + 7;
ll fact(int x) {
	ll tmp = 1;
	for (int i = x; i > 1; i--) {
		tmp *= i;
		tmp %= mod;
	}
	return tmp;
}
int main() {
	int n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0;
		return 0;
	}
	if (abs(n - m) == 1) {
		ll ans = fact(n) * fact(m) % mod;
		cout << ans;
		return 0;
	}
	if (n == m) {
		ll ans = 2 * fact(n) * fact(m) % mod;
		cout << ans;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

n = int(input())

a = n / 100

b = n % 100

if a >=1 and a <= 12:
    if b >= 1 and b <=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b >= 1 and b <=12:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
fun main(args: Array<String>) {
    a85(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a85(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val date = "2018" + args[0].removeRange(0, 4)
    println(date)
}


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

int n;
long long ans=1;
bool zero=false, minuss=false;

int main(){
	cin >> n;
	for (int i=0;i<n;i++){
		long long a;
		cin >> a;
		if (a==0) zero=true;
		else if (ans<=1000000000000000000/a) ans*=a;
		else minuss=true;
	}
	if (zero) cout << 0 << "\n";
	else if (minuss) cout << -1 << "\n";
	else cout << ans << "\n";
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    string a,b;
    cin >> a >> b;
    for(int i = 0; i < a.size(); i++){
        bool flag = true;
        for(int j = 0; j < b.size(); j++){
            if(a[(i+j) % a.size()] != b[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
    }   
    cout << "No" << endl;
  
}


Measured memory_bytes: 3216
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    string x;
    cin >> x;
    int cnt = 0, maxc = 0;
    for (auto &&c: x) {
        if (c == 'T') ++cnt;
        else --cnt;
        maxc = max(maxc, cnt);
    }
    cout << maxc * 2 << endl;
}

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

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
  if (left > right) {
    cout << "Left" << endl;
  }
  else if (left < right) {
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

//Mayan Crucial Prediction
public class Main{

	int[] day = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int MOD = 13*20*20*18*20;
	int B = 20*20*18*20;
	int KA = 20*18*20;
	int T = 18*20;
	int W = 20;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			String in = sc.next();
			if("#".equals(in))break;
			String[] t = in.split("\\.");
			int n = t.length;
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=Integer.parseInt(t[i]);
			if(n==5)toSeireki(a[0], a[1], a[2], a[3], a[4]);
			else toMayan(a[0], a[1], a[2]);
		}
	}
	
	void toSeireki(int b, int ka, int t, int w, int ki){
		int days = b*B + ka*KA + t*T + w*W + ki;
		int y = 2012, m = 12, d = 21;
		while(0 < days){
			if(m==1 && d==1){
				int yearDay = 365 + leap(y);
				if(yearDay <= days){
					y++;
					days-=yearDay;
					continue;
				}
			}
			if(m==2){
				if(d==day[2]+leap(y)){
					m++; d=1;
				}
				else d++;
			}
			else{
				if(d==day[m]){
					m++; d=1;
					if(m==13){
						y++; m=1;
					}
				}
				else d++;
			}
			days--;
		}
		System.out.printf("%d.%d.%d\n", y, m, d);
	}

	int leap(int y){
		return y%4==0 && (y%100!=0 || y%400==0) ? 1 : 0;
	}
	
	void toMayan(int y, int m, int d){
		int Y = 2012, M = 12, D = 21;
		int days = 0;
		while(Y!=y || M!=m || D!=d){
			days%=MOD;
			if(M==1 && D==1){
				if(Y!=y){
					int year = 365+leap(Y);
					days+=year;
					Y++;
					continue;
				}
			}
			if(M==2){
				if(D==day[2]+leap(Y)){
					M++; D=1;
				}
				else D++;
			}
			else{
				if(D==day[M]){
					M++; D=1;
					if(M==13){
						Y++; M=1;
					}
				}
				else D++;
			}
			days++;
		}
		days%=MOD;
		int b = days/B; days%=B;
		int ka = days/KA; days%=KA;
		int t = days/T; days%=T;
		int w = days/W; days%=W;
		int ki = days;
		System.out.printf("%d.%d.%d.%d.%d\n", b, ka, t, w, ki);
	}

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

Measured memory_bytes: 29076