akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


string s;
int main(){
	cin>>s;
	bool ans=0;
	if(s.size()%2==1)ans=!ans;
	if(s[0]!=s[s.size()-1])ans=!ans;
	if(ans)cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)

@mt
def slv(N, A):
    ans = 0
    M = Mod(10**9+7)
    for i in range(0, 60):
        m = 1 << i
        c = 0
        for a in A:
            if m & a > 0:
                c += 1
        ans = M.add(M.mul(M.mul(c, N-c), m), ans)
    return ans

def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))

    # N = 3 * (10**5)
    # A = [random.randint(0, 2**60) for _ in range(N)]
    # print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 127028
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b;
	int ans=0;
	scanf("%d %d",&a,&b);
	if(b>=a)ans=a;
	else ans=a-1;
	printf("%d\n",ans);
	return 0;
}



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

int main(){
    int N; cin >> N;
    string s[N], X;
    int t[N], t_sum[N+1];
    for(int i=0; i<N; i++){
        cin >> s[i] >> t[i];
    }
    cin >> X;
    t_sum[N] = 0;
    for(int i=N-1; i>=0; i--){
        t_sum[i] = t_sum[i+1] + t[i];
    }
    for(int i=0; i<N; i++){
        if(X == s[i]){
            cout << t_sum[i+1] << endl;
            continue;
        }
    }
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int count1=0;
  int count2=0;
  int count3=0;
  int count4=0;
  int count5=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
      count1++;
    }
    else{
      if(count1!=0){
        if(count2!=0){
          if(count3!=0){
            if(count4!=0){
              count5=count1;
              count1=0;
            }
            else{
              count4=count1;
              count1=0;
            }
          }
          else{
            count3=count1;
            count1=0;
          }
        }
        else{
          count2=count1;
          count1=0;
        }
      }
    }
  }
  cout << max(max(max(max(count1,count2),count3),count4),count5) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

int main(){
  string s,t;
  cin >> s >> t;
  for(char c='a';c<='z';c++){
    string temp=s;
    temp+=c;
    if(temp==t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
return 0;}

Measured memory_bytes: 3628
/*
AtCoder Beginner Contest 177- C - Sum of product of pairs
https://atcoder.jp/contests/abc177/tasks/abc177_c
*/

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif
//
//    int tc; cin >> tc;
//    TC(tc) solve();
	int n;
	cin >> n;
	vi a(n);
	ll sum=0, ans=0;
	REP(i,n){
		cin >> a[i];
		sum+=a[i];
		sum%=MOD;
	}
	REP(i,n){
		sum-=a[i];
		if(sum<0) sum+=MOD;
		ans+=sum*a[i];
		ans%=MOD;
	}
	OUT((ans%MOD));
    return 0;
}


Measured memory_bytes: 3944
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}
 
int main(){

  while(1){
	int n = 0;

	cin >> n;

	if(n==0) break;

	int ans = 0;
	string shoukou[100];

	REP(i,n) cin >> shoukou[i];

	bool right = true; // down = true
	bool left  = true; // up = false

	bool down = true;

	REP(i,n){
	  if(shoukou[i]=="lu")
		left = false;
	  else if(shoukou[i]=="ru")
		right = false;
	  else if(shoukou[i]=="ld")
		left = true;
	  else if(shoukou[i]=="rd")
		right = true;
	  if(right == left && down != right){
		ans ++;
		down = not(down);
	  }
}

	cout << ans << endl;
  }
}

Measured memory_bytes: 1212
def North(d):
    d = [d[1]] + [7 -d[0]] + [d[2]]
    return d
       
def East(d):
    d = [7-d[2]] + [d[1]] + [d[0]]
    return d
       
def South(d):
    d = [7-d[1]] + [d[0]] + [d[2]]
    return d
   
def West(d):
    d = [d[2]] + [d[1]] + [7-d[0]]
    return d
   
def Right(d):
    d = [d[0]] + [d[2]] + [7-d[1]]
    return d
   
def Left(d):
    d = [d[0]] + [7-d[2]] + [d[1]]
    return d
    
while True:
    n = int(input())
    if n == 0: break
    
    dice = [1,2,3]
    result = 1
    for _ in range(n):
        direction = input().rstrip()
        if direction == 'North':
            dice = North(dice)
        if direction == 'East':
            dice = East(dice)
        if direction == 'South':
            dice = South(dice)
        if direction == 'West':
            dice = West(dice)
        if direction == 'Right':
            dice = Right(dice)
        if direction == 'Left':
            dice = Left(dice)
           
        result += dice[0]
       
    print(result)

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

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

    long long ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                ans += gcd(gcd(a,b),c);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3592
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

a = list(input())
n = int(input())
ans = 0
if n == 1:
    kkk = s(a)
    for i in range(len(kkk)):
        if kkk[i][1] >= 2:
            ans += kkk[i][1]//2
    print(ans)
else:
    aa = a+a
    kkk = s(aa)
    kk = s(a)
    if kkk[0][0] != kk[-1][0]:
        for i in range(1,len(kk)-1):
            ans +=kk[i][1]//2
        ans *= n
        ans += (kk[0][1]//2 + kk[-1][1]//2) * n
    else:
        if len(kkk) != 1:
            for i in range(1,len(kk)-1):
                ans +=kk[i][1]//2
            ans *= n
            ans += (kk[0][1] + kk[-1][1])//2*(n-1) + (kk[0][1]//2 + kk[-1][1]//2)
        else:
            ans = kk[0][1]*n//2


    print(ans)





Measured memory_bytes: 38384
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    int maxLength = k - a.at(n - 1) + a.at(0);
    for (int i = 1; i < n; i++) {
        maxLength = max(maxLength, a.at(i) - a.at(i - 1));
    }

    int ans = k - maxLength;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4052
#include <stdio.h>
int num;
int asd[10000];
int count = 0;
int check(int i){
    return asd[i] - asd[i-1];
}
int main(void){

int n1 = scanf("%d",&num);
for(int i = 0;i< num;i++){
    int n2 = scanf("%d",&asd[i]);
}
/*
printf("num %d\n",num);
for(int i = 0;i<num;i++){
    printf("asd: %d\n",asd[i]);
}*/

for(int i= 0;i<num;i++){
    if(check(i)==0){
        asd[i]+=2;
        if(check(i+1)==0)
        asd[i]++;
        count++;

    }
}
printf("%d\n",count);




}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = Integer.parseInt(sc.next());
        int N = Integer.parseInt(sc.next());
        
        if(D == 0) {
            if(N == 100) {
                System.out.println(101);
            }else {
                System.out.println(N);
            }
        }else if(D == 1) {
            if(N == 100) {
                System.out.println(10100);
            }else {
                System.out.println(N*100);
            }
        }else {
            if(N == 100) {
                System.out.println(1010000);
            }else {
                System.out.println(N*10000);
            }
        }
    }
}

Measured memory_bytes: 23764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var colors []int // 1:黒, 0:白, -1:無色
var g [][]int
var N int
var d [2][1000000]int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	g = make([][]int, N)
	for i := 0; i < N-1; i++ {
		a, b := nextInt()-1, nextInt()-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	dfs(0, -1, 0, 0)
	dfs(N-1, -1, 0, 1)

	c1 := 0
	c2 := 0
	for i := 0; i < N; i++ {
		if d[0][i] <= d[1][i] {
			c1++
		} else {
			c2++
		}
	}

	if c1 > c2 {
		fmt.Println("Fennec")
	} else {
		fmt.Println("Snuke")
	}
}

func dfs(x, y, z, w int) {

	d[w][x] = z

	for i := 0; i < len(g[x]); i++ {
		if g[x][i] == y {
			continue
		}

		dfs(g[x][i], x, z+1, w)

	}
}


Measured memory_bytes: 29312
from heapq import heappush, heappop
INF = 10**18
while 1:
    M, N, K, D = map(int, input().split())
    if M == N == K == D == 0:
        break
    *C, = map(int, input().split())
    def convert(s):
        if s == 'H':
            return 0
        if s[0] == 'C':
            return int(s[1:])
        if s[0] == 'L':
            return M+int(s[1:])
        return 1+N+M
    G = [[] for i in range(N+M+2)]
    H = [-1]*(N+M+2)
    for i in range(M):
        H[i+1] = i
    for i in range(D):
        s, t, e = input().split()
        s = convert(s); t = convert(t)
        e = int(e)
        G[s].append((t, e))
        G[t].append((s, e))

    dist = [[INF]*(1 << 6) for i in range(N+M+2)]
    que = [(0, 0, 0)]
    while que:
        cost, state, v = heappop(que)
        if dist[v][state] < cost:
            continue
        for w, e in G[v]:
            d = cost + e*K; n_state = state
            if H[w] != -1:
                if state & (1 << H[w]):
                    continue
                n_state |= (1 << H[w])
                d -= C[H[w]]
            if d < dist[w][n_state]:
                dist[w][n_state] = d
                heappush(que, (d, n_state, w))
    print(min(dist[N+M+1]))



Measured memory_bytes: 6200
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

#define PI 3.141592
#define INF 100001
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    int a,b;
    int ans;
    cin>>a>>b;
    if(a*b>=a+b&&a*b>=a-b){
        ans=a*b;
    }else if(a+b>=a*b&&a+b>=a-b){
        ans=a+b;
    }else if(a-b>=a*b&&a-b>=a+b){
        ans=a-b;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import sys,re
c=lambda l,n:re.sub("\w",lambda x:chr((ord(x.group(0))-97+n)%26+97),l)
for i in sys.stdin:
	n=0
	while not re.search("th(e|is|at)",c(i,n)):n+=1
	print c(i,n).strip()

Measured memory_bytes: 4208
#include <stdio.h>

int main()
{
    long n = 0, count = 0;
    int k = 0, x = 0;
    scanf("%ld %d", &n, &k);
    while (n > 0)
    {
        n--;
        scanf("%d", &x);
        if (x >= k) count++;
    }
    printf("%ld", count);
}

Measured memory_bytes: 128
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b))yes;
	else no;
	
}
// a+b+r(ab)<c
// ab<(c-a-b)^2






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, A, B, curr, next, ret = 0;
  cin >> N >> A >> B >> curr;
  for (int i = 1; i < N; i++) {
    cin >> next;
    ret += min((next - curr) * A, B);
    curr = next;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  if (a[n-1] < accumulate(a.begin(),a.end()-1,0)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def check(A, X):
    N = len(A)
    Ans = [None]*(N**2)
    cnt = 0
    po = 0
    for i in range(N):
        a, x = A[i], X[i]
        a += 1
        x -= 1
        if Ans[x] is not None:
            return False
        cnt += a-1
        if cnt > x:
            return False
        cnt += 1
        Ans[x] = a
        res = a-1
        while res:
            if Ans[po] is None:
                res -= 1
                Ans[po] = a
            po += 1
    
    cnt = 0
    po = N**2-1
    for i in range(N-1, -1, -1):
        a, x = A[i], X[i]
        a += 1
        x -= 1
        cnt += N-a
        if N**2-x < 1 + cnt:
            return False
        cnt += 1
        res = N-a
        while res:
            if Ans[po] is None:
                res -= 1
                Ans[po] = a
            po -= 1
    
    return Ans
N = int(readline())
X = list(map(int, readline().split()))
A = sorted(list(range(N)), key = lambda x: X[x])
X.sort()

Ans = check(A, X)
if Ans:
    print('Yes')
    print(*Ans)
else:
    print('No')

Measured memory_bytes: 50596
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main() {
	int n,k,ans=0;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		ans+=2*min(a[i],abs(k-a[i]));
	}
	cout<<ans;
}



Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if (a != 1 && b != 1) cout << 1 << endl;
    else if (a != 2 && b != 2) cout << 2 << endl;
    else cout << 3 << endl;

    
}


Measured memory_bytes: 256
import sys
from fractions import gcd
N, M = map(int, input().split())
an = list(map(lambda x: int(x)//2, input().split()))

lcm = an[0]
for a in an[1:]:
    l = lcm*a//gcd(lcm, a)
    if not (l//lcm % 2 == l//a % 2):
        print(0)
        sys.exit()
    lcm = l
print((M//lcm+1)//2)

Measured memory_bytes: 16312
#include <stdio.h>
int main(void){
  int y,m,d,n,i;
  struct data{
    char g[10];
    int y,m,d;
  }a[4]={
    {"meiji",1868,9,8},{"taisho",1912,7,30},{"showa",1926,12,25},{"heisei",1989,1,8}
  };
  while(scanf("%d %d %d",&y,&m,&d)!=EOF){
    if(y<1868){
      puts("pre-meiji");
      continue;
    }
    for(i=3;i>=0;i--){
      if(y>=a[i].y)break;
    }
    n=i;
    if(y==a[n].y&&(m<a[n].m||m==a[n].m&&d<a[n].d))
      n--;
    if(n==-1)puts("pre-meiji");
    else printf("%s %d %d %d\n",a[n].g,y-a[n].y+1,m,d);
  }
  return 0;
}

Measured memory_bytes: 608
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
#define P pair<int,int>
#define mp(a,b) make_pair(a,b)
#define ll long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

int main() { 
	ll q = read(), h = read(), s = read(), d = read();
	
	ll one = min(min(4*q,2*h),s);
	ll two = min(2*one,d);
	
	ll n = read();
	if( n & 1 ) cout<<n / 2 * two + one<<endl;
	else cout<<n / 2 * two<<endl; 
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
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 A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n,m,k;
  cin>>n>>m>>k;
  bool judge = false;

  rep(i,0,n + 1){
    rep(j,0,m + 1){
      if(i * m + j * n - 2 * i * j == k){
        judge = true;
        break;
      }
    }
    if(judge == true) break;
  }

  cout<<(judge == true ? "Yes" : "No")<<'\n';
  return 0;
}

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

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
#define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        int _a; cin >> _a;
        A[i] = _a;
    }
    sort(A.begin(), A.end());
    vector<ii> BC;
    for (int i = 0; i < M; i++) {
        int _b, _c; cin >> _b >> _c;
        BC.push_back(ii(_b, _c));
    }
    sort(
        BC.begin(),
        BC.end(),
        [](const ii& x, const ii& y){return x.second > y.second;}
    );

    vector<int> C;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < BC[i].first && C.size() < N; j++) {
            C.push_back(BC[i].second);
        }
    }

    int total = 0;
    for (int i = 0; i < N; i++) {
        if (i < C.size() && A[i] < C[i]) A[i] = C[i];
        total += A[i];
    }
    cout << total << endl;
}


Measured memory_bytes: 3316
#include <stdio.h>

#define DEBUG

#ifndef DEBUG 
#define fprintf (void)
#endif 

int charnum(char c);

int main(void){

	int n;
	int i,j;
	int tnum[110],hnum[110];
	tnum[0]=hnum[0]=27;
	int tscore=0, hscore=0;
	char memory;
	char trash;
	
	scanf("%d",&n);
	scanf("%c",&trash);
	
	for(i=0;i<n;i++){
		for(j=1;tnum[j-1]!=0;j++){
			scanf("%c",&memory);
			tnum[j]=charnum(memory);
		}
		
		for(j=1;hnum[j-1]!=0;j++){
			scanf("%c",&memory);
			hnum[j]=charnum(memory);
		}
		
		j=1;
		
		while(1){
			if(tnum[j]==hnum[j]&&tnum[j]>0){
				j++;
			}else if(tnum[j]>hnum[j]){
				tscore+=3;
				break;
			}else if(tnum[j]<hnum[j]){
				hscore+=3;
				break;
			}else{
				tscore++;
				hscore++;
				break;
			}
		}		
	}
	
	printf("%d %d\n",tscore,hscore);
	
	return 0;
}

int charnum(char c){
	if(c==' '||c=='\n'){return 0;}
	else if(c=='a'||c=='A'){return 1;}
	else if(c=='b'||c=='B'){return 2;}
	else if(c=='c'||c=='C'){return 3;}
	else if(c=='d'||c=='D'){return 4;}
	else if(c=='e'||c=='E'){return 5;}
	else if(c=='f'||c=='F'){return 6;}
	else if(c=='g'||c=='G'){return 7;}
	else if(c=='h'||c=='H'){return 8;}
	else if(c=='i'||c=='I'){return 9;}
	else if(c=='j'||c=='J'){return 10;}
	else if(c=='k'||c=='K'){return 11;}
	else if(c=='l'||c=='L'){return 12;}
	else if(c=='m'||c=='M'){return 13;}
	else if(c=='n'||c=='N'){return 14;}
	else if(c=='o'||c=='O'){return 15;}
	else if(c=='p'||c=='P'){return 16;}
	else if(c=='q'||c=='Q'){return 17;}
	else if(c=='r'||c=='R'){return 18;}
	else if(c=='s'||c=='S'){return 19;}
	else if(c=='t'||c=='T'){return 20;}
	else if(c=='u'||c=='U'){return 21;}
	else if(c=='v'||c=='V'){return 22;}
	else if(c=='w'||c=='W'){return 23;}
	else if(c=='x'||c=='X'){return 24;}
	else if(c=='y'||c=='Y'){return 25;}
	else if(c=='z'||c=='Z'){return 26;}
	else{return 27;}
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

#define chmin(x, y) x = min(x, y)

const i64 INF = 1e8;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  i64 C;
  cin >> n >> C;
  vector<i64> H(n);
  REP(i, n) cin >> H[i];

  vector<i64> dp(n);
  vector<tuple<i64, i64, int>> lines;

  auto is_ok = [&](int i, i64 x) -> bool {
    auto [a1, b1, _1] = lines[i];
    auto [a2, b2, _2] = lines[i - 1];
    i64 y1 = a1 * x + b1;
    i64 y2 = a2 * x + b2;
    if (y1 > y2) return false;
    return true;
  };

  auto jumpto = [&](int i) -> int {
    i64 x = H[i];

    int ok = 0, ng = int(lines.size());
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      bool r = is_ok(mid, x);
      DEBUG(i, x, mid, r);
      if (r) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    assert(ok >= 0);
    assert(ok < lines.size());
    auto [p, q, r] = lines[ok];
    return r;

    /*
    i64 mincost = INF;
    int mj = n - 1;
    for (int j = i + 1; j < n; ++j) {
      i64 cost = H[j] * H[j] - 2 * H[j] * x + dp[j];
      if (mincost > cost) {
        mincost = cost;
        mj = j;
      }
    }
    return mj;
    */
  };

  auto add_line = [&](int i) -> void {
    i64 a = -2 * H[i];
    i64 b = H[i] * H[i] + dp[i];
    while (lines.size() > 1) {
      int m = lines.size();
      auto [a1, b1, _1] = lines[m - 1];
      auto [a2, b2, _2] = lines[m - 2];
      if ((a2 - a1) * (b - b2) + (b1 - b2) * (a - a2) >= 0) {
        lines.pop_back();
      } else {
        break;
      }
    }
    lines.emplace_back(a, b, i);
  };

  dp[n - 1] = 0;
  add_line(n - 1);

  for (int i = n - 2; i >= 0; --i) {
    int j = jumpto(i);
    assert(j < n);
    assert(j >= 0);
    assert(H[j] > H[i]);
    i64 hd = (H[j] - H[i]);
    dp[i] = hd * hd + C + dp[j];
    add_line(i);
  }
  cout << dp[0] << endl;
}


Measured memory_bytes: 12576
'use strict'
function main(input) {
    const tmp = input.split(" ");
    const N = parseInt(tmp[0], 10);
    const L = parseInt(tmp[1], 10);

    const serialNum = Array.from(new Array(N)).map((v, index) => index + 1);
    let tastes = serialNum.map((i) => L + i - 1);

    const absTastes = tastes.map((taste) => Math.abs(taste));
    const smallestAbsVal = absTastes.reduce((a, b) => Math.min(a, b));
    const smallestAbsValInd = absTastes.indexOf(smallestAbsVal);

    tastes.splice(smallestAbsValInd, 1);
    const totalTaste = tastes.reduce((sum, taste) => sum + taste);
    console.log(totalTaste);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 20424
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// dou
    long double ans,a,b,x;
	cin>>a>>b>>x;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    }
    else{
        ans = M_PI / 2 - atan(2 * x / (a * b * b));
    }
    ans = 180.00*ans/M_PI;
    cout<<fixed << setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <iomanip>
#include <map>

using namespace std;

typedef long long ll;

int D;

int main() {
    cin >> D;
    cout << "Christmas ";
    if (D == 22) {
        cout << "Eve Eve Eve" << endl;
    } else if (D == 23) {
        cout << "Eve Eve" << endl;
    } else if (D == 24) {
        cout << "Eve" << endl;
    } else if (D == 25) {
        cout << endl;
    }
}

Measured memory_bytes: 256
# 2020-08-30, Sun

a, b, c, x = map(int, [input() for i in range(4)])
ans = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1

print(ans)

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

bool check(string s) {
    if (s.size() % 2 == 1) {
        return false;
    }
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[i + s.size() / 2]) {
            return false;
        }
    }
    return true;
}
int main() {
    string S;
    cin >> S;
    int tmpLength = S.size();
    S.pop_back();
    for (int i = 0; i < tmpLength; i++) {
        if (check(S)) {
            cout << S.size() << endl;
            return 0;
        }
        S.pop_back();
    }

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(m[x]==0) v.push_back(x);
		m[x]++;
	}
	int ans=0;
	for(int i=0;i<=v.size();i++)
	{
		if(v[i]>m[v[i]]) ans+=m[v[i]];
		else if(v[i]<m[v[i]]) ans+=m[v[i]]-v[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double th;
  if(a*a*b/2<=x){
    double n = x/a/a;
    th = atan(2*(b-n)/a)*180/3.141592653589793;
  }else{
    th = atan(b*b*a/2/x)*180/3.141592653589793;
  }
  printf("%.10f\n",th);
  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>

#define PI  3.14159265358979323846264338327950288

using namespace std;

int main(void){

	double r;

	cin>>r;

	printf("%f %f\n",r*r*PI,r*2*PI);
	cin>>r;
	return 0;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


}

Measured memory_bytes: 3592
n = input()
b = int(n) - 1

a = input().split()
nlist = [int(i) for i in a]

#calc func
for j in range(int(n)):
	if j != 0:
		for c2 in reversed(range(0,j)):
			if nlist[c2] > nlist[j]:
				stk = nlist[c2]
				nlist[c2] = nlist[j]
				nlist[j] = stk
				j = j - 1
				c2 = j - 1

#print func
	for i in range(int(b)):
		print(nlist[i], end=" ")

	print(nlist[b])




Measured memory_bytes: 5984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  
  vector<ll> a(m);  rep(i, 0, m) {cin >> a[i]; sum += a[i];}
  
  if(n >= sum)
    cout << n-sum << "\n";
  else
    cout << -1 << endl;
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double time[2];
    while(cin>>time[0]>>time[1]){
        if(time[0]<35.5&&time[1]<71)cout<<"AAA\n";
        else if(time[0]<37.5&&time[1]<77)cout<<"AA\n";
        else if(time[0]<40.0&&time[1]<83)cout<<"A\n";
        else if(time[0]<43.0&&time[1]<89)cout<<"B\n";
        else if(time[0]<50.0&&time[1]<105)cout<<"C\n";
        else if(time[0]<55.0&&time[1]<116)cout<<"D\n";
        else if(time[0]<70&&time[1]<148)cout<<"E\n";
        else cout<<"NA\n";
    }
}

Measured memory_bytes: 1192
n=int(input())
a=[int(i) for i in input().split()]

abs_min=abs(a[0])
abs_sum=0
cnt=0
for val in a:
	if val<0:
		cnt+=1
	abs_sum+=abs(val)
	abs_min=min([abs_min,abs(val)])

if cnt%2==0:
	print(abs_sum)
else:
	print(abs_sum-2*abs_min)

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

const int N = 310;

typedef pair<int, int> P;
typedef long long LL;

int G[2][N * 2][N * 2], n;

vector<P> dir;

void dfs(int x, int y, int t) {
    for (auto v : dir) {
        int tx = x + v.first, ty = y + v.second;
        if (tx > n * 2 || ty > n * 2 || tx < 1 || ty < 1 || G[t][tx][ty]) continue;
        G[t][tx][ty] = 3 - G[t][x][y], dfs(tx, ty, t);
    }
}

void Just_DOIT(int t, int d) {
    dir.clear();
    for (int i = 0; i < 2 * n; i++)
        for (int j = 0; j < 2 * n; j++)
            if ((LL)i * i + (LL)j * j == d) 
                for (int t = 0; t < 4; t++) 
                    dir.push_back(P(t & 1 ? i : -i, t & 2 ? j : -j));
    for (int i = 1; i <= n * 2; i++)
        for (int j = 1; j <= n * 2; j++) if (!G[t][i][j]) 
            G[t][i][j] = 1, dfs(i, j, t);
}

vector<P> fuck[4];

int main() {
    int d1, d2; scanf("%d%d%d", &n, &d1, &d2);
    Just_DOIT(0, d1), Just_DOIT(1, d2);
    for (int i = 1; i <= n * 2; i++)
        for (int j = 1; j <= n * 2; j++)
            fuck[G[0][i][j] + G[1][i][j] * 2 - 3].push_back(P(i, j));
    for (int i = 0; i < 4; i++) if (fuck[i].size() >= n * n) {
        for (int j = 0; j < n * n; j++) printf("%d %d\n", fuck[i][j].first - 1, fuck[i][j].second - 1);
        return 0;
    }
}


Measured memory_bytes: 34904
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long ans = 0;

        long a = x / 11;
        ans = a * 2;
        
        if(x % 11 <= 6 && x % 11 != 0) {
            ans++;
        }else if (x % 11 != 0){
            ans += 2;
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){string s;
cin>>s;
long long n,i,m=0,p=0;
n=s.size();if((n%2)==1)
cout<<"No";
else{
for(i=0;i<n;i+=2){
  if(s[i]!='h'){
      m=1;break;
  }
}if(m==1)
cout<<"No";
else{
    for(i=1;i<n;i+=2){
        if(s[i]!='i'){
            p=1;break;
        }
    }if(p==1)
    cout<<"No";
    else
    cout<<"Yes";
}}
 
    return 0;
  
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int N,X,T; cin >> N >> X >> T;
    int ans = (N+X-1)/X * T;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3644
import java.io.*; 
import java.util.*; 
public class Main {
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	}
}



Measured memory_bytes: 26552
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M;
    cin >> N >> M;
    // vec<lint> prices(N);
    // range(i, 0, N) cin >> prices.at(i);
    priority_queue<lint> items;
    range(i, 0, N) {
        lint item; cin >> item;
        items.emplace(item);
    }
    range(_, 0, M) {
        lint highest = items.top(); items.pop();
        items.emplace(highest / 2);
    }
    lint res = 0;
    range(i, 0, N) {
        res += items.top(); items.pop();
    }
    cout << res << "\n";
}

Measured memory_bytes: 1400
#include <iostream>

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

int main() {
  std::string str;
  std::cin >> str;

  if (str == "ABC")
    std::cout << "ARC" << '\n';
  else
    std::cout << "ABC" << '\n';
  return 0;
}


Measured memory_bytes: 3568
def sumd(S,n,k):
    res=0
    temp=int(S[0])
    for i in range(n-1):        
        if k&(1<<i):
            res+=temp
            temp=int(S[i+1])
        else:
            temp=temp*10+int(S[i+1])
    res+=temp
    return res

S=input()
n=len(S)
ans=0
for k in range(1<<(n-1)):
    ans+=sumd(S,n,k)
print(ans)

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

using namespace std;

int main() {
    int k, i;
    string s;
    cin>>k;
    cin>>s;
    if(k>=s.length())
    cout<<s;
    else
    {
    for(i=0;i<k;i++)
    printf("%c", s[i]);
    
    printf("...");
    }
    
    
    
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<class T,class F>
struct segtree{
  int n;
  T e;
  F f;
  std::vector<T> dat;

  segtree(){}
  segtree(int sz,T _e,F _f):e(_e),f(_f){
    n = 1;
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
  }
  segtree(std::vector<T> const& v,T _e,F _f):e(_e),f(_f){
    build(v);
  }
  void build(std::vector<T> const& v){
    n = 1;
    int sz = v.size();
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
    for(int i=0;i<sz;++i){
      dat[i+n] = v[i];
    }
    for(int i=n-1;i>0;--i){
      dat[i] = f(dat[i<<1],dat[i<<1|1]);
    }
  }
  void set(int p,T v){
    for(dat[p+=n]=v;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  T query(int l,int r){
    T res = e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l&1){
        res = f(res,dat[l]);
        l++;
      }
      if(r&1){
        r--;
        res = f(res,dat[r]);
      }
    }
    return res;
  }
  T operator[](int k){
    return query(k,k+1);
  }
};

int main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  auto f = [](auto a,auto b){
    while(1){
      if(a==0)return b;
      if(b==0)return a;
      swap(a,b);
      a%=b;
    }
  };
  segtree<ll,decltype(f)> seg(a,0,f);

  ll ans = 0;
  rep(i,n){
    ll left = seg.query(0,i);
    ll righ = seg.query(i+1,n);
    chmax(ans,f(left,righ));
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 3072
def main():
  n, mods = 0, [1]+[0]*2019
  d = 1
  for i in reversed(input()):
    n = (n+int(i)*d)%2019
    d = d*10%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()

Measured memory_bytes: 9212
N = int(input())
n = N % 10
if n == 3:
  print ('bon')
elif n == 0:
  print ('pon')
elif n == 1:
  print ('pon')
elif n == 6:
  print ('pon')
elif n == 8:
  print ('pon')
else:
  print ('hon')

Measured memory_bytes: 9104