akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    if (N == 1)
    {
        putout("Yes");
        putout(2);
        cout << 1 << " " << 1 << endl;
        cout << 1 << " " << 1 << endl;
        return 0;
    }
    ll k = -1;
    Loop(i, 1, N + 1)
    {
        ll x = i;
        if (x * (x - 1) == 2 * N)
        {
            k = x;
            break;
        }
    }
    if (k == -1)
    {
        putout("No");
        return 0;
    }
    putout("Yes");
    putout(k);
    vector<vector<ll>> S(k);
    ll ind = 0;
    ll now = 1;
    ll kaisu = k - 1;
    loop(i, k - 1)
    {
        loop(j, kaisu)
        {
            S[ind].push_back(now);
            S[ind + 1 + j].push_back(now);
            now++;
        }
        ind++;
        kaisu--;
    }
    loop(i, k)
    {
        cout << k - 1 << " ";
        loop(j, k - 1)
        {
            cout << S[i][j];
            if (j != k - 2)
                cout << " ";
            else
                putout("");
        }
    }
    return 0;
}
//にゃーん(悲痛な叫び)


Measured memory_bytes: 5004
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;
	int ans = max(0, A - 2 * B);
	cout << ans << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=5e5+100;
ll val[N];
ll t[20];
ll dp[(1<<16)];
vector <int> f(ll x){
    vector <int> bit;
    while(x){
        bit.pb(x%2);
        x/=2;
    }
    while(bit.size()<16){
        bit.pb(0);
    }
    return bit;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=0;i<n-1;i++){
        ll u,v,w;
        cin >> u >> v >> w;
        u++;
        v++;
        val[u] ^= w;
        val[v] ^= w;
    }
    ll ans=0;
    for (int i=1;i<=n;i++){
        t[val[i]]++;
     ///   cout << i << " " << val[i] << endl;
        if (t[val[i]]==2 && val[i]!=0) ans++;
        t[val[i]]%=2;
    }
    t[0]=0;
    memset(dp,69,sizeof dp);
    ll cnt1=0;
    for (int i=0;i<=15;i++){
        cnt1+=(t[i] << i);
     //   cout << t[i] << endl;
    }
    dp[0]=0;
    vector <pii> a;
    for (int i=0;i<(1<<16);i++){
        vector <int> bit=f(i);
       ll cnt=0;
        if (bit[0]) continue;
        for (int j=0;j<16;j++){
            cnt+=bit[j];
        }
        a.pb({cnt,i});
    }
  //  cout << cnt1 << endl;
    sort(a.begin(),a.end());
    for (int i=0;i<a.size();i++){
        ll x=a[i].S;
        vector <int> bit=f(x);
        for (int j=0;j<16;j++){
            if (bit[j]) dp[x]=min(dp[x],dp[(x^(1<<j))]+1);
            for (int k=j+1;k<16;k++){
                if (!bit[j] || !bit[k]) continue;
                if (bit[(j^k)]) dp[x]=min(dp[x],2+dp[(x^((1<<j) + (1<<k) + (1<<(j^k))))]);
                else dp[x]=min(dp[x],1+dp[(x^((1<<j) + (1<<k) + (1<<(j^k))))]);
               // if (x==14){
                 //   cout << dp[x] << " " << j << " " << k << " " << (j^k) << " " << 1+dp[(x^((1<<j) + (1<<k) + (1<<(j^k))))] << endl;
                //}
            }
        }

    }
    cout << dp[cnt1]+ans << endl;
}


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

/*
template<size_t max_N>
struct Prime{
    bool is_prime[max_N];
    constexpr Prime() : is_prime() {
        for(int i = 0; i < max_N; i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for (int i = 0; i < max_N; i++)
        {
            if(!is_prime[i]) continue;
            for (int j = i*i; j < max_N; j+=i) is_prime[j] = false;
        }
        
    }
};
*/

template<size_t max_N, size_t prime_size>
struct Prime{
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    int_fast64_t nlike[max_N];
    size_t counter = 0;
    constexpr Prime() : sieve(), prime(), nlike() {
        for(int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for(int_fast64_t i = 2; i < max_N; ++i){
            if(sieve[i]){
                prime[counter] = i;
                ++counter;
                if(counter > prime_size)break;
            }
            for(int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
        for (int i = 1; i < max_N; i++)
        {
            if(i%2==1 && sieve[i] && sieve[(i+1)/2]) nlike[i] = nlike[i-1] + 1;
            else nlike[i] = nlike[i-1];
        }
    }
};

constexpr void check_like(std::vector<int>& n_like, const Prime<100100, 10000>& p){
}
int main(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int PRIME_MAX = 1e5+100;
    int Q; cin >> Q;
    vector<int> l(Q), r(Q);
    vector<int> n_like(PRIME_MAX, 0);
    for (int i = 0; i < Q; i++) cin >> l[i] >> r[i];
    constexpr auto p = Prime<PRIME_MAX, 10000>();
    
    for (int i = 0; i < Q; i++)
    {
        cout << p.nlike[r[i]] - p.nlike[l[i]-1] << "\n";
    }
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n, k; cin >> n >> k;
	vector<int> P(n);
	for (int i=0; i<n; i++) cin >> P[i];
	sort(P.begin(), P.end());
	int ret = 0;
	for (int i=0; i<k; i++) ret += P[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N,A,B;cin>>N>>A>>B;
    int rep=(N+A-1)/A;
    if(rep<=B&&A+B<=N+1){
        if(A==1){
            for(int i=N;i>=1;i--){
                cout<<i<<endl;
            }
        }else if(B==1){
            for(int i=1;i<=N;i++){
                cout<<i<<endl;
            }
        }else{
            vector<int> S(N);
            int now=0;
            for(int i=rep-1;i>0;i--){
                for(int j=1;j<=A;j++){
                    S[now]=i*A+j-(A-((N-1)%A+1));
                    now++;
                }
            }
            for(int j=1;j<=(N-1)%A+1;j++){
                S[now]=j;
                now++;
            }
            
            int play=B-rep;
            
            for(int i=0;i<play/(A-1);i++){
                reverse(S.begin()+A*i,S.begin()+A*(i+1));
            }
            
            reverse(S.begin()+A*(play/(A-1)+1),S.begin()+A*(play/(A-1)+1)+play%(A-1)+1);
            
            for(int i=0;i<N;i++){
                cout<<S[i]<<endl;
            }
            
        }
    }else cout<<-1<<endl;
    
}




Measured memory_bytes: 3328
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 

 
int main()
{
    int M;
  
 // 整数の入力
    scanf("%d", &M);
 // printf("%d\n",N);

    printf("%d\n", 48 - M);
    return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),m=read(),k=read();
	REP(i,n+1)REP(j,m+1){
		if(i*(m-j)+j*(n-i)==k){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main(){
    string s;
    cin >> s;
    bool check = false;
    ll count = s.length();
    while(check != true){
        for(ll i = 0; i < s.length(); i++){
            if(s[i]=='S' && s[i+1]=='T'){
                s.erase(i, 2);
                i-=2;
            }
        }
        if(count == s.length())
            check = true;
        count = s.length();
    }
    cout << s.length() << endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    while(1)
    {
        int a,b,n,m=0;
        int ans[10000];
        int road[17][17]={0};
        int con[17][17]={0};
        road[0][1]=1;
        cin>>a>>b;
        if(a==0&&b==0)break;
        cin>>n;
        for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            con[x][y]=1;
        }
        for(int i=1;i<=a;i++)for(int j=1;j<=b;j++)
        {
            //????????\?????????continue;
            if(con[i][j]==1)continue;
            //if(i==1||j==1)road[i][j]=1;
            else road[i][j]=road[i-1][j]+road[i][j-1];
            /*
            if(i==1||j==1)road[i][j]=1;
            else road[i][j]=road[i-1][j]+road[i][j-1];
            for(int k=0;k<n;k++)if(i==con1[k]&&j==con2[k])road[i][j]=0;
            */
        }
        /*
        for(int i=0;i<=8;i++){
            for(int j=0;j<=10;j++){
                printf("[%3d]",road[i][j]);
            }
            puts("");
        }
        */
        cout<<road[a][b]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};
int main() {
long long n,m;
cin>>n>>m;
dsu d=dsu(n);
long long x,y;
for(long long i=0;i<m;i++){
  cin>>x>>y;
  d.merge(x-1,y-1);
}
long long ans=0;
long long used[n]={0};
for(long long i=0;i<n;i++){
  used[d.leader(i)]=1;
}
for(long long i=0;i<n;i++){
  if(used[i]==1){
    ans++;
  }
}
ans--;
cout<<ans<<endl;

    return 0;
}

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

using namespace std;

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

	int n, a, b;
	string s;
	cin >> n >> a >> b;
	cin >> s;

	int i = 0, o = 0,oo=0;

	for (auto x : s) {
		if (x == 'c')
			cout << "No" << endl;
		else if (x == 'a') {
			if (a + b > i + o) {
				cout << "Yes" << endl;
				i++;
			}
			else
				cout << "No" << endl;
		}
		else {
			oo++;
			if (a + b > i + o) {
				if (oo <= b) {
					o++;
					cout << "Yes" << endl;
				}
				else
					cout << "No" << endl;
			}
			else
				cout << "No" << endl;
		}

	}

	return 0;

}

Measured memory_bytes: 848
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <sstream>
#include <stdio.h>
#include<math.h>
using namespace std;

int main(){

    string s;

    cin >> s;

    int count=0;

    if(s[0]=='1'){
        count++;
    }
    if(s[1]=='1'){
        count++;
    }
    if(s[2]=='1'){
        count++;
    }

    cout << count << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
string str;
int sum,size;
map <char,int> t;
int main(){
	t['I']=1;
	t['V']=5;
	t['X']=10;
	t['L']=50;
	t['C']=100;
	t['D']=500;
	t['M']=1000;
	while(cin>>str){
		size=str.size();
		sum=0;
		for(int i=0;i<size-1;i++){
			if(t[str[i]]<t[str[i+1]])sum-=t[str[i]];
			else sum+=t[str[i]];
		}
		cout<<sum+t[str[size-1]]<<endl;
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 5e6+100;
const int mod = 1e9+7;
int main() {
	int a,b;
	sd(a);
	sd(b);
	if(a+b==15){
		printf("+\n");
	}
	else if(a*b==15){
		printf("*\n");
	}
	else{
		printf("x\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int dsum = 0, d = 0, i = 0;
		int s[] = new int[n];
		for (int j = 0; j < s.length; j++)
			s[j] = sc.nextInt();
		while (i <= n) {
			if(i>0)d = dsum + s[i-1];
			else d=0;
			if (d > x)
				break;
			else {
				dsum = d;
				i++;
			}
		}
		System.out.println(i);
	}
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int min_value = 1e9;
    rep(i, N) if (A[i] < min_value) min_value = A[i];

    // vector<int> P;
    // P.push_back(-1);
    // rep(i, N) if (A[i] == min_value) P.push_back(i);
    // P.push_back(N);

    // int l = P.size();
    // int res = 0;
    // rep(i, l-1) {
    //     int step = K - 1;
    //     int dist = P[i+1] - P[i] - 1;
    //     res += (dist + step - 1) / step;
    // }

    // int res = 0;
    // int i = 0;
    // while (i < N) {
    //     if (A[i] != min_value) {
    //         res += 1;
    //         i += (K - 1);
    //     } else {
    //         i += 1;
    //     }
    // }

    // cout << res << endl;

    cout << ((N-1) + (K-1) - 1) / (K-1) << endl;
}

Measured memory_bytes: 3604
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
h=list(map(int,input().split()))
ans=[0]*n
tmp=1
for i in range(n-1):
    if h[i]>=h[i+1]:
        ans[i]=tmp
        tmp+=1
    else:
        tmp=1
print(max(ans))

Measured memory_bytes: 63984
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int n;

int main() {
	cin >> n;
	int t = n % 10;
	if (t == 2 || t == 4 || t == 5 || t == 7 || t == 9) cout << "hon";
	else if (t == 3) cout << "bon";
	else cout << "pon";
}

Measured memory_bytes: 3636
import java.util.*

fun main(args:Array<String>?): Unit {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val need = Array(n){ Stack<Pair<Int, Int>>()}
    repeat(m){
        val (a, b, c) = readLine()!!.trim().split(' ').map(String::toInt)
        need[b].add(Pair(a, c))
    }
    println(solve(need))
}
fun solve(needs: Array<out Collection<Pair<Int, Int>>>): Int {
    val memo = IntArray(needs.size){-1}
    memo[0] = 0
    fun sub(current: Int): Int {
        return when(memo[current]){
            -1 -> {
                memo[current] = needs[current].map{(a, c) -> sub(a) + c}.max()!!
                memo[current]
            }
            else -> memo[current]
        }
    }
    return sub(needs.size - 1)
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll N,M,N2;
ll C[202020];
ll p2[404040];
ll dp[202020];
ll i, j, k, ans;

int main(){
    scanf("%lld", &N);
    N2 = N * 2;
    fornum(i,0,N){
        scanf("%lld", &C[i]);
    }

    sort(C, C + N);

    p2[0] = 1;
    fornum(i,0,N2){
        p2[i + 1] = p2[i] * 2 % MOD;
    }

    j = 0;
    k = 0;
    for (i = N - 1; 0 <= i;--i){
        ll jj = j + p2[N - i - 1];
        ans += C[i] * jj % MOD * p2[i];
        ans %= MOD;
        j = j * 2 + p2[N - i-1];
        j %= MOD;

        //printf("%lld\n", j);
    }
    ans *= p2[N];
    ans %= MOD;
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll r = 0;
    for (int i = 1; i <= n; i++) {
        ll k = n / i;
        r += i * (k * (k + 1) / 2);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define clr(A, x) memset(A, x, sizeof(A))
#define cpy(A, B) memcpy(A, B, sizeof(B))
#define g(s) getline(cin, s) ///ai grija la fin/cin ///
#define FASTIO ios_base::sync_with_stdio(0)
const long long INFLL = 2 * 1e18 + 100;
const int INFINT = 2 * 1e9 + 100;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//ifstream fin("dijkstra.in");
//ofstream fout("dijkstra.out");
void die()
{
    cout << "-1";
    exit(0);
}
const int NMAX = 2* 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int sol = INFINT;

void solve(string s, char obt, int steps)
{
    string temp;
    for0(i, s.size())
    {
        if(s[i] == obt) temp += obt;
        else if(i + 1 < s.size() && s[i + 1] == obt) temp += obt;
        else temp += s[i];
        if(temp.size() == s.size() - 1)
        {
            for(auto it: temp)
                if(it != obt)
                {
                    solve(temp, obt, steps + 1);
                    return;
                }
            sol = min(sol, steps);
            //cout << temp << endl;
        }
    }
}

int main()
{
    FASTIO;
    string s;
    cin >> s;
    char aux = s[0];
    for(auto it: s)
        if(it != aux)
        {
            for0(i, 30)
            {
                if(char('a' + i) > 'z')
                    break;
                solve(s, char('a' + i), 1);
            }
            return cout << sol, 0;
        }
    cout << 0;


    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    print(int(sqrt(N)) ** 2)


if __name__ == '__main__':
        main()

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

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

int main(){
	int N,A[1000];
	cin >> N;
	rep(i, N)
		cin >> A[i];
	sort(A, A + N);
	cout << abs(A[0]-A[N-1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	ll a,b,x;
	cin>>a>>b>>x;
	ll ans;
	if(a==0)ans=b/x + 1;
	else ans=b/x - (a-1)/x;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

using namespace std;

char S[2000][2000];
int U[2000][2000];
int L[2000][2000];
int R[2000][2000];
int D[2000][2000];

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            cin >> S[i][j];

            U[i][j] = 0;
            L[i][j] = 0;
            R[i][j] = 0;
            D[i][j] = 0;
        }
    }

    rep(i, H) {
        rep(j, W) {
            // upper
            if(i == 0) {
                U[i][j] = S[i][j] == '#' ? 0 : 1;
            } else {
                U[i][j] = S[i][j] == '#' ? 0 : U[i-1][j] + 1;
            }

            // left
            if(j == 0) {
                L[i][j] = S[i][j] == '#' ? 0 : 1;
            } else {
                L[i][j] = S[i][j] == '#' ? 0 : L[i][j-1] + 1; 
            }

            int ri = H - i - 1;
            int rj = W - j - 1;

            // bottom
            if(ri == H-1) {
                D[ri][j] = S[ri][j] == '#' ? 0 : 1;
            } else {
                D[ri][j] = S[ri][j] == '#' ? 0 : D[ri+1][j] + 1; 
            }

            // right
            if(rj == W-1) {
                R[i][rj] = S[i][rj] == '#' ? 0 : 1;
            } else {
                R[i][rj] = S[i][rj] == '#' ? 0 : R[i][rj+1] + 1; 
            }
        }
    }

    int64_t ret = 0;
    rep(i, H) {
        rep(j, W) {
//            cout << D[i][j] << ", " ;
            ret = max(ret, (int64_t)(U[i][j] + L[i][j] + D[i][j] +R[i][j]));
        }
//        cout << endl;
    }
    cout << ret - 4 + 1 << endl;
    return 0;
}



Measured memory_bytes: 69532
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

int N, x, a[100000];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> x;
  FOR(i, 0, N) cin >> a[i];
  ll ans = 0;
  if (a[0] > x){
    ans += a[0] - x;
    a[0] = x;
  }
  int m;
  FOR(i, 1, N){
    if(a[i - 1] + a[i] > x){
      m = a[i - 1] + a[i] - x;
      a[i] -= m;
      ans += m;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
n = int(input())
s = [3,5,7]

ans = 0
a = [""]
for i in range(len(str(n))):
    b = []
    for j in a:
        for k in s:
            k1 = int(j + str(k))
            b.append(str(k1))
            if k1 <= n and "3" in str(k1) and "5" in str(k1) and "7" in str(k1):
                ans += 1
    a = b

print(ans)

Measured memory_bytes: 42844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y));

int main()
{
	int r,c,i,j,k;
	int* list;
	int** data;
	int* count;
	while(scanf("%d %d",&r,&c),r)
	{
		if(r == 1)
			printf("%d\n",c);
		else
		{
			list = mem(int,2 << (r-1));
			count = mem(int,2 << (r-1));
			data = mem(int*,r);
			for(i = 0;i < r;i++)
			{
				data[i] = mem(int,c);
				for(j = 0;j < c;j++)
				{
					scanf("%d",&data[i][j]);
				}
			}
			for(i = 0;i < c;i++)
			{
				int num = 0;
				for(j = 0;j < r;j++)
				{
					num += data[j][i] << j;
				}
				list[num]++;
			}
			for(i = 0;i < (2 << (r-1));i++)
			{
				count[i] = 0;
			}
			for(i = 0;i < (2 << (r-1));i++)
			{
				for(j = 0;j < (2 << (r-1));j++)
				{
					int num = 0;
					for(k = 0;k < r;k++)
					{
						if(((~(j ^ i)) >> k) & 1)
						{
							num++;
						}
					}
					if(num <= r/2)
					{
						num = r-num;
					}
					count[i]+= num*list[j];
				}
			}
			int max = 0;
			for(i = 0;i < (2 << (r-1));i++)
			{
				if(max < count[i])
				{
					max = count[i];
				}
			}
			printf("%d\n",max);
		}
	}
	return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  vector<int> V(N + 1, 0);
  for(int x = 1; x < 105; x++){
    for(int y = 1; y < 105; y++){
      for(int z = 1; z < 105; z++){
        int a = x*x + y*y + z*z + x*y + y*z + z*x;
        if(a <= N)
          V.at(a)++;
      }
    }
  }
  for(int i = 1; i < N+1; i++){
    cout << V.at(i) << endl;
  }
  
}

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

int main() {
    int cur, nxt, price;
    while (cin >> cur >> nxt >> price, cur) {
        int ma = 0;
        for (int sum = 0; sum <= 1000; sum++) {
            for (int x = 1; x < sum; x++) {
                int y = sum - x;
                int cur_x = x * (100 + cur) / 100;
                int cur_y = y * (100 + cur) / 100;
                if (cur_x + cur_y != price) continue;
                int nxt_x = x * (100 + nxt) / 100;
                int nxt_y = y * (100 + nxt) / 100;
                ma = max(ma, nxt_x + nxt_y);
            }
        }
        cout << ma << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	ll res = 1;
	a %= mod;
	assert(b >= 0);
	for (; b; b >>= 1)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s,w;
	cin>>s>>w;
	if(w>=s) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
	return 0;
}


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

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    n%=12;
    rep(i,n){
        if(i%2==0){
            a-=b;
        }else b+=a;
    }
    cout<<a<<" "<<b<<endl;
}


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

string i_to_s(int n){
	string s;
	do{
		s.push_back( (n%10)+'0' );
		n /= 10;
	}while( n != 0 );
	reverse( s.begin() , s.end() );
	return s;
}

string FizzBuzz(int i){
	return i%3?i%5? i_to_s(i):"Buzz":i%5?"Fizz":"FizzBuzz";
}

int main(){
	int m, n;
	int p[1001];
	
	while( cin >> m >> n , m|n ){
		int num = m;
		bool flag = true;
		for(int i=0 ; i<1001 ; ++i )
			p[i] = 1;
		
		for(int i=0, j=0 ; i<n ; ++i , ++j, j%=m ){

			while( p[j] == 0 && flag ){
				j++;
				j %= m;
			}
			string s;
			cin >> s;

			if( !(s == FizzBuzz(i+1)) && flag ){
				p[j] = 0;
				num--;
			}
			if(num==1){
				flag = false;
			}
		}
		vector<int> vc;
		for(int i=0 ; i<m ; ++i ){
			
			if( p[i] )
				vc.push_back( i+1 );
		}
		for(int i=0 ; i<(int)vc.size() ; ++i){
			cout << vc[i];
			(i==vc.size()-1)? cout << endl : cout << " ";
		}

	}
}

Measured memory_bytes: 940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    cout << 2*(N-1) << endl;
    int a_min = *min_element(a.begin(), a.end());
    int a_max = *max_element(a.begin(), a.end());
    if(abs(a_min) <= abs(a_max)) {
        int max_pos = distance(a.begin(), max_element(a.begin(), a.end()));
        for(int i=0; i<N; i++) {
            if(i != max_pos) {
                cout << max_pos+1 << " " << i+1 << endl;;
            }
        }
        for(int i=1; i<N; i++) {
            cout << i << " " << i+1 << endl;
        }
    } else {
        int min_pos = distance(a.begin(), min_element(a.begin(), a.end()));
        for(int i=0; i<N; i++) {
            if(i != min_pos) {
                cout << min_pos+1 << " " << i+1 << endl;;
            }
        }
        for(int i=N; i>1; i--) {
            cout << i << " " << i-1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int dp[100001], n, a[100001], k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  dp[0]=0;
  for(int i=1;i<n;i++){
    dp[i]=1e9;
  }
  for(int i=0;i<n;i++){
  	for(int j=1;j<=k;j++)
    dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
  }
  cout<<dp[n-1]<<"\n";
}
  

Measured memory_bytes: 1024
import string

S = str(input())
T = str(input())

S_l = [[] for _ in range(26)]
T_l = [[] for _ in range(26)]
alpha = string.ascii_lowercase

for n in range(len(S)):
    for m in range(26):
        if S[n] == alpha[m]:
            S_l[m].append(n)

for n in range(len(T)):
    for m in range(26):
        if T[n] == alpha[m]:
            T_l[m].append(n)

for i in range(25, -1, -1):
    if S_l[i] == T_l[i] and S_l[i] !=0:
        del S_l[i]
        del T_l[i]

S_l = sorted(S_l)
T_l = sorted(T_l)

if S_l == T_l:
    print('Yes')
else:
    print('No')





Measured memory_bytes: 21352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int a,b;
	cin >> a >> b;
	cout << ((a+b)%24) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n'

using namespace std;

long long n, x, a, r;

long long hcf(long long a, long long b){
    if(b == 0){
        return a;
    } else{
        return hcf(b, a % b);
    }
}

int main(){
    vector<long long> v;
    cin >> n >> x;
    for(long long i = 0; i < n; i++){
        cin >> a;
        v.push_back(abs(x-a));
    }

    r = v[0];

    for(long long i = 0; i < n; i++){
        r = hcf(r, v[i]);
    }

    cout << r;


}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//2, 4, 8
//48, 24, 24

Measured memory_bytes: 1400
n = int(input())
a = [int(i) for i in input().split()]

fl = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        a[i+1] -= 1

    if a[i] > a[i+1]:
        print('No')
        fl = 1
        break

if fl==0:
    print('Yes')


Measured memory_bytes: 14252
from sys import stdin
def main():
  from builtins import int, map, range
  readline = stdin.readline
  n, q = map(int, readline().split())
  values = [0] * n
  links = [[] for _ in range(n)]
  for _ in range(n - 1):
    a, b = map(int, readline().split())
    links[a - 1].append(b - 1)
    links[b - 1].append(a - 1)
  for _ in range(q):
    p, x = map(int, readline().split())
    values[p - 1] += x
  s = [(0, -1)]
  while s:
    i, p = s.pop()
    for j in links[i]:
      if j == p:
        continue
      values[j] += values[i]
      s.append((j, i))
  print(*values)
main()


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	long long ans=0;
	int mx=0;
	for(int i=0;i<n;i++)
	{
		int a;
		cin >> a;
		ans+=max(mx-a,0);
		mx=max(mx,a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		if(S.length()==1) {
			System.out.println(S);
			System.exit(0);
		}
		int[] N = new int[S.length()];

		int patternCount = 1;
		String tmpBit = "";
		for(int i=0; i<N.length; i++) {
			N[i] = Integer.parseInt(String.valueOf(S.charAt(i)));
			if(i>0) {
				patternCount*=2;
				tmpBit = tmpBit + "1";
			}
		}

		long sum=0;
		for(int i=0; i<patternCount; i++) {
			String bin = Integer.toBinaryString(i);
			while(bin.length()<tmpBit.length()) {
				bin = "0" + bin;
			}
			String add = String.valueOf(N[0]);
			for(int j=0; j<bin.length(); j++) {
				if(bin.charAt(j)=='1') {
					sum+=Integer.parseInt(add);
					add = "";
				}
				add = add + N[j+1];
			}
			if(add.length()>0) {
				//System.out.printf("sum:%d + add:%s = ",sum, add);
				sum+=Long.parseLong(add);
				//System.out.println(sum);
			}
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 23764
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var N = parseInt(input[0]);
  var list = input[1].split(" ").map((a)=>Number(a));
  var ruiseki = 0;
  for(var i = 0; i < list.length; i++){
    ruiseki += list[i];
  }
  var result = [];
  var tmp = 0;//x1を求めるとき用に偶数要素の累積を持たせる
  for(var i = 1; i < list.length; i = i + 2){
    tmp += list[i];
  }
  result[0] = ruiseki - 2 * tmp;
  for(var i = 1; i < list.length; i++){
    result.push(2 * list[i - 1] - result[i - 1]);
  }
  myout(result.join(" "));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 38208
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}




Measured memory_bytes: 9600
from fractions import gcd
A, B, C, D = [int(i) for i in input().split()]
result = B+1 - A
def lcm(a, b):
    return (a * b) // gcd(a, b)
def wareru(min_num, max_num, waru):
    return (max_num)//waru - (min_num-1)//waru
result -= wareru(A, B, C) + wareru(A, B, D) - wareru(A, B, lcm(C,D))
print(result)

Measured memory_bytes: 5076
def gcd(x, y):
    while y != 0:
        r = x % y
        x = y
        y = r
    return x

A, B = map(int, input().split())
gcd = gcd(A, B)
result = 1
d = 2
while d * d <= gcd:
    e = 0
    while gcd % d == 0:
        gcd //= d
        e += 1
    if e > 0:
        result += 1
    d += 1
if gcd > 1:
    result += 1
print(result)

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

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

  int ans = 1;

  while (s != 4 && s != 2 && s != 1) {
    if (s % 2 == 0) s /= 2;
    else s = 3 * s + 1;
    ans++;
  }

  cout << ans + 3 << endl;
}

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

int main(){
    ll n,ans,sum;
  cin >> n;
    ll a[n];
    ll b[n];
    map<ll,ll> hoge;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        hoge[a[i]]++;
    }

    for(ll i = 0; i < n; i++){
        b[i] = hoge[a[i]];
    }

    for(auto itr = hoge.begin(); itr != hoge.end(); itr++){
        sum += itr->second * (itr->second-1) / 2;
    }
    for(ll i = 0 ; i < n; i++){
        if(hoge[a[i]] > 1){
        ans = sum - hoge[a[i]] * (hoge[a[i]]-1)/2 + (hoge[a[i]]-1) * (hoge[a[i]]-2)/2;
        }
        else ans = sum;
        cout << ans << endl;
    }
}
    

Measured memory_bytes: 12672
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
 
using namespace std;
 
int main()
{
	const int MAX_N = 200000;
	long long l, r;
	cin >> l;
	cin >> r;
 
	long long answer = 2019;
	for (long long i = l; i < r; i++)
	{
		for (long long j = l + 1; j < r + 1; j++)
		{
			answer = min(answer, (i*j) % 2019);
			if (answer == 0)
			{
				cout << 0;
				return 0;
			}
		}
	}
 
	cout << answer;
	return 0;
 
}

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

int main(void){
    vector<long> v;
    long value;
    int N;
    long long answer;

    cin >> N;

    for(int i = 0; i < N; ++i){
        cin >> value;
        v.push_back(value);
    }

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

    int i = 1; //到着した人の人数
    int index = N - 1; //フレンドリー最大
    answer = 0; //心地よさの初期値
    answer += v[index]; //２人目が来た時の心地よさ
    --index;
    ++i;
    while(true){
        if(i == N) break;
        answer += v[index];
        ++i;
        if(i == N) break;
        answer += v[index];
        ++i;
        --index;
    }

    cout << answer << endl;
    
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int n,m,k;
char buff[20][20];
bool row[maxn],col[maxn];
bool check() {
    int x=0;
    for(int i=1;i<=n;i++) {
        if(row[i]) continue;
        for(int j=1;j<=m;j++) {
            if(col[j]) continue;
            if(buff[i][j]=='#') x++;
        }
    }
    return x==k;
}
int ans=0;
void dfs(int rs,int cs) {
    if(rs==n+1&&cs==m+1) {if(check()) ans++;return ;}
    if(rs==n+1) {
        col[cs]=0;
        dfs(rs,cs+1);
        col[cs]=1;
        dfs(rs,cs+1);
    }else {
        row[rs]=0;
        dfs(rs+1,cs);
        row[rs]=1;
        dfs(rs+1,cs);
    }
}
int main() {
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) scanf("%s",buff[i]+1);
    dfs(1,1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3696
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10????????? cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1?????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// ?????§??¬?´???°???Greatest Common Divisor???
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// ????°???¬?????°???Least Common Multiple???
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y??´??????????????´?????????
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector??¨???
// vec[i][j]?????¢?????\????????\????????¨??????vec???????????????????????????????????????.

// ------------------- include, typedef, define END. -------------------

vector<LL> sosuu(1000001,1);

void sosuuRekkyo() {
	// ??¨????????????????????????
	sosuu[0] = 0;
	sosuu[1] = 0;
	FOR(i, 2, sqrt(1000000)) {
		if (sosuu[i] == 1) {
			for (LL j = 2; i*j <= 1000000;j++) {
				sosuu[i*j] = 0;
			}
		}
	}
}

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//??????????????????????????????.

	LL a, d, n;
	sosuuRekkyo();

	while (1) {
		cin >> a >> d >> n;
		LL nowValue = a;

		if (a == 0 && d == 0 && n == 0)
			return 0;

		while (1) {
			if(sosuu[nowValue]==1)n--;
			if (n <= 0) {
				cout << nowValue << endl;
				break;
			}
			nowValue += d;
		}
	}

	return 0;
}

Measured memory_bytes: 8792