akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    set<int> s = {1, 2, 3};
    int A, B;
    input(A, B);
    s.erase(A);
    s.erase(B);

    cout << *(s.begin()) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:13:09:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAXN 10000001
#define M 32

using namespace std;
using namespace __gnu_pbds;

ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,i,ans;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        ans=modex(10,n);
        ans=(ans-(2*modex(9,n))%mod+mod)%mod;
        ans=(ans+modex(8,n))%mod;
        cout<<ans;
    }
}










Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int add_l = 0, add_r = 0;
  rep(i, n) {
    if (s[i] == '(')
      add_r++;
    else if (add_r)
      add_r--;
    else
      add_l++;
  }
  rep(i, add_l)
    s = '('+s;
  rep(i, add_r)
    s += ')';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL &x, LL &y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i%m;
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

LL N, A, B, C, D;
std::vector<std::vector<LL>>memo;
LL dp(LL i, LL j)
{
	if (i == 0) return 1;
	if (j > B) return 0;
	if (memo[i][j] != -1) return memo[i][j];
	LL res = dp(i, j + 1), c = 1;
	for (LL k = 1; k <= D && j*k <= i; ++k)
	{
		c = ((c*mod_comb(i - j * (k - 1), j, mod) % mod)*mod_inverse(k, mod)) % mod;
		if (k >= C)
		{
			res += (dp(i - j * k, j + 1)*c) % mod;
			res %= mod;
		}
	}
	return memo[i][j] = res;
}

int main()
{
	in >> N >> A >> B >> C >> D;

	mod_fact(N, mod);
	memo.resize(N + 1);
	rep(i, memo.size()) memo[i].resize(N + 1, -1);
	out << dp(N, A) << std::endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int nax = 3007;
ll v[nax][nax];
ll dp[nax][nax][4];
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r, c, k;
	cin >> r >> c >> k;
	for (ll i = 0; i < r; i++) {
		for (ll j = 0; j < c; j++) {
			v[i][j] = 0;
			dp[i][j][0] = 0;
			dp[i][j][1] = 0;
			dp[i][j][2] = 0;
			dp[i][j][3] = 0;
		}
	}
	for (ll i = 0; i < k; i++) {
		ll x, y, val;
		cin >> x >> y >> val;
		--x, --y;
		v[x][y] = val;
	}
	dp[0][0][0] = 0, dp[0][0][1] = v[0][0];
	for (ll i = 0; i < r; i++) {
		for (ll j = 0; j < c; j++) {
			for (ll x = 0; x < 4; x++) {
				if (i + 1 < r) {
					dp[i + 1][j][0] = max(dp[i][j][x], dp[i + 1][j][0]);
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][x] + v[i + 1][j]);
				}
				if (j + 1 < c) {
					dp[i][j + 1][x] = max(dp[i][j][x], dp[i][j + 1][x]);
					if (x + 1 <= 3)dp[i][j + 1][x + 1] = max(dp[i][j + 1][x + 1], dp[i][j][x] + v[i][j + 1]);
				}
			}
		}
	}
	cout << max({dp[r - 1][c - 1][0], dp[r - 1][c - 1][1], dp[r - 1][c - 1][2], dp[r - 1][c - 1][3]}) << endl;
}


Measured memory_bytes: 355864
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    string s;
    s.reserve(pow(10,5));
    int q;
    cin >> s >> q;
    int query, f;
    string c;
    bool rev = false;
    for(int i = 0; i < q; i++) {
        cin >> query;
        if(query == 1) {
            rev = !rev;
        } else {
            cin >> f >> c;
            if((!rev && f == 1) || (rev && f == 2)) {
                s.insert(0, c);
            } else {
                s.push_back(c.at(0));
            }
        }
    }
    if(rev) {
        reverse(s.begin(), s.end());
    }
    cout << s;
}

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

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

int count( int n, int x){
  int cnt = 0;
  for ( int i = 1; i <= n-2; i++ ){
    for ( int j = i+1; j <= n-1; j++ ){
      for ( int k = j+1; k <= n; k++ ){
        if ( i + j + k == x ) cnt++;
      }
    }
  }
 return cnt;
}

int main(){
  int n, x;
  
  while(1){
    cin >> n >> x;
    if ( n == 0 && x == 0 ) break;
    cout << count(n, x) << endl;
 }
 
 return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin>>c;
  if(c=='a'){
    cout<<"vowel"<<endl;
  }
    else if(c=='i'){
      cout<<"vowel"<<endl;
    }
      else if(c=='u'){
        cout<<"vowel"<<endl;
      }
  else if(c=='e'){
    cout<<"vowel"<<endl;
  }
  else if (c=='o'){
    cout<<"vowel"<<endl;
  }
    else{
      cout<<"consonant"<<endl;
    }
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
from collections import deque
a = deque([[i] for i in range(1, m+1)])
flag = True
while flag:
    s = a.popleft()
    for i in range(1, m + 1):
        if s[-1] <= i:
            if len(s) <= n-1:
                a.append(s+[i])
            else:
                flag = False
                break
a.append(s)
max_a = 0
ns = []
for i in range(q):
    ns.append(list(map(int, input().split())))
for ai in a:
    max_a = max(max_a, sum(ns[i][3] for i in range(q) if ai[ns[i][1] - 1] - ai[ns[i][0]-1] == ns[i][2]))
print(max_a)


Measured memory_bytes: 104404
#include<stdio.h>
#define ST_SIZE ((1 << 18) - 1)
#define INF 0x7fffffff
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int LL;
LL dat[ST_SIZE];
LL input(void);
void update(LL k, LL a, LL n);
LL minimize(LL a, LL b, LL k, LL l, LL r);
int main (void) {
  int command;
  LL i, n, q, s, t, n2 = 1;
  n = input();
  q = input();
  while (n2 < n) n2 *= 2;
  n = n2;
  for (i = 0; i < 2 * n - 1; i++) dat[i] = INF;
  for (i = 0; i < q; i++) {
    command = input();
    if (!command) {
      s = input();
      t = input();
      update(s, t, n);
    } else {
      s = input();
      t = input();
      printf("%lld\n", minimize(s, t + 1, 0, 0, n));
    }
  }
}

LL input(void)
{
  LL n = 0;
  int c = getchar_unlocked();
  if (c == '-') {
    c = getchar_unlocked();
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return -n;
  } else {
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return n;
  }
}

void update(LL k, LL a, LL n)
{
  k += n - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k - 1)/ 2;
    dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

LL minimize(LL a, LL b, LL k, LL l, LL r)
{
  if (a >= r || b <= l) return INF;
  else if (a <= l && b >= r) return dat[k];
  else {
    LL vl , vr;
    vl = minimize(a, b, k * 2 + 1, l, (l + r) / 2);
    vr = minimize(a, b, k * 2 + 2 , (l + r) / 2, r);
    return min(vl, vr);
  }
}


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

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

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

int main(){
	int a,b,q; scanf("%d%d%d",&a,&b,&q);
	lint s[100004],t[100004];
	rep(i,a) scanf("%lld",s+i+2);
	rep(i,b) scanf("%lld",t+i+2);
	s[0]=t[0]=-2*INF;
	s[1]=t[1]=-INF;
	s[a+2]=t[b+2]=INF;
	s[a+3]=t[b+3]=2*INF;
	a+=4;
	b+=4;

	rep(_,q){
		lint x; scanf("%lld",&x);
		lint ans=INF;
		{
			auto it=lower_bound(s,s+a,x);
			lint next[2]={*it,*prev(it)};
			for(lint y:next){
				auto jt=lower_bound(t,t+b,y);
				ans=min(ans,abs(y-x)+min(abs(*jt-y),abs(*prev(jt)-y)));
			}
		}
		{
			auto it=lower_bound(t,t+b,x);
			lint next[2]={*it,*prev(it)};
			for(lint y:next){
				auto jt=lower_bound(s,s+a,y);
				ans=min(ans,abs(y-x)+min(abs(*jt-y),abs(*prev(jt)-y)));
			}
		}
		printf("%lld\n",ans);
	}

	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;



int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  int N,K;
  cin>>N>>K;
  if (N%K!=0) cout<<1<<"\n"; else cout<<0<<"\n";
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            int d = sc.nextInt();;
            int t = sc.nextInt();;
            int s = sc.nextInt();;
            if (t*s >= d) return "Yes";
            else return "No";
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}

Measured memory_bytes: 27032
#include<stdio.h>

int main(){
	int a[4], b[4];
	int hit, blow;
	int i,j;

	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF){
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);

		hit = 0;
		blow = 0;

		for(i = 0; i < 4; i++){
			for(j = 0; j < 4; j++){
				if(a[i] == b[j])
					blow++;
			}
			if(a[i] == b[i]){
				hit++;
				blow--;
			}
		}

	printf("%d %d\n",hit, blow);

	}

	return 0;
}

Measured memory_bytes: 592
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<functional>
#include<queue>
#define INF 999999

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	if (b-a <= 0)cout << "delicious" << endl;
	else if (b - a > x)cout << "dangerous" << endl;
	else cout << "safe" << endl;
	return 0;

}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, a[], b[];
		int n2 = 1000000;
		long count[];
		long k;
		n = sc.nextInt();
		k = sc.nextLong();
		
		a = new int[n];
		b = new int[n];
		count = new long[n2];
		
		for(int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			count[a[i]] += b[i];
		}
		
		sc.close();
		
		Arrays.sort(a);
		int tmp = a[0];
		long sum = count[a[0]];
		
		for(int i = 1; i < n; ++i) {
			if(a[i] != a[i - 1])
			sum += count[a[i]];
			if(sum >= k) {
				tmp = a[i];
				break;
			}
		}
		
		System.out.println(tmp);
	}

}


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

using namespace std;

int main()
{
    long long k, a, b; cin >> k >> a >> b;
    
    if (a >= b - 2)
    {
        cout << k + 1;
        return 0;
    }
    
    long long cnt = 1;
    
    cnt += min(k, a - 1);
    k -= min(k, a - 1);
    
    if (k == 0) 
    {
        cout << cnt;
        return 0;
    }
    
    if (k % 2 == 0)
    {
        cout << cnt + (k / 2) * (b - a);
    }
    else 
    {
        cout << cnt + (k / 2) * (b - a) + 1;
    }
    
    return 0;
}
    
    

Measured memory_bytes: 256
import std.stdio : readln , chomp, writeln;
import std.string : split;
import std.conv : to;

const int MAX_N = 1000;
const int MAX_W = 1000;

int W;
int N;
int[] value;
int[] weight;

int[2] solve()
{
	// ref がなかった気をつけて
	foreach(ref i; done){ i[] = false; }
	search(0, W);
	int[2] res = [memo[0][W], note[0][W]];
	return res;
}

bool[MAX_W+1][MAX_N] done;
int[MAX_W+1][MAX_N] memo; // 価値の総量(best版)
int[MAX_W+1][MAX_N] note; // 重さの総量(同上)
int search(int i, int w)
{
	if(i==N){return 0;}
	if(done[i][w])return memo[i][w];
	int[] res = [search(i+1, w), w<weight[i] ? 0 : search(i+1, w-weight[i])+value[i]];
	int max = res[0]>=res[1] ? 0 : 1;
	int one = max==0 ? 0 : weight[i];
	done[i][w] = true;
	memo[i][w] = res[max];
	note[i][w] = i+1>=N ? one : note[i+1][w - one] + one;
	return res[max];
}

void main()
{
	io();
}

void io()
{
	int num = 0;
	while(true){
		W = readln().chomp().to!int();
		if(W==0)break;
		N = readln().chomp().to!int();
		value = new int[N];
		weight = new int[N];
		foreach(i; 0..N){
			string[] str = readln().split(",");
			value[i] = str[0].chomp.to!int();
			weight[i] = str[1].chomp.to!int();
		}
		writeln("Case ",++num,":");
		int[2] res = solve();
		writeln = res[0];
		writeln = res[1];
	}
}

Measured memory_bytes: 11044
a, b = map(int, input().split())

cnt = 1
tmp = 0
ans = 0
while True:
    if b == 1:
        print(ans)
        exit()
    if cnt >= 2:
        tmp += a - 1
    else:
        tmp += a
    cnt += 1
    ans += 1
    if tmp >= b:
        break

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define PI_INT 3.14159265358979323846
#define PI acos(-1.0)
#define LL long long
#define N 100000007
#define MOD 10000007
#define MX numeric_limits<long long>::max();
#define MN numeric_limits<long long>::min();
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define FILL(v, n) fill(v.begin(), v.end(), n);
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define PRINT(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define SCAN(v) for(int i=0; i<n; i++) { int temp; cin>>temp; v.push_back(temp); }
#define SORT(v) sort(v.begin(), v.end());

using namespace std;

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

    if(n%2==0)
        printf("0.5000000000\n");
    else
    {
        double temp=(n+1)/2.0;

        double ans=temp/n;

        printf("%0.10f\n", ans);
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    V<int>a(n);
    for(int i=0;i<n;i++){
        a[i]=i+1;
    }
    do{
        for(int i=0;i<n;i++){
            cout<<a[i];
            if(i<n-1)cout<<" ";
        }
        cout<<endl;
    }
    while(next_permutation(all(a)));
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------















































Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        while (in.hasNext()) {
            double xa = nd(in), ya = nd(in), xb = nd(in), yb = nd(in), //
                    xc = nd(in), yc = nd(in), xd = nd(in), yd = nd(in);
            double vabx = xb - xa, vaby = yb - ya;
            double vcdx = xd - xc, vcdy = yd - yc;
            double naiseki = vabx * vcdx + vaby * vcdy;
            String ans = Math.abs(naiseki) < 1e-10 ? "YES" : "NO";

            System.out.println(ans);
        }
    }

    private static double nd(Scanner in) {
        return in.nextDouble();
    }
}

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

bool m[5000][5];
int h[5];
int sum;

bool check(int a) {
  int i, j;
  for (i=0; i<5; i++) {
    if (!m[a][i]) break;
  }
  if (i != 5) return false;
  for (i=0; i<5; i++) {
    j = a;
    while (j < h[i]) {
      m[j][i] = m[j+1][i];
      ++j;
    }
    j = h[i]-1;
    while (j>=0 && !m[j][i]) {
      --j;
    }
    h[i] = j+1;
  }
  return true;
}

int main() {
  int n, d, p, q, mh;
  while (1) {
    cin >> n;
    if (!n) break;
    sum = 0;
    for (int i=0; i<5*n; i++) {
      for (int j=0; j<5; j++) {
        m[i][j] = false;
      }
    }
    for (int i=0; i<5; i++) {
      h[i] = 0;
    }
    for (int i=0; i<n; i++) {
      cin >> d >> p >> q;
      --q;
      sum += p;
      if (d == 1) {
        mh = 0;
        for (int j=0; j<p; j++) {
          if (mh < h[j+q]) {
            mh = h[j+q];
          }
        }
        for (int j=0; j<p; j++) {
          m[mh][j+q] = true;
          h[j+q] = mh+1;
        }
        if (check(mh)) sum -= 5;
      } else {
        mh = h[q];
        for (int j=0; j<p; j++) {
          m[j+mh][q] = true;
        }
        h[q] += p;
        for (int j=p-1; j>=0; j--) {
          if (check(j+mh)) sum -= 5;
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}

int main(){
	Speed_UP
	ll t;
	t=1;
  while(t--){
      string s;
      cin>>s;
      ll ans=0;
      for(int i=0;i<sz(s);i++){
        ans+=s[i]-'0';
      }
      if(ans%9==0)
        cout<<"Yes";
      else
        cout<<"No";
		
		
		
	}





}


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

typedef long long ll;

const ll MOD=1000000007;

int n;
map<string,ll> dp[105];
set<string> agc;
string cs;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    agc.insert("AGC");
    //A*GC
    agc.insert("AAGC");
    agc.insert("ACGC");
    agc.insert("AGGC");
    agc.insert("ATGC");
    //AG*C
    agc.insert("AGAC");
    agc.insert("AGCC");
    agc.insert("AGGC");//
    agc.insert("AGTC");
    //AGC*
    agc.insert("AGCA");
    agc.insert("AGCC");//
    agc.insert("AGCG");
    agc.insert("AGCT");
    //*AGC
    agc.insert("AAGC");//
    agc.insert("CAGC");
    agc.insert("GAGC");
    agc.insert("TAGC");
    //ACG*
    agc.insert("ACGA");
    agc.insert("ACGC");//
    agc.insert("ACGG");
    agc.insert("ACGT");
    //*ACG
    agc.insert("AACG");
    agc.insert("CACG");
    agc.insert("GACG");
    agc.insert("TACG");
    //GAC*
    agc.insert("GACA");
    agc.insert("GACC");
    agc.insert("GACG");//
    agc.insert("GACT");
    //*GAC
    agc.insert("AGAC");//
    agc.insert("CGAC");
    agc.insert("GGAC");
    agc.insert("TGAC");

    agc.insert("ACG");
    agc.insert("GAC");

    cs="ACGT";

    cin>>n;
    if(n==1){
        cout<<4<<endl;
        return 0;
    }
    if(n==2){
        cout<<16<<endl;
        return 0;
    }
    if(n==3){
        cout<<61<<endl;
        return 0;
    }
    for(int c1=0;c1<4;c1++){
        for(int c2=0;c2<4;c2++){
            for(int c3=0;c3<4;c3++){
                for(int c4=0;c4<4;c4++){
                    string s,fs;
                    s+=cs[c1];
                    s+=cs[c2];
                    s+=cs[c3];
                    s+=cs[c4];
                    if(!agc.count(s)){
                        dp[4][s]=1;
                    }
                }
            }
        }
    }
    for(int i=5;i<=n;i++){
        for(int c1=0;c1<4;c1++){
            for(int c2=0;c2<4;c2++){
                for(int c3=0;c3<4;c3++){
                    for(int c4=0;c4<4;c4++){
                        string s;
                        s+=cs[c1];
                        s+=cs[c2];
                        s+=cs[c3];
                        s+=cs[c4];
                        if(agc.find(s)==agc.end()){
                            for(int fc=0;fc<4;fc++){
                                string fs;
                                fs+=cs[fc];
                                fs+=cs[c1];
                                fs+=cs[c2];
                                fs+=cs[c3];
                                if(agc.find(fs)==agc.end()){
                                    dp[i][s]+=dp[i-1][fs];
                                    dp[i][s]%=MOD;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    ll ans=0;
    for(map<string,ll>::iterator it=dp[n].begin();it!=dp[n].end();it++){
        ans+=it->second;
    }
    cout<<(ans%MOD)<<endl;

    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    
    int a, b;
    vector<vector<int>> to(100005);
    rep(i,m) {
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    vector<int> dep(n,1001001001);
    vector<int> dir(n);
    queue<int> q;
    dep[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int i = q.front();
        q.pop();
        for(int j : to[i]) {
            if(dep[j] > dep[i] + 1) {
                dep[j] = dep[i] + 1;
                dir[j] = i;
                q.push(j);
            }
            else if(dep[j] > dep[i] + 1) {
                dep[j] = dep[i] + 1;
                dir[j] = i;
                q.push(j);
            }
        }
    }
    
    cout << "Yes" << endl;
    rep(i,n) {
        if(i == 0)
            continue;
        cout << dir[i] + 1 << endl;
    }
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin()  ;v.end()
#define endl "\n";

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll n, k;
ll res = 0;
vector<int> v;

void p(int i = 1, int pre = k) {
    if (!pre) {
        int cnt = 0;
        for (int i : v)cnt = gcd(cnt, i);
        res += cnt;
        return;
    }
    // cout<<pre;
    for (int j = i; j <= n; ++j) {
        v.push_back(j);
        p(i, pre - 1);
        v.pop_back();
    }
}

ll mod = 1e9 + 7;

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

    ll dp[100005] = {0};
    ll ans = 0;
    for (int i = n; i > 0; --i) {
        ll now = 0;
        for (int j = i * 2; j <= n; j += i) {
            now += dp[j];
            now %= mod;

        }
        dp[i]=(binpow(n/i,k,mod)+mod-now)%mod;
        ans+=dp[i]*i;
        ans%=mod;
    }
    cout << ans  << " ";

    return 0;
}


Measured memory_bytes: 4400
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )

using namespace std;

int main(void) {

	int A, B;

	scanf("%d %d", &A, &B);

	int ans = max(A + B, A - B);
	ans = max(ans, A * B);

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if(x>=r && x+r<=W && y>=r && y+r<=H){
	printf("Yes\n");
    }else{
	printf("No\n");
    }
    return 0;
    }


Measured memory_bytes: 2104
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; ++i){
			a[i] = sc.nextInt();
		}

		Map<Integer , Integer> m = new HashMap<Integer , Integer>();
		for(int i : a){
			m.put(i , m.containsKey(i) ? m.get(i) + 1 : 1);
		}

		int sum = 0;

		for(int k : m.keySet()){
			int v = m.get(k);
			if(v > k){
				sum +=  (v-k);
			}else if(v < k){
				sum += v;
			}
		}

		System.out.println(sum);
	}
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int N, n = 0, minn;
  minn = t.size();
  N = s.size() - t.size() + 1;
  for ( int i = 0; i < N; i++) {
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i + j) != t.at(j)) {
        n++;
      }
    }
    if (n < minn) {
      minn = n;
    }
    n = 0;
    if ( minn == 0) {
      break;
    }
  }
  cout << minn << endl;
}

Measured memory_bytes: 3628
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,c,k,a[1 << 17],ans;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> c >> k;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}
	sort(a + 1,a + 1 + n);
	int lst = c;
	int lstt = a[1] + k;
	int ans = 1;
	for(int i = 1;i <= n;i++)
	{
		if(lst < i || lstt < a[i])
		{
			ans++;
			lst = i + c - 1;
			lstt = a[i] + k;
		}
	}
	rc(ans);
}

Measured memory_bytes: 640
let input_int_array n =
  Array.init n (fun _ -> Scanf.scanf "%d " (fun v -> v))

let () =
  let n = read_int ()
  in let cards = input_int_array n
  in Array.sort Pervasives.compare cards;
  Array.fold_left (fun (v,i) c ->
    (if i mod 2 = 0 then v+c else v-c), i+1
  ) (0,0) cards
  |> (fun (u,_) -> abs u)
  |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int ans =0;
   int temp=0;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T')
       {
           ans = max(ans,temp);
           temp=0;
       }
       else
       {
           temp++;
       }
   }
   cout<<max(ans,temp)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans1 = a*c;
    ll ans2 = a*d;
    ll ans3 = b*c;
    ll ans4 = b*d;
    ll ans;
    ans = max({ans1, ans2});
    ans = max({ans, ans3});
    ans = max({ans, ans4});
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n, a, b;
    std::cin >> n >> a >> b;

    /* std::cout << (pow_mod(2, n, mod) - nCr_mod(n, a) - nCr_mod(n, b) + mod - 1) % mod << std::endl; */
    long long ans = pow_mod(2, n, mod) - nCr_mod(n, a) - nCr_mod(n, b) - 1;
    ans %= mod;
    if (ans < 0) {
        ans += mod;
    }

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


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int m,n;

int main(){
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long long int N = 0, sum = 0;
	scanf("%lld", &N);
	for(int i = 0; i <= N; i++){
		if(i % 3 != 0 && i % 5 != 0){
			sum += i;
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1724
N = int(input())
D1 = [0] * N
D2 = [0] * N
for n in list(range(N)):
    D1[n], D2[n] = map(int, input().split())

ans = 'No'
for i in list(range(N - 2)):
    if D1[i] == D2[i] and D1[i + 1] == D2[i + 1] and D1[i + 2] == D2[i + 2]:
        ans = 'Yes'
        break

print(ans)


Measured memory_bytes: 8996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int n, d;
    cin(n); cin(d);

    vector<vector<int>> x(n, vector<int>(d));
    rep2(i, n) {
        rep2(j, d) cin(x[i][j]);
    }

    int result = 0;
    rep2(i, n) {
        rep3(j, i + 1, n) {
            int sum = 0;
            rep2(k, d) {
                sum += pow(x[j][k] - x[i][k], 2);
            }
            if (floor(pow(sum, 0.5)) == pow(sum, 0.5)) ++result;
        }
    }

    print(result);
    return 0;
}

Measured memory_bytes: 4060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

int main(void)
{
    string s;
    int i;

    cin >> s;

    rep(i, 0, s.size())
    {
        if (i % 2 == 1 && s[i] == 'R')
        {
            cout << "No" << endl;
            return 0;
        }
        else if (i % 2 == 0 && s[i] == 'L')
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
int a[111111];
int main()
{
  int n,ans=0,p=66;
  bool f=false;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    p++;
    if(a[i]==i){
      ans++;
      if(f)
        ans--;
      else{
        f=true;
        p=0;
      }
    }
    if(p==1)
      f=false;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end(),greater<int>());
    ll sum = 0;
    for(int i=K; i<N; i++){
        sum += A[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int>P;

#define INF 2ll<<60ll
#define F first
#define S second

int main(){
  int n;
  int temp=0,sum=0;
  int a[100005];
  int x[100005];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  
  for(int i=1;i<n;i+=2){
    temp+=a[i]*2;
  }
  x[0]=sum-temp;
  
  for(int i=1;i<n;i++){
    x[i]=2*a[i-1]-x[i-1];
  }

  for(int i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n",x[i]);
    }else{
      printf("%d ",x[i]);
    }
  }
  
  return (0);
}


Measured memory_bytes: 2048
/*
  AtCoder Beginner Contest 102
  B - Maximum Difference
*/

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int N;
int minval, maxval;

int main() {
  scanf("%d", &N);

  minval = 1000000001, maxval = -1;
  int buf;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &buf);
    if (buf < minval) minval = buf;
    if (buf > maxval) maxval = buf;
  }

  printf("%d\n", maxval - minval);  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const double PI = 3.14159265358979;
const ll INF =  1e15 + 7;
const ll MOD = 998244353;
const ll nax = 500010;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		string s;
		cin >> s;
		int n = s.length();
		for (int i = 0; i < n; i++) {
			if (s[i] == '?') {
				s[i] = 'D';
			}
		}
		cout << s;
	}
	return 0;
}




















Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll n;
ll minn=LLONG_MAX;


int main(){
FLASH;
cin>>n;
for(ll i=1;i*i<=n;i++)
{
  if(n%i==0)
  {
	ll one=i;
	ll two=n/i;
	
	minn=min(minn,abs(1-one)+abs(1-two));
	  
  }	
}

cout<<minn<<endl;






return 0;
} 


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int cnt=0;
    for (int i=100;i>0;i--){
        if (A%i==0 && B%i==0){
            cnt++;
            if (cnt==K){
                cout << i;
                return 0;
            }
        }
    }
}

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

using namespace std;

#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define int long long
#define INF 99999999

signed main()
{
	while (1){
		int a, b, c, d, e, na, nb, nc;
		cin >> a >> b >> c >> d >> e >> na >> nb >> nc;

		if (!(a || b || c || d || e))break;

		int ans = (na*a+nb*b+nc*c);

		REP(i, na + nb + nc+1){
			int C = min(i, nc);
			int B = min(i - C, nb);
			int A = min(i - B - C, na);
			int D = max(i, d);
			if (!i)D = 0;
			ans = min(ans, (nc - C)*c + (nb - B)*b + (na - A)*a + D*e);
			//cout << i << ":" << ans << endl;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
n = gets.to_i
a = gets.split.map(&:to_i)

ans = 0

f = true
prev = a[0]
(n-1).times{|i|
  if prev==a[i+1] && f
    ans += 1
    f = false
  else
    f = true
  end
  prev = a[i+1]
}

p ans

Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) { // n が 0 になるまで
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main()
{
	int a, b;
	cin >> a >> b;
	int counter = 0;
	for (int i = a; i <= b; i++) {
		if (i % 10 == (i / 10000) % 10 && (i / 10) % 10 == (i / 1000) % 10) counter++;
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
// C++ program to Find Number of digits 
// in base b. 
#include <iostream> 
#include <math.h> 
using namespace std; 

// function to print number of 
// digits 
void findNumberOfDigits(long n, int base) 
{ 
	// Calculating log using base 
	// changing property and then 
	// taking it floor and then 
	// adding 1. 
	int dig = (int)(floor( log(n) / 
						log(base)) + 1); 
	
	// printing output 
	cout<< dig; 
} 

// Driver method 
int main() 
{ 
	int n; cin>>n;
  	int k; cin>>k;
  	findNumberOfDigits(n,k);
  
	
	return 0; 
} 

// This code is contributed by Manish Shaw 
// (manishshaw1) 


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

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

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

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

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

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    LL ans = 0;
    vector<string> ss, ss2;
    REP(i,0,1<<n) {
        string a,b;
        REP(j,0,n) {
            if (i & (1 << j)) a += s[j];
            else b += s[j];
        }
        //reverse(all(b));
        ss.push_back(a + " " + b);
    }
    REP(i,0,1<<n) {
        string a,b;
        REP(j,0,n) {
            if (i & (1 << j)) a += s[j+n];
            else b += s[j+n];
        }
        reverse(all(b));
        reverse(all(a));
        ss2.push_back(a + " " + b);
    }
    sort(all(ss2));
    for (auto &s1: ss) {
        //cerr << s1 << endl;
        //cerr << upper_bound(all(ss2), s1) - lower_bound(all(ss2), s1) << endl;
        ans += upper_bound(all(ss2), s1) - lower_bound(all(ss2), s1);
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 41328
#include <cstdio>
#include <cmath>

constexpr int INSUU = 128;
constexpr int SOSUU = 100000;

int Eratosthenes(int* primes){
  primes[0] = 2;
  primes[1] = 3;
  primes[2] = 5;
  primes[3] = 7;
  int prime_p = 4;
  for(int p = 11; p <= SOSUU; p+=2){
    bool is_prime = true;
    for(int i = 0; i < prime_p; i++){
      if((p % primes[i]) == 0){
	is_prime = false;
	break;
      }
    }
    if(is_prime){
      primes[prime_p++] = p;
    }
  }
  return prime_p;
}

int main(){
  int primes[SOSUU];
  int prime_count = Eratosthenes(primes);
  int insuus[INSUU];
  int insuu_count = 0;
  int n;
  scanf("%d", &n);
  if(n <= 2){
    printf("0\n"); return 0;
  }
  int c = n;
  for(;;){
    bool c_is_prime = true;
    for(int i = 0; i < prime_count; i++){
      if((c % primes[i]) == 0){
  	insuus[insuu_count++] = primes[i];
  	c /= primes[i];
  	c_is_prime = false;
  	break;
      }
    }
    if(c == 1) { break; }
    if(c_is_prime){
      insuus[insuu_count++] = c;
      break;
    }
  }

  int mult = 1;
  int last = 0;
  for(int i = 1; i < insuu_count; i++){
    if(insuus[i] != insuus[last]){
      mult *= pow(insuus[last], i-last) - pow(insuus[last], i-last-1);
      last = i;
    }
  }
  mult *= pow(insuus[last], insuu_count-last) - pow(insuus[last], insuu_count-last-1);
  printf("%d\n", mult);
}

Measured memory_bytes: 1096
#include<bits/stdc++.h>
using namespace std;
int a[111111];
int ans=0;
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
  	cin>>a[i];
  }
  int p=0;
  for(int i=n-1;i>0;i--)
  {
  	if(a[i]<=a[i-1])
  	  p++,ans=max(ans,p);
  	else
  	  p=0;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 640