akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

ll A[200000];
ll cnt[200001];
ll sel[200001];

int main()
{
	int N;
	ll sum = 0;

	cin >> N;
	rep(i, N) cin >> A[i];

	rep(i, N) cnt[A[i]]++;
	repc(i, 1, N) {
		sel[i] = cnt[i] * (cnt[i] - 1) / 2;
		sum += sel[i];
	}

	rep(i, N) {
		ll ans = sum;
		ll c = cnt[A[i]] - 1;

		ans -= sel[A[i]];
		ans += c * (c - 1) / 2;

		cout << ans << endl;
	}

	return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int h,w;
cin>>h>>w;
char im[h*2][w];
rep(i,h){
    rep(j,w){
        char c;
        cin>>c;
        im[2*i][j]=c;
        im[2*i+1][j]=c;
    }
}
rep(i,2*h){
    rep(j,w){
        cout<<im[i][j];
    }
    cout<<endl;
}
return 0;
}

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

#define SQ(x) ((x) * (x))

using namespace std;

int par[128];

int find(int x)
{
    return (par[x] >= 0 ? par[x] = find(par[x]) : x);
}

void merge(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (-par[x] < -par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

bool same(int x, int y)
{
	return (find(x) == find(y));
}

int main()
{
	int n;

	while (scanf("%d", &n) && n){
		double x[128], y[128], z[128], r[128];

		vector<pair<double, pair<int, int> > > edges;

		for (int i = 0; i < n; i++){
			scanf("%lf %lf %lf %lf", &x[i], &y[i], &z[i], &r[i]);
			for (int j = 0; j < i; j++){
				edges.push_back(make_pair(max(0.0, sqrt(SQ(x[i] - x[j]) + SQ(y[i] - y[j]) + SQ(z[i] - z[j])) - r[i] - r[j]), make_pair(i, j)));
			}
		}

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

		memset(par, -1, sizeof(par));
		double ans = 0;
		for (int i = 0; i < edges.size(); i++){
			if (!same(edges[i].second.first, edges[i].second.second)){
				ans += edges[i].first;
				merge(edges[i].second.first, edges[i].second.second);
			}
		}

		printf("%.3lf\n", ans);
	}

	return (0);
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){

    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

template<typename T>bool chkmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool chkmin(T &a,T b){return (a>b)?a=b,1:0;}

inline long long read() {
 long long x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
unordered_map<long long,int>ha;
int pr[100005],tot;
long long  a[100005];
int cnt=pow(10,10*1.0/3);
int n;
long long l[100005],r[100005];
int main () {
#ifndef ONLINE_JUDGE
//file("agc003d");
#endif
//cout<<cnt<<endl;
    F(i,2,cnt){
		int flag=0;
	   F(j,2,i-1){
	     if(i%j==0){
		    flag=1;
			break;
		 }
	   }
	   if(!flag)pr[++tot]=i;
	}
	n=read();
	F(i,1,n){
		long long now=1,fi=1;
	  a[i]=read();
	  F(j,1,tot){
	     int ls=0;
		 while(a[i]%pr[j]==0)a[i]/=pr[j],ls++;
		 ls%=3;
		 if(ls){
		    F(i,ls,2){
			   now*=pr[j];
			   if(now>1e10)now=0;
			}
			while(ls)fi*=pr[j],ls--;
		 }
	  }
	  ha[fi*a[i]]++;
	  l[i]=fi*a[i],r[i]=now;
	  long long w=sqrt(a[i]);
	  if(w*w!=a[i]){
	     if(a[i]*r[i]<=1e10)r[i]*=a[i];
		 else r[i]=0;
		 if(a[i]*r[i]<=1e10) r[i]*=a[i];
			else r[i]=0;
	  }
	  else{
	     if(r[i]*w<=1e10)r[i]*=w;
		 else r[i]=0;
	  }
	}
	int ans=0;
	F(i,1,n){
		if(l[i]==1)continue;
	   ans+=max(ha[l[i]],ha[r[i]]);
	   ha[l[i]]=ha[r[i]]=0;
	}
	ans+=(ha[1]>0);
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 9800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, R;
    cin >> N >> R;
    if(N >= 10) cout << R << endl;
    else cout << R + 100*(10-N) << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var na = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var x = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var nx = na[0] * Max(x.Max(), na[1]);
        var dp = new long[na[0]+1, 2*nx+1];
        dp[0,nx] = 1;
        for (var i = 0; i < na[0]; i++)
            x[i] -= na[1];
        for(var i = 0; i <= na[0]; i++)
        {
            for(var j = 0; j <= 2*nx; j++)
            {
                if (i == 0 && j != nx) { dp[i, j] = 0; continue; }
                else if (i == 0) continue;
                var dif = j - x[i-1];
                if (dif < 0 || dif > 2 * nx) dp[i, j] = dp[i - 1, j];
                else dp[i, j] = dp[i - 1, j] + dp[i - 1, dif];
            }
        }
        WriteLine(dp[na[0], nx] - 1);
    }

    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 14432
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  string s = to_string(a) + to_string(b);
  int n = stoi(s);
  int _n = (int)sqrt(n);
  if (_n * _n == n) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3164
{-# LANGUAGE TypeApplications #-}

import Data.Maybe
import Data.List
import Control.Monad
import Data.Bifunctor
import Control.Applicative
import Data.Monoid

main :: IO ()
main = do
    [n, m, x] <- fmap (read @Int) . words <$> getLine
    list <- replicateM n $ fromJust . uncons . fmap (read @Int) . words <$> getLine
    print $ (fromMaybe (-1) . foldl1May min . map fst . filter (all (>= x) . take m . snd) . fmap (bimap getSum (fmap getSum . getZipList . getAp)) . fmap mconcat . traverse (: [mempty]) . fmap (bimap Sum (Ap . ZipList . fmap Sum))) list
    pure ()


foldl1May :: (a -> a -> a) -> [a] -> Maybe a
foldl1May f (x:xs) = Just $ foldl f x xs
foldl1May _ _ = Nothing

Measured memory_bytes: 5264
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int a[n];
  int x = 0;
  int y = 1000000000;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    if (a[i] > x)
      x = a[i];
  }
  for(int i = 0; i < n; i++) {
    if (a[i] < y)
      y = a[i];
  }
  cout << x - y;
}
  

Measured memory_bytes: 3560
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<climits>

using namespace std;

long long len(const char *str){
  long long ret = 0;
  str++;
  while(*str!=')'){
    //printf(" %s : ret=%d\n",str,ret);
    if(isdigit(*str)||*str=='('){
      long long num;
      if(*str=='('){
        num = 1;
      }else{
        sscanf(str,"%lld",&num);
        while(isdigit(*str)) str++;
      }
      long long length;
      if(*str=='('){
        length = len(str);
      }else{
        length = 1;
      }
      //printf("  len=%d, num=%d\n",length,num);
      if(*str=='('){
        long long nest = 0;
        do{
          if(*str=='(') nest++;
          else if(*str==')') nest--;
          str++;
        }while(nest!=0);
      }else{
        str++;
      }
      ret+=num*length;
    }else if(isalpha(*str)){
      long long cnt = 0;
      while(isalpha(*str)){
        cnt++;
        //printf("  alpha: %d (%c)\n",cnt,*str);
        str++;
      }
      //printf("  alpha: %d (%c)\n",cnt,*str);
      ret+=cnt;
    }
    if(ret > INT_MAX) return INT_MAX;
  }
  return ret;
}

char parse(const char *str, long long p){
  //printf("str: %s  p: %lld\n",str,p);
  int f = (*str=='('?1:0);
  if(p<0 || *str=='\0') return '0';
  if(isdigit(*str)||*str=='('){
    long long num;
    if(*str=='('){
      num = 1;
    }else{
      sscanf(str,"%lld",&num);
      while(isdigit(*str)) str++;
    }
    long long length;
    if(*str=='('){
      length = len(str);
      //printf(" %s: %d\n",str,length);
    }else{
      length = 1;
    }
    if(length==INT_MAX){
      return parse(str+f, p);
    }else if(num*length>p){
      return parse(str+f, p%length);
    }else{
      if(*str=='('){
        long long nest = 0;
        do{
          if(*str=='(') nest++;
          else if(*str==')') nest--;
          str++;
        }while(nest!=0);
      }else{
        str++;
      }
      return parse(str, p-num*length);
    }
  }else if(isalpha(*str)){
    if(p==0) return *str;
    else return parse(str+1, p-1);
  }
}

int main(){
  char buff[120];
  long long p;
  while(scanf("%s%lld",buff,&p),p!=0 || strcmp(buff,"0")!=0)
    printf("%c\n",parse(buff,p));
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int A[100100];
int main()
{
	int N;
	cin>>N;
	int Left=0;
	long long ans=0;
	for(int i=0;i<N;i++)
		cin>>A[i];
	for(int i=0;i<N;i++)
	{
		if(!A[i])
		{
			Left=0;
			continue;
		}
		ans+=(Left+A[i])/2;
		Left=(Left+A[i])%2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
MOD = 10**9+7

n,m = MAP()
x = MAP()
x.sort()

if n>=m:
    print(0)
    exit(0)

ll = []
for i in range(m-1):
    ll.append(x[i+1]-x[i])
ll.sort()
print(sum(ll[0:max(0, m - n)]))

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

int main(){
    long K, A, B;
    cin >> K >> A >> B;
    if(K <= A){
        cout << 1 << endl;
    }else if(A <= B){
        cout << -1 << endl;
    }else{
        cout << ((K - B - 1) / (A - B)) * 2 + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <iomanip>
#include <complex>
#include <unordered_map>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<unsigned, unsigned> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef pair<ll, ll> l4;
typedef long double ld;

typedef unsigned ui;
#define mp make_pair
#define pb push_back

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

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%lld", a+i);
  ll ans = 0;
  bool done = false;
  while (!done)
    {
      done = true;
      for (int i = 0; i < n; ++i)
	if (a[i] >= n)
	  {
	    done = false;
	    ll tmp = a[i]/n;
	    ans += tmp;
	    a[i] %= n;
	    for (int j = 0; j < n; ++j)
	      if (i != j)
		a[j] += tmp;
	  }
    }
  printf("%lld\n", ans);
}


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

using namespace std;

int main() {

  int a, b, c;
  cin >> a >> b;
  double ans, ra, rb;
  ra = a;
  rb = b;
  ans = ra / rb;
  cout << fixed << setprecision(10) << ans;
  return 0;
}


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

using ll = long long;
#define mod 1000000007
#define init ios::sync_with_stdio(0), cin.tie(0);
typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main()
{
    init;

    ll n;

    cin >> n;

    int maxi = 1;

    while (n > pow(26, maxi))
    {
        n -= pow(26, maxi);
        maxi++;
    }
    string res = "";
    maxi--;
    // cout << maxi << endl;
    //;
    while (maxi >= 0)
    {
        ll tmp = pow(26, maxi);
        ll nn = (n - 1) / tmp;

        res += (char)(nn + 'a');
        //  cout << nn << ' ' << n << endl;

        n = (n) % tmp;
        if (n == 0)
            n += pow(26, maxi);
        //   cout << tmp << ' ' << n << endl;

        maxi--;
    }
    //res[res.length() - 1]--;
    cout << res << endl;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;cin>>n;
  vector<int>p(n);
  for(int i=0;i<n;i++)
    cin>>p.at(i);  
  int count=0;
   for(int i=0;i<n;i++)
   {
     if(p.at(i)!=i+1)
      count++;
   }
  if(count<3)
    cout<<"YES";
  else
    cout<<"NO";
}
  
  
  
  


Measured memory_bytes: 256
def f(n,x):
    for i in range(9):
        if n[i] != -1 and n[i] != x[i]: return 1
import itertools
u=[1,2,3,4,5,6,7,8,9]
a=0
n=list(map(int,input().split()))
for x in itertools.permutations(u):
    if f(n,x):continue
    if x[0]+x[2]+x[5]-x[8]+(x[1]+x[4]-x[7])*10+(x[3]-x[6])*100==0:a+=1
print(a)

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int n, m;
   cin >> n >> m;
   vector<int> L(m), R(m);
   for (int i = 0; i < m; ++i) {
      cin >> L[i] >> R[i];
   }

   int d = *min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end());
   cout << max(d+1, 0) << endl;

   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int a[maxn];
int main() {
	int n;
	cin >> n;
	n *= 2;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort (a, a + n);
	int ans = 0;
	for (int i = n - 2; i >= 0; i -= 2)
		ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s not in dic: dic[s] = 1
  else: dic[s] += 1
v = dic.values()
v = sorted(v)
max_num = v[len(v)-1]
ans = []
for s in dic:
  if dic[s]==max_num:
    ans.append(s)
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 34652
k, s = gets.split.map{|i| i.to_i}
# x+y+z<=kなのでたとえばx+y<=k-z, z<=k-x-y
res = 0
for x in 0..k do
    for y in 0..k do
        z = s-x-y
        if 0<=z && z<=k then
            res+=1
        end
    end
end
puts res

Measured memory_bytes: 1788
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

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

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: Vec<char> = sc.chars();
    for i in 0..S.len() {
        if i % 2 == 0 {
            if S[i] == 'L' {
                println!("No");
                return;
            }
        } else {
            if S[i] == 'R' {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
//#define test
#define MP make_pair
#define PB push_back
#define set(a,b,c) a[b.first][b.second]=c
#ifdef test
#define IOS()
#define time() cout<<double(end-start)/CLOCKS_PER_SEC<<"S\n"
#else
#define IOS() ios::sync_with_stdio(0)
#define time()
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char maze[1001][1001];
int h,w;
bool ok(int y,int x)
{
	return (x>=0&&x<w&&y>=0&&y<h&&maze[y][x]=='.');
//	if(pii.first)
}
int main()
{
	while(cin>>h>>w)
	{
		double start=clock();
		int dis[h][w];
		bool b[h][w]={0};
		memset(dis,0x3f,sizeof dis);
		pii from;
		cin>>from.first>>from.second;//(y,x)
		from.first--;
		from.second--;
		pii to;
		cin>>to.first>>to.second;
		to.first--;
		to.second--;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				cin>>maze[i][j];
			}
		} 
		deque<pii> d;
		d.PB(from);
		set(b,from,1);
		set(dis,from,0);
		while(d.size())
		{
			pii f=d.front();d.pop_front();
			int x=f.second;
			int y=f.first;
			for(int i=y-2;i<=y+2;i++)
			{
				for(int j=x-2;j<=x+2;j++)
				{
					if(!ok(i,j)) continue;
					if(i==y&&x==j) continue;
					if(abs(i-y)+abs(j-x)==1)
					{
						if(dis[y][x]<dis[i][j])
						{
							dis[i][j]=dis[y][x];
							b[i][j]=1;
							d.push_front(MP(i,j));
						}
					}
					else
					{
						if(dis[y][x]+1<dis[i][j])
						{
							dis[i][j]=dis[y][x]+1;
							b[i][j]=1;
							d.push_back(MP(i,j));
						}
					}
				}
			}
		}
		if(b[to.first][to.second]) cout<<dis[to.first][to.second]<<"\n";
		else cout<<"-1\n";
		double end=clock();
		time();
	}
} 
/*
.....
.....
.....
.....
.....
*/

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


int main() {
	set<int> s = { 1, 9, 7, 4 };
	set<int> ss;
	for(int i=0;i<4;i++) {
		int n;
		cin >> n;
		ss.insert(n);
	}
	if(s == ss) {
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define mod (1000000007)

ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll f(ll n){return power(2,n);}

void solve() 
{
    int n;cin>>n;
    ll sum0=0,sum=1;
    map<Pll,P> cnt;
    REP(i,n){
        ll a,b;
        cin>>a>>b;
        if(a==0&&b==0){
            sum0++;
            continue;
        }
        ll GCD=gcd(a,b);
        a/=GCD;b/=GCD;
        if(b<0)a=-a,b=-b;//180
        if(a<=0)cnt[{b,-a}].second++;//90
        else cnt[{a,b}].first++;
    }
    for(auto it:cnt){
        ll t=(mod+f(it.second.first)+f(it.second.second)-1)%mod;
        (sum*=t)%=mod;
    }
    cout<<(sum+sum0+mod-1)%mod<<endl;
}

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

Measured memory_bytes: 16008
#include<iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	if (B == 1) {
		
	}
	else {
		for (int i = 1; i < 100; i++) {
			if (i * A - i + 1 >= B) {
				ans = i;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;

int main(){
    TIME
    int n;
    cin >> n;
    for(int i = 1 ,x ; i <= n ; i ++){
        cin >> x;
        if(x % 2 == 0){
            if(x % 3 == 0 || x % 5 == 0){

            }
            else{
                cout << "DENIED\n";
                r_0;
            }
        }
    }
    cout << "APPROVED";
}
///...


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

char cons[] = "  kstnhmyr";

int main()
{
	char str[1024];
	
	scanf("%s", str);
	
	int i = 0;
	while (str[i] != '\0'){
		if (str[i] >= '2' && str[i] <= '9'){
			printf("%c", cons[str[i] - '0']);
		}
		if (str[i] >= '1' && str[i] <= '9'){
			switch (str[i + 1]){
				case 'T':
				printf("a");
				break;
				
				case 'L':
				printf("i");
				break;
				
				case 'U':
				printf("u");
				break;
				
				case 'R':
				printf("e");
				break;
				
				case 'D':
				printf("o");
				break;
			}
		}
		else {
			if (str[i + 1] == 'T'){
				printf("wa");
			}
			else if (str[i + 1] == 'U'){
				printf("nn");
			}
			else {
				printf("wo");
			}
		}
		
		i += 2;
	}
	
	puts("");
	
	return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    string x;
    int n;
    int k;
    cin >> k;
    cin >> x;
    n = x.length();
    if(n <= k)cout << x;
    else{
        ff(i,0,k - 1)cout << x[i];
        cout << "...";
    }
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if (a == b)
                c = "Yes";
            else
                c = "No";
            Console.WriteLine(c);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long

using namespace std;

const int N = 5005;

int n, dp[N][N];

pair <int,int> ar[N];

bool cmp (pair <int ,int> a, pair <int ,int> b)
{
    return a.fr + a.sc < b.fr + b.sc;
}

main ()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &ar[i].fr, &ar[i].sc);

    sort(ar + 1, ar + n + 1, cmp);

    memset(dp, 0x3f3f3f3f, sizeof(dp));

    dp[0][0] = 0;

    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = 0;
        for (int j = 1; j <= n; j++)
        {
            dp[i][j] = dp[i - 1][j];

            if (dp[i - 1][j - 1] <= ar[i].fr)
                dp[i][j] = min( dp[i][j], dp[i - 1][j - 1] + ar[i].sc );
        }
    }
    int ans;

    for (int i = n; i >= 1; i--)
        if ( dp[n][i] != dp[N - 1][N - 1] )
        {
            ans = i;
            break;
        }
    cout << ans;
}


Measured memory_bytes: 196096
// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;

class Restr
{
    public int Id;
    public String Name;
    public int Score;
}

class GFG
{

    public static void Main()
    {
        var input = Console.ReadLine().Split(' ');

        var n = int.Parse(input[0]);
        List<Restr> lst = new List<Restr>();
        for (int i = 0; i < n; i++)
        {
            var input2 = Console.ReadLine().Split(' ');
            var Name = (input2[0]).ToString();
            var Score = int.Parse(input2[1]);

            Restr c = new Restr();
            c.Id = i + 1;
            c.Name = Name;
            c.Score = Score;

            lst.Add(c);
        }

        GuidBook(n, lst);


    }

    public static void GuidBook(int n, List<Restr> lst)
    {


        var ll = lst.GroupBy(x => x.Name).Select(x => x).OrderBy(x => x.Key);

        foreach (var nn in ll)
        {
            foreach (var ans in nn.ToList().OrderByDescending(x => x.Score))
            {
                Console.Write(ans.Id);
                Console.WriteLine();
            }
        }


    }
}


Measured memory_bytes: 13920
def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    mod = 10**9+7
    s = 0
    sq = 0
    for i in range(n):
        s += a[i]
        sq += (a[i])**2

    print(((s**2-sq)//2)%mod)

resolve()

Measured memory_bytes: 105168
n,m=gets.split.map(&:to_i)

from1=[]
toN=[]
m.times{
  a,b=gets.split.map(&:to_i)
  from1[b] = true if a==1
  toN[a] = true if b==n
}

puts (2..n-1).any?{|i|from1[i]&&toN[i]}?"POSSIBLE":"IMPOSSIBLE"


Measured memory_bytes: 4860
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;
int main()
{
  long long n;
  string str;
  unordered_map<string, bool> kuji;

  cin >> n;
  for (long long i = 0; i < n; i++)
  {
    cin >> str;
    kuji[str] = true;
  }

  cout << kuji.size() << endl;
  return 0;
}


Measured memory_bytes: 17792
using System;

class A{
	public static void Main(){

		int input = int.Parse (Console.ReadLine ());
		string[] s = Console.ReadLine ().Split (' ');

		for (int i = input; i!=0; i--) {
			Console.Write (s [i-1]);
			if (i-1 == 0) {
				Console.WriteLine ();
			} else {
				Console.Write (" ");
			}
		}
	}
}

Measured memory_bytes: 8940
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <string>
#define MAX_U   10
#define MIN_U   0
using namespace std;
void printa(){cout<<endl;}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int main(void){
    int a,b,c,k;
    cin >>a>>b>>c>>k;
    if(a>50||b>50||c>50||k>10||a<1||b<1||c<1||k<1){
        exit(0);
    }
    if(a>b&&a>c||a>b&&a==c||a==b&&a>c){
        for(int i=0;i<k;i++){
            a=a*2;
        }
        printa(a+b+c);
        exit(0);
    }
    else if(b>a&&b>c||b>a&&b==c||b==a&&b>c){
        for(int i=0;i<k;i++){
            b=b*2;
        }
        printa(a+b+c);
        exit(0);
    }
    else if(c>a&&c>b||c>a&&c==b||c==a&&c>b){
        for(int i=0;i<k;i++){
            c=c*2;
        }
        printa(a+b+c);
        exit(0);
    }
    else if(a==b||a==c){
        for(int i=0;i<k;i++){
            a=a*2;
        }
        printa(a+b+c);
        exit(0);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  map<char,int> mp;
  string s; cin >>s;
  rep(i,4) mp[s[i]]++;
  print(mp['+']-mp['-']);
}


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

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let n = read1::<usize>();
    let p = readn::<usize>(" ");

    let mut r = vec![0; n+1];
    for i in 1..n+1 {
        r[p[i-1]] = i;
    }

    let mut a = "".to_string();
    let mut b = "".to_string();
    for i in 1..n+1 {
        a = a + &((30000 * i).to_string()) + " ";
        b = b + &((30000 * (n - i) + r[i]).to_string()) + " ";
    }

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

Measured memory_bytes: 4732
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] l = new Integer[n];
        for(int i=0; i<n; i++) {
            l[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(l,Comparator.reverseOrder());

        int cnt = 0;
        for(int i=0; i<n-2; i++) {
            for(int j=i+1; j<n-1; j++) {
                for(int k=j+1; k<n; k++) {
                    if(l[k]>l[i]-l[j]) cnt++;
                    else break;
                }
            }
        }
        System.out.println(cnt);
    }
}

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

int main(){
  vector<int> sq(128);
  int i,j,k;
  for(i=0;i<128;i++){
    sq.at(i)=i*i;
  }
  
  int n,d;
  cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d,0));
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      cin >> x.at(i).at(j);
    }
  }
  
  int s=0,dis2;
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      dis2=0;
      for(k=0;k<d;k++){
        dis2 += (x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
      }
      for(k=0;k<128;k++){
        if(dis2==sq.at(k)){
          s++;
        }
      }
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
struct Edge{
  int s;
  int t;
  int l;
};
struct Node{
  int no;
  int num;
  int c;
  vector<Edge> edge;
  void calc(int i){
    no=i;
    num=edge.size();
  }
};
bool cn(Node a,Node b){
  return a.num<b.num;
}
signed main(){
  int n;cin>>n;
  vector<Node> node(n+1);
  vector<int> c(n);
  rep(i,n-1){
    int a,b;
    Edge buf;cin>>a>>b;
    buf.s=a;buf.t=b;
    node[a].edge.push_back(buf);
    buf.s=b;buf.t=a;
    node[b].edge.push_back(buf);
  }
  rep(i,n)cin>>c[i];
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  /*rep(i,n){
    cout<<c[i]<<"\t";
  }
  cout<<endl;
  */
  int s=0;
  int max=0;int max_index=0;
  rep1(i,n){
    node[i].calc(i);
    if(node[i].num>max){
      max_index=i;
      max=node[i].num;
    }
  }
  queue<int> que;
  que.push(max_index);
  vector<bool> memo(n+1,true);
  node[max_index].c=c[0];
  memo[max_index]=false;
  s=1;
  int res=0;
  //cout<<"max_index = "<<max_index<<endl;;
  while(!que.empty()){
    int buf=que.front();
    que.pop();
    //memo[buf]=false;
    rep(i,node[buf].num){
      if(memo[node[buf].edge[i].t]){
        que.push(node[buf].edge[i].t);
        node[node[buf].edge[i].t].c=c[s];
        memo[node[buf].edge[i].t]=false;
        res+=c[s];
        //cout<<"res+= "<<c[s]<<endl;
        s++;
      }
    }
  }
  cout<<res<<endl;
  rep1(i,n){
    cout<<node[i].c<<endl;
  }
  return 0;
}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int N; cin >> N;

    bool f = false;
    for (int d = 0; d <= N/7; d++) {
        if ((N -7 * d) % 4 == 0) {
            f = true;
            break;
        }
    }

    Yes(f);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {

	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int count=0;
		for(int i=0;i<line.length();i++){
			char ch = line.charAt(i);
			if(ch=='1'){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 19924
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int main()
{
	fast;
	ll t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		if(n == 0)
			cout<<1;
		else
			cout<<0;
	}
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//b1/2+b2/2=a1
//b2/2+b3/2=a2
//b3/2+b1/2=a3

//b1+b2=2*a1..1
//b2+b3=2*a2..2
//b3+b1=2*a3..3

//1+2-3
//2*b2=2(a1+a2-a3)
//b2=a1+a2-a3

//b1+b2=2*a1..1
//b2+b3=2*a2..2
//b3+b4=2*a3..3
//b4+b1=2*a4..4
//1+2-3+4
//1223,122-4,1122
//b1+b2=a1+a2-a3+a4=2*a1
//1-2+3-4
//0
//1個特定できれば楽っぽいんだけど。楽に特定できんかな
//1122は作れる
//12=a1*2
//1122=2(a1+a2-a3+a4-...)
//b2=2*a1/b1
//元通りですわ
//1234たして2341ひいたら0ですわそりゃ。
//ああああ山は奇数個。偶数個だとむずいけど奇数個ならすぐでるわ
//b1+b2=2*a1..1
//b2+b3=2*a2..2
//b3+b4=2*a3..3
//b4+b5=2*a4..4
//b5+b1=2*a5..5
//1+3+5=123451
//2+4=2345
//b1*2がでる
int main(){
  ll N; cin>>N;
  vector<ll> A(N,0), B(N,0);
  ll odd=0, even=0;
  for(int i=0; i<N; i++){
    ll a; cin>>a; A[i]=a;
    if(i%2==0) even+=a;
    else odd+=a;
  }
  ll b=even-odd;
  cout<<b<<" ";
  for(int i=0; i<N-1; i++){
    ll ans=A[i]*2-b;
    cout<<ans;
    if(i<N-2)
      cout<<" ";
    b=ans;
  }
}

Measured memory_bytes: 2944
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }

        long[] dp = new long[n * n];
        for (int i=0; i<n; i++) {
            dp[i * n + i] = a[i]; 
        }

        for (int i = n - 2; i > -1; i--) {
            for (int j = i + 1; j < n; j++) {
                dp[i * n + j] = Math.max(a[i] - dp[(i + 1) * n + j], a[j] - dp[i * n + (j - 1)]);
            }
        }
        System.out.println(dp[n - 1]);
    }
}

Measured memory_bytes: 98424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 100010
int main(){
    int n,sum=0; ll ans=0;
    cin>>n;
    int x[n];
    for(int i=0;i<n;i++){cin>>x[i];sum+=x[i];ans+=x[i]*x[i];}
    int tar=sum/n;
    ll tmp=n*tar*tar-2*tar*sum;
    tar++;
    ll tmp2=n*tar*tar-2*tar*sum;
    ans+=min(tmp,tmp2);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int t, n, i;
	int s, f;
	
	while (scanf("%d", &t), t){
		scanf("%d", &n);
		for (i = 0; i < n; i++){
			scanf("%d %d", &s, &f);
			t -= (f - s);
		}
		if (t > 0){
			printf("%d", t);
		}
		else {
			printf("OK");
		}
		printf("\n");
	}
	return (0);
}

Measured memory_bytes: 604
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			while(true)
			{
				string s = Console.ReadLine();
				string[] sar = s.Split(' ');
				int a = int.Parse(sar[0]);
				int b = int.Parse(sar[2]);
				switch (sar[1])
				{
					case "+":
						Console.WriteLine(a + b);
						break;
					case "-":
						Console.WriteLine(a - b);
						break;
					case "*":
						Console.WriteLine(a * b);
						break;
					case "/":
						Console.WriteLine(a / b);
						break;
					default:
						goto fin;
				}
			}
		fin:
			return;
		}
	}
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a, b;
	cin >> a;
	cin >> b;
	if(a == 1){
		if(b == 2) cout << 3;
		else cout << 2;
	}
	if(a == 2){
		if(b == 1) cout << 3;
		else cout << 1;
	}
	if(a == 3){
		if(b == 1) cout << 2;
		else cout << 1;
	}

	return 0;
}



Measured memory_bytes: 256
/// Coded by Dhiman Sarker Bappi (Dhimanda) - RMSTU
#include<bits/stdc++.h>
using namespace std;
#define    ll          long long
void dhimanda();
int main()
{
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a) cout << k <<endl;
    else{
        if(a+b>=k) cout <<a <<endl;
        else{
            ll r = k - (a+b);
            if(r <= c) {
                cout << a - r<<endl;
            }
            else{
                cout << 0 <<endl;
            }

        }
    }
    return 0;
}

// Contact : chessdhiman@gmail.com


Measured memory_bytes: 3636
N, M, K = map(int, input().split())
L = []
R = []
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
P = []
Q = []
for i in range(K):
    p, q = map(int, input().split())
    P.append(p)
    Q.append(q)

def build_table(L, R):
    s = [[0] * (N+1) for i in range(N+1)]
    for i in range(M):
        s[L[i]][R[i]] += 1
    for i in range(N):
        for j in range(N):
            s[i+1][j+1] += s[i+1][j]
            s[i+1][j+1] += s[i][j+1]
            s[i+1][j+1] -= s[i][j]
    return s

s = build_table(L, R)
for i in range(K):
    p, q = P[i], Q[i]
    ans = s[q][q] - s[q][p-1] - s[p-1][q] + s[p-1][p-1]
    print(ans)

Measured memory_bytes: 99800
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;

int main(){
  int m,d;
  cin>>m>>d;

  int res=0;
  for(int i=1;i<=m;i++){

    for(int j=1;j<=d;j++){
      if(j%10<=1) continue;
      if((j/10)%10<=1) continue;
      if((j%10)*((j/10)%10)==i) res++;
    }
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum_func(vector<int> a){
  int sum = 0;
  for (int i = 0; i < a.size();i++){
    sum += a[i];
  }
  return sum;
}
int main(){
  int n, m;
  while(1){
    cin >> n >> m;
    if(n==0&&m==0){
      break;
    }
    vector<int> a(n), b(m);
    int sum = 0;
    for (int i = 0; i < n;i++){
      cin >> a[i];
      sum += a[i];
    }
    for (int i = 0; i < m;i++){
      cin >> b[i];
      sum += b[i];
    }
    if(sum%2!=0){
      cout << -1 << endl;
      continue;
    }
    int suma, sumb, cent=sum/2;
    suma = sum_func(a);
    int min_p = 1e9;
    int tmpa=-1, tmpb=-1;
    for (int i = 0; i < n;i++){
      for (int j = 0; j < m;j++){
        if(abs(suma-a[i])+b[j]==cent){
          if(a[i]+b[j]<min_p){
            min_p = a[i] + b[j];
            tmpa = a[i];
            tmpb = b[j];
          }
        }
      }
    }
    if(tmpa==-1&&tmpb==-1){
      cout << -1 << endl;
    }else{
      cout << tmpa << " " << tmpb << endl;
    }
  }
  return 0;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  if(N==3){
    cout << "2 5 63" << endl;
    return 0;
  }else if(N==4){
    cout << "2 5 20 63" << endl;
    return 0;
  }
  int a,b;
  if(N%2==1){
    a = min((N/4-1)*4+3,9999);
    b = N - a;
  }else{
    a = min((N-1)/4*4,10000);
    b = N - a;
  }
  REP(i,1,a+1) cout << 3*i << " ";
  int cnt = 0, x = 2;
  while(true){
    if(x%3==0){
      x += 2; continue;
    }else{
      cout << x << (cnt != b-1 ? " ": "") ;
      if(cnt == b-1) break;
      else cnt++;
      x += 2;
    }
  }
  return 0;
}


Measured memory_bytes: 384