akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define pb push_back
#define nl cout << "\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c.size())
#define mp make_pair
#define mt make_tuple
#define get(x,c) get<x>(c)
#define trav(a,x) for(auto a=x.begin() ; a!=x.end() ; a++)
#define rep(i,n) for(int i=0 ; i<n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x,ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x,ll ex ,ll md) {ll ans = 1ll;while(ex > 0){if(ex & 1ll) ans = (ans*x)%md; ex >>= 1ll;x=(x*x)%md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e5 + 11;
ll n ;
string x;
ll count_one(string &x){
    ll ct = 0;
    rep(i,sz(x)) ct += (x[i]=='1');
    return ct;
}
ll convert(string &x , ll mod){
    if(mod == 0) return 0;
    ll ans = 0;
    rep(i,sz(x)){
        if(x[i] =='1'){
            ans += powermod(2,sz(x)-1-i,mod);
            ans %= mod;
        }
    }
    return ans;
}
ll val(ll index,ll pres , ll mod){
    if(mod == 0) return 0;
    if(x[index] == '1'){
        pres -= powermod(2,sz(x)-index-1,mod);
        pres=(pres+mod)%mod;
    }
    else{
        pres += powermod(2,sz(x)-index-1,mod);
        pres %= mod;
    }
    return (pres+mod)%mod;
}
void solve(){
    cin >> n >> x;
    ll one = count_one(x);
    // cout << x << " : " << one << endl; return;
    ll val_inc = convert(x,one+1);
    ll val_dec = convert(x,one-1);
    // cout << one <<" " << val_inc << " " << val_dec << endl;
    // return;
    rep(i,sz(x)){
        ll op = 1;
        if(x[i]=='1'){
            if(one-1 == 0){
                cout << 0<<endl;
                continue;
            }
            ll num = val(i,val_dec,one-1);
            // cout << i <<" : " << num << endl;
            while(num){
                op++;
                num %= (__builtin_popcountll(num));
            }
        }
        else{
            ll num = val(i,val_inc,one+1);
            // cout << i <<" : " << num << endl;
            while(num){
                op++;
                num %= (__builtin_popcountll(num));
            }
        }
        cout << op << endl;
    }
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC = 1;
    // cin >> NTC;
    ll PTC = 0;
    while(PTC++ < NTC){
        // cout << "Case #" << PTC << ":" << ' ';
        solve();
        cout << "\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
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...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main(){
	IOS();
	vector<int>ans;
	while(1){
		int N,M;
		cin>>N>>M;
		if(!N&&!M)break;
		vector<int>v[M];
		rep(i,0,N){
			int D,V;
			cin>>D>>V;
			D--;
			v[D].push_back(V);
		}
		rep(i,0,M)sort(all(v[i]),greater<>());
		int sum = 0;
		rep(i,0,M)sum+=v[i][0];
		ans.push_back(sum);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 3180
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_ = 0
rest = 0

for i in range(n):
  if a[i] >= b[i] + rest:
    sum_ += b[i] + rest
    rest = 0
  elif a[i] >= rest:
    sum_ += a[i]
    rest = b[i] - (a[i]- rest)
  else:
    sum_ += a[i]
    rest = b[i]

sum_ += min(a[n], rest)
print(sum_)

Measured memory_bytes: 18624
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        int n = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        out.println(n >= 10 ? r : 100*(10-n)+r);

        out.flush();
    }
}

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int n, h;
    cin >> n >> h;
    vector<pair<int, int>> ab(n);
    cin >> ab;
    auto it = max_element(ab.begin(), ab.end());
    auto max_ab = *it;
    ab.erase(it);
    sort(ab.begin(), ab.end(), [](const auto& a, const auto& b) {
        return a.second > b.second;
    });
    TRACE(max_ab, ab);
    int ans = 0;
    for (const auto& p : ab) {
        if (h <= max_ab.second || p.second < max_ab.first) break;
        h -= p.second;
        ans++;
    }
    if (h > 0) {
        if (h <= max_ab.second) ans++;
        else ans += (h - max_ab.second + max_ab.first - 1) / max_ab.first + 1;
    }
    cout << ans << '\n';
}


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

using namespace std;

int main() {
  long long a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if (a[0] & 1 and a[1] & 1 and a[2] & 1) {
    cout << a[0] * a[1] << endl;
  } else {
  	cout << "0\n";
  }
  return 0;
}



Measured memory_bytes: 3600
import java.util.Scanner;

/**
 * https://abc064.contest.atcoder.jp/tasks/abc064_d
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();
		
		int current = 0;
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<N; i++){
			String c = Character.toString(s[i]);
			if(c.equals("(")){
				current++;
				sb.append(c);
			}else{
				if(current>0){
					sb.append(c);
					current--;
				}else{
					sb = new StringBuilder("("+ sb.toString()+")");
				}
			}
		}
		for(int i=0; i<current; i++){
			sb.append(")");
		}
		
		System.out.println(sb);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    vector<vector<vector<int> > > dp(11, vector<vector<int> >(11, vector<int>(11,0)));

    for(int n=0; n<N; n++){
        int x=S[n]-'0';
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                dp[i][j][x]=dp[i][j][10];
            }
            dp[i][x][10]=dp[i][10][10];
        }
        dp[x][10][10]=1;
    }
    int ans=0;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            for(int k=0; k<10; k++){
                ans+=dp[i][j][k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
  cin >> a >> b;
	if(a>0){
		cout << "Positive" << endl;
	}
	else if(b<0){
		if((b-a+1)%2==0){
			cout << "Positive" << endl;
		}else if((b-a+1)%2==1){
			cout << "Negative" << endl;
		}
	}
	else if(a<=0&&b>=0){
		cout << "Zero" << endl;
	}
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  array<int, 3> vars;
  cin >> n >> vars[0] >> vars[1] >> vars[2];
  vector<pair<int, int>> vp(n);
  for (auto &p : vp) {
    string s;
    cin >> s;
    p.first = s[0] - 'A';
    p.second = s[1] - 'A';
  }

  vector<char> ans;
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    auto &p = vp[i];

    // 両方0
    if (!vars[p.first] && !vars[p.second]) {
      ok = false;
      break;
    }

    // 片方のみ0
    if (!vars[p.first] || !vars[p.second]) {
      if (vars[p.first]) {
        vars[p.first]--;
        vars[p.second]++;
        ans.push_back('A' + p.second);
      } else {
        vars[p.first]++;
        vars[p.second]--;
        ans.push_back('A' + p.first);
      }

      continue;
    }

    // 両方1
    if (vars[p.first] == 1 && vars[p.second] == 1) {
      if (i == n - 1 || p == vp[i + 1]) {
        vars[p.first]++;
        vars[p.second]--;
        ans.push_back('A' + p.first);
      } else {
        auto &p_next = vp[i + 1];
        if (p_next.first == p.first || p_next.second == p.first) {
          vars[p.first]++;
          vars[p.second]--;
          ans.push_back('A' + p.first);
        } else {
          vars[p.first]--;
          vars[p.second]++;
          ans.push_back('A' + p.second);
        }
      }

      continue;
    }

    if (vars[p.first] < vars[p.second]) {
      vars[p.first]++;
      vars[p.second]--;
      ans.push_back('A' + p.first);
    } else {
      vars[p.first]--;
      vars[p.second]++;
      ans.push_back('A' + p.second);
    }
  }

  if (!ok) {
    cout << "No" << '\n';
    return 0;
  }

  cout << "Yes" << '\n';
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    string s, t;
    cin >> s >> t;

    NREP() {
        cout << s[i] << t[i];
    }
    cout << endl;
}


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

using namespace std;

int main() {
	int n;
	int k[100];
	int kari;
	int counter;

	while(cin >> n) {
		if (n == 0) {
			break;
		}
		counter = 0;
		for (int i = 0; i < n; i++) {
			cin >> k[i];
		}

		for (int i = n-1; i > 0; i--) {
			for (int j = 0; j< i; j++) {
				if (k[j] > k[j+1]) {
					kari = k[j];
					k[j] = k[j+1];
					k[j+1] = kari;
					counter++;
				}
			}
		}

		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4;
	int n;
	
	scanf("%d",&n);
	
	for(;n>0;n--){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		
		if(x2==x1){
			if(x3==x4){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
			continue;
		}
		
		if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	while( true ) {
		cin >> n;
		if(n == 0) {
			break;
		}

		vector<int> a(n), b(n), c(n);

		for(int i = 0; i < n; i++) {
			cin >> a[i] >> b[i] >> c[i];
		}

		vector< vector< int > > map(10, vector< int >(10, INT_MAX / 4));

		for(int i = 0; i < n; i++) {
			map[a[i]][b[i]] = c[i];
			map[b[i]][a[i]] = c[i];
		}
		for(int i = 0; i < 10; i++) {
			map[i][i] = 0;
		}

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

		int total[10];

		for(int i = 0; i < 10; i++) {
			total[i] = 0;
		}

		int min_cost = INT_MAX / 2, town;

		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++) {
				if(map[i][j] >= INT_MAX / 4) {
					continue;
				}
				total[i] += map[i][j];
			}
		}

		for(int i = 0; i < 10; i++) {
			if(total[i] == 0) {
				continue;
			}
			if(min_cost > total[i]) {
				min_cost = total[i];
				town = i;
			}
		}

		cout << town << " " << total[town] << endl;
	}
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int d = int.Parse(Console.ReadLine());
            int[] p = new int[d];
            for (int i = 0; i < d; i++)
            {
                p[i] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine(p.Sum() - p.Max() / 2);
        }
    }
}


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


string rot(string x) {
  x.insert(x.begin(), x[x.size() - 1]);
  x.pop_back();
  return x;
}

int main() {
  string s, t;
  cin >> s >> t;
  rep(i, s.size()) {
    s = rot(s);
    if (s == t) {
      puts("Yes");
      return 0;
    } 
  }
  puts("No");
  return 0;
}

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

int main(){
  int max = 0, a[100000], b, n, x = -1e9 - 5, x2 = 1e9 + 5;
  cin >> n;

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

  sort(a, a+n, greater<int>());

  for(int i=1; i<n; ++i){
    if(a[0] - (a[i] - 1) >= a[i]){
      //単調増加
      x = (x >= a[i] ? x : a[i]);
    }else{
      x2 = (x2 <= a[i] ? x2 : a[i]);
    }
  }

  x = (abs(x - a[0]/2) > abs(x2 - a[0]/2) ? x2 : x);

  cout << a[0] << " " << x << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define int long long
#define ll long long
#define mod 998244353
//#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 
bool cmp(char ch,char c)
{
    return ch>c;
}
using namespace std;

int32_t main()
{
   //

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
     //cin>>t;
    while(t--)
        {
           int n,flag=0;
           cin>>n;
           vector<int> a(n+1);
           loop(i,0,n){
               cin>>a[i];
               if(a[i]%2==0 && (a[i]%5!=0)&&(a[i]%3!=0))
               flag=1;
           }
           if(flag==0)
           cout<<"APPROVED"<<endl;
           else cout<<"DENIED"<<endl;
        }
    return 0;
}



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



int main() {
  int A,B;
  cin >> A>>B;
  
  int r = 0;
  for(int i=A;i<B+1;i++){
    int temp=i;
    int one = temp%10; temp/=10;
    int ten = temp%10; temp/=100;
    int thu = temp%10; temp/=10;
    int tth = temp%10;
    if(tth==one && ten==thu){ 
      r++;
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		System.out.println(a <= x && a + b >= x ? "YES" : "NO");
	}
}


Measured memory_bytes: 35668
n = int(input())
a = list(map(int, input().split()))
cums = [0]
for i in a:
    cums.append(cums[-1] + i)

ans = float('inf')
for i in range(1, n):
    l = cums[i]
    r = cums[-1] - cums[i]
    ans = min(ans, abs(l-r))
print(ans)

Measured memory_bytes: 24832
n = int(input())
A = list(map(int, input().split()))

from itertools import accumulate
B = [0] + A
B = list(accumulate(B))

INF = 10**18
dp = [[INF]*(n+1) for i in range(n+1)]
# dp[i][j]: 区間[i, j)のスライムを取り除いたコストの最小値
for i in range(n):
    dp[i][i+1] = 0
# 区間の幅(d)が狭い方から更新していく(d: 2, 3, ...n+1)
# d = 0, 1については初期化で更新した
for d in range(2, n+1):
    for i in range(n+1-d):
        j = i + d
        for k in range(i+1, j):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]+B[j]-B[i])
#print(dp)
print(dp[0][n])

Measured memory_bytes: 42860
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,child,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
//}}}

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

  int a;
  cin >> a;
  int ans = a;
  rep(i, N - 1){
    cin >> a;
    ans = gcd(a, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	   int chai(int a);
	   int a,b,n,i;
	   scanf("%d%d%d",&n,&a,&b);
	   int sum=0;
	   for(i=1;i<=n;i++)
	   {
	   	if(chai(i)<=b&&chai(i)>=a)
	   	{
	   		sum+=i;
		}
	   }
	   printf("%d\n",sum);
}
int chai(int a)
{
	int g,s,b,q,w;
	if(a>=10000&&a<=99999)
	{
		w=(a/10000)%10;
		q=(a/1000)%10;
		b=(a/100)%10;
		s=(a/10)%10;
		g=a%10;
		return(w+q+b+s+g);
	}
	if(a>=1000&&a<=9999)
	{
		q=(a/1000)%10;
		b=(a/100)%10;
		s=(a/10)%10;
		g=a%10;
		return(q+b+s+g);
	}
	if(a>=100&&a<=999)
	{
		b=(a/100)%10;
		s=(a/10)%10;
		g=a%10;
		return(b+s+g);
	}
	if(a>=10&&a<=99)
	{
		s=(a/10)%10;
		g=a%10;
		return (s+g);
	}
	else
    return (a);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz size()
#define FORN(i,j,n) for(int i=j; i<(int)n;i++) 
#define FOR(i,n) FORN(i,0,n)
#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )
#define MOD 998244353LL
#define LIM 262150
#define ones(x) __builtin_popcount(x)
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
using namespace std;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;
ll n;
ll dp[100005];
ll arr[100005];
int main() {
	fastio;
	cin>> n;
	FOR(i,n) cin>> arr[i];
	dp[0] = 0;
	FORN(i,1,n){
		dp[i] = 1e12;
	}
	FOR(i,n){
		dp[i+1] = min(dp[i]+abs(arr[i+1]-arr[i]),dp[i+1]);
		dp[i+2] = min(dp[i]+abs(arr[i+2]-arr[i]),dp[i+2]);
	}
	cout<< dp[n-1] << "\n";
	return 0;
}

Measured memory_bytes: 5136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2005,mod=1000000007;
int n,m,k,nxt[N],dp[N],ans;
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
signed main(){
	n=read(); m=read(); k=read(); swap(n,m);
	int jb=k-1;
	nxt[n+1]=n+1;
	for(int i=n;i>=0;i--)nxt[i]=i+((n-i)%jb==0?jb:(n-i)%jb);
	dp[0]=1; 
	for(int i=0;i<(n+m-1)/(k-1);i++){
		int meiju=min(n,i*(k-1)),mmm=min(n,(i+1)*(k-1));
		for(int j=1;j<=meiju;j++)add(dp[j],dp[j-1]);
		for(int j=meiju;j>=0;j--){
			if(j+k<=mmm)add(dp[j+k],mod-dp[j]);
			if(nxt[j]<=n&&(i+1)*jb-nxt[j]<m)ans=(ans+dp[j])%mod;
			//cout<<dp[j]<<" "<<i<<" "<<j<<" "<<(i+1)*jb-(j+(n-j)%jb)<<endl;
		}
	}
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define MAX_N 100
using namespace std;

int n;
double a[MAX_N];

void solve()
{
    double res = 0;
    for (int i = 0; i < n; i++)
    {
        res += 1 / a[i];
    }

    res = 1 / res;

    cout << setprecision(16) << res << endl;
}

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

    solve();
}


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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll R_MAX = 2;

ll L, R;

void input() {
	scanf("%lld%lld", &L, &R);
}
//3 673
void solve() {
	ll ans = 0;
	ll j=0;
	vector<ll> a;
	bool is673=false;
	bool is3=false;

	if(R-L+1>=2019){
		p(0);return;
	}
	ll minval=INF*2;
	for(ll i=L;i<R;i++){
		for(ll j=L+1;j<=R;j++){
			ll t=((i%2019)*(j%2019))%2019;
			chmin(minval,t);
		}
	}

	printf("%lld\n", minval);
}

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


Measured memory_bytes: 256
#include <iostream>

int main(){
    int a,b;
    std::cin >> a >> b;
    if(a>=13){
        std::cout << b << std::endl;
    } else if(a>=6){
        std::cout << b/2 << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

int main() {
    int n, d;
    cin >> n >> d;
    int s = 2 * d + 1;
    int ans = n / s;
    if (n % s != 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	char s[100000] = {}, d[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	int i, c[26] = {};

	scanf("%s", &s[0]);

	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] == 'a') {
			c[0]++;
		}
		if (s[i] == 'b') {
			c[1]++;
		}
		if (s[i] == 'c') {
			c[2]++;
		}
		if (s[i] == 'd') {
			c[3]++;
		}
		if (s[i] == 'e') {
			c[4]++;
		}
		if (s[i] == 'f') {
			c[5]++;
		}
		if (s[i] == 'g') {
			c[6]++;
		}
		if (s[i] == 'h') {
			c[7]++;
		}
		if (s[i] == 'i') {
			c[8]++;
		}
		if (s[i] == 'j') {
			c[9]++;
		}
		if (s[i] == 'k') {
			c[10]++;
		}
		if (s[i] == 'l') {
			c[11]++;
		}
		if (s[i] == 'm') {
			c[12]++;
		}
		if (s[i] == 'n') {
			c[13]++;
		}
		if (s[i] == 'o') {
			c[14]++;
		}
		if (s[i] == 'p') {
			c[15]++;
		}
		if (s[i] == 'q') {
			c[16]++;
		}
		if (s[i] == 'r') {
			c[17]++;
		}
		if (s[i] == 's') {
			c[18]++;
		}
		if (s[i] == 't') {
			c[19]++;
		}
		if (s[i] == 'u') {
			c[20]++;
		}
		if (s[i] == 'v') {
			c[21]++;
		}
		if (s[i] == 'w') {
			c[22]++;
		}
		if (s[i] == 'x') {
			c[23]++;
		}
		if (s[i] == 'y') {
			c[24]++;
		}
		if (s[i] == 'z') {
			c[25]++;
		}
	}

	for (i = 0; i <= 26; i++) {
		if (i == 26) {
			printf("None\n");
			break;
		}
		if (c[i] == 0) {
			printf("%c\n", d[i]);
			break;
		}
	}

	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int n; cin >> n;
    vi a(n+1); REP1(i, n) cin >> a[i];
    vi odd(100001), even(100001);
    REP1(i, n)
    {
        if(i % 2 == 1) odd[a[i]]++;
        else even[a[i]]++;
    }
    vi::iterator itr1, itr2;
    itr1 = max_element(ALL(odd));
    itr2 = max_element(ALL(even));
    int ans = INF;
    if(distance(odd.begin(), itr1) != distance(even.begin(), itr2))
    {
        ans = n - (*itr1 + *itr2);
    }
    else
    {
        int m1 = 0, m2 = 0, d1 = distance(odd.begin(), itr1), d2 = distance(even.begin(), itr2);
        REP1(i, n)
        {
            if(m1 < odd[i] && i != d1) m1 = odd[i];
            if(m2 < even[i] && i != d2) m2 = even[i];
        }

        ans = min(n-(m1+*itr2), n-(*itr1+m2));
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define ll long long
const int maxm=2e6+5;
int n,x;
int cal(int a,int b){
    if(!a)return 0;
    int ans=0;
    ans+=cal(b%a,a);
    ans+=b/a*2*a;
    return ans;
}
signed main(){
    cin>>n>>x;
    int a=x,b=n-x;
    if(a>b)swap(a,b);
    int ans=cal(a,b)+n;//外面两条边的长度=x+(n-x)=n
    ans-=__gcd(n,x);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll gcd(ll a, ll b) // gcd(a,b) これはいる
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll MODadd(ll a, ll b) // (a+b) % MOD これいる？
{
    return (a + b) % MOD;
}

ll MODsub(ll a, ll b) // (a-b) % MOD これいる？
{
    return (a - b + MOD) % MOD;
}

ll MODexp(ll a, ll b) // a^b % MOD これはいる
{
    if (b == 0)
    {
        return 1;
    }
    else if (b % 2 == 0)
    {
        return (MODexp(a, b / 2) * MODexp(a, b / 2)) % MOD;
    }
    else if (b % 2 == 1)
    {
        return (a * MODexp(a, b - 1)) % MOD;
    }
}

int main()
{
    ll N;
    cin >> N;
    map<Pll, Pll> mp;
    vector<Pll> mp1;
    ll a, b;
    // a,bが共に0なものは全てのイワシと仲が悪いので別で考える
    ll zero = 0;
    rep(0, i, N)
    {
        cin >> a >> b;

        // a,bに0が存在する場合はここで処理
        if (a == 0 && b == 0)
        {
            zero++;
        }
        else if (a == 0)
        {
            mp[make_pair(1, 0)].first += 1;
        }
        else if (b == 0)
        {
            mp[make_pair(1, 0)].second += 1;
        }
        else
        {
            // I=A/Bを既約分数で管理する
            ll g = gcd(a, b);
            a /= g;
            b /= g;

            // aは必ず正の値にして管理すると楽
            if (a < 0)
            {
                a *= -1;
                b *= -1;
            }
            mp1.push_back(make_pair(a, b));
            if (b > 0)
            {
                mp[make_pair(a, b)].first += 1;
            }
            else
            {
                mp[make_pair(-b, a)].second += 1;
            }
        }
    }

    ll ans = 1;

    for (auto p : mp)
    {
        ll res = (MODexp(2, p.second.first) + MODexp(2, p.second.second) - 1 + MOD) % MOD;
        ans *= res;
        ans %= MOD;
    }
    ans = (ans + zero - 1 + MOD) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 21968
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		Set<Integer> S=new HashSet<>();
		int q=Integer.parseInt(in.next());
		for(int i=0;i<q;i++) {
			int odr=Integer.parseInt(in.next());
			if(odr==0) {
				int x=Integer.parseInt(in.next());
				S.add(x);
				out.println(S.size());
			}
			else if(odr==1){
				int x=Integer.parseInt(in.next());
				out.println((S.contains(x))? 1 : 0);
			}
			else {
				int x=Integer.parseInt(in.next());
				S.remove(x);
			}
		}
		out.flush();
	}

}



Measured memory_bytes: 113248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;




int main()
{
	string S;

	cin >> S;

	int AA,BB;

	AA = atoi(S.substr(0,2).c_str());
	BB = atoi(S.substr(2,2).c_str());

	if (0 < AA && AA <= 12){
		if(0 < BB && BB <= 12){
			printf("AMBIGUOUS");
		}
		else {
			printf("MMYY");
		}
	}
	else {
		if (0 < BB && BB <= 12) {
			printf("YYMM");
		}
		else {
			printf("NA");
		}
	}


	return 0;
}



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

int main(){
  int N,a,r=1; cin>>N;
  REP(i,N){
    cin>>a; if(r&&(a%2==0)){if(a%3&&a%5){r=0;}}
  }
  cout<<(r?"APPROVED\n":"DENIED\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue


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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	string s, t; cin >> s >> t;
	int l = lcm(n, m);
	for (int i = 0; i < l; i += l / n) {
		if (i % (l / m) == 0) {
			if (s[i / (l / n)] != t[i / (l / m)]) {
				cout << -1 << endl; return 0;
			}
		}
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int a=0,b=0,n;
    string A,B;
    cin>>n;
    for(int i=0;i<n; i++){
        cin>>A>>B;
        if(A==B){
            a++;
            b++;
        }
        else if(A>B)
        a+=3;
        else
        b+=3;
        }
        cout<<a<<" "<<b<<endl;
        return 0;
    }


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

const int MAXN = 1e5;
int a[MAXN];

int main(void){
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(x >= 1 && x <400) a[0]++;
		else if(x < 800) a[1]++;
		else if(x < 1200) a[2]++;
		else if(x < 1600) a[3]++;
		else if(x < 2000) a[4]++;
		else if(x < 2400) a[5]++;
		else if(x < 2800) a[6]++;
		else if(x < 3200) a[7]++;
		if(x >= 3200) ans++;
	}
	int cnt = 0;
	for(int i = 0; i < 8; i++){
		if(a[i]) cnt++;
	}
	cout << max(cnt, 1) << " " << cnt + ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	n := readInt()
	a := make([]int64, n)
	var s int64
	for i := range a {
		a[i] = readInt64()
		s += a[i]
	}

	x := make([]int64, n)
	x[0] = s
	for i := range a {
		if i%2 == 1 {
			x[0] -= 2 * a[i]
		}
	}

	for i := range a {
		if i != 0 {
			x[i] = 2*a[i-1] - x[i-1]
		}
		fmt.Println(x[i])
	}
}


Measured memory_bytes: 5632
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+10;

struct node
{
    ll x,v;
}a[N];

bool px(node a,node b)
{
    return a.x<b.x;
}

int n;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&a[i].x,&a[i].v);
    sort(a,a+n,px);
    int sc=0;
   for(int i=0;i<n;i++)
   {
       if(a[i].x==-1)
        continue;
       int val=a[i].x+a[i].v;
       for(int j=i+1;j<n;j++)
       {
           if(a[j].x-a[j].v<val)
           {
               if(a[j].x+a[j].v<val)
               {
                   a[i].x=-1;
                   break;
               }
               else
               {
                   a[j].x=-1;
               }
           }
           else
            break;
       }
   }
   for(int i=0;i<n;i++)
    if(a[i].x!=-1)
    sc++;
   printf("%d\n",sc);
    return 0;
}








Measured memory_bytes: 1792
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define int long long 
using namespace std;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif


// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int n;
    cin>>n;
    string s;
    cin>>s;
    int len=s.length();
    for(int i=0;i<len;i++)
    {
        s[i]=char(((s[i]-'A')+n%26)%26+65);
    }
    cout<<s;

// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
n = int(input())
a = ''
for i in range(100):
    if n==0:
        break
    if (n % (2**(i+1)) != 0):
        a = '1'+a
        if i%2 == 0:
            n -= 2**i
        else:
            n += 2**i
    else:
        a = '0'+a
if a=='':
    a = '0'
print(a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<ll>> a(w+2,vector<ll>(h+2,0)),b(w+2,vector<ll>(h+2,0));
    rep(i,h){
        rep(j,w){
            char s;
            cin >> s;
            if (s=='#') b.at(j+1).at(i+1)=1;
        }
    }
    a.at(1).at(1)=1;
    rep(i,h){
        rep(j,w){
            if (b.at(j+1).at(i+1)==0) a.at(j+1).at(i+1)=(a.at(j+1).at(i+1)+a.at(j).at(i+1)+a.at(j+1).at(i))%MOD;
        }
    }
    cout << a.at(w).at(h) << endl;
}

Measured memory_bytes: 16000
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int a,b,c;
	cin>>a>>b>>c;
	int x,ans;
	if((b+c) < a) cout<<0<<endl;
	else {
		x = a-b;
		ans=c-x;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3644
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);


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

    ll n,l,t;
    cin>>n>>l>>t;
    l *= 2;
    t *= 2;
    ll x[n],w[n];
    for(ll i=0;i<n;i++){
        cin>>x[i]>>w[i];
        w[i]--;
        x[i] *= 2;
    }
    ll cnt = 0;
    for(ll i=1;i<n;i++){
        if(w[0]!=w[i]){
            ll dif = x[i]-x[0];
            if(w[0]==1) dif = l-dif;
            ll tmp = t;
            if(tmp >= dif/2){
                tmp -= dif/2;
                cnt++;
            }
            cnt += tmp/(l/2);
            cnt %= n;
        }
    }
    for(ll i=0;i<n;i++){
        if(w[i]==0) x[i] = (x[i]+t)%l;
        else x[i] = (x[i]+l-(t%l))%l;
    }
    ll now = x[0];
    sort(x,x+n);
    if(w[0]==1)for(ll i=0;i<n;i++){
        if(x[i] == now){
            for(ll j=0;j<n;j++){
                cout << x[(i+j+cnt)%n]/2 << "\n";
            }
            return 0;
        }
    }
    else for(int i=n-1;i>=0;i--){
        if(x[i] == now){
            for(int j=0;j<n;j++){
                cout << x[(i+j+n-cnt)%n]/2 << "\n";
            }
            return 0;
        }
    }
}

Measured memory_bytes: 2816
#include<stdio.h>
int main(void)
{
	int r, D, x;
	scanf("%d%d%d", &r, &D, &x);
	for (int i = 0; i < 10; i++)
	{
		printf("%d\n", r * x - D);
		x = r * x - D;
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;ll g=c*d/__gcd(c,d);
	cout<<(b-a+1ll)-b/c+(a-1)/c-b/d+(a-1)/d+b/g-(a-1)/g;
	return 0;
}

Measured memory_bytes: 256
#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 si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#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 vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
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(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    
    int N,M;
    cin >> N >> M;
    
    vvi G(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
        
    }
    
    vi C(N,-1);
    queue<int> que;
    que.push(0);
    C[0] = 0;
    while (!que.empty()) {
        int p = que.front();
        que.pop();
        
        for (int g : G[p]) {
            if(C[g] > 0) continue;
            C[g] = p+1;
            que.push(g);
        }
    }
    
    rep(i,N){
        if(C[i] < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cyes;
    reps(i,1,N) cout << C[i] << endl;

    return 0;
}


Measured memory_bytes: 10064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n;
  int m;
  scanf("%ld%d",&n,&m);
  int a[m],i;
  long int sum=0;
  for(i=0;i<m;++i)
  {
   scanf("%ld",&a[i]);
    sum+=a[i];
   
  }
  if(sum>n)
    printf("-1");
  else
    printf("%ld",n-sum);
}

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

int main(){
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> p(n);
  r(i,n){
    string s; int a;
    cin >> s >> a;
    p.at(i)=make_pair(make_pair(s,-a),i+1);
  }
  sort(p.begin(),p.end());
  r(i,n)cout << p.at(i).second<<endl;
}

Measured memory_bytes: 256