akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;


signed main(){
    int n, x, ans = 0;
    cin >> n >> x;
    int a = max(x, n - x);
    int b = min(x, n - x);
    while(1){
        if(b == 0) break;
        if(a < b) swap(a, b);
        ans += 3 * b * (a / b);
        int tmp = b;
        b = a % b;
        a = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = IntStream.range(0, 3 * n).map(i -> scanner.nextInt()).toArray();
			// それぞれ前半と後半の計算結果
			long[] result1 = new long[n + 1], result2 = new long[n + 1];
			// 前半の計算用
			Queue<Integer> minQueue = new PriorityQueue<>((x, y) -> x.compareTo(y));
			result1[0] = IntStream.range(0, n).mapToLong(i -> (long) a[i]).sum();
			// 後半の計算用
			Queue<Integer> maxQueue = new PriorityQueue<>((x, y) -> y.compareTo(x));
			result2[n] = IntStream.range(2 * n, 3 * n).mapToLong(i -> (long) a[i]).sum();
			IntStream.range(0, n).forEach(i -> {
				minQueue.add(a[i]);
				maxQueue.add(a[3 * n - i - 1]);
			});
			IntStream.rangeClosed(1, n).forEach(i -> {
				// 前半の計算
				minQueue.add(a[n + i - 1]);
				result1[i] = result1[i - 1] + a[n + i - 1] - minQueue.poll();
				// 後半の計算
				maxQueue.add(a[n + n - i]);
				result2[n - i] = result2[n - i + 1] + a[n + n - i] - maxQueue.poll();
			});
			System.out.println(IntStream.rangeClosed(0, n).mapToLong(i -> result1[i] - result2[i]).max().getAsLong());
		}
	}
}


Measured memory_bytes: 70532
def getMinSDiff(H, W):
    Ans = H*W
    for x in range(1, W):
        # |--
        S1 = H*x
        S2 = (W - x) * (H // 2)
        S3 = H*W - (S1 + S2)
        Ans1 = max(S1, S2, S3) - min(S1, S2, S3)

        # | |
        S1 = x*H
        S2 = (W - x) // 2 * H
        S3 = H*W - (S1 + S2)
        Ans2 = max(S1, S2, S3) - min(S1, S2, S3)

        # 最小値を更新
        Ans = min(Ans, Ans1, Ans2)
    return Ans

if __name__ == "__main__":
    H, W = map(int, input().split(" "))
    if (W % 3 == 0) or (H % 3 == 0):
        print("0")
        exit()
    else:
        Ans = min(getMinSDiff(H, W), getMinSDiff(W, H))
        print(Ans)
        exit()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	ll N;
	cin>>N;
	vint A;
	ll sum=0;
	for(int i=0;i<N;i++){
		int c;
		cin>>c;
		A.pb(c);
		sum+=c;
	}
	if(sum%(N*(N+1)/2)){
		cout<<"NO"<<endl;
		return 0;
	}
	ll k=sum*2/(N+1)/N;
	vint d;
	for(int i=0;i<N;i++)
		d.pb(A[(i+1)%N]-A[i]-k);
	for(int i=0;i<N;i++){
		if(d[i]>0 || d[i]%N){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int r, g, b;
    
    scanf("%d%d%d", &r, &g, &b);
    
    if ((100*r+10*g+b)%4==0) {
        printf("YES");
    } else {
        printf("NO");
    }
    
    return 0;
}



Measured memory_bytes: 1716
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int solve(string s, int x) {
    int N = s.length();
    int ret = 0;
    while(1) {
        bool ok = true;
        int prev = -1;
        rep(i,0,N) {
            int p = s[i] - 'a';
            if(prev < 0) prev = p;
            else if(prev != p) ok = false;
        }
        if(ok) break;

        ret++;
        string temp = "";
        rep(i,0,N-1) {
            int a = s[i] - 'a', b = s[i+1] - 'a';
            int nxt = 0;
            if(a == x || b == x) {
                nxt = x;
            }
            else nxt = a;
            temp += ('a' + nxt);
        }
        N--;
        s = temp;
    }
    return ret;
}

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

    int ans = INF;
    rep(i,0,26) {
        chmin(ans, solve(s, i));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
 string s;
 cin >> s;
 s = 'A' + s;
 int n = s.size();
 bool k = true,g = true;
 for(int i = 1; i < n;i++){
 	if(i % 2 ==0){
 		if(s.at(i) == 'R'){
 			g = false;
 		}
 	}
 	else{
 		if(s.at(i) == 'L'){
 			k = false;
 		}
    }
 }

 	if(k&&g){
 		cout << "Yes" << endl;
 	}
 	else{
 		cout << "No" << endl; 
 	}
 } 



Measured memory_bytes: 256
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    k,n = mi()
    a = li()

    a = sorted(a)
    ans = k
    for i in range(n-1):
        ans=min(ans,k-(a[i+1]-a[i]))
    ans = min(ans,k-(k-a[n-1])-a[0])
    print(ans)


main()





Measured memory_bytes: 28244
s = str(input())
n = len(s)
rcount = 0
for i in range(n):
  if int(s[0]) % 2 == 0:
    if i % 2 == 0:
      if int(s[i]) % 2 == 1:
        rcount += 1
    else:
      if int(s[i]) % 2 == 0:
        rcount += 1
  if int(s[0]) % 2 == 1:
    if i % 2 == 0:
      if int(s[i]) % 2 == 0:
        rcount += 1
    else:
      if int(s[i]) % 2 == 1:
        rcount += 1
print(rcount)
  

Measured memory_bytes: 3188
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

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

int main(){
    double R;
    cin>>R;
    const double PI=3.14159265358979323846;
    double ans = 2*PI*R;
    cout<<ans<<endl;
return 0;

}

Measured memory_bytes: 3788
n=int(input());a=list(map(int,input().split()));c=0
for i in range(n):
 for j in range(i+1,n)[::-1]:
  if a[j]<a[j-1]:
   a[j],a[j-1]=a[j-1],a[j];c+=1
print(*a)
print(c)


Measured memory_bytes: 5608
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
int d2, d4, needhelp;

int main() {
	scanf("%d", &n);
	long long temp;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &temp);
		if (temp % 4 == 0) {
			d4++;
			continue;
		}
		if (temp % 2 == 0) {
			d2++;
			continue;
		}
		needhelp++;
	}
	if (d2 != 0)needhelp++;
	if (needhelp > d4 + 1) {
		printf("No");
		return 0;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
void Yay(bool condition){

    if(condition){
        p("Yay!");
    }else{
        p(":(");
    }
    return;
}

//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[5005],y[5005],z[500005];
ll dp[2005][2005];
long double l[5000];
char s[500005],t[500005];
ll ans;

bool flag,dame;

int main(){
	cin >> n >> m;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	for(i=1;i<=m;i++){
		cin >> y[i];
	}
	x[0] = -1;
	y[0] = -2;
	dp[0][0] = 1;
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			if(i == 0 && j == 0)continue;
			if(x[i] == y[j]){
				dp[i][j] = dp[i][j-1] + dp[i-1][j];
			}else{
				dp[i][j] = dp[i-1][j] + dp[i][j-1] + (mod - dp[i-1][j-1]);
			}
			dp[i][j] %= mod;
			//pe(dp[i][j]);
		}
		//el;
	}
	p(dp[n][m]);

	
	return 0;
}


Measured memory_bytes: 45312
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll H,N;
  cin>>H>>N;
  ll total=0;
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    total+=A;
  }
  if(total>=H) {
cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
}
  


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//vvi(n, vector<int>(m, -1))
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()
#define out(x) cout << (x) << endl;

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s;
  n = s.size();

  int odd = 0;
  int even = 0;
  rep(i, n){
    if(i%2 == 0){
      if(s[i] != '1') ++odd;
      if(s[i] != '0') ++even;
    }else{
      if(s[i] != '0') ++odd;
      if(s[i] != '1') ++even;
    }
  }
  out(min(odd, even));
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<endl;
  }else if(b==c){
    cout<<a<<endl;
  }else if(a==c){
    cout<<b<<endl;
  }
  return 0;
}

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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string a, b;
int r;

signed main() {
	cin >> a >> b;
	r = stoi(a+b);
	rep(i,1000) {
		if (i*i==r) {
			cout << "Yes" << ln;
			return 0;
		}
		if (i*i>r) break;
	}
	cout << "No" << ln;
}

Measured memory_bytes: 256
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int left;
            public int right;

            public Point(int left, int right)
            {

                this.left = left;
                this.right = right;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {


            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ans = (args[0] / args[1] + (args[0] % args[1] == 0 ? 0 : 1)) * args[2];
            Console.WriteLine(ans);

        }

    }

}

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

int main(){

	int a,b;
	char c[16];
	int d;

	int n = scanf("%d %d", &a,&b);
	if(n < 2){
		return 0;
	}

	sprintf(c,"%d%d",a,b);

	d = atoi(c);

	for(int i=1;i<=d;i++){
		
		if(i*i == d){
			printf("Yes");
			return 0;
		}	
	
	}

	printf("No");
	
	return 0;

}

Measured memory_bytes: 128
S = [0] * 13
H = [0] * 13
C = [0] * 13
D = [0] * 13

SUIT = {}
SUIT['S'] = S
SUIT['H'] = H
SUIT['C'] = C
SUIT['D'] = D

n = input()
for _ in xrange(n):
    line = raw_input().split()
    (SUIT[line[0]])[int(line[1]) - 1] = 1

for suit in ['S', 'H', 'C', 'D']:
    for i in xrange(13):
        if (SUIT[suit])[i] == 0:
            print '%s %d' % (suit, i + 1)

Measured memory_bytes: 6472
#include <stdio.h>

int main(void) {
  int H, R;
  scanf("%d %d", &H, &R);

  if(H >= 0) {
    printf("1\n");
  }
  else if(H + R == 0) {
    printf("0\n");
  }
  else {
    printf("-1\n");
  }

  return 0;
}



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

using ll = long long;

const int MAXN = 55;
const int MAXV = 55 * MAXN;
int N;
int A;
ll dp[MAXN][MAXN][MAXV + 100];

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

	cin >> N >> A;
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		int X; cin >> X;
		for (int n = 0; n <= i; n++) {
			for (int v = 0; v < MAXV; v++) {
				dp[i+1][n+1][v+X] += dp[i][n][v];
				dp[i+1][n][v] += dp[i][n][v];
			}
		}
	}

	ll ans = 0;
	for (int n = 1; n <= N; n++) {
		ans += dp[N][n][n * A];
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 67840
import std.stdio, std.string;
void main() {
	readln;
	int a, b = 0;
	foreach (string l; lines(stdin)) {
		string[] d = l.split;
		if (d[0] > d[1]) a += 3;
		else if (d[1] > d[0]) b += 3;
		else {
			a++;
			b++;
		}
	}
	"%d %d".writefln(a, b);
}

Measured memory_bytes: 2460
N=int(input())
cnt=[0]*(N+1)
li=[]
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            li.append(x**2+y**2+z**2+x*y+y*z+z*x)
for i in li:
    if i<=N:
        cnt[i]+=1
for i in range(1,N+1):
    print(cnt[i])

Measured memory_bytes: 143204
#include <stdio.h>
#define SENTINEL 2000000000
long long  a[200010],count = 0;
void merge(int left,int mid,int right)
{
    int n1 = mid - left, n2 = right - mid;
    int l[n1 + 10],r[n2 + 10];
    int i,j,k;
    for(i = 0;i < n1;i++)
        l[i] = a[left + i];
    for(i = 0;i < n2;i++)
        r[i] = a[mid + i];
    i = j = 0;
    l[n1] = r[n2] = SENTINEL;
    for(k = left;k < right;k++)
    {
        if(l[i] < r[j])
            a[k] = l[i++];
        else
        {
            count+=n1 - i;
            a[k] = r[j++];
        }
    }
}
void mergesort(int left,int right)
{
    if(left + 1 < right)
    {
        long long mid = (left + right) / 2;
        mergesort(left,mid);
        mergesort(mid,right);
        merge(left,mid,right);
    }
}
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i = 0;i < n;i++)
        scanf("%lld",&a[i]);
    mergesort(0,n);
    printf("%lld\n",count);
    return 0;
}

Measured memory_bytes: 4084
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    string s;
    int year=0;
    int month=0;
    int day=0;
    cin >> s;
    for(int i=0; i<4; i++){
      if(i!=0){
          year *= 10;
      }
      year += s[i] - '0';
    }
    for(int i=5; i<7; i++){
      if(i!=0){
          month *= 10;
      }
      month += s[i] - '0';        
    }
    for(int i=8; i<10; i++){
      if(i!=0){
          day *= 10;
      }
      day += s[i] - '0';        
    }
    if(year > 2019 || (year==2019 && month > 4)){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g;}
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	int n; cin >> n;
	vi x(n), y(n), h(n);
	rep(i, n)cin >> x[i] >> y[i] >> h[i];
	rep(cx, 101)rep(cy, 101)
	{
		int H = 0;
		bool valid = true;
		rep(i, n)
		{
			if (h[i] > 0)
			{
				int d = abs(cx - x[i]) + abs(cy - y[i]);
				H = h[i] + d;
				break;
			}
		}
		rep(i, n)
		{
			int d = abs(cx - x[i]) + abs(cy - y[i]);
			if (h[i] != max(H - d, 0))
			{
				valid = false;
				break;
			}
		}
		if (valid)
		{
			co(cx << " " << cy << " " << H);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	string S;
	string T;
	cin >> S >> T;
	int cnt = 0;
	if (S[0] == T[0]) {
		cnt++;
	}
	if (S[1] == T[1]) {
		cnt++;
	}
	if (S[2] == T[2]) {
		cnt++;
	}
	cout << cnt;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
vector<int>gr[maxn];
int vis[maxn];
int distt[maxn];
int par[maxn];
void bfs(int he){
    queue<int>q;
    q.push(he);
    distt[he]=0;
    vis[he]=0;
    while(q.si){
        int tt=q.front();
        q.pop();
        for(auto x:gr[tt]){
            if(vis[x]){
                par[x]=tt;
                q.push(x);
                vis[x]=0;
                distt[x]=distt[tt]+1;
            }
        }
    }
}
void bfs2(int he,int wh){
    queue<int>q;
    q.push(he);
    vis[he]=0;
    while(q.si){
        int tt=q.front();
        q.pop();
        for(auto x:gr[tt]){
            if(vis[x]&&x!=wh){
                q.push(x);
                vis[x]=0;
            }
        }
    }
}
void dfs(int he,int di){
    //pr2(he,di);
    distt[he]=di;
    vis[he]=0;
    for(auto x:gr[he]){
        if(vis[x]) dfs(x,di+1);
    }
}
void solve()
{ 
    int n,u,v;
    cin>>n>>u>>v;
    int u1=u;
    rep0(i,n+2) vis[i]=1;
    rep0(i,n-1){
        int x,y;
        cin>>x>>y;
        gr[x].pb(y);
        gr[y].pb(x);
    }
    bfs(v);
    int x=distt[u];
    int x1=x;
    //deb(x);
    x/=2;
    int mx=distt[par[u]];
    if(distt[u]%2==0) x--;
    //deb(x);
    while(x--){
        u=par[u];
    }
    //deb(u);
    rep0(i,n+3){
        vis[i]=1;
    }
    bfs2(v,u);
    vector<int>vv;
    rep1(i,n){
        if(vis[i]&&gr[i].si==1) {vv.pb(i);}
    }
    dfs(u,distt[par[u]]);
    //deb(distt[9]);
    for(auto x:vv){
        mx=max(mx,distt[x]);
    }
    pr(mx);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


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

using namespace std;

# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


#define M_DEBUG if (1)

/******************************************************************************
	Main
******************************************************************************/
int main()
{
	// bingo[i][j][0] : i行j列の数
	// bingo[i][j][0] : i行j列に印がついているかどうか(0：ついてない、1：ついてる)
	int bingo[3][3][2] = {{{0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}}};
	cin >> bingo[0][0][0] >> bingo[0][1][0] >> bingo[0][2][0];
	cin >> bingo[1][0][0] >> bingo[1][1][0] >> bingo[1][2][0];
	cin >> bingo[2][0][0] >> bingo[2][1][0] >> bingo[2][2][0];

	int n = 0;
	cin >> n;
	assert(n >= 1 && n <= 10);
	rep(i, n) {
		int b = 0;
		cin >> b;
		assert(b >= 1 && b <= 100);
		// 印をあけられるかチェック
		rep(j, 3) {
			rep(k, 3) {
				if (bingo[j][k][0] == b) bingo[j][k][1] = 1; 
			}
		}
	}

	string ret = "No";
	// たてよこ
	rep(i, 3) {
		if (bingo[i][0][1] == 1 
		    && bingo[i][1][1] == 1
			&& bingo[i][2][1] == 1)
		{
			ret = "Yes";
		} 
		if (bingo[0][i][1] == 1 
		    && bingo[1][i][1] == 1
			&& bingo[2][i][1] == 1)
		{
			ret = "Yes";
		} 
	}
	// ななめ
	if (bingo[0][0][1] == 1 
		&& bingo[1][1][1] == 1
		&& bingo[2][2][1] == 1)
	{
		ret = "Yes";
	} 
	if (bingo[0][2][1] == 1 
		&& bingo[1][1][1] == 1
		&& bingo[2][0][1] == 1)
	{
		ret = "Yes";
	}

	cout << ret << endl;

	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

ll N, A, B, C, D;
map<ll, ll> mp;
ll cost[6] = {0};
ll solve(ll x){
    if(x==0) return 0;
    if(x==1) return D;
    if(mp.find(x) != mp.end()) return mp[x];
    const ll INF = (1ll<<60);
    ll res = INF;
    if(x<=INF/D) chmin(res, x*D);
    for(ll sig: {-1, 1}){
        for(ll i=0;i<=5;i++){
            ll nx = x + sig * i;
            if(nx<0) continue;
            for(ll div: {2, 3, 5}){
                if(nx%div==0 and nx/div<x) chmin(res, solve(nx/div)+cost[div]+i*D);
            }
        }
    }
    mp[x] = res;
    return res;
}

void solve(){
    cin >> N >> A >> B >> C >> D;
    mp.clear();
    cost[2] = A;
    cost[3] = B;
    cost[5] = C;
    auto res = solve(N);   
    cout << res << endl;
    //for(auto x: mp) cout << x << endl;
}

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

    ll T;
    cin >> T;
    while(T--) solve();

    return 0;
}

Measured memory_bytes: 7100
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second

const int inf = (int)3e6;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n, a, b, c, k, x, y, timer, lg, q;
ll dp[100100];
int tin[100100], tout[100100], up[100100][20];
vector <pii> g[100100];

void dfs(int v, int p = 0) {
    tin[v] = ++timer;
    up[v][0] = p;
    
    for (int i = 1; i <= lg; ++i)
        up[v][i] = up[up[v][i - 1]][i - 1];
    
    for (int i = 0; i < (int)g[v].size(); ++i){
        int to = g[v][i].f;
        if (to != p) {
            dp[to] = dp[v] + g[v][i].s;
            dfs(to, v);
        }
    }
    tout[v] = ++timer;
}

bool upper(int a, int b) {
    return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
    if (upper(a, b)) return a;
    if (upper(b, a)) return b;
    for (int i = lg; i >= 0; --i)
        if (!upper(up[a][i], b))
            a = up[a][i];
    return up[a][0];
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    lg = 1;
    while ((1<<lg) <= n)  ++lg;
    for(int i = 1; i < n; ++i){
        cin >> a >> b >> c;
        g[a - 1].pb(mp(b - 1, c));
        g[b - 1].pb(mp(a - 1, c));
    }
    dfs(0);
    cin >> q >> k;
    k--;
    while(q--){
        cin >> x >> y;
        x--,y--;
        ll ans = 0;
        int pr = lca(x, k);
        int pr1 = lca(y, k);
        cout << dp[x] - dp[pr] + dp[k] - dp[pr] + dp[k] - dp[pr1] + dp[y] - dp[pr1] << endl;
    }
}


Measured memory_bytes: 24448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
}

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

signed main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int l,r;
  l=0;
  r=1;
  int A;
  A=v[0];
  int ans=1;
  while(r<N){
    int k=0;int c=1;
    for(int i=0;i<21;i++){
      if((A&c)&(v[r]&c))k++;
      c*=2;
    }
    if(k){
      A-=v[l];
      l++;
    }
    else{
      ans+=r-l+1;
      A+=v[r];
      r++;
    }
  }
  cout<<ans<<endl;
}


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

bool check(string s) {
    int n = s.length();
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n = s.length();
    string l = s.substr(0, n / 2);
    string r = s.substr((n + 1) / 2);
    if (check(s) && check(l) && check(r)) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            string read = Console.ReadLine(),msg;
            var temp_string = read.Split(' ');
            int a =int.Parse(temp_string[0]), b =int.Parse(temp_string[1]);

            if(a<b)
            {
                msg = "a < b";
            }
            else if(a>b)
            {
                msg = "a > b";
            }
            else
            {
                msg = "a == b";
            }

            Console.WriteLine(msg);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8852
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        int c = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt() -1;
            if(a[x] == 0) c++;
            a[x]++;
        }
        Arrays.sort(a);
        int ans = 0;
        for (int i = n-c; i < n-k; i++) {
            ans += a[i];
        }

        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 84460
# -*- coding: utf-8 -*-
"""
A - Pair
https://atcoder.jp/contests/abc108/tasks/abc108_a

"""
import sys


def solve(K):
    even = K // 2
    odd = (K+1) // 2
    return even * odd


def main(args):
    K = int(input())
    ans = solve(K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline

N = int(input())
S = input()
S = S[:-1]
m = 0
diff = 0
for s in S :
    if s == '(' :
        diff += 1
    elif s == ')' :
        diff -= 1
    m = min(m, diff)
print(('('*(-m))+S+(')'*(diff-m)))

Measured memory_bytes: 38256
#include <stdio.h>
#define N 45

int main(){
  int i,n;
  int fib[N];

  fib[0] = fib[1] = 1;

  for(i = 2; i < 45; ++i) {
    fib[i] = fib[i-1] + fib[i-2];
  }

  scanf("%d", &n);

  printf("%d\n", fib[n]);
  
  return 0;
}



Measured memory_bytes: 2112
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100004],k;
int num[2][47];
ll dp[47][2]; 
int main(){
	memset (dp,-1,sizeof(dp));
	memset (num,0,sizeof(num));
	cin>>n>>k;
	for (int i=0;i<n;i++){
		cin>>a[i];
		for (ll j=0;j<46;j++){
			if (a[i]&(1ll<<j)) num[1][j]++;
			else num[0][j]++;
		}
	}
	dp[46][1]=0;
	int twt=0;
	for (ll i=45;i>=0;i--){
		int q=0;
		if ((1ll<<i)&k) q=1,twt=1;
		dp[i][1]=dp[i+1][1]+num[1-q][i]*(1ll<<i);
		if (q==1 && twt) dp[i][0]=dp[i+1][1]+num[1][i]*(1ll<<i);
		if (dp[i+1][0]!=-1 && twt) dp[i][0]=max(dp[i+1][0]+max(num[0][i],num[1][i])*(1ll<<i),dp[i][0]);
	}
	cout<<max(dp[0][0],dp[0][1]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
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...));
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    auto v = make_vec<int>(h, w);
    rep(i, h) rep(j, w) {
        char c;
        cin >> c;
        v[i][j] = c - '0';
    }

    vector<int> f(h);
    int ans = INF;
    rep(bit, 1 << (h - 1)) {
        int now = __builtin_popcount(bit);
        f[0] = 0;
        rep(i, h - 1) {
            if (bit & (1 << i))
                f[i + 1] = f[i] + 1;
            else
                f[i + 1] = f[i];
        }

        vector<int> cnt(f[h - 1] + 1);
        rep(j, w) {
            vector<int> tmp(f[h - 1] + 1);
            rep(i, h) {
                if (v[i][j] == 1) tmp[f[i]]++;
            }
            bool flg = 0;
            rep(i, f[h - 1] + 1) {
                if (tmp[i] > k) now = INF;
                if (cnt[i] + tmp[i] > k) flg = 1;
            }

            if (flg) {
                rep(i, f[h - 1] + 1) {
                    cnt[i] = tmp[i];
                }
                now++;
            } else {
                rep(i, f[h - 1] + 1) {
                    cnt[i] += tmp[i];
                }
            }
        }
        chmin(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
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;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin>>n;
    vector<ll>t(n);
    rep(i,0,n){
        cin>>t[i];
    }
    ll x=t[0];
    rep(i,1,n){
        x=lcm(x,t[i]);
    }
    cout<<x<<endl;

    
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = 1;
    rep(i,n){
        if(s[i]!=s[n-1-i]){
            flag = 0;
        }
    }
    rep(i,(n-1)/2){
        if(s[i]!=s[(n-1)/2-1-i])flag = 0;
    }
    for(int i=(n+3)/2-1;i<n;i++){
        if(s[i]!=s[(n+3)/2+n-2-i])flag = 0;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <climits>
using namespace std;
typedef long long ll;
ll INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	int h[n],dp[n];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++) cin>>h[i];
	for(int i=0;i<n;i++){
		int tmp=INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j<0) continue;
			int x=dp[i-j]+abs(h[i-j]-h[i]);
			tmp=min(tmp,x);
		}
		if(tmp==INT_MAX) continue;
		dp[i]=tmp;
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1152
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	ws := make([]string,n)
	m :=  make(map[string]int,n)
	for i := 0; i < n; i++ {
		var w string
		fmt.Scan(&w)
		ws[i] = w
		m[w]++
	}

	var last string
	for _,v := range ws {
		ss := strings.Split(v,"")
		if (last != "" && ss[0] != last) || m[v] > 1 {
			fmt.Println("No")
			return
		}
		last = ss[len(ss) - 1]
	}
	fmt.Println("Yes")
}

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

using namespace std;

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



int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll X, Y;
    cin >> X >> Y;

    int ans = 0;
    while(X <= Y){
        X *= 2;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

n,m=map(int,input().split())
l=divisore(m)
for i in l:
 if m/n>=i:
  print(i)
  exit()

Measured memory_bytes: 3064
s=gets.chomp.bytes.map{|b|b-97};n=gets.to_i;s.size.times{|i|n>=(m=(26-s[i])%26)&&n-=m-s[i]=0};s[-1]=(s[-1]+n)%26;puts s.map{|e|(e+97).chr}*''

Measured memory_bytes: 7668
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
for i in range(n):
    tmp = 0
    for j in range(i,n):
        if s[i] == s[j]:
            tmp += 1
    for j in range(m):
        if s[i] == t[j]:
            tmp -= 1
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3064
/*
  I used a template program in C.
*/

#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;
 
Node treeMinimum(Node x){

  /*my code beginning*/
  while ( x->left != NIL ){
    x = x->left;
  }
  return x;
  /*my code end*/

}
 
Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){ /*find*/

  /*my code beginning*/
  if ( u == NIL || k == u->key ){
    return u;
  }
  if ( k < u->key ){ 
    return treeSearch(u->left,k);
  } else { 
    return treeSearch(u->right,k);
  }
  /*my code end*/

}
 
Node treeSuccessor(Node x){

  /*my code beginning*/
  Node y;
  if ( x->right != NIL ){ 
    return treeMinimum(x->right);
  }
  y = x->parent;
  while ( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
  /*my code end*/

}
 
Node treeDelete(Node z){ /*delete*/
  Node y; // node to be deleted
  Node x; // child of y

  /*my code beginning*/
  if ( z->left == NIL || z->right == NIL ){ 
    y = z;
  } else {
    y = treeSuccessor(z);
  }
  if ( y->left != NIL ){ 
    x = y->left;
  } else {
    x = y->right;
  }
  if ( x != NIL ){ 
    x->parent = y->parent;
  }
  if ( y->parent == NIL ){ 
    root = x;
  } else if ( y == y->parent->left ){ 
    y->parent->left = x;
  } else {
    y->parent->right = x;
  }
  if (y != z){
    z->key = y->key;
  }
  return y;
  /*my code end*/

}
 
 
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;

  /*my code beginning*/
  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;
  }
  /*my code end*/

}
 
void inorder(Node u){

  /*my code beginning*/
  if (u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
  /*my code end*/

}
void preorder(Node u){

  /*my code beginning*/
  if (u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
  /*my code end*/

}

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

  /*my code beginning*/
  root=NIL;
  /*my code end*/

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

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

int main()
{
    string S;
    ll Q;
    cin >> S;
    cin >> Q;
    
    char query[Q][3];
    for(ll i=0;i<Q;i++){
        cin >> query[i][0];
        if(query[i][0]=='2'){
            cin >> query[i][1] >> query[i][2];
        }
    }

    bool direct=true;
    vector<char> ans;
    ll num=S.size();
    for(ll i=0;i<num;i++)
        ans.push_back(S[i]);
    for(ll i=0;i<Q;i++){
        //cout << query[i][0] << endl;
        if(query[i][0]=='1'){
            direct=!direct;
        }else{
            if(direct){
                if(query[i][1]=='1'){
                    ans.insert(ans.begin(),query[i][2]);
                    
                }else{
                    ans.push_back(query[i][2]);
                }
            }else if(!direct){
                if(query[i][1]=='2'){
                    ans.insert(ans.begin(),query[i][2]);
                }else{
                    ans.push_back(query[i][2]);
                }
            }
        }
    }
    if(!direct){
        reverse(begin(ans),end(ans));
    }
    for(ll i=0;i<ans.size();i++){
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 1660