akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
  char a, b;
  scanf("%c %c", &a, &b);

  if(a == 'H') {
    if(b == 'H') {
      printf("H\n");
    } else {
      printf("D\n");
    }
  } else {
    if(b == 'H') {
      printf("D\n");
    } else {
      printf("H\n");
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdint>
#include <cmath>

int main()
{
    std::int64_t a;
    double b;
    std::cin >> a >> b;
#if 1
    // 四捨五入する
    std::int64_t b2 = (std::int64_t)std::llround(b * 100.0);
#else
    // + 0.5 してから切り捨てる
    std::int64_t b2 = (std::int64_t)(b * 100.0 + 0.5);
#endif
    std::cout << a * b2 / 100 << std::endl;
}


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

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

  int n;
  cin >> n;
  double a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  for (int i = 0; i < n - 1; i++) {
    a[i+1] = (a[i] + a[i+1]) / 2;
  }
  cout << a[n - 1] << '\n';
}

Measured memory_bytes: 256
import collections,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
n = I()
ukv = [LI() for _ in range(n)]
graph = {i:collections.deque() for i in range(1,n+1)} #1_indexed
for x in ukv:
    u,k,*v = x
    for y in v:
        graph[u].append(y)
seen = [0]*(n+1) #1_indexed
min_dist = [-1]*(n+1) #1_indexed
queue = collections.deque() #頂点NOを入れておく
def bfs():
    seen[1] = 1
    queue.append(1)
    min_dist[1] = 0
    while queue:
        q_NO = queue.popleft()
        q_dist = min_dist[q_NO]
        if not graph[q_NO]:
            continue
        g = graph[q_NO]
        for _ in range(len(g)):
            g_NO = g.popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            queue.append(g_NO)
            min_dist[g_NO] = q_dist+1
bfs()
for i,ans in enumerate(min_dist[1:],1):
    print(i,ans)


Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



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

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

vector<int> prevn(1100);

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;rep(i,1100)prevn[i] = -1;prevn[s] = INF;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        prevn[e.to] = v;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<int>

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

int n, a[51];vector<P> ans;
signed main(){
  cin>>n;int mx = 0, ind;
  rep(i,n){
    cin>>a[i];
    if(abs(mx) <= abs(a[i])){
      mx = a[i], ind = i;
    }
  }
  rep(i,n)ans.push_back(P(ind, i));
  if(mx >= 0){
    rep(i,n-1)ans.push_back(P(i, i+1));
  }else{
    rep(i,n-1)ans.push_back(P(n-i-1, n-i-2));
  }
  cout << ans.size() << endl;
  rep(i, ans.size())cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N;
    cin >> N;
    vector<int> X(N);

    REP (i, N) {
        cin >> X[i];
    }

    int ans = INT_MAX;
    FOR (x, 1, 100) {
        int sum = 0;
        REP (i, N) {
            int d = x - X[i];
            sum += d * d;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char d[8][10];
  char s;
  int x,y,p,i,j;
  while(1){
    p=0;
    for(i=0;i<8;i++){
      if(scanf("%s",d[i])==EOF)break;
      for(j=0;j<8;j++){
	if(p==0&&d[i][j]=='1'){
	  p=1;
	  x=j;
	  y=i;
	}
      }
    }
    if(p==0)break;
    if     (d[y  ][x+3]=='1'&&x+3<8)        printf("C\n");
    else if(d[y+3][x  ]=='1'&&y+3<8)        printf("B\n");
    else if(d[y+2][x+1]=='1'&&y+2<8&&x+1<8) printf("F\n");
    else if(d[y+2][x-1]=='1'&&y+2<8&&x-1>-1)printf("D\n");
    else if(d[y+1][x-1]=='1'&&y+1<8&&x-1>-1)printf("G\n");
    else if(d[y+1][x+2]=='1'&&y+1<8&&x+2<8) printf("E\n");
    else                                    printf("A\n");
   }
  return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
#include<string.h>
int main()
{
    char s1[10],s2[10],s3[10];
    char a,b,c;
    scanf("%s %s %s",s1,s2,s3);
    a=toupper(s1[0]);
    b=toupper(s2[0]);
    c=toupper(s3[0]);
    printf("%c%c%c\n",a,b,c);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#define inf 0x3f3f3f3f
#define esp 1e-7
#define pi 3.1415926535897932384626
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int n,p;
long long dp[100][2];
int num[100];

int main(){
	n=read();p=read();
	for (int i=1;i<=n;i++)	num[i]=read();
	dp[0][0]=1;
	for (int i=1;i<=n;i++){
		dp[i][1]=dp[i-1][1];
		if (num[i]&1==1)	dp[i][1]+=dp[i-1][0];
		else				dp[i][1]+=dp[i-1][1];
		dp[i][0]=dp[i-1][0];
		if (num[i]&1==1)	dp[i][0]+=dp[i-1][1];
		else				dp[i][0]+=dp[i-1][0];
	}
	cout<<dp[n][p]<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79680
#include <bits/stdc++.h>
using namespace std;
#define INF 100005
#define maxx 1000000000000

int n,k;
long long a[INF+5];
long long mem[INF];

long long rec(int pos)
{
    if(pos==n-1)
    {
        return 0;
    }
    if(mem[pos]!=-1) return mem[pos];
    long long tot=maxx;
    for(int i=pos+1,j=0;i<n && j<k;i++,j++)
    {
        int dis=abs(a[pos]-a[i]);
        tot=min(tot,dis+rec(i));
    }
    return mem[pos]=tot;
}

int main()
{
    memset(a,0,sizeof(a));
    memset(mem,-1,sizeof(mem));
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    long long ans=rec(0);
    printf("%lld\n",ans);
}


Measured memory_bytes: 6528
#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>;

int main() {
	int n;
	cin >> n;
	int r = n%1000;
	if (r==0) cout << 0 << endl;
	else cout << 1000-r << endl;
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vi ints (N);
	vi vals (N);
	F0R(i, N) {
		int a, b; cin >> a >> b;
		ints[i] = a;
		vals[i] = b;
	}

	ll best = 0;
	F0R(i, N) if ((ints[i] | K) == K) best += vals[i];

	R0F(i, 32) if ((K & (1 << i)) > 0){
		int up = K ^ (1 << i);
		up |= (1 << i) - 1;
		ll cur = 0;
		F0R(j, N) if ((ints[j] | up) == up) cur += vals[j];
		best = max(best, cur);
	}
	print(best);
}

Measured memory_bytes: 3992
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(_Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,_Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

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

    vector<int> x(n), y(n), mm(m);
    REP(i,n) cin >> x[i] >> y[i];

    while(1){
        bool f = true;
        REP(i,n){
            if(mm[x[i]-1] >= mm[y[i]-1]){
                mm[y[i]-1] = mm[x[i]-1] + 1;
                f = false;
            }
        }
        if(f) break;
    }
    prfe(mm);

    REP(i,m){
        REP(j,m){
            if(mm[j] == i){
                cout << j+1 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main () {
	string s;
	cin >> s;
	string ans = "";
	for (int i=0; i<s.length(); i++) {
		if (s[i] =='B') {
			if (ans.size()) ans.pop_back();
		} else 
			ans.push_back(s[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(rall(t));
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3596
n = int(input())
a = list(map(int, input().split()))

cnt = 0
b = []
for ai in a:
    if ai <= 0:
        b.append(-ai)
        cnt += 1
    else:
        b.append(ai)
if cnt % 2 == 0:
    ans = sum(b)
else:
    ans = sum(b) - 2 * min(b)
print(ans)

Measured memory_bytes: 65184
s=input().split("/")
flg=0
if int(s[0])<2019:
    flg=1
elif int(s[0])==2019 and int(s[1])<=4 and int(s[2])<=30:
    flg=1

if flg==1:
    print("Heisei")
else:
    print("TBD")



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


void main() {
    auto S = readln.split.map!(to!int);
    auto N = S[0];
    auto K = S[1];
    auto A = readln.split.map!(to!long).array;

    long ans = 0;
    long tmp = 0;
    long s = A.map!(a => max(0, a)).sum;

    foreach (i; 0..K-1) {
        tmp += A[i];
        s -= max(0, A[i]);
    }

    foreach (i; 0..N-K+1) {
        tmp += A[i+K-1];
        s -= max(0, A[i+K-1]);
        ans = max(ans, s + max(0, tmp));
        tmp -= A[i];
        s += max(0, A[i]);
    }

    ans.writeln;
}


Measured memory_bytes: 4476
n, x, y = map(int, input().split(' '))
d_dict = {i:0 for i in range(1, n)}
for i in range(1, n):
    for j in range(i + 1, n + 1):
        if j <= x or y <= i:
            d_dict[j - i] += 1
        elif i <= x and x < j <= y:
            d_dict[min(j - i, x - i + y - j + 1)] += 1
        elif i <= x and j > y:
            d_dict[x - i + j - y + 1] += 1
        elif x < i < y and j < y:
            d_dict[min(j - i, i - x + y - j + 1)] += 1
        elif x < i < y and j >= y:
            d_dict[min(j - i, i - x + j - y + 1)] += 1
for i in range(1, n):
    print(d_dict[i])

Measured memory_bytes: 3572
#include<stdio.h>
main() {
	int a[10000];
	int n, i,k;
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		scanf("%d", &a[i]);
	}
	
	for (int j = 0;j <n/2;j++) {
		int b = a[j];
		a[j] = a[n - j - 1];
		a[n - j - 1] = b;
	}
	for (int k = 0;k < n-1;k++) {
		printf("%d ", a[k]);
	}
	printf("%d\n", a[n - 1]);
		
}


Measured memory_bytes: 2040
#include <stdio.h>
int main(void){
    int x=0,n,ans=0;
    char s[110];
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++){
        if(s[i]=='I')x++;
        else x--;
        if(ans<x)ans=x;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(void) {
	int l,a,b,c,d;
	scanf("%d%d%d%d%d", &l, &a, &b, &c, &d);
	if((a + c-1)/c > (b + d-1)/d) printf("%d\n", l-(a + c-1)/c);
	else printf("%d\n", l-(b + d-1)/d);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string s,t;
  cin >> s >> t;
  for(int i=N;i>=1;i--){
    if(s.substr(N-i,i)==t.substr(0,i)){
      cout << s.substr(0,N-i).size()+N << endl;
      return 0;
    }
  }
  cout << 2*N << endl;
}

Measured memory_bytes: 256
#include <iostream>//bit DP
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
int T[105];
int main(){
  int n,k;cin>>n>>k;
  for(int i=1;i<=k;i++){
    int d;cin>>d;
    for(int j=1;j<=d;j++){
      int a;cin>>a;
      T[a]++;
    }
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(T[i]==0)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
using namespace std;

int n, t, s;
int a[3001], b[3001];

int dp[3002][3001];
int ans;

int main(){
	scanf("%d %d %d", &n, &t, &s);
	for(int i=1; i<n+1; i++) scanf("%d %d", &a[i], &b[i]);

	for(int i=1; i<n+1; i++){
		for(int j=0; j<t+1; j++){
			if(s <= j-b[i] || j <= s){
				if(j - b[i] >= 0)
					dp[i][j] = max(dp[i][j], dp[i-1][j-b[i]] + a[i]);
			}
			dp[i+1][j] = dp[i][j];
			ans = max(ans, dp[i][j]);
		}
	}
/*
	for(int i=0; i<t+1; i++){
		for(int j=0; j<n+1; j++){
			printf("%d\t", dp[j][i]);
		}
		printf("\n");
	}
*/
	printf("%d\n", ans);
}

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

typedef pair<lint, lint> P;
lint MOD = 1e9+7;

vector<P> prime_factorize(lint N){
	vector<P> ans;
	for(lint a = 2; a*a <= N; a++){
		if(N%a == 0){
			lint ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}

lint modpow(lint m, lint n){
  if(n == 0) return 1;
  else if(n % 2 == 0) return modpow(m * m % MOD, n/2);
  else{
    return modpow(m, n - 1) * m % MOD;
  }
}

lint modinv(lint a, lint m) {
    lint b = m, u = 1, v = 0;
    while (b) {
        lint t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

signed main(){
  lint N; cin >> N;
  vector<lint> a(N);
  map<lint, lint> MAP;
  for(lint i = 0; i < N; i++) {
    cin >> a[i];
    vector<P> vec = prime_factorize(a[i]);
    for(lint j = 0; j < vec.size(); j++) MAP[vec[j].first] = max(MAP[vec[j].first], vec[j].second);
  }
  lint g = 1;
  for(auto i : MAP){
    g *= modpow(i.first, i.second);
    g %= MOD;
  }
  lint ans = 0;
  for(lint i = 0; i < N; i++){
    ans += modinv(a[i], MOD) * g;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int v[1010]={0};
int w[1010]={0};
int dp[1010][10010]={{0}};
int n,W;
int main(){
	cin >>n>>W;
	for (int i = 0; i < n; i++){
		cin>>v[i]>>w[i];
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= W; j++){
			if (j-w[i] >= 0){
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
			else{
				dp[i + 1][j] = dp[i][j];
			}

		}

	}

	cout << dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 5220
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S": a.append(y + 0)
	elif x == "H": a.append(y + 13)
	elif x == "C": a.append(y + 26)
	else: a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13: print("S {}".format(i - 0))
		elif i <= 26: print("H {}".format(i - 13))
		elif i <= 39: print("C {}".format(i - 26))
		else: print("D {}".format(i - 39))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long k,a,b,c;
  cin>>k>>a>>b;
  c=1;
  if(a>=b){
    cout<<k+1<<endl;
  }
  else {
    if(k<a+1){
      cout<<k+1<<endl;
    }
    else if(b-a==1){
      cout<<k+1<<endl;
    }
    else{
       if(k>=a-c+2){
          k-=(a-c+2);
          c=b;
        }
        while(k>1){
          c+=(b-a);
          k-=2;
        }
  if(k==1){
    c++;
    k--;
  }
      cout<<c<<endl;
    }
}
}

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

#define NMAX 100100
#define INF 2000000000

#define MOD 1000000007

typedef unsigned long long ull;

using namespace std;

priority_queue<int> heap;
int n, m;

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

    for(int i = 0; i < n; i++)
    {
        int aux;
        cin >> aux;

        heap.push(aux);
    }

    while(m--)
    {
        ull biggest = heap.top();
        heap.pop();

        biggest /= 2;

        heap.push(biggest);
    }

    ull sum = 0;

    while(!heap.empty())
    {
        sum += heap.top();
        heap.pop();
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
	string s;
		cin >>s;
	char ans[12];
	int legth=0;

	for(int i=0;i<s.size();i++){
		switch(s[i]){
			case '0':
			ans[legth]='0';
			legth++;
			break;
			case '1':
			ans[legth] =  '1';
			legth++;
			break;
			case 'B':
			if(legth!=0){
				ans[legth-1]='\0';
				legth--;
			}
			break;
		}
	}
	ans[legth]='\0';
	cout <<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0;i<(1<<(n-1));i++)
	{
		long long cur=0;
		long long ret=0;
		for(int j=0;j<n;j++)
		{
			cur*=10;
			cur+=s[j]-'0';
			if(j<n-1&&i>>j&1)
			{
				ret+=cur;
				cur=0;
			}
		}
		ret+=cur;
		ans+=ret;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;cin>>k;
    cout<<a[k-1]<<endl;
    
    return 0;
}


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

int main() {
	int x,y;
  	cin>>x>>y;
  	if(x==2){
     	if(y==2) cout<<"Yes"<<endl;
      	else cout<<"No"<<endl;
    }else if(x==4||x==6||x==9||x==11){
     	if(y==4||y==6||y==9||y==11) cout<<"Yes"<<endl;
      	else cout<<"No"<<endl;
    }else{
     	if(y==2||y==4||y==6||y==9||y==11) cout<<"No"<<endl;
      	else cout<<"Yes"<<endl;
    }
  	
}	

Measured memory_bytes: 3612
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""

#D
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.keys())
i = 0
while i < len(l):
    if d[l[i]] < 2:
        l.pop(i)
        i -= 1
    i += 1
l.sort()
k = 0
for i in l:
    k ^= ~(d[i]%2)
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 18848
#include <iostream>

using namespace std;

int main(void) {
    int n;
    cin >> n;
    long long int a = 1000000007;
    long long int ten = 1;
    long long int nine = 1;
    long long int eight = 1;
    for (int i = 0; i < n; i++) {
        ten = (ten * 10) % a;
        nine = (nine * 9) % a;
        eight = (eight * 8) % a;
    }
    long long int ans = (((ten + eight - 2 * nine) % a) + 1000000007) % a;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)b - *(int*)a;
}

int main(){

  int n;
  scanf("%d",&n);

  int l[n];
  for(int i = 0; i < n; ++i){
    scanf("%d",l+i);
  }

  qsort(l,n,sizeof(int),sort);
  int sum = 0;
  for(int i = 1; i < n; ++i){
    sum += l[i];
  }

  if(l[0] < sum) printf("Yes");
  else printf("No");

  return 0;
}


Measured memory_bytes: 1708
#include<stdio.h>

int main(){
	
	int a;
	int b;
	int c;
	scanf("%d %d %d",&a,&b,&c);
	
	
	
	
	if(a>9 || b>9 || c>9 || a<1 || b<1 || c<1){
		printf("eror!");
	}
	else if(a == b && b == c && a == c){
		printf("No");
	}
	else if(a == b || a == c || b == c){
		printf("Yes");
	}
	else if(a>b || b>c || c>a){
		printf("No");
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

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

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

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

#define TEST 0

	if (TEST) {
		test;
		solve();
	} else {
		solve();
	}

	return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short

#define pb push_back

#define fst first
#define snd second
#define mp make_pair

#define MOD 1000000007
#define all(v) (v).begin(),(v).end()
#define frl(i,n) for(long long i=0;i<n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << "\n"
#define displayvec(vec) cout<<#vec<<": "; for(auto vd : vec) cout<<vd<<" "; cout<<"\n"

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

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) is >> v[i];
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) os << v[i] << " ";
  os << endl;
  return os;
}

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector< ll > h(n), dp(n);
    cin>>h;
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(ll i = 2; i < n; ++i){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 4708
# この提出を含めて
# この時間までに提出している私のすべてのBの提出は嘘解法でした

# ランダムに作成した下記のテストケースで解答が不一致でした

# 6 2 5 3
# 6 4 3 2 1 1

# https://atcoder.jp/contests/agc041/submissions/9179921
# 4

# 自分
# 6

def main():
    from bisect import bisect_left, bisect_right
    from itertools import accumulate
    import sys

    input = sys.stdin.readline

    N, M, V, P = map(int, input().split())
    *A, = sorted(map(int, input().split()))
    acc = (0,) + tuple(accumulate(A))

    def is_ok(mid):
        x = A[mid]
        ika = bisect_right(A, x)
        rest = max(0, V - ika)
        if rest >= P:
            # 上位P-1に毎回加算して、
            # rest-(P-1)人に対し、最大値を上げないようにして、均等に割り振る
            rng = N - ika - (P - 1)  # 加算先候補数
            times = V - (P - 1) - ika  # M人のjudgeがtimes回加算する

            range_sum = acc[mid + 1 + rng] - acc[mid + 1]
            to_sub = A[mid + rng] * rng - range_sum
            to_dist = M * times - to_sub

            if to_dist <= 0:
                return A[N - P] <= x + M
            else:
                to_add = (to_dist + rng - 1) // rng
                return max(A[N - P], A[mid + rng] + to_add) <= x + M

        else:
            return A[N - P] <= x + M

    def binary_search():
        ok = N - 1
        ng = -1
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    idx = binary_search()
    print(N - bisect_left(A, A[idx]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 15028
#include <cstdio>
#define maxn 100005
using namespace std;

typedef long long LL;

int cnt[maxn];
LL sum = 0;

inline LL s(const LL& i)
{
	return cnt[i] * i;
}

int main(int argc, char** argv)
{
	int n, q;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		int t;
		scanf("%d", &t);
		sum += t;
		cnt[t] ++;
	}
	scanf("%d", &q);
	while(q--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		sum -= s(x) + s(y);
		cnt[y] += cnt[x];
		cnt[x] = 0;
		sum += s(y);
		printf("%lld\n", sum);
	}
	return 0;
}

Measured memory_bytes: 2124
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        System.out.println(xor(b) ^ xor(a - 1));
        sc.close();
    }
    static long xor(long x) {
        if (x % 2 != 0) {
            if ((x + 1) / 2 % 2 != 0) {
                return 1;
            } else {
                return 0;
            }
        } else {
            return xor(x + 1) ^ (x + 1);
        }
    }
}

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

signed main(void)
{
	int k;
	int odd, even;
	cin >> k;
	even = k / 2;
	odd = k - even;
	cout << even * odd << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<ll> a, b;

int main(){
    int n;
    cin >> n;
    rep(i, n){
        ll c, d;
        cin >> c >> d;
        if (n%2 == 0) c *= 2, d *= 2;
        a.push_back(c);
        b.push_back(d);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    ll x, y;
    if (n%2==0){
        x = (a[n/2-1] + a[n/2]) / 2;
        y = (b[n/2-1] + b[n/2]) / 2;
    }
    else{
        x = a[n/2];
        y = b[n/2];
    }
    cout << y - x + 1 << endl;

    return 0;
}


Measured memory_bytes: 6532
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;

    bool can = false;

    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (i*j == N) {
            can = true;
        }
      }
    }
  
    if (can == false) {
      cout << "No" << endl;
    }

    else if (can == true) {
      cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _ in range(h)]
res = [['#'] * w for _ in range(h)]

for r in range(h):
    for c in range(w):
        if s[r][c] == '#':
            continue
        counter = 0
        for y in range(3):
            for x in range(3):
                nr = r + y - 1
                nc = c + x - 1
                if 0 <= nr < h and 0 <= nc < w and s[nr][nc] == '#':
                    counter += 1
        res[r][c] = str(counter)

for row in res:
    print(''.join(row))


Measured memory_bytes: 3188
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int Q;
    cin >> Q;

    int N = 100010;
    vector<bool> like2017(N + 1, false);
    for (int i = 2; i < N + 1; ++i) {
        if (i % 2 == 0) {
            continue;
        }
        bool isPrime1 = true;
        bool isPrime2 = true;
        for (int j = 2; j * j <= i; ++j) {
            if (i % j == 0) {
                isPrime1 = false;
            }
            if (((i + 1) / 2) % j == 0) {
                isPrime2 = false;
            }
            if (!isPrime1 && !isPrime2) {
                break;
            }
        }
        if (isPrime1 && isPrime2) {
            like2017[i] = true;
        }
    }

    vector<int> accumLike2017(N + 1, 0);
    for (int i = 1; i < N + 1; ++i) {
        accumLike2017[i] = accumLike2017[i - 1];
        if (like2017[i]) {
            accumLike2017[i] += 1;
        }
    }

    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        int ans = accumLike2017[r] - accumLike2017[l];
        if (like2017[l]) {
            ans += 1;
        }
        cout << ans << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

int main()
{
    long long x;
    cin>>x;
    bitset<32>b(x);
    cout<<b<<endl;
    cout<<(~b)<<endl;
    cout<<(b<<1)<<endl;
    cout<<(b>>1)<<endl;
    return 0;
}



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


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

 int sum=0;
 vector<int >a(x);
 for(int i=0;i<x;i++)
 {
     cin>>a[i];


 }
 for(int j=0;j<x;j++)
 {
     for(int k=j+1;k<x;k++)
     {
     sum+=(a[j]*a[k]);
     }



 }
 cout<<sum<<endl;


 
  return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val strings = mutable.HashMap.empty[String, Int]

    for {
      _ <- 0 until n
    } {
      val s = in.readLine()
      val count = strings.getOrElse(s, 0)
      strings.update(s, count + 1)
    }

    val orderedStrings = strings.toSeq.sortWith {
      case ((_, count1), (_, count2)) => count1 > count2
    }

    val max = orderedStrings.head._2
    orderedStrings.takeWhile {
      case (_, count) => count == max
    }.map(_._1).sorted.foreach(out.println)

    out.flush()
  }
}


Measured memory_bytes: 72940
def abc058_b():
    o = input()
    e = input()
    passwd = [""] * (len(o) + len(e))
    for i in range(len(o)):
        passwd[2 * i] = o[i]
    for i in range(len(e)):
        passwd[2 * i + 1] = e[i]
    print("".join(passwd))


abc058_b()

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



int main() {
  int A,B;
  cin >> A >> B;
  int ans = -1;
  
  for(double i = B*10; i<(B+1)*10; i++){
  //  cout << i;
    if( (25*A)/2.0 <= i && i < ((A+1)*25)/2.0 ){
  //    cout << i;
      ans = i;
      break;
    }
    
  }
  
 // cout << (25*A)/2.0 << endl;
  //cout << ((A+1)*25)/2.0 << endl;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, k, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n >> k;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  SORT(d);
  rep(i, 0, k)
  {
    ans += d[i];
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;

    if(n < 105) {
        cout << 0 << endl;
    }else{
        int ans = 0;
        for (int i = 105; i <= n; i+=2) {
            int cnt = 0;
            for (int j = 1; j <= n; ++j) {
                if(i % j == 0) {
                    cnt++;
                }                
            }
            if(cnt == 8) {
                ans++;
            }
        }
        cout << ans << endl;

    }


    return 0;
}


Measured memory_bytes: 256
P = [1 for _ in range(100)]
P[0]=0
P[1]=0
for i in range(2,11):
    for j in range(i*i,100,i):
        P[j] = 0
Q = []
for i in range(100):
    if P[i]==1:
        Q.append(i)
N = int(input())
C = {p:0 for p in Q}
for p in Q:
    cnt = 0
    k = 1
    while p**k<=N:
        for i in range(2,N+1):
            if i%(p**k)==0:
                cnt += 1
        k += 1
    C[p]=cnt
c2=0
c4=0
c14=0
c24=0
c74=0
for p in C:
    if C[p]>=2:
        c2 += 1
    if C[p]>=4:
        c4 += 1
    if C[p]>=14:
        c14 += 1
    if C[p]>=24:
        c24 += 1
    if C[p]>=74:
        c74 += 1
ans = ((c4*(c4-1))//2)*(c2-2)
ans += c24*(c2-1)
ans += c14*(c4-1)
ans += c74
print(ans)

Measured memory_bytes: 38640
N = int(input())
T = [int(input()) for i in range(N)]

import fractions
def gcd(a, b):
    return fractions.gcd(a, b)

def lcm(a, b):
    return (a * b) // gcd(a, b)

x = 1
for i in range(N):
    for j in range(N):
        x = lcm(x, lcm(T[i], T[j]))


if x <= 10 ** 18:
    print(x)
else:
    print(10 ** 18)


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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    ll a,as,b,bs;
    cin>>a>>as>>b>>bs;

    ll T;
    cin>>T;

    if(as==bs){
        if(a==b){
            cout<<"YES"<<endl;
            return;
        }else{
            cout<<"NO"<<endl;
            return;
        }
    }

    if(a==b){
        cout<<"YES"<<endl;
        return;
    }

    if(as<bs){
        cout<<"NO"<<endl;
        return;
    }else{
        double t=(double)(abs(b-a))/(double)(as-bs);
        if(t<=T){
            cout<<"YES"<<endl;
            return;
        }else{
            cout<<"NO"<<endl;
            return;
        }
    }

}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

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

int main(){
  int n,a,b;
  scanf("%d",&n);
  scanf("%d",&a);
  scanf("%d",&b);
  int max,min;
  if(a>b) {
    max = b;
  } else {
    max = a;
  }
  if(a+b<n) {
    min = 0;
  } else {
    min = a+b-n;
  }
  printf("%d %d\n",max,min);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int r = scanner.nextInt();

        while(!(n == 0 && r == 0)){
            int[] a = new int[50];
            for(int i = 0; i < n; i++)
                a[n - i - 1] = i + 1;

            int[] b = new int[50];
            for(int i = 0; i < r; i++){
                int p = scanner.nextInt() - 1;
                int c = scanner.nextInt();

                for(int j = 0; j < n; j++){
                    if(0 <= j && j < p)
                        b[j + c] = a[j];
                    else if(p <= j && j < p + c)
                        b[j - p] = a[j];
                    else
                        b[j] = a[j];

                }

                System.arraycopy(b,0,a,0,b.length);

            }
            System.out.println(b[0]);

            n = scanner.nextInt();
            r = scanner.nextInt();
        }
    }
}



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

int main(){
 	string s,t;
  	cin >>s>>t;
  	int n,m;
  	n=s.size();
  	m=t.size();
  	vector<vector<int>> dp(m+1,vector<int>(n+1,0));
  	for(int i=1;i<=m;i++){
    	for(int j=1;j<=n;j++){
        	if(s[j-1]==t[i-1]){
            	dp[i][j]=dp[i-1][j-1]+1;          
            }
        	else{dp[i][j]=max(dp[i-1][j],dp[i][j-1]);}
        }
    }
  
   string res = ""; 
   int j = n, i = m;
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
          
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
          
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[j-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; 
         
          // DP の遷移を遡る
        }
    }
    cout << res << endl;
  	
  	
}

Measured memory_bytes: 35584
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

    int A,B,C,D;
    cin >> A >> B >> C >> D;

    cout << max(A*B,C*D) << endl;

    return 0;

}

Measured memory_bytes: 256
while line = gets
  n = line.chomp.to_i
  break if n == 0
  change = 1000 - line.chomp.to_i
  i = 0
  [500, 100, 50, 10, 5, 1].each do |currency|
    i += change / currency
    change = change % currency
  end
  puts i
end

Measured memory_bytes: 8604