akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
#define rep(i,j,k) for(ll i=0;i<j;i+=k)
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	string s,t;
	cin>>s>>t;
	ll count = 0;
	for(ll i=0;i<s.length();i++) {
		if(s[i]!=t[i])
			count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3864
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    int ans = 1000000;
    for (int i = 0; i <= 101; i++) {
        bool exist = false;
        for (int j = 0; j < n; j++) {
            if (i == p[j]) {
                exist = true;
                break;
            }
        }
        if (!exist && abs(x - i) < abs(x - ans)) {
            ans = i;
        }
    }

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

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S,T;
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n[101]={0};
	int a,b;
	while(cin>>a>>b) 
	{
		fill(n,n+101,0);
		n[a]++; n[b]++;
		while(cin>>a>>b,a) 
		{
			n[a]++; n[b]++;
		}
		int odd=0;
		for(int i = 1; i < 101; ++i)
		{
			if(n[i]%2==1) odd++;
		}
		cout<<(odd==2?"OK":"NG")<<endl;
	}
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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


int main()
{
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    int ans = 2 * N;
    bool ok = true;
    int itr = 0;
    for (int i = N;i < 2 * N;i++)
    {
        string s = S.substr(i - N);
        string t = T.substr(0,2 * N - i);
        if (s == t)
        {
            ans -= s.size();
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
l = sorted(list(map(int, input().split())))
A, B, C = map(int, l)

ans = 0

while C - A >= 2:
    A += 2
    ans += 1

while C - B >= 2:
    B += 2
    ans += 1


if A == B == C:
    print(ans)
elif C - A == 1 and C - B == 1:
    ans += 1
    print(ans)
else:
    ans += 2
    print(ans)


Measured memory_bytes: 9088
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto cnt0 = new long[](N + 1);
    auto cnt1 = new long[](N + 1);
    long ans = 1;

    foreach (a; A) {
        if (a == 0) {
            cnt0[0] += 1;
        } else if (cnt0[a - 1] > 0) {
            ans = ans * (cnt0[a - 1]) % MOD;
            cnt0[a - 1] -= 1;
            cnt0[a] += 1;
        } else {
            writeln(0);
            return;
        }
        cnt1[a] += 1;
    }

    long hoge = A.map!(a => a == 0).sum;
    hoge = hoge == 1 ? 3 : 6;

    if (cnt1.map!(a => a > 3).any) {
        writeln(0);
        return;
    }

    ans = ans * hoge % MOD;
    ans.writeln;
}

Measured memory_bytes: 6104
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

string word[4] = {"dream", "dreamer", "erase", "eraser"};

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    rep(i, 4)   reverse(word[i].begin(), word[i].end());
    
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    
    bool can = true;
    for(int i = 0; i < s.size() ; ){
        bool can2 = false;
        rep(j, 4){
            int word_len = word[j].size();
            string tmp = s.substr(i, word_len);
            if(tmp == word[j]){
                can2 = true;
                i += word_len;
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else    cout << "NO" << endl;
}

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


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

    int count = 0;
    for(int i = 0; i < n; i++){
        count = count + i;

    }
    for(int i = 0; i < m; i++){
        count = count + i;
    }
    cout << count;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                    long long int
#define ull                   unsigned long long int
#define vll                   vector<long long int>
#define loop(i,a,b) 		  for(ll i=(ll)a;i<(ll)b;++i)
#define pb                    push_back
#define ii					  pair<int, int> 
#define vii					  vector<ii>
#define vvi					  vector<vector<int>> 
#define pi                    acos(-1.0)
#define MOD                   1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void f_io(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
struct Interval 
{ 
    int val, idx; 
}; 
  
// Compares two intervals according to staring times. 
bool compareInterval(Interval i1, Interval i2) 
{ 
    return (i1.val < i2.val); 
}


int main(){ 
    f_io();
        ll t,n,w,a,k,x;
 
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.size();i++){
        ans+=s[i]-'0';
    }

    if(ans%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }


   

}



    
    
    

        




    




      







   





         
    

Measured memory_bytes: 3740
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n;
    cin >> n;
    
    int ans = 0;
    
    
    rep(i,1,n+1){
	string s = to_string(i);
	if(sz(s)&1)ans++;
    }

    P(ans);
    return  0;
}


Measured memory_bytes: 256
#include <cstdio>

int N,M,A[101];

int main(){
	scanf("%d%d",&N,&M);
	for(int i = 1; i <= N; i++){
		scanf("%d",&A[i]);
	}
	for(int k = 1; k <= M; k++){
		for(int j = 1; j < N; j++){
			if((A[j] % k) > (A[j+1] % k)){
				int tmp = A[j];
				A[j] = A[j+1];
				A[j+1] = tmp;
			}
		}
	}
	for(int i = 1; i <= N; i++){
		printf("%d\n",A[i]);
	}
	return 0;
}

Measured memory_bytes: 2752
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;



void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x ->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;
}
      


void inorder(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);


  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24040
A = int(input())
B = int(input())
C = int(input())
X = int(input())
c = 0
for i in range(0, A+1):
    for j in range(0, B+1):
        for k in range(0, C+1):
            if i*500 + j*100 + k*50 == X:
                c += 1
print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
ll a,b,c,d;
int main(){
	ios::sync_with_stdio(0);
	cin>>a>>b>>c>>d;
	ll ans=b*d;
	ans=max(ans,max(a*c,max(a*d,b*c)));
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;
static const int INF = 99999999;

typedef pair<int,int> P;

unsigned int dp[101][101];

void solve()
{
	int n; 
	cin >> n;
	vector<P> v(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> v[i].first >> v[i].second;
	}

	for(int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= n; ++j)
		{
			dp[i][j] = INF;
		}	
		dp[i][i] = 0;
	}
	for(int i = 1; i < n; ++i)//ツ閉敖づ個個按津ィ
	{
		for(int j = 0; j < n - i; ++j)//ツ開ツ始ツ暗環置ツづ個個按津ィ
		{
			for(int k = j; k < j + i; ++k)//ツ静伉断ツ暗環置ツづ個個按津ィ
			{
				int cost = v[j].first * v[k].second * v[k + 1].first * v[j + i].second;
				dp[j][j + i] = min(dp[j][j + i], cost + dp[j][k] + dp[k + 1][j + i]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
}

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

Measured memory_bytes: 0
#include <iostream>
#define N 10000000
using namespace std;

int prime[N] = {};
bool is_prime[N] = {};

void sieve()
{
    int p = 0;
    for (int i = 2; i < N; ++i)
    {
        if (is_prime[i])
        {
            prime[p++] = i;
            for (int j = 2 * i; j < N; j += i)
            {
                is_prime[j] = false;
            }
        }
    }
}

int main()
{
    for (int i = 0; i < N; ++i)
    {
        is_prime[i] = true;
    }
    is_prime[0] = false;
    is_prime[1] = false;
    sieve();

    int n, c = 0;
    cin >> n;
    for (int i = 0; i < N;++i){
        if(prime[i]%10==1){
        cout << prime[i] << " ";
        ++c;
        }
        if(c==n)
            break;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 2e5 + 10;
char s[N];
int dp[2][N], ch[N];
int main(){
	int n, c, k;
	scanf("%d %d %d",&n, &k, &c);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++){
		if(s[i] == 'x') {
			dp[0][i] = dp[0][i - 1];
			continue;
		}
		dp[0][i] = max(dp[0][max(i - c - 1, 0)] + 1, dp[0][i - 1]);
	}
	if(c == 0){
		if(dp[0][n] > k) return 0;
		for(int i = 1; i <= n; i++){
			if(s[i] !='x') printf("%d\n", i);
		}
		return 0;
	}
	for(int i = n; i > 0; i--){
		if(s[i] == 'x'){
			dp[1][i] = dp[1][i + 1];
			continue;
		}
		dp[1][i] = max(dp[1][min(n + 1, i + c + 1)] + 1, dp[1][i + 1]);
	}
	for(int i = -c + 2; i <= n; i++){
		int l = max(1, i), r = min(n, i + c - 1);
		if(dp[0][l - 1] + dp[1][r + 1] >= k){
			ch[l]++;
			ch[r + 1]--;
		}
	}
	for(int i = 1; i <= n; i++){
		ch[i] += ch[i - 1];
		if(ch[i] == 0 && s[i] != 'x')printf("%d\n", i);
	}

}

Measured memory_bytes: 2816
from collections import deque

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

p = deque(p)
q = deque(q)
r = deque(r)

ans = 0
MIN = -1
N = X + Y
for _ in range(N):
    tmp_p, tmp_q, tmp_r = MIN, MIN, MIN
    if len(p) > 0 and X > 0:
        tmp_p = p.popleft()
    if len(q) > 0 and Y > 0:
        tmp_q = q.popleft()
    if len(r) > 0:
        tmp_r = r.popleft()
    
    if tmp_p >= tmp_q and tmp_p >= tmp_r:
        ans += tmp_p
        X -= 1
        if tmp_q != -1:
            q.appendleft(tmp_q)
        if tmp_r != -1:
            r.appendleft(tmp_r)

    elif tmp_q >= tmp_p and tmp_q >= tmp_r:
        ans += tmp_q
        Y -= 1
        if tmp_p != -1:
            p.appendleft(tmp_p)
        if tmp_r != -1:
            r.appendleft(tmp_r)

    else:
        ans += tmp_r
        if tmp_q != -1:
            q.appendleft(tmp_q)
        if tmp_p != -1:
            p.appendleft(tmp_p)

print(ans)


Measured memory_bytes: 29560
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
   lli L,R,N,M,K,sum=0,num=0,flag=0;
   cin >> N;
   Vec(P,lli,N,0);
   Vec(Q,lli,N,0);
   rep(i,0,N)cin >> P[i];
   rep(i,0,N){
      if(i%2==0)sum+=P[i];
      else sum-=P[i];
   }
   Q[0]=sum;
   Q[N-1]=(P[N-1]-Q[0]/2)*2;
   rrep(i,N-2,0)Q[i]=(P[i]-Q[i+1]/2)*2;
   rep(i,0,N)cout << Q[i] << " ";
   cout << endl;
}

Measured memory_bytes: 2944
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
P = read_ints()


def ret_mean(X):
    return (X + 1) / 2



class cumsum1d:
    def __init__(self, ls: list):
        '''
        1次元リストを受け取る
        '''
        from itertools import accumulate
        self.ls_accum = [0] + list(accumulate(ls))

    def total(self, i, j):
        # もとの配列lsにおける[i,j)の中合計
        return self.ls_accum[j] - self.ls_accum[i]
      
P_mean = [ret_mean(p) for p in P]
P_accum = cumsum1d(P_mean)

ans = 0
# print(P_accum)
for i in range(N - K + 1):
    j = i + K
    ans = max(ans, P_accum.total(i,j))
print(ans)


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

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

}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3584
l = input().split()
H = int(l[0])
W = int(l[1])

S = []
for i in range(H):
    l = input().split()
    S.append(l[0])

# print(H, W, S)

# TS = []
# for i in range(W):
#     tmp = ''
#     for j in range(H):
#         tmp += S[j][i]
#     TS.append(tmp)

# print(TS)

HL = []
for i in range(H):
    l = 0
    begin = 0
    tmp = []
    for j in range(W):
        if S[i][j] == '.':
            l += 1
        else:
            tmp.extend([l]*(j - begin))
            tmp.append(0)
            begin = j + 1
            l = 0
    if begin != W:
        tmp.extend([l]*(W - begin))
    HL.append(tmp)

WL = []
for i in range(W):
    l = 0
    begin = 0
    tmp = []
    for j in range(H):
        if S[j][i] == '.':
            l += 1
        else:
            tmp.extend([l]*(j - begin))
            tmp.append(0)
            begin = j + 1
            l = 0
    if begin != H:
        tmp.extend([l]*(H - begin))
    WL.append(tmp)

max_l = 0
for i in range(H):
    for j in range(W):
        l = HL[i][j] + WL[j][i]
        max_l = max(l, max_l)
print(max_l - 1)


Measured memory_bytes: 127448
/*
M-SOLUTIONS プロコンオープン
3以上の整数Nが与えられる。
正N角形の内角の和を求める。
制約
・3<=N<=100
方針
N角形の内角の和は、(N-2)*180
で求めらえる。
*/

#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;
const int MOD = 1000000007;


int main(){
    int N; cin >> N;
    cout << (N-2)*180 << endl;
}



Measured memory_bytes: 3644
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;
  using iterator = std::vector<Edges>::iterator;
  using const_iterator = std::vector<Edges>::const_iterator;

public:
  Graph(const int &size = 0) : g(size) {}
  int size() const { return g.size(); }
  const Edges &operator[](const int &i) const { return g[i]; }
  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }
  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }
  iterator begin() { return g.begin(); }
  const_iterator begin() const { return g.begin(); }
  iterator end() { return g.end(); }
  const_iterator end() const { return g.end(); }
};

std::pair<Weight, Edges> prim(const Graph &g, const int &root = 0) {
  struct comp {
    bool operator()(const Edge &e, const Edge &f) const { return e.weight > f.weight; }
  };
  Edges tree;
  Weight total = 0;
  std::vector<int> vs(g.size());
  std::priority_queue<Edge, std::vector<Edge>, comp> q;
  q.emplace(-1, root, 0);
  while (q.size()) {
    Edge e = q.top();
    q.pop();
    if (vs[e.dst]) continue;
    vs[e.dst] = true;
    total += e.weight;
    if (e.src != -1) tree.emplace_back(e);
    for (auto &f : g[e.dst]) {
      if (!vs[f.dst]) q.emplace(f);
    }
  }
  return {total, tree};
}

main {
  int n, m;
  while (cin >> n >> m, n) {
    Graph g(n);
    while (m--) {
      int a, b, cost;
      cin >> a >> b >> cost;
      g.addEdge(a, b, cost);
    }
    cout << prim(g).first << endl;
  }
}

Measured memory_bytes: 3028
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int X;
	get(X);

	if (X >= 30) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
using namespace std;

int main(){
  char s[30];
  scanf("%s", s);
  int n = strlen(s);
  int i;
  vector<char> v;
  for(i=n-1;i>=0;i--){
    v.push_back(s[i]);
  }
  for(i=0;i<n;i++)
    printf("%c", v[i]);
  printf("\n");

  return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,f,ans,cnt,last;

main() {
    cin >> n;
    while(n) {
        ans += last = n%10;
        if (n%10 != 9 && n/10) f++;
        n/=10;
        cnt++;
    }
    if (f) ct(last+(cnt-1)*9-1)
    else ct(ans)
}

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

int main(){
    int m,na,nb;
    while(cin>>m>>na>>nb){
        if(m==0){
            break;
        }
        int p[m];
        for(int i=0;i<m;i++){
            cin>>p[i];
        }
        sort(p,p+m);
        reverse(p,p+m);
        int k=p[na-1];
        int c=k-p[na];
        int l=na;
        for(int i=na;i<nb;i++){
            if(c<=p[i]-p[i+1]){
                l=i+1;
                c=p[i]-p[i+1];
            }
        }
        cout<<l<<endl;
    }
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> hoge(1,0);
    int count=1;
    int j=0;
    if(s[0]=='0'){
        hoge.push_back(0);
        j++;
    }
    rep(i,n){
        if(s[i+1]==s[i]){
            count++;
            //cout << count<<endl;
        }
        if(s[i+1]!=s[i]){
            hoge.push_back(hoge.at(j)+count);
            count=1;
            //cout << hoge[j]<<endl;
            j++;
        }
    }
    //cout <<hoge.size()<<endl;
    int max_=0;
    int hoges=hoge.size();
    // rep(i,hoges){
    //     cout << hoge[i]<<endl;

    // }
    for(int i=0;i<hoges;i+=2){
        int r=i+2*k+1;
        max_=max(max_,hoge.at(min(hoges-1,r))-hoge.at(i));
        //cout <<max_<<endl;
    }
    cout << max_;

}

Measured memory_bytes: 1020
N, M, C=map(int, input().split())
b=list(map(int, input().split()))
a=[list(map(int, input().split())) for i in range(N)]
cnt=0
judge=0
for i in range(N):
    for j in range(M):
        judge+=a[i][j]*b[j]
    if judge+C>0:
        cnt+=1
    judge=0
print(cnt)

Measured memory_bytes: 3064
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
  

    ll n ,a ,b;
    cin>>n>>a>>b;
    ll sum = 0;
    ll arr[n];
    rep(i,0,n) cin>>arr[i];
    for(ll i = 1;i<n;i++){
        sum+=min((arr[i]-arr[i-1])*a, b);
    }
    cout<<sum<<endl;
 
 
    
 
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int d[15];

int main(){
	cin >> N;
	++d[0];
	repp(i,0,N){
		int x;
		cin >> x;
		++d[x];
	}
	repp(i,0,13){
		if(d[i] > 2) return cout << 0 << endl , 0;
		if(d[i] == 2 && i%12 == 0) return cout << 0 << endl , 0;
	}
	int ans = 0;
	d[12] *= 2;
	repp(i,0,1<<24){
		bool b = 1;
		repp(j,0,13) if(((i>>j)&1)+((i>>(24-j))&1) != d[j]) b = 0;
		if(b){
			int s = 24;
			int x = 0;
			repp(k,1,24){
				if(i&(1<<k)){
					s = min(s,k-x);
					x = k;
				}
			}
			s = min(s,24-x);
			ans = max(ans,s);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.time.Year;
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        HashSet<String> set=new HashSet<>();
        for (int i = 0; i < n; i++) {
            String s=sc.next();
            String t=sc.next();
            if(s.equals("insert")){
                set.add(t);
            }else {
                out.println(set.contains(t)?"yes":"no");
            }
        }
    }
}


Measured memory_bytes: 252852
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int r;
	cin >> r;
	float area = 2.0 * 3.141592653589793238 * r;
	cout << fixed << setprecision(2) << area;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define ll long long
#define pb push_back;
using namespace std;
ll cnt,mini=1e9,maxi=-1;
ll n,m,k,x;
ll a[101],b[100001];
ll mini1=1e9,maxi1=-1,cnt1,cnt2,cnt3,ans,sum;
int main(){
ios_base::sync_with_stdio(0);
	// freopen (" .txt", "r", stdin);
	// freopen (" .txt", "w", stdout);
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
	if(a[i]%2==0){
		if(a[i]%3!=0 && a[i]%5!=0){
			cout<<"DENIED";
		return 0;
		}
	}
	}
	cout<<"APPROVED";
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    string s;

    cin >> s;

    int sum = 0;

    for(int i = 0;i < s.length();i++){
        sum += s[i] - '0';
    }

    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3472
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

string S;
int SX, SY, TX, TY;

void a(int sx, int sy, int tx, int ty) {
	REP(i, 0, abs(tx - sx)) {
		S += (tx > sx ? 'R' : 'L');
	}
	REP(i, 0, abs(ty - sy)) {
		S += (ty > sy ? 'U' : 'D');
	}
}

int main() {
	cin >> SX >> SY >> TX >> TY;
	a(SX, SY, TX, TY);
	a(TX, TY, SX, SY);
	S += 'D';
	a(SX, SY - 1, TX + 1, TY);
	S += 'L';
	S += 'U';
	a(TX, TY + 1, SX - 1, SY);
	S += 'R';
	cout << S << endl;
	return 0;
}


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

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

    int N, M;

    cin >> N >> M;;

    cout << (N * (N-1)/2) + (M * (M-1)/2);

    return 0;
}


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

public class Main {
	
	class Node {
		HashSet<Integer> edgeTo = new HashSet<>();
		boolean isSearched = false;
		
		void add(int N){
			edgeTo.add(N);
		}
	}
	
	public Main() {
		FastScanner scanner = new FastScanner();
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		
		Node[] P = new Node[N];
		
		LinkedList<Node> openList = new LinkedList<>();
		
		for (int i = 0; i < N; i++) {
			P[i] = new Node();
			openList.add(P[i]);
		}
		
		for (int i = 0; i < M; i++) {
			int A = scanner.nextInt() - 1;
			int B = scanner.nextInt() - 1;
			
			P[A].add(B);
			P[B].add(A);
		}
		
		int MAX = 0;
		
		while(!openList.isEmpty()){
			Node S = openList.poll();
			if (S.isSearched) continue;
			
			LinkedList<Node> Q = new LinkedList<>();
			Q.add(S);
			
			int sum = 0;
			
			while (!Q.isEmpty()){
				Node node = Q.poll();
				if (node.isSearched) continue;
				
				for (int i : node.edgeTo) {
					if ( !P[i].isSearched ) {
						Q.add(P[i]);
					}
				}
				
				node.isSearched = true;
				sum++;
			}
			
			MAX = Math.max(MAX, sum);
		}
		
		System.out.println(MAX);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

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: 115400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N;
int X[MAXN],D[MAXN];
LL ans;
LL dp[MAXN];
vector<int> maxR[MAXN];
int Rmax[MAXN];

struct Node{
    int l,r;
}node[MAXN];
stack< pair<int,int> >st;

bool cmp(const Node& a,const Node& b){
    if(a.l==b.l) return a.r<b.r;
    return a.l<b.l;
}

void work(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
//        scanf("%d%d",&X[i],&D[i]);
        X[i]=read();
        D[i]=read();
        node[i].l=X[i];
        node[i].r=X[i]+D[i]-1;
    }
    sort(node+1,node+1+N,cmp);
    dp[N+1]=1;
    for(int i=N;i>=1;i--){
        int l=node[i].l,r=node[i].r;
        int next=i+1;
        while(!st.empty()){
            pair<int,int> tmp=st.top();
            if(node[tmp.first].l<=r){
                st.pop();
                next=tmp.second;
            }
            else{
                break;
            }
        }
        st.push(make_pair(i,next));
        dp[i]=(dp[i+1]+dp[next])%MOD;
//        Rmax[i]=next;
    }
    printf("%lld\n",dp[1]%MOD);
}
/*
4
1 3
5 10
6 1
8 12
*/
///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}








Measured memory_bytes: 10752
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

n = gets.to_i

sum = 0
1.upto(n) do |i|
  unless i % 3 == 0 || i % 5 == 0 || i % 15 == 0
    sum += i
  end
end

puts sum

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

int main() {
	int r, D,x;
	cin >> r >> D >> x;
	int ans = x;
	for (int i = 0; i < 10; i++) {
		ans = ans * r - D;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 

    fast;

    ll h,a;
    cin>>h>>a;

    ll ans=h/a;

    if(h%a)
        ans++;
    cout<<ans<<endl;


   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
 
const ll MAX_N = 2e5 + 5, inf = 1e18, mod = 1000000007;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};
 
template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}
 
void ok() {
    cout << "Yes" << '\n';
}
 
void no() {
    cout << "No" << '\n';
}
 
inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    string s;
    cin >> s;
    make_unique(s);
    if (s.size() >= 2) {
        ok();
    } else {
        no();
    }
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
		int S, T,R,X;
		cin >> S >> T >>R;
		if (S == T)
			X = R;
		if (T == R)
			X = S;
		if (S == R)
			X = T;
		cout << X;
}

Measured memory_bytes: 256