akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

int main() {
    int N, M;
    map< string, int> blue, red;
    
    cin1(N);
    
    string s;
    rep( i, N) {
        cin1(s);
        blue[s]++;
    }
    
    cin1(M);
    
    rep( i, M) {
        cin1(s);
        red[s]++;
    }
    
    int maxv = 0;
    
    for (const auto& imap : blue){
        
        maxv = max( maxv, blue[imap.first] - red[imap.first]);
        
    }
    cout1(maxv);
}



Measured memory_bytes: 504
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = int(input())
    A = list(map(int, input().split()))

    res = 0

    for i in range(1, N):
        if A[i] < A[i-1]:
            res += A[i-1] - A[i]
            A[i] = A[i-1]
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 35328
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    int a,b;
    cin >> a>> b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
p = list(map(int,input().split()))

p_dash = p.copy()
p_dash.sort()

count = 0

for i in range(n):
	if p[i] - p_dash[i] != 0:
		count += 1
	if count == 3:
		flag = False
		break

if count <= 2:
	flag = True

if flag:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
      	if(str.contains("RRR")){System.out.println(""+3);}
      	else if(str.contains("RR")){System.out.println(""+2);}
      	else if(str.contains("R")){System.out.println(""+1);}
      	else{System.out.println(""+0);}
	}
}

Measured memory_bytes: 35544
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  stack<int>que;
  while(cin>>n){
    if(n==0){
      cout<<que.top()<<endl;
      que.pop();
    }else{
      que.push(n);
    }
  }
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int X, N;
    cin >> X >> N;
    vector<int> count(102, 0);
    rep(i,N) {
        int p;
        cin >> p;
        count[p]++;
    }

    if (count[X] == 0) {
        cout << X << endl;
        return 0;
    }

    int i = 1;
    while (true) {
        if (count[X - i] == 0) {
            cout << X - i << endl;
            return 0;
        } else if (count[X + i] == 0) {
            cout << X + i << endl;
            return 0;
        }
        i++;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	string n;
	int x=0,i;
	getline(cin,n,'\n');
	while(n[x]!='\0'){
		x++;
	}	
	x++;
	int t0=0,t1=0;
	//0 start
	for(i=0;i<x;i++){
		if(i%2==0){
			if(n[i]=='1')
			t0++;
		}
		if(i%2==1){
			if(n[i]=='0')
			t0++;
		}
	}
	
	//1start
	for(i=0;i<x;i++){
		if(i%2==0){
			if(n[i]=='0')
			t1++;
		}
		if(i%2==1){
			if(n[i]=='1')
			t1++;
		}
	}
	
	int min;
	if(t0>t1){
		min=t1;	}
	else{
		min=t0;
		}
	cout<<min<<endl;
	return 0;
}


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

using namespace std;

int main()
{
	long a, b, x;

	cin >> x  >> a >> b;

	if (b <= a) {
		cout << "delicious" << endl;
	}
	else if(b-a<=x){
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
}

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


#define int long long
using namespace std;

char a[200000];
int N;
int x[30];
int ans;

signed main()
{
	ans = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		x[a[i] - 'a'] ++;
	}

	for (int i = 0; i <= 'z' - 'a'; i++) {
		ans *= (x[i]+1);
		ans = ans % (1000000007);
	}
	ans--;
	cout << ans << endl;

//	system("pause")
    return 0;
}




Measured memory_bytes: 384
#端から端まで割る
#h<=10に対しては全探索
#wについては極力割らない

h,w,k = map(int, input().split( ))

s= [list(map(int,list(input()))) for i in range(h)]

bit = 1<<h
ans = 10000
for b in range(bit):
    cut = [0]+[j for j in range(1,h) if (b>>j)&1]+[h]
    tmp = len(cut)-2
    white = [0]*h
    for j in range(w):
        for i in range(h): 
            white[i] += (s[i][j])&1
        for u in range(1,len(cut)):
            tmp2 = 0
            for t in range(cut[u-1],cut[u]):
                tmp2 += white[t]
            if tmp2>k and j:##
                tmp += 1
                white = [s[x][j] for x in range(h)]##
            
        for u in range(1,len(cut)):###1列でもアウトな場合
            tmp2 = 0
            for t in range(cut[u-1],cut[u]):
                tmp2 += white[t]
            if tmp2>k and j:##
                tmp = 100000
                white = [s[x][j] for x in range(h)]##
                break##    
    if ans > tmp:
        ans = tmp
print(ans)
        












Measured memory_bytes: 57356
#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);
    vector<int> P(3);
    REP(i,3)cin >> P.at(i);
    sort(P.begin(),P.end());
    cout <<P.at(1) + P.at(0)<< "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string input;
	cin >> input;
	for(int i = 0;i < input.size();++i){
		if(input[i] == 'A')input[i] = 'T';
		else if(input[i] == 'C')input[i] = 'G';
		else if(input[i] == 'T')input[i] = 'A';
		else if(input[i] == 'G')input[i] = 'C';
	}
	cout << input << '\n';
}

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

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str = br.readLine();
			if(str.equals("END OF INPUT")){
				break;
			}
			String[] s = str.split(" " );
			for(int i = 0; i < s.length;i++){
				System.out.print(s[i].length());
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 9692
#include<bits/stdc++.h>
using namespace std;
const int maxn=3010,mod=998244353;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
inline int ksm(int a,int b)
{
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) res=1ll*res*a%mod;
	return res;
}
int A,B,C,D,f[maxn][maxn];
int main()
{
	cin>>A>>B>>C>>D;
	f[A][B]=1;
	for(int i=A;i<=C;i++) for(int j=B;j<=D;j++)
	{
		Add(f[i+1][j],1ll*f[i][j]*j%mod);
		Add(f[i][j+1],1ll*f[i][j]*i%mod);
		Add(f[i+1][j+1],mod-1ll*f[i][j]*i%mod*j%mod);
	}
	cout<<f[C][D]<<endl;
}

Measured memory_bytes: 38804
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, ans = 0;
    bool red[205][205] = {};
    vector<pair<int, int>> blue;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        red[a][b] = true;
    }
    for (int i = 0; i < n; i++) {
        int c, d;
        cin >> c >> d;
        blue.PB(MP(c, d));
    }
    sort(blue.begin(), blue.end());
    for (int i = 0; i < n; i++) {
        int x = -1, y = -1;
        pair<int, int>t = blue[i];
        for (int j = 0; j < t.second; j++) {
            for (int k = 0; k < t.first; k++) {
                if (red[k][j]) {
                    x = k;
                    y = j;
                }
            }
        }
        if (x != -1 && y != -1) {
            ans++;
            red[x][y] = false;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//                               //
    // author : samars_diary //
    // 17-09-2020 │ 20:28:41 //
//                               //

#include <iostream>
using namespace std;

void solve(){
    long long int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int t = 1;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int rot;cin>>rot;
    string str;

    cin>>str;
    for(auto el:str)
    {
        cout<< char((el-'A'+rot)%26+'A');
    }
    cout<<endl;
    
    return 0;
}


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

const int mod=1000000007;
int n,c[200001];
ll dp[200001],sum[200001];
int main(){
    cin>>n;
    rep(i,n) cin>>c[i];
    dp[0]=1;sum[c[0]]=1;
    FOR(i,1,n+1)if(i==n||c[i]!=c[i-1]){
        dp[i]=sum[c[i-1]];
        dp[i]%=mod;
        sum[c[i]]+=dp[i];
        sum[c[i]]%=mod;
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;

    cout << A*B << endl;

}


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

int mini = 9999999;
int n,m,x;
vector<vector<int>> v(1,vector<int> (1));

bool check_x(vector<int> v,int x){
    for(int i=1;i<v.size();i++){
        if(v[i]<x) return false;
    }
    return true;
}

//全購入パターンを作る
//現在の参照番号num,現在のスキル合計配列v,
bool judge(int num,vector<int> sum){
    //終了チェック
    if(num==n){
        //条件チェック
        if(check_x(sum,x)){
            //最小更新
            if(sum[0] < mini){
                mini = sum[0];
            }
        }
        return false;
    }
    
    //i番目を追加しない
    if(judge(num+1,sum)) return true;
    
    //i番目を追加する
    rep(j,m+1)  sum[j] += v[num][j];
    if(judge(num+1,sum)) return true;
    
    //終了
    return false;
}
 

int main() {
    cin >> n >> m >> x;
    //総当たりで調べる(max2^12)
    //vector<vector<int>> v(m+1,vector<int> (n));v[n][m+1]
    v.resize(n);
    for(size_t i=0; i<n; i++){
      v[i].resize(m+1);
    }
    rep(i,n){
        rep(j,m+1){
            cin >> v[i][j];
        }
    }
    
    //総和
    vector<int> tot(m+1);
    rep(i,n){
        rep(j,m+1){
            tot[j] += v[i][j];
        }
    }
    if(!check_x(tot,x)){
        cout << "-1" << endl;
        return 0;
    }
    
    //最小探索
    vector<int> sum(m+1);
    if(judge(0,sum)){
        cout << "gg"; 
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 3628
a=int(input())
b=[int(input()) for i in range(a)]
LIS = [b[0]]
for i in range(1,len(b)):
  if b[i] <= LIS[-1]:
    LIS.append(b[i])
  else:
    lo=0
    hi=len(LIS)
    while lo < hi:
      mid=(lo+hi)//2
      if b[i]>LIS[mid]:
        hi =mid
      else:
        lo=mid+1  
    LIS[lo] = b[i]
print(len(LIS))

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

const int MAX_N = 1<<17;
int n,dat[2*MAX_N-1];

void init(int n_){
	n = 1;
	while(n<n_) n *= 2;
	for(int i=0;i<2*n-1;i++) dat[i] = INT_MAX;
}

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

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

int N,Q,com,x,y;
int main(){
	cin >> N >> Q;
	init(N);
	for(int i=0;i<Q;i++){
		cin >> com >> x >> y;
		if(com==0) update(x,y);
		if(com==1) cout << query(x,y+1,0,0,n) << endl;
	}
}


Measured memory_bytes: 4128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[99];
int main(){
	int n,m;
	scanf("%d%d%s",&n,&m,s);
	int flag=1;
	rep(i,0,n)if(s[i]=='-')flag=0;
	if(s[n]!='-')flag=0;
	rep(i,0,m)if(s[n+1+i]=='-')flag=0;
	puts(flag?"Yes":"No");
}

Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a, b;
  scanf("%d", &a);
  scanf("%d", &b);

  if (a + b >= 10) {
    printf("error\n");
  }else{
    printf("%d\n", a+b);
  }
  return 0;
}


Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    vector<string> s(3);
    for(int i = 0; i < 3; i++){
        cin >> s[i];
        reverse(s[i].begin(), s[i].end());
    }
    int now = 0;
    int next = 0;
    while(1){
        if(s[now].size() == 0){
            if(now == 0){
                cout << 'A' << endl;
                return 0;
            } else if(now == 1){
                cout << 'B' << endl;
                return 0;
            } else {
                cout << 'C' << endl;
                return 0;
            }
        }
        if(s[now][s[now].size() - 1] == 'a'){
            next = 0;
        } else if(s[now][s[now].size() - 1] == 'b'){
            next = 1;
        } else {
            next = 2;
        }
        s[now].pop_back();
        now = next;
        
    }
}

Measured memory_bytes: 384
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, Q = map(int, input().split())
    S = list(input())
    t = [0] * N
    count =0
    for i in range(1,N):
        if S[i-1]=="A" and S[i] =="C":
            count +=1
        t[i] =count

    for j in range(Q):
        l, r = map(int,input().split())
        print(t[r-1]-t[l-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 12348
n = gets.to_i

graph = []
lines = []

for i in 0..n-2
  a, b = gets.split.map(&:to_i)
  graph[a - 1] ||= []
  graph[b - 1] ||= []
  graph[a - 1] << b - 1
  graph[b - 1] << a - 1
  lines << [a - 1, b - 1]
end
k = 0
q = [0]
line_colors = {}
used = [true]
colors = []

while node = q.shift do
  if k < graph[node].size
    k = graph[node].size
  end

  color = 1
  graph[node].each do |c|
    next if used[c]
    if colors[node] == color
      color += 1
    end
    colors[c] = color
    line_colors[[node, c]] = color
    q << c
    used[c] = true
    color += 1
  end
end
puts k
lines.each {|x| puts line_colors[x]}


Measured memory_bytes: 34276
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

    void yes(bool fl = true){
            if(fl) cout << "YES\n";
            else cout << "Yes\n";
    }
    void no(bool fl = true){
        if(fl) cout << "NO\n";
        else cout << "No\n";
    }  

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q;
        ll mod = 1e9 + 7;
        


        void solve(){
            ll h1,s1,h2,s2;
            cin >> h1 >> s1 >> h2 >> s2;
            for(int i=1;i<=2000;i++){
                if(i%2){
                    h2 -= s1;
                    if(h2 <= 0){
                        cout <<"Yes";
                        return;
                    }
                }else{
                    h1 -= s2;
                    if(h1 <= 0){
                        cout << "No";
                        return;
                    }
                }
            }
        }  
            
        int main(){
        ios_base::sync_with_stdio(false);
        
        int cases = 1;
        //cin >> cases;
    
        while(cases--){ 
            solve();
        }

        return 0;

        }

Measured memory_bytes: 3640
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun f (p q)
  (when (> p q)
    (rotatef p q))
  (cond ((zerop p) 0)
        ((= p q) p)
        (t (multiple-value-bind (k l) (floor q p)
             (if (zerop l)
                 (* (+ k k -1) p)
                 (+ (* 2 k p) (f p l)))))))
(defun main ()
  (let* ((n (read))
         (x (read)))
    (println (+ n (f x (- n x))))))

#-swank(main)


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

int L[110];

int main (void) {
	int N, ans = 0;

	cin >> N;
	for (int i = 0; i < 2 * N; i++) cin >> L[i];

	sort(L, L + 2 * N, greater<int>());

	/*for (int i = 0; i < 2 * N; i++) cout << L[i] << " ";
	cout << endl;
	*/

	for (int i = 0; i <= 2 * N; i+=2) {
		ans += min(L[i], L[i+1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
int main() {
  ll N, K;
  string S;
  cin >> N >> K >> S;
  ll score = 0;
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == S[i + 1]) score++;
  }
  ll ans = min(score + 2 * K, N - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            char[] c = in.next().toCharArray();
            long k = in.nextLong();
            for (int i = 0; i < c.length; i++) {
                if (i < c.length - 1) {
                    int need = ('z' - c[i] + 1) % 26;
                    if (k >= need) {
                        k -= need;
                        c[i] = 'a';
                    }
                } else {
                    k = k % 26;
                    c[i] = (char) ((int) (c[i] + k - 'a') % 26 + 'a');
                }
            }

            String s = new String(c);
            out.println(s);


        }

    }
}



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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w, bool f = 0) { this->w = w; if (f) fix(); }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	modulo& operator += (modulo b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	modulo& operator -= (modulo b) { if ((w -= b.w) < 0) w += mod; return *this; }
	modulo& operator *= (modulo b) { w = (num) w * b.w % mod; return *this; }
	modulo& operator /= (modulo b) { w = (num) w * b.inv() % mod; return *this; }
	modulo inline operator + (modulo b) const { modulo r = *this; r += b; return r; }
	modulo inline operator - (modulo b) const { modulo r = *this; r -= b; return r; }
	modulo inline operator * (modulo b) const { modulo r = *this; r *= b; return r; }
	modulo inline operator / (modulo b) const { modulo r = *this; r /= b; return r; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = int(1e9 + 7);
typedef modulo<mod> rem;

const int nsz = int(5e3);
int n, k, a[nsz + 5];
rem dp[nsz + 5], ans;
vector<int> r;

struct union_find {
	int pr[nsz + 5], siz[nsz + 5];
	
	union_find() {
		cont (u, nsz) pr[u] = u, siz[u] = 1;
	}
	
	int inline operator [] (int id) { return qry(id); }
	
	int qry(int u) { return pr[u] == u ? u : pr[u] = qry(pr[u]); }
	
	bool inline link(int u, int v) {
		int pu = qry(u), pv = qry(v);
		if (pu == pv) return 0;
		pr[pv] = pu;
		siz[pu] += siz[pv];
		return 1;
	}
};
union_find uf;

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
		if (a[i] != -1) uf.link(a[i], i);
		if (a[i] == -1) r.push_back(i);
	}
	k = int(r.size());
	
	cont (u, n) {
		if (uf[u] != u || a[u] == -1) continue;
		ans += rem(n - 1).pow(k);
	}
	
	dp[0] = 1;
	loop (i, k) {
		int u = r[i];
		for (int j = i; j >= 0; --j) {
			dp[j + 1] += dp[j] * (j ? rem(j) : rem(1)) * rem(uf.siz[u]);
		}
	}
	
	cont (j, k) {
		ans += dp[j] * rem(n - 1).pow(k - j);
	}
	cont (u, n) {
		if (uf[u] != u || a[u] != -1) continue;
		ans -= rem(n - 1).pow(k - 1);
	}
	
	ans = rem(n) * rem(n - 1).pow(k) - ans;
	printf("%d\n", ans);
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=0,y=0,z=0;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll a,b,c;
  cin >> a >> b >> c;
  if(a*500 >= b) pri("Yes");
  else pri("No");
  return 0;
}


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

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

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

    sort(L.begin(), L.end());
    int sum = 0;
    for(int i = 0; i < N -1; i++){
        sum += L[i];
    }

    if(sum > L[N-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

	return 0;
}

Measured memory_bytes: 256
N = int(input())

grpNos = [-1]*(N+1)
if N % 2:
    grpNos[-1] = 0

N2 = N//2*2
for i in range(1, N//2+1):
    grpNos[i] = i
    grpNos[N2+1-i] = i

anss = []
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if grpNos[i] != grpNos[j]:
            anss.append((i, j))

print(len(anss))
for i, j in anss:
    print(i, j)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,q;
vector<ll>adj[200100];
ll inc[200100];
ll final[200100];
ll visited[200100];
ll dfs(ll x,ll upar)
{
    visited[x]=1;
    final[x]+=upar;
    final[x]+=inc[x];
    for(ll j:adj[x])
    {
        if(visited[j]==0)
        {
            dfs(j,final[x]);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>q;
    ll a,b;
    for(ll i=1;i<n;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ll p,x;
    for(ll i=0;i<q;i++)
    {
        cin>>p>>x;
        inc[p]+=x;
    }
    dfs(1,0);
    for(ll i=1;i<=n;i++)
        cout<<final[i]<<" ";
	return 0;
}


Measured memory_bytes: 24320
def rren(): return list(map(int, input().split()))
n, m = rren()
x = rren()
y = rren()
ans = 0
x_sum = 0
y_sum = 0
for now_x in range(n):
    x_sum += x[now_x] * (now_x - (n-1 - now_x))
for now_y in range(m):
    y_sum += y[now_y] * (now_y - (m-1 - now_y))

print(x_sum * y_sum % 1000000007)


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

int main()
{
    int N,X,i,j,count=1;
    scanf("%d %d",&N,&X);
    int L[N],D[N+1];

    for (i=0; i<N; i++)
    {
        scanf("%d",&L[i]);
    }
    D[0]=0;
    for (j=1; j<=N; j++)
    {
        D[j]=D[j-1]+L[j-1];
        if (D[j]<=X)
            count++;
        else
            break;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let mut a = read::<i64>();
  let mut b = read::<i64>();
  let mut c = read::<i64>();
  let mut d = read::<i64>();

  println!("{}", max(a * b, c * d));
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

bool f(string &s, string &a){
    int cur = 0;
    for(auto c: a){
        while(cur < s.size() && s[cur] != c) ++cur;
        if(cur == s.size()) return false;
        ++cur;
    }
    return true;
}

int main(){
    string s, t;
    cin >> s >> t;
    string a, b;
    rep(i, s.size()){
        if(i%2 == 0) a += s[i];
        else b += s[i];
    }
    if((f(s, a) && f(t, b)) || (f(t, a) && f(s, b))) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3216
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = int.Parse(Console.ReadLine());
            long MOD = 1000000007;
            Combination.combInit(2000, MOD);

            long result = 0;
            for (int i = 1; 3 * i <= S; i++)
            {
                result += Combination.combination(S - 3 * i + i - 1, S - 3 * i);
                result %= MOD;
            }
            Console.WriteLine(result);
        }
    }
    static class Combination
    {
        static long combMax;
        static long combMOD;

        static long[] factorial;
        static long[] inverse;
        static long[] factInv;

        public static void combInit(long _max, long _mod)
        {
            combMax = _max;
            combMOD = _mod;
            factorial = new long[combMax];
            inverse = new long[combMax];
            factInv = new long[combMax];

            factorial[0] = factorial[1] = 1;
            factInv[0] = factInv[1] = 1;
            inverse[1] = 1;

            for (int i = 2; i < combMax; i++)
            {
                factorial[i] = factorial[i - 1] * i % combMOD;
                inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
                factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
            }
        }

        public static long combination(int n, int k)
        {
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
        }
    }
}


Measured memory_bytes: 27600
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {
    var characters = Array.from(new Set(input[0].split(''))).sort();
    var c = '';
    var search = 'a';

    for (c of characters) {

        if (c === search) {
            search = String.fromCharCode(search.charCodeAt() + 1);
        }
        else {
            console.log(search);
            return;
        }
    }

    if (search.charCodeAt() > 'z'.charCodeAt()) {
        console.log('None');
    }
    else {
        console.log(search);
    }
}



Measured memory_bytes: 15408
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

struct BIT {
	int n;
	vector<int>bit, ko;
	BIT(int x) {
		n = x; bit.resize(n, 0); ko.resize(n, 0);
	}
	int sum(int x) {
		int s = 0;
		while (x > 0) {
			s += bit[x]; x -= x & -x;
		}
		return s;
	}
	int kosum(int x) {
		int s = 0;
		while (x > 0) {
			s += ko[x]; x -= x & -x;
		}
		return s;
	}
	void add(int x, int y) {
		while (x <= n) {
			ko[x]++;
			bit[x] += y; x += x & -x;
		}
	}
	int secsum(int l, int r) {
		return sum(r) - sum(l - 1);
	}
	int kosecsum(int l, int r) {
		return kosum(r) - kosum(l - 1);
	}
};
struct info {
	int type, index, x;
	bool operator<(info& a)const {
		return x < a.x;
	}
	bool operator>(info& a)const {
		return x > a.x;
	}
};
vector<info>query;
BIT bit(114514);
int ans[114514];
signed main() {
	int n; cin >> n;
	vector<P>mx;
	mx.push_back({ 0,0 });
	rep(i, n) {
		int a; cin >> a; query.push_back({ 0,i,a });
		if (mx.back().first < a) {
			mx.push_back({ a,i });
		}
	}
	REP(i, mx.size()) {
		query.push_back({ 1,mx[i].second,mx[i - 1].first });
	}
	sort(all(query), greater<>());
	rep(i, query.size()) {
		if (query[i].type == 0) {
			bit.add(query[i].index + 1, query[i].x);
		}
		else {
			int j = bit.secsum(query[i].index + 1, n);
			int k = bit.kosecsum(query[i].index + 1, n);
			ans[query[i].index + 1] = j - k * query[i].x;
		}
	}
	int memo = 0;
	for (int i = n; i > 0; i--) {
		if (ans[i]) {
			int memo2 = ans[i];
			ans[i] -= memo; memo = memo2;
		}
	}
	REP(i, n + 1)cout << ans[i] << endl;
}


Measured memory_bytes: 11672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector<P> dd;
		int h, r;
		for (int i = 0; i < n; i++) {
			cin >> h >> r;
			dd.push_back(P(h, r));
		}
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> h >> r;
			dd.push_back(P(h, r));
		}
		sort(dd.begin(), dd.end());
		int MAX = 0;
		vector<int> dp(n+m, 1);
		for (int i = 1; i < n+m; i++) {
			for (int j = 0; j < i; j++) {
				if (dd[j].first < dd[i].first && dd[j].second < dd[i].second) {
					dp[i] = max(dp[i], dp[j]+1);
				}
			}
			MAX = max(MAX, dp[i]);
		}
		cout << MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
import fractions


def func(l):
    r = fractions.gcd(l[0], l[1])    
    for i in range(1, len(l) - 1):
        r = fractions.gcd(r, l[i + 1])
    return r


def main():
    n, x = map(int, input().split())
    xl = [int(i) for i in input().split()]
    xl.append(x)
    xl.sort()
    
    if n == 1:
      print(abs(xl[1] - xl[0]))
      return
    
    dl = []
    for i in range(len(xl) - 1):
        d = xl[i + 1] - xl[i]
        dl.append(d)

    print(func(dl))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16240
r,c = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(r)]

ans = [[0]*(c+1) for _ in range(r+1)]
for i in range(r):
    cnt = 0
    for j in range(c+1):
        if j != c:
            cnt += L[i][j]
            ans[i][j] = L[i][j]
        else:
            ans[i][j] = cnt
            
for i in range(r):
    for j in range(c+1):
        ans[r][j] += ans[i][j]
        
for i in range(r+1):
    print(*ans[i])


Measured memory_bytes: 6296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>>;
using GraphEdge = vector<vector<int>>;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int main(){
    string s;
    cin >> s;
    rep(i,3){
        if(s[i]=='1')cout << '9';
        else cout << '1';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3572
//g++でビルド

#include "bits/stdc++.h"

using namespace std;


int main(){
    string S;
    cin >> S;
    string result = "TBD";
    string year = S.substr(0, 4);
    string month = S.substr(5,2);
    string day = S.substr(8,2);
    int y = stoi(year);
    int m = stoi(month);
    int d = stoi(day);

    if(y <= 2019 && m <= 4 && d <= 30){
        result = "Heisei";
    }
        

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
void bubbleSort(int arr[], int n) {
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < n - i - 1; j++) {
			if (arr[j] > arr[j + 1]) {
				int swap = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = swap;
			}
		}
	}
}
 
int main() {
	int n;
	scanf("%d", &n);
	int arr[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	int ctr = 0;
	//	bubbleSort(arr, n);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k] && arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[k] + arr[j] > arr[i]) {
					ctr++;
				}
			}
		}
	}
	printf("%d\n", ctr);
	return 0;
}

Measured memory_bytes: 1704
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
l = na()
if sum(l) - max(l) > max(l):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    long a = scanner.nextLong();
    long b = scanner.nextLong();
    long x = scanner.nextLong();
    
    long count = b / x - (a == 0L ? -1L : (a - 1L) / x);
    
    System.out.println(count);
  }
}


Measured memory_bytes: 35524
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-9

using namespace std;
typedef complex<double> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.overlaps_of_seals", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		vector<P> p(n );
		rep (i, n ){
			double x, y;
			scanf ("%lf,%lf", &x, &y );
			p[i].real() = x;
			p[i].imag() = y;
		} // end rep

		vector<P> ip; ip.clear();		
		rep (i, n ){
			for (int j = i+1; j < n; j++ ){
				P d = p[j] - p[i];
				if (abs(abs (d) - 2. ) < EPS ){
					ip.push_back ((p[i]+p[j])/2.0 );
				}else
				if (abs (d) < 2. ){
					double t = acos (abs(d)/2.0 );
					ip.push_back (p[i]+polar(1.0, arg(d)+t ) );
					ip.push_back (p[i]+polar(1.0, arg(d)-t ) );
				} // end if
			} // end for									
		} // end rep

		int res = 1;
		rep (i, ip.size() ){
			int curr = 0;
			rep (j, n ){
				if (abs (ip[i] - p[j] ) < 1. + EPS ){
		 			curr++;
				} // end if
			} // end rep
			res = max (res, curr );
		} // end rep
		cout << res << endl;

	} // end loop
		
	return 0;
}

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

int main(){
	
	long long X;
	long long Y;
	cin >>X>>Y;
	int i;
	for(i=1;i<1000;i++){
		X = 2*X;
		if(X>Y) {
			cout<<i<<endl;
			break;
		}
	}
	
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    ll w,h,x,y;
    string str;
	cin>>w>>h>>x>>y;
    cout<<(long double)w*h/2<<" ";
    if(x+x==w&&y+y==h) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main(){
    int n,sum;
    sum = 0;
    cin >> n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            sum+=d[i]*d[j];
        }
    }
    cout << sum;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>>vii;
typedef vector<ll> vl;
typedef vector<vector<ll>>vll;
typedef pair <int, int> pii;
typedef pair<ll, ll> pll;

vector<ll> dig(ll a){
    vector<ll> soln;
    while(a > 0){
        soln.push_back(a%10);
        a = a/10;
    }
    return soln;
}

map <pll, ll> mp;


void solve(){
    ll n, m;
    cin>>n>>m;
    if(n%2 == 0 || m %2 == 0){
        cout<<(n*m)/2<<endl;
        return ;
    }
    else{
        ll ans = min(n/2 * m  + m/2 + 1, m/2 * n + n/2 + 1);
        cout<<ans<<endl;
        return;
    }
}

int totalMinutes(int h1, int m1, int h2, int m2){
    if(h2 > h1){
        return (h2-h1)*60 + m2-m1;
    }
    else if( h2 == h1){
        if(m2 > m1){
            return m2-m1;
        }
        else return 24*60 + m2-m1;    
    }
    else{
        return (24+h2-h1) + m2-m1;
    }
    return 0;
}


int main(){
    int h1, m1, h2,m2, k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<totalMinutes(h1, m1, h2, m2)- k<<endl;
    return 0;
}

Measured memory_bytes: 3628