akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

// https://atcoder.jp/contests/abc137/submissions/6847236

int p;
const ll INF = 1e18; // O(|V||E|)
int MAX_V = 3000;
vector<ll> d(2501, INF); // 0からの時間
int n, e, r; // 頂点、辺、スタート
bool bell(int n, vector<vector<pii> > edge, int s) {
    d[s] = 0;
    
    rep(cnt, 2 * MAX_V) {
        
        rep(from, n) {
            if (d[from] == INF) continue;
            rep(j, SZ(edge[from])) {
                int to = edge[from][j].F;
                int cost = edge[from][j].S;
                
                if (d[to] > d[from] + cost) {
                   
                    d[to] = d[from] + cost;
                    if (cnt >= 2500 - 1) {
                        d[to] = -INF;
                        if (to == n - 1) return 0;
                    }
                }
            }
        }
        
    }
    
    return 1;
    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> e >> p;
    
    vector<vector<pii> > edge(n);
    rep(i, e) {
        int s, t, d;
        cin >> s >> t >> d;
        s--; t--;
        d = d - p;
        edge[s].eb(t, -d);
    }
    
    if (bell(n, edge, r) == 0) {
        out(-1);
    } else {
        out(max(0LL, -d[n - 1]));
    }
    
}


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

using namespace std;

typedef long long ll;

const int V[8] = {0, 1, 2, 3, 5, 7, 8, 9};

ll hatisin(ll a) {
  ll res = 0;
  ll i = 1;
  int t = 0;
  while(a > 0) {
    t = a % 8;
    res += t * i;
    a /= 8;
    i *= 10;
  }
  return res;
}

ll fukkatu(ll b) {
  ll res = 0;
  ll i = 1;
  int t = 0;
  while(b > 0) {
    t = b % 10;
    res += V[t] * i;
    i *= 10;
    b /= 10;
  }
  return res;
}

int main() {
  ll res;
  while(true) {
    cin >> res;
    if (res == 0) break;
    cout << fukkatu(hatisin(res)) << endl;
  }
  
  return 0;
}

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

typedef pair <int, int> ii;

const int Maxm = 100005;

int n;
int a[Maxm];
int freq[Maxm];
ii best[2][2];
void Get(int from)
{
    fill(freq, freq + Maxm, 0);
    for (int i = from; i < n; i += 2)
        freq[a[i]]++;
    for (int i = 1; i < Maxm; i++)
    {
		if (ii(freq[i], i) > best[from][0])
            best[from][1] = best[from][0], best[from][0] = ii(freq[i], i);
        else if (ii(freq[i], i) > best[from][1])
            best[from][1] = ii(freq[i], i);
	} 
}
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    Get(0); Get(1);
    int res = 0;
    if (best[0][0].second == best[1][0].second)
        res = max(best[0][0].first + best[1][1].first,
                  best[0][1].first + best[1][0].first);
    else res = best[0][0].first + best[1][0].first;
    printf("%d\n", n - res);
    return 0;
}

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

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

struct CITY
{
    int pre;
    int year;
    int num;
    string name;
};
CITY city[100001];

bool cmps(const CITY &a, const CITY &b)
{
    if (a.pre == b.pre)
        return a.year < b.year;
    return a.pre < b.pre;
}

bool cmpt(const CITY &a, const CITY &b)
{
    return a.num < b.num;
}

string to_s(int x)
{
    string ans = "";
    string tmp = to_string(x);
    rep(i, 0, 6 - tmp.size())
    {
        ans += '0';
    }
    ans += tmp;
    return ans;
}

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

    rep(i, 0, m)
    {
        cin >> city[i].pre >> city[i].year;
        city[i].num = i;
    }
    sort(city, city + m, cmps);
    /* rep(i, 0, m)
    {
        cout << city[i].pre << " " << city[i].year << " " << city[i].num << endl;
    }
    cout << endl;*/
    int num = 0;
    rep(i, 0, m)
    {
        //cout << city[i].pre << " " << city[i].year << " " << city[i].num << endl;
        //cout << num << endl;
        if (i == 0)
        {
            city[i].name += to_s(city[i].pre);
            city[i].name += to_s(1);
            num++;
        }
        else
        {
            if (city[i].pre == city[i - 1].pre)
            {
                city[i].name += to_s(city[i].pre);
                city[i].name += to_s(num + 1);
                num++;
            }
            else
            {
                city[i].name += to_s(city[i].pre);
                city[i].name += to_s(1);
                num = 1;
            }
        }
        //cout << num << endl;
    }
    sort(city, city + m, cmpt);
    rep(i, 0, m)
    {
        //cout << city[i].pre << " " << city[i].year << " " << city[i].num << endl;
        cout << city[i].name << endl;
    }
    //cout << endl;
}


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

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

    vector<long long> P(N + 1, 0);
    for (long long i = 1; i <= N; i++)
    {
        long long p;
        cin >> p;
        P[p] = i;
    }

    set<long long> s;
    long long ans = 0;
    for (long long i = N; i > 0; i--)
    {
        s.insert(P[i]);
        if (s.size() < 2)
        {
            continue;
        }
        long long n1 = P[i] - 1;
        long long n2 = 0;
        long long m1 = N - P[i];
        long long m2 = 0;

        auto itr = s.find(P[i]);

        if (itr != s.begin())
        {
            itr--;
            n1 = P[i] - *itr - 1;
            n2 = *itr - 1;
            if (itr != s.begin())
            {
                n2 = *itr - *(--itr) - 1;
            }
        }

        itr = s.find(P[i]);
        if (++itr != s.end())
        {
            m1 = *itr - P[i] - 1;
            m2 = N - *itr;
            if (++itr != s.end())
            {
                m2 = *itr - *(--itr) - 1;
            }
        }

        long long count = 0;
        itr = s.find(P[i]);
        if (itr != s.begin())
        {
            count += (n2 + 1) * (m1 + 1);
        }
        if (++itr != s.end())
        {
            count += (m2 + 1) * (n1 + 1);
        }
        ans += i * count;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,k;
    cin>>n>>k;
    Vec h(n);
    cin>>h;

    ll sum = 0;
    sort(rALL(h));
    rep(i,n){
        if(i<k)continue;
        sum += h[i];
    }
    cout<<sum<<endl;
    return  0;
}


Measured memory_bytes: 1792
s = input()
t = input()

# dp[i][j] : 文字列Sのi文字目までと文字列Tのj文字目まででの値(len, 例)

dp = [[0 for i in range(len(t) + 2)] for j in range(len(s) + 2)]

dp[0][0] = 0

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

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

print(st)

Measured memory_bytes: 121436
#! python3
# diceI.py - サイコロを転がす動きをシミュレートするプログラム

def initDice(numbers): # サイコロオブジェクトに値を入れる
    # サイコロオブジェクトを定義, 配列の数値を、各面にわたす
    dice = {'top': numbers[0], 'bottom': numbers[5], 'front': numbers[1],
            'back': numbers[4], 'right': numbers[2], 'left': numbers[3]}
    return dice

def rollDice(dice, direction): # サイコロを転がしたときの関数
    dice = dice
    if direction == 'N':
        top = dice['front']
        bottom = dice['back']
        front = dice['bottom']
        back = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'S':
        top = dice['back']
        bottom = dice['front']
        front = dice['top']
        back = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'E':
        top = dice['left']
        bottom = dice['right']
        right = dice['top']
        left = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    elif direction == 'W':
        top = dice['right']
        bottom = dice['left']
        right = dice['bottom']
        left = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    return dice

numbers = [int(i) for i in input().split()]
dice = initDice(numbers)
directions = input()
for direction in directions:
  dice = rollDice(dice, direction)

print(dice['top'])


Measured memory_bytes: 5616
from collections import Counter
N = int(input())
blue = []
for i in range(N):
    blue.append(input())
M = int(input())
red = []
for j in range(M):
    red.append(input())
blue_Counter = Counter(blue)
red_Counter = Counter(red)
ans = blue_Counter - red_Counter
if not ans.most_common():
    print(0)
else:
    print(ans.most_common()[0][1])


Measured memory_bytes: 3316
import java.util.*;
import java.lang.*;

public class Main {

    public static void main (String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long a = in.nextLong();
        long b = in.nextLong();

        long i = n / (a + b) * a;
        long j = Math.min(n % (a + b), a);
        System.out.println(i + j);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    int *co;
    co=new int[n];
    for(int i=0;i<n;++i) {
        cin>>co[i];
    }
    sort(co,co+n,greater<int>());
    int nmax=0;
    nmax=c/a;
    int monny=c;
    for(int i=0;i<n;++i) {
        monny+=co[i];
        nmax=max(nmax,monny/(a+(i+1)*b));
    }
    cout<<nmax<<endl;
    return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=1000000;



main(){
    int n;cin>>n;
    int t=in();
    vec v;rep(i,n)v.pb(in());
    v.pb(INT_MAX);
    int ans=0;
    rep(i,n){
        ans+=min(v[i+1]-v[i],t);
    }
    cout<<ans;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if (n == 1)
        cout << "Hello World" << endl;
    else if (n == 2)
    {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

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

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

fn main(){
    let n: u64 = read();

    println!("{}", 8 - (n - 400) / 200);
}



Measured memory_bytes: 2108
//BISMILLAHIR RAHMANIR RAHIM

#include <bits/stdc++.h>
#define loop(i,n) for(int i=0;i<n;i++)
#define pi acos(-1.00)

using namespace std;



int main()
{
long long int n;
cin>>n;
long long int p[n+1],count=0,i,j,q=0;
for(i=0;i<n;i++)
{
    cin>>p[i];
}
j=p[0];
for(i=0;i<n;i++)
{
    if(j>p[i])
    {
        q++;
        j=p[i];
    }

}
cout<<q+1<<endl;

}



Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
int n,k;
  cin >> n>>k;
  if(n%k==0){
cout <<0;
  }
  else {
  cout <<1;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,A[100],temp,count=0,i,j,k;
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  for(i=0;i<N-1;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	  temp=A[j-1];
	  A[j-1]=A[j];
	  A[j]=temp;
	  count++;
      }
    }
  }
  for(k=0;k<N-1;k++) printf("%d ",A[k]);
  printf("%d",A[N-1]);
  printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    if(n%11 == 0){
        cout<<(long long)(n/11)*2<<endl;
    }
    else{
        cout<<(long long)(n/11)*2 + (long long)ceil((long double)(n%11)/6)<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	float n;
	while(scanf("%f",&n)!=EOF){
		if(n<=48){
			printf("light fly\n");
		}
		else if(n<=51){
			printf("fly\n");
		}
		else if(n<=54){
			printf("bantam\n");
		}
		else if(n<=57){
			printf("feather\n");
		}
		else if(n<=60){
			printf("light\n");
		}
		else if(n<=64){
			printf("light welter\n");
		}
		else if(n<=69){
			printf("welter\n");
		}
		else if(n<=75){
			printf("light middle\n");
		}
		else if(n<=81){
			printf("middle\n");
		}
		else if(n<=91){
			printf("light heavy\n");
		}
		else{
			printf("heavy\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1032
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            string S = cin.ReadLine;
            var words = new string[] {"dream","eraser","erase"};
            var checkWords = new string[] {"eraser","erase","er"};
            bool flgForCheck = false;

            for(int i=0; i<S.Length;){
              	flgForCheck = false;
                foreach (string word in words)
                {
                  	if((i + word.Length) > S.Length) continue;
                    if(S.Substring(i,word.Length) == word){
                        i += word.Length;
                        flgForCheck = true;
                        if(word == "dream"){
                            i = Check(i,S,checkWords);
                        }
                        break;
                    }
                }
                if(!flgForCheck)break;
            }

            if(flgForCheck) WriteLine("YES");
            else WriteLine("NO");
        }

        int Check(int i , string S,string[] array){
            foreach(string word in array){
                if((i + word.Length) > S.Length) continue;
                if(S.Substring(i,word.Length) == word){
                    i += word.Length;
                    break;
                }
            }
            return i;
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin >> s;
  if(s[5] == '0' && s[6]-'0' <=4){
      cout << "Heisei" << endl;
  }else{
      cout << "TBD" << endl;
  }

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;

struct NODE{
	ll sum;
	bool done;
	bool group;
	vl edges_to;
	vl edges_cost;
};

void dfs(vector<NODE> &nodes, ll now, bool odd){
	if (nodes[now].done) return;
	nodes[now].done = 1;
	if (!odd) nodes[now].group = 1;
	for (int i = 0; i < nodes[now].edges_to.size(); ++i){
		if (nodes[now].edges_cost[i] % 2 == 0) dfs(nodes, nodes[now].edges_to[i],odd);
		else dfs(nodes, nodes[now].edges_to[i], !odd);
	}
}

int main(){
	ll n; cin >> n;
	vector<NODE> nodes(n);
	for (int i = 0; i < n - 1; ++i){
		nodes[i].done = 0;
		nodes[i].group = 0;
		ll u, v, w; cin >> u >> v >> w;
		nodes[u - 1].edges_to.push_back(v - 1);
		nodes[u - 1].edges_cost.push_back(w);
		nodes[v - 1].edges_to.push_back(u - 1);
		nodes[v - 1].edges_cost.push_back(w);
	}nodes[n - 1].done = 0;
	nodes[n - 1].group = 0;

	dfs(nodes, 0,0);
	for (int i = 0; i < n; ++i) cout << nodes[i].group << endl;
	return 0;
}

Measured memory_bytes: 14336
def run():
    eq = [i for i in input().split()]
    stack = []
    for i in eq:
        if i in '+-*':
            y = stack.pop()
            x = stack.pop()
            if i == '+':
                stack.append(x + y)
            elif i == '-':
                stack.append(x - y)
            elif i == '*':
                stack.append(x * y)
        else:
            stack.append(int(i))
    print(stack.pop())

if __name__ == '__main__':
    run()




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

static class Integral
{
    static void Main()
    {
        var q =
            from d in
                RepeatInfinite<Func<string>>( Console.ReadLine )
                    .Select( x => x() )
                    .TakeWhile( x => x != null )
                    .Select( int.Parse )
            select Enumerable.Range( 1, 600 )
                .TakeWhile( x => x * d <= 600 - d )
                .Sum( x => x * x * d * d * d );
        q.ToList().ForEach( Console.WriteLine );
    }

    static IEnumerable<TSource> RepeatInfinite<TSource>(TSource value)
    {
        while ( true )
            yield return value;
    }
}

Measured memory_bytes: 5980
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
cnt = 0
cnt_money = 0
for i in sorted([rl() for _ in range(n)]):
  a, b = i
  if cnt + b < m:
    cnt += b
    cnt_money += a*b
  else:
    cnt_money += (m - cnt) * a
    break
print(cnt_money)
    

















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

int pa[100001];
pair<pair<int, int>, int> g[100001];
vector<pair<int, pair<int, int> > > ed;

int P(int v){
	if (pa[v])return pa[v] = P(pa[v]);
	return v;
}

inline void aded(pair<pair<int, int>, int> &a, pair<pair<int, int>, int> &b){
	int x = abs(a.first.first - b.first.first), y = abs(a.first.second - b.first.second);
	ed.push_back(make_pair(min(x, y), make_pair(a.second, b.second)));
}

int main(){
	int n;
	scanf("%d", &n);
	f(i, 1, n + 1)scanf("%d%d", &g[i].first.first, &g[i].first.second), g[i].second = i;
	sort(g + 1, g + n + 1);
	f(i, 1, n)aded(g[i], g[i + 1]);
	f(i, 1, n + 1)swap(g[i].first.first, g[i].first.second);
	sort(g + 1, g + n + 1);
	f(i, 1, n)aded(g[i], g[i + 1]);
	sort(ed.begin(), ed.end());
	ll an = 0;
	f(i, 0, ed.size()){
		int a = P(ed[i].second.first), b = P(ed[i].second.second);
		if (a == b)continue;
		an += ed[i].first;
		pa[b] = a;
	}
	printf("%lld\n", an);
}

Measured memory_bytes: 6132
//TLE
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define N 100000
#define max(a, b) (a > b ? a : b)

typedef struct queue
{
  int a;
  int b;
  struct queue *next;
} queue;

typedef struct Queue
{
  queue *front;
  queue *back;
  int size;
} Queue;

Queue *Queue_init()
{
  Queue *Q = malloc(sizeof(Queue));
  Q->front = NULL;
  Q->back = NULL;
  Q->size = 0;
  return Q;
}

queue *queue_create(int a, int b)
{
  queue *q = malloc(sizeof(queue));
  q->a = a;
  q->b = b;
  q->next = NULL;
  return q;
}

void queue_free(queue *q)
{
  if (q != NULL)
    free(q);
}

bool Queue_empty(Queue *Q)
{
  if (Q->size == 0)
    return true;
  return false;
}

void Queue_free(Queue *Q)
{
  if (Q != NULL) {
    if (Queue_empty(Q)) {
      free(Q);
    } else {
      printf("queue isn't empty.\n");
    }
  }
  return ;
}

queue *Queue_back(Queue *Q)
{
  return Q->back;
}

queue *Queue_front(Queue *Q)
{
  return Q->front;
}

void Queue_pop(Queue *Q)
{
  if (Queue_empty(Q))
    return ;
  queue *qf = Q->front;
  Q->front = qf->next;
  Q->size--;
  queue_free(qf);
}

void Queue_push(Queue *Q, int a, int b) {
  queue *aq = queue_create(a, b);
  if (Queue_empty(Q)) {
    Q->front = aq;
    Q->back = aq;
    Q->size++;
    return ;
  }
  queue *bq = Queue_back(Q);
  bq->next = aq;
  Q->back = aq;
  Q->size++;
}

int Queue_size(Queue *Q)
{
  return Q->size;
}

typedef struct node{
  int value;
  Queue *edge;
}node;

node t[N];
int color[N], pc[N];

void init(int n) {
  for (int i = 0; i < n; i++)
  {
    t[i].value = i + 1;
    t[i].edge = Queue_init();
  }
  for (int i=0; i<n-1; i++) {
    color[i] = 0;
    pc[i] = 0;
  }
  return ;
}

void _free(int n) {
  for (int i = 0; i < n; i++)
    Queue_free(t[i].edge);
  return ;
}

void dfs(int a) {
  int c = 1;
  while (!Queue_empty(t[a].edge))
  {
    queue *front = Queue_front(t[a].edge);
    if (color[front->b] == 0)
    {
      if (pc[a] == c)
        c++;
      color[front->b] = c;
      pc[front->a] = c;
      c++;
      dfs(front->a);
    }
    Queue_pop(t[a].edge);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  init(n);
  int a, b, ans = 0;
  for (int i=0; i<n-1; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    Queue_push(t[a].edge, b, i);
    Queue_push(t[b].edge, a, i);
  }
  for (int i=0; i<n; i++)
    ans = max(ans, Queue_size(t[i].edge));
  dfs(0);
  _free(n);
  printf("%d\n", ans);
  for (int i=0; i<n-1; i++)
    printf("%d\n", color[i]);
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;


int main(){ 
    string s;
    cin >> s;
    ll n = (ll)s.size();

    ll cnt[n] = {};
    ll r_cnt = 0;
    rep(i,0,n-1){
        if(s[i] == 'R') r_cnt++;

        if(s[i] == 'R' && s[i+1] == 'L'){
            cnt[i] += ceil(r_cnt/2.0);
            cnt[i+1] += r_cnt - ceil(r_cnt/2.0);
            r_cnt = 0;
        }

    }

    ll l_cnt = 0;
    rep(i,0,n-1){
        if(s[n-i-1] == 'L') l_cnt++;

        if(s[n-i-2] == 'R' && s[n-i-1] == 'L'){
            cnt[n-i-1] += ceil(l_cnt/2.0);
            cnt[n-i-2] += l_cnt - ceil(l_cnt/2.0);
            l_cnt = 0;
        }
    }

    rep(i,0,n){
        cout << cnt[i] << ((i == n-1)? "\n": " ");
    }

}


Measured memory_bytes: 4512
from collections import deque

def updiv(a,b):
    if a % b == 0:
        return a // b
    else:
        return a // b + 1

N,D,A = map(int,input().split())

XH = []

for i in range(N):

    x,h = map(int,input().split())
    XH.append([x,h])

XH.sort()

q = deque([])
qs = 0
ans = 0

for i in range(N):

    X = XH[i][0]
    H = XH[i][1]

 
    while len(q) > 0 and q[0][0] < X-D:
        po = q.popleft()
        qs -= po[1] * A

    if H - qs <= 0:
        continue
        
    else:
        pl = updiv(H-qs,A)
        qs += pl * A
        ans += pl
        q.append([X+D,pl])

print (ans)
        


Measured memory_bytes: 85592
N = int(input())
S = list(input())


for i in range(len(S)):
    S[i] = ord(S[i])

for i in range(len(S)):
    if S[i] + N <= 90:
        S[i] = chr(S[i] + N)
    else:
        S[i] = chr(64 + S[i] + N - 90)


S = ''.join(S)
print(S)

Measured memory_bytes: 66892
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> b(N, 0);
    for (int i = 0; i < N; i++)
        cin >> b[i];

    vector<int> ans(N, -1);
    vector<int> gap(N, 0);
    int flag = 0;

    for (int i = 0; i < N; i++)
        gap[i] = i + 1 - b[i];

    for (int i = N-1; i >= 0; i--) {
        flag = 0;

        for (int j = N-1; j >= 0; j--) {
            if (flag-1 && gap[j] == 0) {
                flag = 1;
                ans[i] = b[j];
                for (int m = j; m < N; m++)
                    gap[m]--;
            }
        }

        //test down

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

        //test up

        if (flag - 1) break;
    }

    //test down

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

    //test up

    if (ans[0] == -1) {
        cout << -1 << endl;
    } else {
        for (int i = 0; i < N; i++)
            cout << ans[i] << endl;
    }

    return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<P> vc;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    vc.push_back(P(x, y));
  }
  sort(ALL(vc));
  REP(i, n) cout << vc[i].first << " " << vc[i].second << endl;
  return 0;
}


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

#define NIL -1
using namespace std;

struct Node{
    int current_node,parent_node,left_child,right_child,sibling_node;
    int depth,height;
};

void preOrder(const vector<Node> &Tree,int current_node){
    printf(" %d",current_node);
    if(Tree[current_node].left_child != NIL) preOrder(Tree,Tree[current_node].left_child);
    if(Tree[current_node].right_child!= NIL) preOrder(Tree,Tree[current_node].right_child);
}

void inOrder(const vector<Node> &Tree,const int current_node){
   if(current_node == NIL) return;
   inOrder(Tree,Tree[current_node].left_child);
   printf(" %d",current_node);
   inOrder(Tree,Tree[current_node].right_child);
}

void postOrder(const vector<Node> &Tree,const int current_node){
    if(current_node == NIL) return;
    postOrder(Tree,Tree[current_node].left_child);
    postOrder(Tree,Tree[current_node].right_child);
    printf(" %d",current_node); 
}

int main(){
    int num_node;
    int current_node,left_child,right_child,degree;
    int root;
    string node_type;
    scanf("%d",&num_node);
    vector<Node> Tree(num_node,Node{NIL,NIL,NIL,NIL,NIL,NIL,NIL});

    for(int i = 0;i < num_node;i++){
        scanf("%d %d %d",&current_node,&left_child,&right_child);
        Tree[current_node].left_child  = left_child;
        Tree[current_node].right_child = right_child;
        Tree[right_child].parent_node  = current_node;
        Tree[left_child].parent_node   = current_node;
        Tree[right_child].sibling_node = left_child;
        Tree[left_child].sibling_node  = right_child;
    }
    for(int i = 0;i < num_node;i++){
        if(Tree[i].parent_node == -1) root = i;
    }
    printf("Preorder\n");
    preOrder(Tree,root);
    printf("\n");
    printf("Inorder\n");
    inOrder(Tree,root);
    printf("\n");
    printf("Postorder\n");
    postOrder(Tree,root);
    printf("\n");
    
    return 0;   
}



Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::string str;
	std::cin >> str;
	int k;
	std::cin >> k;
	long long ans = 0;
	std::vector<int> groups;
	for(int l = 0, r = 0; l < (int) str.size(); l = r) {
		while(r < (int) str.size() && str[l] == str[r]) {
			r++;
		}
		ans += (r - l) / 2;
		groups.push_back(r - l);
	}
	if(groups.size() == 1) {
		ans = (long long) str.size() * k / 2;
	} else {
		ans = 0;
		if(str[0] != str.back()) {
			for(auto size : groups) {
				ans += (long long) k * (size / 2);
			}
		} else {
			ans += (long long) (k - 1) * ((groups[0] + groups.back()) / 2);
			ans += groups.back() / 2;
			groups.pop_back();
			ans += groups[0] / 2;
			groups[0] = 0;
			for(auto size : groups) {
				ans += (long long) k * (size / 2);
			}
		}
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
  	long sum=0;
  	scanf("%d",&n);
  	int a[n];
  	for(int i=0;i<n;i++){
    	scanf("%d",&a[i]);
    }
  	for(int i=1;i<n;i++){
    	if(a[i-1]>a[i]){
          sum += a[i-1]-a[i];
     	  a[i] = a[i-1];
        }
    }
  	printf("%ld\n",sum);
}

Measured memory_bytes: 2892
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))

ans=0
diff=10**9
for i in range(N):
    t=T-0.006*H[i]
    d=abs(A-t)
    if d<diff:
        ans=i+1
        diff=d
print(ans)

Measured memory_bytes: 38384
n,m = map(int,input().split())
l = []
for i in range(n):
    l1 = list(map(int,input().split()))
    l.append(l1)
l2 = []
for i in range(m):
    l2.append(int(input()))

for i in range(n):
    tmpc = 0
    for j in range(m):
        tmpc+=l[i][j]*l2[j]
    print(tmpc)


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(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 complex<double> xy_t;
typedef vector<lint> poly;
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;}

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

template<class T> struct  SegTree{
    typedef  function<T(T, T)> F;
    int n = 1;
    vector<T> node;
    T et;
    F f, g;

    SegTree(int n_, T et_, F f_, F g_):
    et(et_), f(f_), g(g_){
        while(n < n_) n *= 2;
        node.resize(n*2-1, et);
    }

    void update(int i, T x){
        i += n-1;
        node[i] = g(node[i], x);
        while(i){
            i = (i-1) / 2;
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }

    T query(int a, int b){
        T vl = et, vr = et;
        for(a+=n-1, b+=n-1; a<b; a=(a-1)/2, b=(b-1)/2){
            if(!(a&1)) vl = f(vl, node[a++]);
            if(!(b&1)) vr = f(node[--b], vr);
        }
        return f(vl, vr);
    }
};

int main(){
    lint n, K;
    scanf("%lld%lld", &n, &K);
    lint a[n], s[n+1];
    vector<lint> v(n+1);
    s[0]=v[0]=0;
    rep(i, n){
        scanf("%lld", &a[i]);
        a[i]-=K;
        s[i+1]=s[i]+a[i];
        v[i+1]=s[i+1];
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    SegTree<lint> st(n+2, 0, plus<>(), plus<>());
    rep(i, n+1){
        int idx=lower_bound(v.begin(), v.end(), s[i])-v.begin();
        st.update(idx, 1);
    }
    lint ans=0;
    rep(i, n+1){
        int idx=lower_bound(v.begin(), v.end(), s[i])-v.begin();
        st.update(idx, -1);
        ans+=st.query(idx, n+2);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 7360
@n = gets.to_i
@list = @n.pred.times.collect { gets.split.collect(&:to_i) }

def run(i, t)
  if i >= @n.pred
    return t
  end
  c, s, f = @list[i]
  if t < s
    t = s
  end
  m = t % f
  unless m.zero?
    t += f - m
  end
  t += c
  run(i + 1, t)
end

@n.times do |i|
  puts run(i, 0)
end


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144C_Walk_on_Multiplication_Table
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            long min = long.MaxValue;
            long a = 0;
            long b = 0;
            for (int i = 1; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                {
                    long tmp = n / i;
                    if (i + tmp < min)
                    {
                        min = i + tmp;
                        a = i;
                        b = tmp;
                    }
                }
            }

            Console.WriteLine(a - 1 + b - 1);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>
using namespace std;
int N, A[100001], B[2]; long long ans;
int main() {
  scanf("%d", &N);
  for(int i = 0; i < N+1; i++) scanf("%d", &A[i]);
  for(int i = 0; i < N+1; i++) {
    scanf("%d", &B[1]); if(i == N) B[1] = 0;
    ans += min(A[i], B[0]+B[1]);
    B[0] = B[1]-min(B[1], max(A[i]-B[0], 0));
  }
  printf("%ld", ans);
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
    int r1,r2;
    double r3 ;
    scanf("%d %d",&r1,&r2);
    if((r1 >= 1 && r1 <= 100) && (r2 >= 1 && r2 <= 100 ))
    {
        r3 = double(1.0/r1) + double(1.0/r2) ;
        r3 = 1.0/r3 ;
        printf("%.10f\n",r3);

    }

    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  int ans=a[0];
  rrep(i,n-1){
    ans=gcd(ans,a[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3716
class Array
  def cumsum; s = 0; map{|k| s += k } end
  def mod(m); map{|k|k%m} end
end

n,k = gets.split.map(&:to_i)
a   = [0] + gets.split.map{ |k| k.to_i - 1 }

c = a.cumsum.mod(k)

ans = 0
h = Hash.new(0)

(n+1).times do |i|
  h[c[i-k]] -= 1 if i >= k
  ans += h[c[i]]
  h[c[i]] += 1
end

puts ans

Measured memory_bytes: 33292
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
typedef pair<ll, int> P;

int main() {
    int n, k;
    cin >> n >> k;
    vector <P> vec;
    for (int i = 0; i < n; i++) {
        int t;
        ll d;
        cin >> t >> d;
        vec.push_back(P(d, t));
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    vector <ll> redundant;
    map <int, int> mp;
    ll sm = 0LL;
    for (int i = 0; i < k; i++) {
        sm += vec[i].first;
        if (mp[vec[i].second] == 0) {
            mp[vec[i].second] = 1;
        } else {
            redundant.push_back(vec[i].first);
        }
    }

    int pos = redundant.size() - 1;
    ll sz = mp.size();
    ll ans = sm + sz * sz;
    for (int i = k; i < n; i++) {
        if (sz == k) break;
        if (mp[vec[i].second] > 0) continue;

        sm -= redundant[pos--];
        sm += vec[i].first;
        mp[vec[i].second] = 1;
        sz++;

        ans = max(ans, sm + sz * sz);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;


ll h, w;

ll func(ll x, ll y){
    ll res = 100000000010;
    REP(i, 1, y){
        ll rec1 = x * i;
        ll rec2, rec3;
        if ((y - i) % 2){
            rec2 = x * ((y - i) / 2);
            rec3 = x * ((y - i) + 1 / 2);
        }else{
            rec2 = rec3 = x * (y - i) / 2;
        }

        ll n1 = max(rec1, max(rec2, rec3)) - min(rec1, min(rec2, rec3));

        if (x % 2){
            rec2 = x / 2 * (y - i);
            rec3 = (x + 1) / 2 * (y - i);
        }else{
            rec2 = rec3 = x / 2 * (y - i);
        }
        ll n2 = max(rec1, max(rec2, rec3)) - min(rec1, min(rec2, rec3));

        res = min(res, min(n1, n2));
    }

    return res;
}


int main(){
    cin >> h >> w;
    ll m1 = func(h, w);
    ll m2 = func(w, h);

    cout << min(m1, m2) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  cout << 48 - a << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

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

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
    int X;
    cin >> X;
    for (int p = X; ; p++) {
        bool f = 1;
        for (int i = 2; i * i <= p; i++) {
            if (p % i == 0) {
                f = 0;
                break;
            }
        }
        if (f) {
            cout << p << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys
import os
from operator import itemgetter

N=int(input())

S=[0]*N
P=[0]*N
X=[0]*N
X2=[0]*N
for i in range(N):
    S[i], P[i] =  input().split()
    X[i]=S[i]+P[i]
    P[i]=int(P[i])

D=[list(x) for x in zip(*sorted(zip(P, S), key=itemgetter(0),reverse=True))]
S=D[1]
P=D[0]
D=[list(x) for x in zip(*sorted(zip(S, P), key=itemgetter(0)))]
S=D[1]
P=D[0]
for i in range(N):
    X2[i]=P[i]+str(S[i])
    print(X.index(X2[i])+1)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

int K;
string S;

int main() {
    cout << fixed << setprecision(15);
    cin >> K >> S;
    if (S.size() > K) {
        S = S.substr(0, K) + "...";
    }
    cout << S << endl;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

ll gcd(ll m, ll n) {
    return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n) {
    return m * (n / gcd(m, n));
}

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

    ll x = 1;
    ll t;
    for (int i = 0; i < n; i++) {
        cin >> t;
        x = lcm(x, t);
    }
    cout << x << endl;
}


Measured memory_bytes: 256