akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

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

bool prime_number(int n){
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   double a,b,x=0,y=0,rad;
   char c;
   
   while(1){
      cin >> a >> c >> b;
      if(a+b==0) break;
      x+=a*cos(M_PI*rad/180);
      y+=a*sin(M_PI*rad/180);      
      rad-=b;
      //cout << x << endl;
      //cout << y << endl;
      //cout << rad << endl;
   }
   int ai, bi;
   ai=x; bi=y;
   cout << -bi << endl;
   cout << ai << endl;
   
   return 0;
}

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

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

    string sub_s = "";
    for (int i = s.size() - 1; i >= 0; i--) {
        sub_s.insert(sub_s.begin(), s[i]);
        if (sub_s == "dream" || sub_s == "dreamer" || sub_s == "erase" ||
            sub_s == "eraser") {
            sub_s = "";
        }
    }

    string msg;
    if (sub_s == "") {
        msg = "YES";
    } else {
        msg = "NO";
    }

    cout << msg << endl;

    return 0;
}


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

int main () {
  vector<int> num(3);
  for (int i=0;i<3;i++) cin >> num [i];

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

  if (num[0]==5 && num[1]==5 && num[2]==7) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int a;
    cin>>a;
    double x;
    x = 0.0;
    for(int i = 1;i <= a;i++) {
        if(i % 2 == 1)
            x += 1.0;
    }
    cout<<x/a<<endl;

    return 0;
}





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

int main() {
	int week;
	cin >> week;
	int debt = 100;
	while (week--)
	{
		debt = ((debt * 105) / 100) + ((debt % 20) > 0 ? 1 : 0);
	}
	cout << debt * 1000 << endl;

	return 0;
}

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

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;

    int ans = 0;
    const int max = std::max({A, B, C});
    const int sum = A + B + C;
    if ((sum % 2 == 0 && max % 2 == 0) || (sum % 2 != 0 && max % 2 != 0)) {
        ans = (max * 3 - sum) / 2;
    } else {
        ans = ((max + 1) * 3 - sum) / 2;      
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
int n;
ll x;
cin >> n>>x;
ll a[n],sum=0,cnt=0;
bool flag=true;
for(int i=0;i<n;i++) {
  cin >>a[i];
  sum+=a[i];
  if(a[i]<=x) flag=false;
}
if(flag){
  cout << 0<<endl;
  return 0;
}
if(sum==x) {
  cout << n<<endl;
  return 0;
}
if(sum<x){
   cout<< n-1<<endl;
   return 0;
}
if(sum>x){
  sort(a,a+n);
  for(int i=0;i<n;i++){
    cnt+=a[i];
    if(i==0){
    if(cnt==x) {
      cout << 1<<endl;
      return 0;
    }
  }
  else{
    if(cnt==x) {
      cout << i+1<<endl;
      return 0;
    }
    if(cnt>x) {
      cout << i<<endl;
      return 0;
    }
  }
  }
}
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int b, c;
    ll a, ans = 1;
    scanf("%lld %d.%d", &a, &b, &c);
    ans = a * b + a * c / 100;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <cstring>

using namespace std;

#define N 10001

char s[N];

struct node
{
	int x;
	int count;
}a[N];
int p;

char *key[10]={" ", "',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ"};

int main()
{

	while(scanf("%s",s)!=EOF)
	{
		p=0;
		int len=strlen(s);
		int i,j,temp=1;;
		char pre=s[0];
		for(i=1;i<len;i++)
			if(pre!=s[i])
			{
				a[p].x=pre-'0';
				if(a[p].x==1)
				a[p].count=(temp-1)%5;
				else if(a[p].x==0)
					a[p].count=temp-1;
				else if(a[p].x==7 || a[p].x== 9)
					a[p].count=(temp-1) % 8;
				else
					a[p].count=(temp-1)%6;

				temp=1;
				p++;
				pre=s[i];
			}
			else
				temp++;

				a[p].x=pre-'0';
				if(a[p].x==1)
				a[p].count=(temp-1)%5;
				else if(a[p].x==0)
					a[p].count=temp-1;
				else if(a[p].x==7 || a[p].x== 9)
					a[p].count=(temp-1) % 8;
				else
					a[p].count=(temp-1)%6;
			
			temp=1;
				p++;


			for(i=0;i<p;i++)
				if(a[i].x==0)
					for(j=0;j<a[i].count;j++)
						printf(" ");
					else
						printf("%c",key[a[i].x][a[i].count]);

					printf("\n");
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = sc.nextInt();

        if (x == 1 || x == 2 * N - 1) {
            out.println("No");
            out.flush();
            return;
        }

        out.println("Yes");
        if (N == 2) {
            for (int i = 1, n = 2 * N; i < n; ++i) {
                out.println(i);
            }
        } else {
            if (x > N) {
                for (int i = N; i < N * 2; ++i) {
                    if (i != x) {
                        out.println(i);
                    }
                }
                out.println(x);
                for (int i = 1; i < N; ++i) {
                    if (i != x) {
                        out.println(i);
                    }
                }
            } else {
                for (int i = N + 1; i < N * 2; ++i) {
                    if (i != x) {
                        out.println(i);
                    }
                }
                out.println(x);
                for (int i = 1; i < N + 1; ++i) {
                    if (i != x) {
                        out.println(i);
                    }
                }
            }
        }
        out.flush();
    }
}

Measured memory_bytes: 24824
#include <stdio.h>

bool vis[3000];
long long cnt[3000];
const long long MOD=1000000007;

int n;

int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++) {
		int num=i;
		for(int j=2;j<num;j++) {
			if(num%j==0) {
				cnt[j]+=1;
				num/=j;
				j--;
			}
		}
		if(num>1) 
			cnt[num]++;
	}

	long long res=1;
	for(int i=1;i<=n;i++) {
		if(cnt[i]) {
			res*=(cnt[i]+1);
			res%=MOD;
		}
	}

	printf("%lld\n",res);

	return 0;
}

Measured memory_bytes: 128
import java.util.*;
//https://atcoder.jp/contests/abc104/tasks/abc104_c

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int R = Integer.parseInt(sc.next());
        sc.close();

        if (R<1200) {
            System.out.println("ABC");
        } else if (R<2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 21844
n,w = map(int,input().split())
dp = [0]*(w+1) # DPテーブルの作成
v = []
W = []
for i in range(n):
    v_,w_ = map(int,input().split())
    v.append(v_)
    W.append(w_)
for i in range(n):
    for j in range(W[i],w+1):
        if j >= W[i]:
            a = j // W[i]
            dp[j] = max(dp[j],dp[j-W[i]]+v[i])
        else:
            dp[j] = dp[j]
print(dp[w])



Measured memory_bytes: 5724
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = sorted([a, b, c, d, e], key=lambda x: x % 10)

ans = 0
flag = False
for i in range(len(l)):
    if l[i] % 10 == 0:
        ans += l[i]
    elif flag == False:
        ans += l[i]
        flag = True
    else:
        ans += l[i]
        ans += 10 - l[i] % 10
print(ans)

'''
ans = 10**18
for v in itertools.permutations([a, b, c, d, e], 5):
    m = 0
    for i in range(len(v)):
        m += v[i]
        if i == len(v)-1:
            break
        if v[i] % 10 != 0:
            m += 10 - v[i] % 10
    ans = min(ans, m)
print(ans)

'''
# 全ての順列を計算する、最後の値は１０の余りを加算しない。


Measured memory_bytes: 3064
N, K, Q = map(int, input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())
list = [K-Q] *N
for i in range(Q):
  list[A[i]-1] += 1
for i in range(N):
  if list[i] >= 1:
    print('Yes')
  else:
    print('No')
  

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> snuke(n);
  int ans = n;
  rep(i,k){
    int d;
    cin >> d;
    rep(j,d){
      int a;
      cin >> a;
      if(snuke.at(a-1) == 0){
        snuke.at(a-1) ++;
        ans --;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long a = l[0], b = l[1], c = l[2];

        var d = c - a - b;
        Console.WriteLine(d > 0 && d * d > 4 * a * b ? "Yes" : "No");
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

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

    string S, T;
    cin >> S >> T;

    string ans = "";
    REP(i,N){
        ans += S[i];
        ans += T[i];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	int n;
	cin>>n;
	cout<<(n+(pow(n,2))+(pow(n,3)));
	//cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 4120
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<int> p(n),q(n),r(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    rep(i,n) r[i]=i+1;
    int pi=0,qi=0;
    int cnt=0;
    do {
        bool pflag=1,qflag=1;
        rep(i,n) {
            if (p[i]!=r[i]) pflag=0;
            if (q[i]!=r[i]) qflag=0;
        }
        if (pflag) pi=cnt;
        if (qflag) qi=cnt;
        ++cnt;
    } while (next_permutation(r.begin(), r.end()));
    cout << abs(pi-qi) << endl;

    return 0;
}

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

int main(){
  while(1){
    string str;
    cin >> str;
    if(str == "0") break;
    int sum = 0;
    for(int i = 0;i < str.size();i++){
      sum += str[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int H, N;
	cin >> H >> N;
	string ans = "No";
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		H -= A;
		if (H <= 0) {
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;
    while (cin >> s) {
        string ans = "";
        for (int i=0; i<(int)s.size(); ++i) {
            if (s[i] == '@') {
                for (int j=s[i+1]-'0'; j>0; --j) {
                    ans += s[i+2];
                }
                i += 2;
            } else {
                ans += s[i];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i=1;
   for(i=1;;i++)
    {
        int x;
        scanf("%d",&x);
        if(x==0)
            break;
        printf("Case %d: %d\n",i,x);
    }
    return 0;
}


Measured memory_bytes: 3212
o,x,b;
main(a){
  for(scanf("%d");~scanf("%s",&a);o=o==3?b=x=!printf("%d\n",x):o)
      for(a%=9,a-8?b=b*2+1,x+=b/8,b&=7:o++;a<7&b;b/=2)x++;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <list>

#define MAX (100000)

using namespace std;

int Q[MAX];
int head, tail;

void initialize(){
    head = 0;
    tail = 0;
}

bool isEmpty(){
    return head == tail;
}

bool isFull(){
    return head == (tail + 1) % MAX;
}

void enqueue(int x){
    if(isFull()){
        //error
    }
    Q[tail] = x;
    if(tail + 1 == MAX){
        tail = 0;
    }else{
        tail++;
    }
}

int dequeue(){
    if(isEmpty()){
        //error
        return -1;
    }
    int x = Q[head];
    if(head + 1 == MAX){
        head = 0;
    }else{
        head++;
    }
    return x;
}

int main(void){
    int n, q;
    cin >> n >> q;
    
    list<string> process; //process_name
    std::list<std::string>::iterator itr;
    string name;
    int time[n];
    
    for(int i = 0; i < n; i++){
        cin >> name >> time[i];
        process.push_back(name);
    }
    
    initialize();
    
    for(int i = 0; i < n; i++){
        enqueue(time[i]);
    }
    
    int current_time = 0;
    while(1){
        itr = process.begin();
        int now = dequeue();
        if(now == -1){
            break;
        }
        if(now - q <= 0){
            current_time += now;
            cout << *itr << " " << current_time << endl;
            process.erase(itr);
        }else{
            current_time += q;
            now -= q;
            enqueue(now);
            process.push_back(*itr);
            process.erase(itr);
        }
    }
    
}


Measured memory_bytes: 7640
import math

n, m = map(int, input().split())
x = 0
y = 0
if n >= 2:
    x = math.factorial(n) // ((math.factorial(n-2))*2)
elif n <= 1:
    x = 0
if m >= 2:
    y = math.factorial(m) // ((math.factorial(m-2))*2)
elif m <= 1:
    y = 0
print(x + y)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const ll INF = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];

void input() {
    cin >> N >> M >> L;
    for(int i = 1; i <= M; i++) cin >> A[i] >> B[i] >> C[i];
    cin >> Q;
    for(int i = 1; i <= Q; i++) cin >> s[i] >> t[i];
}

void solve() {
    input();
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return;
}

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

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

vector<vector<ll>> c;
ll mod = 1e9+7;

ll comb(ll n, ll m){
    if(n<m) return 0;
    if(c[n][m] != -1){
        return c[n][m];
    }

    if(n==m || m==0){
        return c[n][m] = 1;
    }else{
        return c[n][m] = (comb(n-1,m-1) + comb(n-1,m))%mod;
    }
}

int main(){
    ll N, K;  cin >> N >> K;

    c.resize(N, vector<ll>(N,-1));
    for(ll i=1; i<=K; i++){
        ll tmp = (comb(N-K-1,i) + 2*comb(N-K-1,i-1))%mod;
        if(i>=2) tmp = (tmp + comb(N-K-1,i-2))%mod;

        if(N-K-1>=0){
            cout << comb(K-1,i-1)*tmp%mod << endl;
        }else if(i==1){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }

    }

}


Measured memory_bytes: 31744
# -*- coding: utf-8 -*-
S = input()
ans = 0
for i in range(len(S)):
  if S[i] == "R":
    if ans == 0:
      ans += 1
    else:
      if i > 0 and S[i] == S[i-1] == "R":
        ans += 1
print(ans)

Measured memory_bytes: 61560
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for k in b:
    i=bisect.bisect_left(a,k)
    j=bisect.bisect_right(c,k)
    if 0<i and j!=len(c):
        ans+=i*(n-j)
print(ans)

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

int main(){
    string s , t ;
    cin >> s >> t ;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    for(int i=0;i<min(s.size(),t.size());i++){
        if ( s[i] > t[i] ){
            cout << "No" << endl;
            return 0 ;
        }
        else if ( t[i] > s[i] ){
            cout << "Yes" << endl;
            return 0 ;
        }
    }
    if ( s.size() < t.size() ){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,p,q,a=0,b=0;cin>>n>>q;
  while(--n){
    p=q;cin>>q;
    if(p>=q)a++;
    else a=0;
    b=max(b,a);
  }
  cout<<b;
}

Measured memory_bytes: 256
/*
🧡 QMsh 🧡
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MOD = (int)1e9 + 7;

int ans = 0;
int cnt[26];

void rec(int l, int ansv)
{
    if (l == 26)
    {
        ans = (ans + ansv) % MOD;
        return;
    }
    rec(l + 1, ansv);
    rec(l + 1, (ll)(ansv) * cnt[l] % MOD);
}

signed main()
{
#ifdef POSPELOV
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    string s;
    cin >> n >> s;

    for (char c : s)
        cnt[c - 'a']++;

    int ans = 1;
    for (int i : cnt)
        ans = ((ll)ans * (i + 1)) % MOD;

    cout << ans - 1;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<int> V(N,N); // 縦の壁
	vector<int> H(N,N); // 横の壁
	int Ci, Cj; // 角の白石の座標
	Ci = N;
	Cj = N;
	ll b = ((ll)(N-2))*((ll)(N-2)); // 黒の石の数

	for(int q = 0; q < Q; q++){
		int sw,x;
		cin >> sw >> x;
		if(sw == 1){
			// 下向き
			if(x < Cj){
				b -= Ci - 2;
				for(int j = x + 1; j < Cj; j++) {H[j] = Ci; }
				Cj = x;
				H[x] = 1;
			}else{
				b -= H[x] - 2;
				H[x] = 1;
			}
		}else{
			// 右向き
			if(x < Ci){
				b -= Cj - 2;
				for(int i = x + 1; i < Ci; i++) {V[i] = Cj; }
				Ci = x;
				V[x] = 1;
			}else{
				b -= V[x] - 2;
				V[x] = 1;
			}
		}
	}
	cout << b << endl;
	return(0);
}


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

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


Measured memory_bytes: 256
#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>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=998244353;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int solve(){}
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int tt=1;
    //tc{

    //	cout<<"Case #"<<tt++<<": "<<solve()<<endl;
    //}
    int n,s;
    cin>>n>>s;
    v arr(n);in(arr,n);
    v dp(s+1,0);
    int ans=0;
    for(int i=0;i<n;i++)
    {
  		// v dp1=dp;
  		for(int j=s;j>=0;j--)
  		{
  			if((j+arr[i])<=s)
  			{
  				dp[j+arr[i]]+=dp[j];
  				dp[j+arr[i]]%=mod;
  			}

  		}
  		if(arr[i]<=s)
  		{
  			dp[arr[i]]+=(i+1);
  			dp[arr[i]]%=mod;
  		}
  		ans+=dp[s];
  		ans%=mod;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

    int a,b,x,y,z;
    scanf("%d %d",&a,&b);
    x=a+b;
    y=a-b;
    z=a*b;
    if((x>y)&&(x>z))
        printf("%d\n",x);
    else if((y>z))
        printf("%d\n",y);
    else
        printf("%d\n",z);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 17;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e5) return 6;
  if (x >= (long long)1e4) return 5;
  if (x >= (long long)1e3) return 4;
  if (x >= (long long)1e2) return 3;
  if (x >= (long long)1e1) return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  if (pt_in + 32 > tail_in) load();
  char c;
  bool minus = 0;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
  if (minus) x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char* s) {
  if (pt_out > buf_size - 32) flush();
  for (int i = 0; s[i] != 0; ++i) print(s[i]);
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int A[200000], B[200000];
  REP(i, N) scan(A[i]);
  REP(i, N) scan(B[N - 1 - i]);
  int ngs[200000];
  int ngp = 0;
  int ngx = -1;
  REP(i, N) {
    if (A[i] == B[i]) {
      ngs[ngp++] = i;
      ngx = A[i];
    }
  }
  int l = 0, r = N - 1, st = 0;
  REP(j, ngp) {
    int i = ngs[j];
    int target;
    if (st == 0) {
      if (A[l] != ngx && B[l] != ngx) {
        target = l++;
      } else {
        st = 1;
      }
    }
    if (st == 1) {
      if (A[r] != ngx && B[r] != ngx) {
        target = r--;
      } else {
        println("No");
        return 0;
      }
    }
    swap(B[i], B[target]);
  }
  println("Yes");
  REP(i, N) println(B[i]);
  return 0;
}

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

using namespace std;

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

#define F first
#define S second

const int MAXN = 1e3 + 10;

int n;
char c[MAXN][MAXN];

void go(int l, int r){
	int ln = r-l;
	assert(ln != 6);
	if (ln < 8){
		if (ln == 4) {
			c[l][l] = c[l][l+1] = 'a';
			c[l+1][l] = c[l+1][l+1] = 'b';
			c[l+2][l] = c[l+3][l] = 'c';
			c[l+2][l+1] = c[l+3][l+1] = 'd';
			c[l][l+2] = c[l+1][l+2] = 'e';
			c[l][l+3] = c[l+1][l+3] = 'f';
			c[l+2][l+2] = c[l+2][l+3] = 'g';
			c[l+3][l+2] = c[l+3][l+3] = 'h';
		}
		else if (ln == 5) {
			c[l][l] = c[l][l+1] = 'a';
			c[l][l+2] = c[l][l+3] = 'b';
			c[l][l+4] = c[l+1][l+4] = 'c';
			c[l+2][l+4] = c[l+3][l+4] = 'd';
			c[l+4][l+4] = c[l+4][l+3] = 'e';
			c[l+4][l+2] = c[l+4][l+1] = 'f';
			c[l+4][l] = c[l+3][l] = 'g';
			c[l+2][l] = c[l+1][l] = 'h';
			c[l+1][l+1] = c[l+2][l+1] = 'i';
			c[l+3][l+2] = c[l+3][l+3] = 'j';
		}
		else if (ln == 7){
			c[l][l+1] = c[l][l+2] = 'a';
			c[l][l+3] = c[l][l+4] = 'b';
			c[l][l+5] = c[l][l+6] = 'c';
			c[l+1][l] = c[l+2][l] = 'd';
			c[l+3][l] = c[l+4][l] = 'e';
			c[l+5][l] = c[l+6][l] = 'f';
			c[l+1][l+1] = c[l+1][l+2] = 'g';
			c[l+1][l+3] = c[l+2][l+3] = 'h';
			c[l+3][l+3] = c[l+3][l+2] = 'i';
			c[l+3][l+1] = c[l+2][l+1] = 'j';
			c[l+4][l+4] = c[l+4][l+5] = 'k';
			c[l+4][l+6] = c[l+5][l+6] = 'l';
			c[l+6][l+6] = c[l+6][l+5] = 'm';
			c[l+6][l+4] = c[l+5][l+4] = 'n';
		}
	}
	else{
		if (ln-4 != 6)
			go(l, l+r-4), go(l+r-4, r);
		else
			go(l, l+r-5), go(l+r-5, r);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	if (n == 2)
		cout << "-1\n";
	else {
		if (n == 3)
			cout << "a..\na..\n.bb\n";
		else if (n == 6)
			cout << "a.....\na.....\n.bb...\n...a..\n...a..\n....bb\n";
		else{
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					c[i][j] = '.';

			go(0, n);
			for (int i = 0; i < n; i++){
				for (int j = 0; j < n; j++)
					cout << c[i][j];
				cout << "\n";
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2176
"""
Writer: SPD_9X2
https://atcoder.jp/contests/exawizards2019/tasks/exawizards2019_d

結局はS中で最小の物以下になる
また、それ以下になったらもう変化しない

通り数を数えなくてはダメ
→0以上min(S)未満の整数kに関して、最後にkになっているのは何通りあるかを数える？

大きい方からdp

具体的には、小さい方で割ったのちに大きい方で割るのは意味がないので大きい方から見ていく
dp[i][n] = 大きい方からi番目までの中で黒板に書かれてる数字がnとなる順序数

推移は、普通に割ったあまりのとこに推移させる & 自分が最初に来た後　
O(max(X,S)*N)

→解けて無いなぁ(途中に来た場合をどうやって数え上げるんですか…)
計算量にNが2回かかってしまう…

影響のあるやつだけ考える？
大きい方から、変化のあるやつだけ取っていく。min(S)以下になったら終了。変化のない奴の位置の組み合わせは…？

N枚のカードをN個あるスロットルに入れ、右側から黒板に向けて射出していくことを考える
dp[i][j] = i枚目までスロットルに入れた時、今射出して黒板の数字がjになる置き方の組み合わせ数
とすれば、Sより大きいjに関しては割ればよいし、そうでなければそれ以降の好きなところにおいてよいので…？
→いやなんか違うな

=========解説を見た=========
https://drken1215.hatenablog.com/entry/2019/04/01/201600
dp[i][x]=
スタート時点での整数がxであるときに、最初のi個についての順列すべてを考えたときに得られる値の総和

うーん総和を直接dpしちゃうのかぁ…
小さい方から見た時に、最初以外に入れても変化しないので
dp[i+1][x] = i * dp[i][x] + dp[i][x % s[i+1]]

→小さい方から見ればよかったかぁ…あと、xをすべてdpに乗せて調べ上げるという発想はなかった…
（無意識のうちに無理だろと思ってしまっていた）


"""
mod = 10**9+7
N,X = map(int,input().split())

S = list(map(int,input().split()))
S.sort()

dp = [[ i for i in range(X+1) ] for j in range(N+1)]

for i in range(N):

    for x in range(X+1):

        dp[i+1][x] = ((i) * dp[i][x] + dp[i][x % S[i]]) % mod


print (dp[N][X])


Measured memory_bytes: 257172
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s; cin >> s;
	int n = s.size();
	if(s[n - 1] != '0' || s[0] != '1') {
		cout << "-1\n";
		return 0;
	}
	for(int i = 0; i < n - 1; i++) {
		if(s[i] != s[n - 2 - i]) {
			return cout << "-1\n", 0;
		}
	}
	auto gen = [&](int n) {
		vector<pair<int, int> > edges;
		int now = 1, tail = 1;
		for(int i = 1; i < n; i++) {
			edges.emplace_back(tail, ++now);
			if(s[i - 1] == '1') tail = now;
		}
		return edges;
	};
	auto ans = gen(n);
	for(auto &e : ans) {
		cout << e.fi << ' ' << e.se << '\n';
	}
	return 0;
}


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

using namespace std;

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 0; i < k; i++)
        cout << s << " ";
    for (int i = k; i < n; i++)
        cout << (s == (int)1e9 ? 1 : (int)1e9) << " ";
    cout << endl;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		int n = str.length;

		int a[] = new int[n];

		for (int i = 0; i < n;) {
			int r = 0;
			int l = 0;
			int now = 0;

			while (i < n && str[i].equals("R")) {
				i++;
				r++;
			}

			now = i;
			a[now - 1] = a[now - 1] + (r + 1) / 2;
			a[now] = a[now] + r / 2;

			while (i < n && str[i].equals("L")) {
				i++;
				l++;
			}
			a[now - 1] = a[now - 1] + l / 2;
			a[now] = a[now] + (l + 1) / 2;
		}

		System.out.print(a[0]);
		for (int j = 1; j < n; j++) {
			System.out.print(" " + a[j]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 57596
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

ll ans = 0;

void gcd(ll a, ll b){
  if(a<b) swap(a, b);
  //cout << a << " " << b << endl;
  if(a%b){
    ans+=(a/b)*2*b;
    //cout << ans << endl;
    gcd(a%b, b);
  }
  else{
    ans+=(a/b)*2*b; ans-=b; return;
  }
}


int main(){
  ll n, x; cin >> n >> x;
  ll b = n-x;
  ans+=n;
  gcd(x, b);
  cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

import functools

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)


N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12


ans=0
for index,item in enumerate(a):
    ans+=(calc)//item

print(int((ans)%(10**9+7)))
    



Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long

int count_one[21]={0};

void dec_digit(int a){
    rep(i,20){
        if(  (1<<i) & a){
            count_one[i]--;
        }
    }
}

bool check_digit(){
    rep(i,20){
        if(count_one[i]>1 )return false;
    }
    return true;
}

bool  check_and_up_digit( int a ){
    int new_count_one[21];
    memcpy(new_count_one, count_one, sizeof(count_one));
    // rep(i,20)new_count_one[i]= count_one[i];
    // print("hoge");
    rep(i,20){
        if(a  & (1<<i) ){
            new_count_one[i]++;
        }
    }

    rep(i,20){
        if(new_count_one[i] > 1  ){
            return false;
        }
    }
    memcpy(count_one, new_count_one, sizeof(new_count_one));
    // rep(i,20)count_one[i]= new_count_one[i];
    return true;
}

signed main(){
    
    int N;
    vector<int>A;
        
    cin>>N;
    
    int r = 0;
    int sum=0;
    ll ans= 0;
    // print("hoge");
    rep(i,N){
        int tmp;cin>>tmp;
        A.pb(tmp);
    }
    rep(l,N){
        while(r <N && (sum + A[r]) == (sum ^ A[r]) ){
            
            sum +=A[r];
            // print(sum);
            r++;
            
        }
        ans += r -l;
        if(r == l ){
            r++;
        }else{            
            // dec_digit(A[l]) ;
            sum -=A[l];
            // print(sum);
            // if(r != l+1)
            // ans++;
        }
    
    }
    print(ans);

    return 0;
}


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

struct Edge{
    int to; // 辺の行先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t),weight(w){}
};

using Graph = vector<vector<Edge>>;
vector<int> color;

void dfs(const Graph &G, int v,long long weight){
    color[v] = weight % 2;
    for( auto next_v : G[v]){
        if(color[next_v.to] == -1){
            dfs(G,next_v.to,weight + next_v.weight);
        }
    }
}

int main(){
    int N;
    cin >> N;
    Graph G(N+1);
    for(int i = 0; i < N - 1; i++){
        int from, to, weight;
        cin >> from >> to >> weight;
        G[from].push_back(Edge(to,weight));
        G[to].push_back(Edge(from,weight));
    }   

    color.assign(N + 1,-1);
    for(int v = 1; v <= N; v++){
        if(color[v] != -1) continue;
        dfs(G,v,0);
    }

    for(int i = 1; i <= N; i++){
        cout << color[i] << endl;
    }


}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n,d;
	cin >> n >> d;
	
	int ans = (n+d*2) / (d*2+1);
	
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		
		long[] x = new long[n + 1];
		for(int i = 0; i < n; i++) {
				x[i + 1] = a[i] - x[i];
		}
		long dif = x[n];
		long[] ans = new long[n];
		ans[0] = dif;
		for(int i = 1; i < n; i++) {
			ans[i] = (a[i - 1] - ans[i - 1] / 2 ) * 2;
		}
		for(int i = 0; i < n; i++) {
			out.print(ans[i] + " ");
		}
		
		out.close();
	} 

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


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

using namespace std;

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 int n;
 cin >> n;
 vector<int> C(n + 1, 0);
 for (int i = 1; i <= n; i++) {
  for (int j = i; j <= n; j += i) C[j]++;
 }
 //for (int i = 1; i < 10; i++) cout << C[i] << ' ';
 //cout << '\n';
 int ans = 0;
 for (int i = 1; i < n; i++) {
  ans += C[i];
 }
 cout << ans << '\n';
 return 0;
}


Measured memory_bytes: 7124
#include <stdio.h>

int main(void){
    int apple, piece;
    char order[50];
    
    fgets(order, 50, stdin);
    sscanf(order, "%d %d", &apple, &piece);
    
    piece += apple * 3;
    
    printf("%d\n", piece / 2);
    return 0;
}

Measured memory_bytes: 128
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto ai = readln.split.to!(short[]);

  auto k = ai.reduce!(max);
  auto bi = countingSort(ai, k);

  writeln(bi.to!(string[]).join(" "));
}

short[] countingSort(short[] ai, int k)
{
  auto ci = new int[](k + 1);

  foreach (a; ai) ++ci[a];
  foreach (i; 1..k+1) ci[i] += ci[i - 1];

  auto bi = new short[](ai.length);

  foreach_reverse (a; ai) {
    bi[ci[a] - 1] = a;
    --ci[a];
  }

  return bi;
}

Measured memory_bytes: 125092
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (string s)
{
	auto n = s.length.to !(int);
	s ~= ".?!";
	auto f = new int [3] [n + 4];
	f[1][1] = 1;
	f[2][2] = 1;
	foreach (i; 0..n)
	{
		foreach (j; 1..3)
		{
			if (f[i][j])
			{
				f[i + 3 - j][3 - j] = max
				    (f[i + 3 - j][3 - j], f[i][j] + 1);
				if (s[i - j..i] != s[i..i + j])
				{
					f[i + j][j] = max
					    (f[i + j][j], f[i][j] + 1);
				}
			}
		}
	}
	return max (f[n][1], f[n][2]);
}

void main ()
{
	string s;
	while ((s = readln.strip) != "")
	{
		writeln (solve (s));
	}
}


Measured memory_bytes: 4408
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int score = 0;
  F0R(i, S.size() - 1) {
    if (S[i] == S[i + 1]) score++;
  }
  score += K * 2;
  chmin(score, N - 1);
  cout << score;
}
#endif


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define F first
#define S second
int main()
{
    Hello
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    if(arr[0] == arr[1] && arr[1] != arr[2])
        cout << "Yes";
    else if(arr[1] == arr[2] && arr[1] != arr[0])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())

dp = [ [ 0 for i in range(3010)] for j in range(3010) ]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        else:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1])

i = len(s)-1
j = len(t)-1
ans = ""

while (i>=0 and j>=0):
    if dp[i+1][j+1] == dp[i+1][j]:
        j -= 1
    elif dp[i+1][j+1] == dp[i][j+1]:
        i -= 1
    else:
        ans = s[i] + ans
        i -= 1
        j -= 1

print(ans)

Measured memory_bytes: 120284
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main() {
    int a , b , c;
    cin >> a >> b >> c;
    if(b - a == c - b){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import collections

n = int(input())
SS = []

i = 0
j = 0
r = 0
s = 0

for k in range(n):
    k = input()
    if k == "AC":
        i += 1
    elif k == "WA":
        j += 1
    elif k == "TLE":
        r += 1
    elif k == "RE":
        s += 1

print('AC x ' + str(i))
print('WA x ' + str(j))
print('TLE x ' + str(r))
print('RE x ' + str(s))



Measured memory_bytes: 9284
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i < ll (n); i++)

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll sum=0;
    forn(i,n) cin>>a[i], sum+=a[i];
    ll ans=0;
    forn(i,n)
    {
        sum-=a[i];
        ans+=((a[i]*(sum%1000000007))%1000000007);
        ans=ans%1000000007;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  multiset<double> ms;
  
  for(int i = 0; i < n; ++i)
  {
    double x;
    cin >> x;
    ms.insert(x);
  }
  while(ms.size() != 1)
  {
    auto it = ms.begin();
    double u = *it;
    ms.erase(it);
    it = ms.begin();
    double v = *it;
	ms.erase(it);
  	ms.insert((u+v)/2);
  }
  cout << *ms.begin();
  return 0;
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

main:-
    get_number(A),
    get_number(B),
    get_number(C),
    writeln(C),
    writeln(A),
    writeln(B).


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

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

fastio _fast_io;

ll x, y;

int main() {
    cin >> x >> y;
    if (abs(x - y) <= 1)
        cout << "Brown" << endl;
    else
        cout << "Alice" << endl;

    return 0;
}


Measured memory_bytes: 3672