akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int k;
  cin>>k;
  ll d[10][10];
  rep(i,0,10){
    d[0][i]=1;
  }
  rep(i,0,9){
    rep(j,0,10){
      if(j==0){
        d[i+1][j]=d[i][j]+d[i][j+1];
      }
      else if(j==9){
        d[i+1][j]=d[i][j-1]+d[i][j];
      }
      else{
        d[i+1][j]=d[i][j-1]+d[i][j]+d[i][j+1];
      }
    }
  }
  ll e[10][10];
  ll cur=0;
  rep(i,0,10){
    rep(j,0,10){
      cur+=d[i][j];
      e[i][j]=cur;
    }
  }
  cur=0;
  int p,q;
  bool r=true;
  rep(i,0,10){
    rep(j,1,10){
      if(cur+d[i][j]<k){
        cur+=d[i][j];
      }
      else{
        p=i;
        q=j;
        r=false;
        break;
      }
    }
    if(!r) break;
  }
  ll now=k-cur;
  cout<<q;
  while(p>0){
    if(q==0){
      if(d[p-1][q]>=now){
        cout<<0;
      }
      else{
        cout<<1;
        now-=d[p-1][q];
        q++;
      }
    }
    else if(q==9){
      if(d[p-1][q-1]>=now){
        cout<<8;
        q--;
      }
      else{
        cout<<9;
        now-=d[p-1][q-1];
      }
    }
    else{
      if(d[p-1][q-1]>=now){
        cout<<q-1;
        q--;
      }
      else if(d[p-1][q-1]+d[p-1][q]>=now){
        cout<<q;
        now-=d[p-1][q-1];
      }
      else{
        cout<<q+1;
        now-=d[p-1][q-1]+d[p-1][q];
        q++;
      }
    }
    p--;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string c;

  cin >> c;

  if (c[0] == 'a' || c[0] == 'e' || c[0] == 'i' || c[0] == 'o' || c[0] == 'u')
    cout << "vowel" << endl;

  else
    cout << "consonant" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var a, b int
  
  fmt.Scanf("%d %d", &a, &b)
  
  ans := "No"
  switch a {
    case 2: 
      if b == 2 {
        ans = "Yes"
      }
    case 4, 6, 9 ,11: 
      if b == 4 {
        ans = "Yes"
      } 
      if b == 6 {
        ans = "Yes"
      } 
      if b == 9 {
        ans = "Yes"
      } 
      if b == 11 {
        ans = "Yes"
      }
    default:
      if b == 1 {
        ans = "Yes"
      } 
      if b == 3 {
        ans = "Yes"
      } 
      if b == 5 {
        ans = "Yes"
      } 
      if b == 7 {
        ans = "Yes"
      }
      if b == 8 {
        ans = "Yes"
      }
      if b == 10 {
        ans = "Yes"
      }
      if b == 12 {
        ans = "Yes"
      }
  }
  
  fmt.Printf("%s", ans)
}

Measured memory_bytes: 1828
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  ULL N; cin >> N;
  ULL ans = 0;
  REP1(i, N-1) ans += i;
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <tuple>
#include <cstdio>
using namespace std;
typedef tuple<int, int, int> T;

int h, w;
string s[20];
int meY, meX;
int gostY, gostX;
string moves;

int minCost[20][20];
int INF = 1000;

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

void outAns() {
	int y = gostY;
	int x = gostX;
	
	for (int i = 0; i < INF; i++) {
		if (minCost[y][x] <= i) {
			cout << i << " " << y << " " << x << endl;
			return;
		}
		
		char type = moves[i % moves.length()];
		string dir = "8624";
		int j;
		for (j = 0; j < 4; j++) {
			if (dir[j] == type) {
				break;
			}
		}
		if (j == 4) continue;
		
		//?????? == j??§?§????
		int ny = y + dy[j];
		int nx = x + dx[j];
		if (0 <= ny && ny < h && 0 <= nx && nx < w) {
			y = ny;
			x = nx;
		}
	}
	cout << "impossible" << endl;
}

int main() {
	while (cin >> h >> w, h) {
		int i, j;
		for (i = 0; i < h; i++) cin >> s[i];
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (s[i][j] == 'A') {
					meY = i;
					meX = j;
				}
				if (s[i][j] == 'B') {
					gostY = i;
					gostX = j;
				}
			}
		}
		cin >> moves;
		
		for (i = 0; i < h; i++) for (j = 0; j < w; j++) minCost[i][j] = INF;
		
		queue<T> que;	//cst, y, x
		que.push(T(0, meY, meX));
		while (!que.empty()) {
			T now = que.front(); que.pop();
			int cst = get<0>(now);
			int y = get<1>(now);
			int x = get<2>(now);
			if (minCost[y][x] <= cst) continue;
			minCost[y][x] = cst;
			
			for (int i = 0; i < 4; i++) {
				int ny = y + dy[i];
				int nx = x + dx[i];
				if (!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
				if (s[ny][nx] == '#') continue;
				que.push(T(cst + 1, ny, nx));
			}
		}
		
		outAns();
	}
	return 0;
}

Measured memory_bytes: 2936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		int array[] = new int [6];

		for (int i = 0; i < 6; i++) {
			array[i] = scanner.nextInt();
		}

		Diceroll dice = new Diceroll();

		// Dicerollクラスに配列arrayの要素を引き渡し
		dice.setNum(array[0], array[1], array[2], array[3], array[4], array[5]);

		// 回転方向読み取り
		String commando = scanner.next();

		for (int i = 0; i < commando.length(); i++) {

			// commandoの文字をDicerollクラスのrollメソッドに引き渡し
			dice.roll(commando.charAt(i));
		}

		// DicerollクラスからgetTopメソッドを出力
		System.out.println(dice.getTop());

	}
}

class Diceroll {

	private int num[];
	private int work[];

	Diceroll() {

		num = new int [6];
		work = new int [6];

	}

	public void roll(char order) {

		for (int i = 0; i < 6; i++) {
			work[i] = num[i];
		}

		switch (order) {

		case 'N' :
			setNum(work[1], work[5], work[2], work[3], work[0], work[4]);
			break;

		case 'S' :
			setNum(work[4], work[0], work[2], work[3], work[5], work[1]);
			break;

		case 'W' :
			setNum(work[2], work[1], work[5], work[0], work[4], work[3]);
			break;

		case 'E' :
			setNum(work[3], work[1], work[0], work[5], work[4], work[2]);
			break;
		}
	}

	public int getTop() {
		return num[0];
	}

	public void setNum(int num0, int num1, int num2, int num3, int num4, int num5) {

		num[0] = num0;
		num[1] = num1;
		num[2] = num2;
		num[3] = num3;
		num[4] = num4;
		num[5] = num5;

	}

}





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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}

const int N = 2e3 + 3;
int n, m, k, query;
ll ans;
ll mt[N][N], cnt[N][N];

void Solve(){
    int a, b;
    cin >> m >> n >> a >> b;
    if(a * 2 > n || m < b * 2){
        cout << -1;
        exit(0);
    }
    for(int i = 1; i <= m; i++){
        if(i&1 && i <= 2 * b){
            for(int j = 1; j <= a; j++){
                mt[i][j] = 1;
            }
            for(int j = a + 1; j <= n; j++){
                mt[i][j] = 0;
            }
        } else{
            for(int j = 1; j <= a; j++){
                mt[i][j] = 0;
            }
            for(int j = a + 1; j <= n; j++){
                mt[i][j] = 1;
            }
        }
    }
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            cout << mt[i][j];
        }cout << endl;
    }

}

int main(){
    speed;
    cout << fixed << setprecision(6);
    Solve();
}













Measured memory_bytes: 17664
index = "ABCDEFGHI".index
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
while 1:
    N = int(input())
    if N == 0:
        break
    s, t, b = map(index, input().split())
    S = [[0]*3 for i in range(3)]
    sy, sx = divmod(s, 3)
    ty, tx = divmod(t, 3)
    by, bx = divmod(b, 3)
    T = [[0]*3 for i in range(3)]
    S[sy][sx] = 1
    for i in range(N):
        for y in range(3):
            for x in range(3):
                if x == bx and y == by:
                    T[y][x] = 0
                    continue
                r = 0
                for dx, dy in dd:
                    nx = x + dx; ny = y + dy
                    if not 0 <= nx < 3 or not 0 <= ny < 3 or (bx == nx and by == ny):
                        nx = x; ny = y
                    r += S[ny][nx]
                T[y][x] = r
        S, T = T, S
    su = sum(sum(e) for e in S)
    print("%.15f" % (S[ty][tx] / su))



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

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

  string ans = "Christmas";
  if (D == 24)
    ans += " Eve";
  if (D == 23)
    ans += " Eve Eve";
  if (D == 22)
    ans += " Eve Eve Eve";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int a, b;
  string s;
  while (cin >> s, s != "#") {
    a = 0, b = -1;
    for (int i = s.length()-1; i >= 0; i--) {
      if (s[i] == 'n' && b == -1) {
        a = 0;
        b = 0;
      } else if (s[i] == 'w' && b == -1) {
        a = 90;
        b = 0;
      } else if ((s[i] == 'n' || s[i] == 'w') && b == 0) {
        a = 45;
        b = 1;
      } else if (s[i] == 'n') {
        a = a*2-45;
        b *= 2;
      } else if (s[i] == 'w') {
        a = a*2+45;
        b *= 2;
      }
    }
    if (b == 0 || b == 1) cout << a << el;
    else cout << a << "/" << b << el;
  }
}

Measured memory_bytes: 1188
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Tuple{Int,Int}[]
	b = Tuple{Int,Int}[]
	f = 0
	lx = 0
	rx = 0
	for i in 1:n
		s = readline() |> chomp
		l = 0
		r = 0
		for j in 1:length(s)
			if s[j]=='('
				l += 1
			else
				if l==0
					r+=1
				else
					l-=1
				end
			end
		end
		if l>r
			push!(a,(l,r))
		else
			push!(b,(l,r))
		end
		lx+=l
		rx+=r
	end
	f = 0
	if lx!=rx
		f = 1
	end
	lc = 0
	a = sort(a,by=x->x[2])
	for i in 1:length(a)
		if lc-a[i][2]<0
			f = 1
		end
		lc+=a[i][1]-a[i][2]
	end
	b = sort(b,by=x->x[1],rev=true)
	for i in 1:length(b)
		if lc-b[i][2]<0
			f = 1
		end
		lc += b[i][1]-b[i][2]
	end
	println(f==0 ? "Yes" : "No")
end

main()

Measured memory_bytes: 249032
#include<stdio.h>
#include<stdlib.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m[1010],i,j,k,d[510][510]={};
  while(scanf("%d",&n),n){
    for(i=0;i<n;i++)scanf("%d",&m[i]);
    for(i=0;i<=n;i++){
      for(j=0;i+j<=n;j++){
	if(i<2)d[j][j+i]=0;
	else if(d[j+1][j+i-1]+2==i&&abs(m[j]-m[j+i-1])<2)d[j][j+i]=i;
	else{
d[j][j+i]=0;
	  for(k=j+1;k<i+j;k++)d[j][j+i]=MAX(d[j][j+i],d[j][k]+d[k][j+i]);
	}
      }
    }
    printf("%d\n",d[0][n]);
  }
  return 0;
}



Measured memory_bytes: 3696
#include <cstdio> 
#include <algorithm>      
#define N 18   
#define ll long long 
#define mod 1000000007 
#define setIO(s) freopen(s".in","r",stdin) 
using namespace std;        
int bin[N],f[N][1<<N],fac[1<<N],inv[1<<N],a[N];    
int qpow(int x,int y) 
{
    int tmp=1; 
    for(;y;y>>=1,x=(ll)x*x%mod) 
        if(y&1) tmp=(ll)tmp*x%mod; 
    return tmp; 
}
int C(int x,int y) { if(x<y) return 0; return (ll)fac[x]*inv[y]%mod*inv[x-y]%mod; }    
int count(int x) 
{ 
    int c=0;  
    while(x) { if(x&1) ++c;  x>>=1; }   
    return c;  
}
int main() 
{ 
    // setIO("input");  
    int i,j,n,m;  
    scanf("%d%d",&n,&m);                                    
    bin[0]=fac[0]=inv[0]=1; 
    for(i=1;i<=n;++i) bin[i]=bin[i-1]<<1;         
    for(i=1;i<=bin[n];++i) fac[i]=(ll)fac[i-1]*i%mod,inv[i]=qpow(fac[i],mod-2);
    for(i=1;i<=m;++i) scanf("%d",&a[i]);      
    sort(a+1,a+1+m); 
    f[m+1][0]=1;    
    int cnt=0; 
    for(i=m;i>=1;--i) 
    {
        for(j=0;j<bin[n];++j) 
        {

            f[i][j]=(ll)(f[i][j]+f[i+1][j])%mod;      
            int t=bin[n]-1-j;  // 共有 t 个空位置                    
            for(int k=0;bin[k]<bin[n];++k) 
            {  
                if(j&bin[k]||!f[i+1][j]) continue;        
                (f[i][j|bin[k]]+=((ll)f[i+1][j]*C(t-a[i]+1,bin[k]-1)%mod*fac[bin[k]]%mod)%mod)%=mod;  
            }         
        }
    }     
    int ans=0;   
    for(i=0;i<bin[n];++i) 
    {
        int d=(count(i)&1)?mod-1:1;          
        ans=(ll)(ans+(ll)f[1][i]*fac[bin[n]-1-i]%mod*d%mod)%mod;   
    }    
    ans=(ll)ans*bin[n]%mod;   
    printf("%d\n",ans); 
    return 0;
}

Measured memory_bytes: 19072
def main():
    from sys import stdin
    input = stdin.readline
    import numpy as np
    n, m, s, t = map(int, input().split())
    uvab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[u-1].append([v-1, a, b]) for u, v, a, b in uvab]
    [g[v-1].append([u-1, a, b]) for u, v, a, b in uvab]

    import heapq

    yen = np.full(n, np.inf)
    h = [(0, s-1)]
    heapq.heapify(h)
    while h:
        d, i = heapq.heappop(h)
        if yen[i] == np.inf:
            yen[i] = d
            for x, y, z in g[i]:
                heapq.heappush(h, (d+y, x))

    snk = np.full(n, np.inf)
    h = [(0, t-1)]
    heapq.heapify(h)
    while h:
        d, i = heapq.heappop(h)
        if snk[i] == np.inf:
            snk[i] = d
            for x, y, z in g[i]:
                heapq.heappush(h, (d+z, x))

    cost = yen+snk
    m = cost[-1]
    for i in range(n-1, -1, -1):
        m = min(m, cost[i])
        cost[i] = m

    cost = 10**15-cost

    for i in cost:
        print(int(i))


main()

Measured memory_bytes: 86500
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var L = Math.Max(Console.ReadLine().Split().Select(int.Parse).Max(), arr[2]);
    var r = Math.Min(Console.ReadLine().Split().Select(int.Parse).Min(), arr[3]);
    Console.WriteLine(L < r ? "No War" : "War");
  }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define MAX 100
using namespace std;
int a[MAX + 1][MAX + 1];

int main() {
  int r, c, t;
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> t;
      a[i][j] = t;
      a[i][c] += t;
      a[r][j] += t;
      a[r][c] += t;
    }
  }
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j < c; j++) {
      cout << a[i][j] << " ";
    }
    cout << a[i][c] << "\n";
  }
}



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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;
const int N = 1e6 + 5;

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

    int r,c,k;
    cin>>r>>c>>k;

    vector<vector<int>> grid(r, vector<int>(c,0));

    for(int i=0;i<k;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        grid[x-1][y-1] = z;
    }

    vector<vector<vector<ll>>> dp(r +1, vector<vector<ll>>(c+1, vector<ll>(3,0)));
    ll ans = 0;

    for(int i = r-1; i>=0; i--)
        for(int j = c-1; j>=0; j--)
        {
            for(int k = 0; k<3; k++)
            {
                if( k == 0)
                {
                    ll val1 = max(dp[i+1][j][0], max(dp[i+1][j][1], dp[i+1][j][2]));
                    dp[i][j][k] = max(val1 + grid[i][j], dp[i][j+1][k]);
                }
                else
                {
                    ll val1 = max(dp[i+1][j][0], max(dp[i+1][j][1], max(dp[i+1][j][2], dp[i][j+1][k-1])));
                    dp[i][j][k] = max(grid[i][j] + val1, dp[i][j+1][k]);
                }
            }
        }

    cout<<max(dp[0][0][0], max(dp[0][0][1], dp[0][0][2]))<<endl;
}


Measured memory_bytes: 531060
li = [int(input()) for i in range(5)]
flag = True
for i in range(5):
    if li[i] % 10 == 0:
        flag = True
    else:
        flag = False
        break

if flag:
    print(sum(li))
else: 
    for i in range(1,10):
        for j in range(5):
            if li[j] % 10 == i:
                a = li[j]
                del li[j]
                break
        else:
            continue
        break

    for i in range(4):
        if li[i] % 10 != 0:
            li[i] = (li[i] // 10 + 1) * 10
    print(sum(li) + a)

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

using namespace std;
int main(){
  string S;
  cin >>S;
  sort(S.begin(),S.end());
  if(S.at(0)==S.at(1)&&S.at(1)!=S.at(2)&&S.at(2)==S.at(3)){
    cout <<"Yes"<<endl;
  }
   else{ cout <<"No"<<endl;}
    }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left";
	else if(a+b==c+d)cout<<"Balanced";
	else if(a+b<c+d)cout<<"Right";
	return 0;
}

Measured memory_bytes: 256
x,n=map(int,input().split())

if n==0:
    print(x)
    exit()
    
p=set(list(map(int,input().split())))

for i in range(0,105):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()


Measured memory_bytes: 61736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OUT(x) cout << (x) << endl;
#define REP(i, n) for (int i=0; i<n; ++i)

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    // ax = by+c
    string str="NO";
    for(int i=1; i<=B; i++){
        if(A*i%B == C) {
            str = "YES";
            break;
        }
    }
    OUT(str);
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> t(n+1,0);
    int sum = 0;
    for(int i = 1;i <= n;i++){
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    vector<int> p(m),x(m);
    for(int i = 0;i < m;i++) cin >> p[i] >> x[i];
    for(int i = 0;i < m;i++){
        for(int j = 1;j <= n;j++){
            if(p[i] == j){
                cout << (sum - t[j] + x[i]) << endl;
            }
        }
    }

}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << endl;
	return (0);
}


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

int vis[1000010];
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=n;;i++){
        int f=0;
        for(int j=2;j*j<=i;j++){
            if(i%j==0)
                f=1;
        }
        if(!f){
            cout<<i;
            break;
        }
    }
}


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

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

int main() {

    string N_str;
    cin >> N_str;
    int n = N_str.length();

    vector<int> N(n, 0);
    rep(i,n) N[i] = N_str[n - 1 - i] - '0';

    vector<vector<int>> dp(n + 1, vector<int>(2, INF));
    dp[0][0] = 0;

    rep(i,n) rep(j,2) {
        rep(A,10) {
            int B;
            if (A - j >= N[i]) B = A - j - N[i];
            else B = 10 + A - j - N[i];
            int j_next = A - j >= N[i] ? 0 : 1;
            dp[i + 1][j_next] = min(dp[i + 1][j_next], dp[i][j] + A + B);
        }
    }

    cout << min(dp[n][0], dp[n][1] + 1) << endl;
    
    return 0;
}

Measured memory_bytes: 59780
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b;
  long long c, d;
  cin >> a >> b >> c >> d;
  long long max, min;
  if(c>d) { max=c; min=d; }
  else { max=d; min=c;}
  while(max!=min)
  {
    max -= min;
    if(max < min) swap(max, min);
  }
  long long g = c*d/max;
  long long  sumc = b/c - (a-1L)/c;
  long long sumd = b/d - (a-1L)/d;
  long long sumcd = b/g - (a-1L)/g;
  cout << b-a+1 -sumc-sumd+sumcd << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Arrays;
import static java.util.stream.Collectors.*;
import static java.util.function.Function.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Integer[] ary = new Integer[n];
		for(int i=0; i<n; i++){
			ary[i] = in.nextInt();
		}
		List<Integer> list = new ArrayList<Integer>();
		list = Arrays.asList(ary);
		Map<Integer, Long> map = list
		.stream()
		.collect(groupingBy(identity(), counting()));

		// 重複なしのkeyを削除
		Iterator<Map.Entry<Integer, Long>> iterator = map.entrySet().iterator();
		while (iterator.hasNext()) {
    		Map.Entry<Integer, Long> e = iterator.next();
    		if (e.getValue() == 1) {
				iterator.remove();
			}
		}

		// 全ての通りを計算
		long total = 0;
		for (Long count : map.values()) {
            total += combination(count, 2);
		}

		for(int i=0; i<n; i++){
			long ans = total;
			if(map.containsKey(ary[i])){
				long tmp = map.get(ary[i]);
				ans = total - combination(tmp, 2) + combination(tmp-1, 2);
			}
			System.out.println(ans);
		}
	}
	public static long factorial(long n) {
		if (n <= 1)
			return 1;
		else {
			return n * factorial(n - 1);
		}
	}
	public static long combination(long n, long r) {
		long top = n;
		for (int i = 0; i < r - 1; i++) {
			top = top * (--n);
		}
		long bottom = factorial(r);
		return top / bottom;
	}
}


Measured memory_bytes: 111448
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cctype>
#include <stack>
#include <map>
#include <cstring>
#include <sstream>
#include <set>
#include <list>
#include <fstream>
#include <iomanip>
#include<assert.h>

#define ll long long
#define ull unsigned long long
#define op                            \
	std::ios::sync_with_stdio(false); \
	std::cin.tie(0);

const int INF = 0x3f3f3f3f;
const int maxn = (100 + 10);
const int mod = (1e9 + 7);

int main()
{
	op
	int n;
	std::string s;
	std::cin>>n;
	std::cin>>s;
	bool flag=true;
	if(n%2) flag=false;
	else
	{
		int t=n/2;
		for(int i=0;i<t;i++)
		{
			if(s[i]!=s[t+i])
			{
				flag=false;
				break;
			}
		}
	}
	if(flag) std::cout<<"Yes\n";
	else std::cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  int n, x, y, i, j;
  cin >> n >> x >> y;
  x--;
  y--;
  //int mid = (x+y)/2;
  vector<vector<int>> data(n, vector<int>(n));
  //data[x][y] = 1;
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      if(i<=x&&j<=x) data[i][j] = j-i;
      if(i>=y&&j>=y) data[i][j] = j-i;
      if(i<=x&&j>=y) data[i][j] = 1 + x - i + j - y;
      if(i>=x&&j<=y) data[i][j] = min(j-i, y-j+i-x+1);
      //if(i==x&&j==y) data[i][j] = 1;
    }
  }
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      if(i<x&&j>x&&j<y) data[i][j] = x - i + data[x][j];
      if(i<y&&i>x&&j>y) data[i][j] = j - y + data[i][y]; 

    }
  }
  //cout << data[x][y] << endl;
  vector<int> A(n-1);
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      int p = data[i][j];
      A[p-1] += 1;
    }
  }
  rep(i, n-1) cout << A[i] << endl;
}


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

using namespace std;

int main(){
  int n;
  int i,c,r[11];
  int ei[8]={0,1,2,3,5,7,8,9};
  while(1){
    cin>>n;
    if(n==0)break;
    
    for(i=0;n>=8;i++){      
      r[i]=n%8;
      n/=8;
    }
    r[i]=n;
    for(;i>=0;i--){
      cout<<ei[r[i]];
    }
    cout<<endl; 
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  int n;
  while( cin >> n, n ) {
    int cnt[100000] = {0};
    
    while( n-- ) {
      int st, en;
      int h, m, s;
      
      scanf("%lld:%lld:%lld", &h, &m, &s);
      st = h*3600 + m*60 + s;
      
      scanf("%lld:%lld:%lld", &h, &m, &s);
      en = h*3600 + m*60 + s;

      for(int i=st; i<en; i++) cnt[i]++;
    }

    int ma = 0;
    for(int i=0; i<100000; i++) ma = max( ma, cnt[i] );

    cout << ma << endl;
    
  }
  
}

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

int main() {

	int a, b;
	char* ans;
	cin >> a >> b;
	if (a > b) {
		ans = "a > b";
	} else if (a < b) {
		ans = "a < b";
	} else {
		ans = "a == b";
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1156
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

A = getN()
print(A + (A ** 2) + (A ** 3))

Measured memory_bytes: 78104
#include<stdio.h>
int main(void)
{
	int n,a,b,c,i,j,d[1001]={0},k,m=0,s,t,h[1000]={0},ans=0;
	scanf("%d %d %d %d",&n,&a,&b,&c);
	for(i=0;i<n;i++)
		scanf("%d",&d[i]);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(d[i]<d[j])
			{
				k=d[i];
				d[i]=d[j];
				d[j]=k;
			}
		}
	}
	ans=c/a;
	m=c;
	for(i=0;i<n;i++)
	{
		m=m+d[i];
		if(ans<m/(a+b*(i+1)))
			ans=m/(a+b*(i+1));
	}
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  N=S.size();
  DV(dp,lli,N,13,0);//dp[i][j]:上位i桁が決まっていて13で割った余りがjな通り数
  if(S[0]=='?')rep(i,0,10)dp[0][i]=1;
  else dp[0][S[0]-'0']=1;
  rep(i,1,N)rep(j,0,13){
    if(S[i]=='?')rep(k,0,10)dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%mod;
    else dp[i][(j*10+S[i]-'0')%13]=(dp[i][(j*10+S[i]-'0')%13]+dp[i-1][j])%mod;
  }
  Out(dp[N-1][5]%mod);
}
  

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

struct dta{
  char s;
  long long m;
};
int main() { 
  string s;cin>>s;
  long long k;cin>>k;
  vector<dta> a;
  long long tmp = 1;
  for(int i = 1; s.size() > i; i++){
    if(s[i-1]!=s[i]){
      a.push_back({s[i-1],tmp});
      tmp = 1;
    }else tmp++;
  }
  a.push_back({s[s.size()-1],tmp});
  if(a.size() == 1){
    long long ans = (long long)s.size()*k;
    cout << ans/2 << endl;
    return 0;
  }
  long long ans = 0;
  for(int i = 1; a.size()-1 > i; i++){
    ans += (a[i].m)/2;
  }
  ans *= k;
  if(a[0].s == a[a.size()-1].s){
    ans += (k-1)*((a[0].m+a[a.size()-1].m)/2) + (a[0].m)/2 + (a[a.size()-1].m)/2;
  }else{
    ans += k*(((a[0].m)/2)+((a[a.size()-1].m)/2));
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(10);
  s[0] = "pon";
  s[1] = "pon";
  s[2] = "hon";
  s[3] = "bon";
  s[4] = "hon";
  s[5] = "hon";
  s[6] = "pon";
  s[7] = "hon";
  s[8] = "pon";
  s[9] = "hon";
  cout << s[n%10] << endl;
  return 0;
}


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

int null = -1;
int n;
int ans;
string x,y;
int dp[1001][1001];

int dfs(int i, int j){
    if(dp[i][j] != null){
        return dp[i][j];
    }
    int res;
    if(i == 0 || j == 0){
        return 0;
    }
    
    if(x[i-1] == y[j-1]){
        res = max(dfs(i,j-1),max(dfs(i-1,j-1)+1,dfs(i-1,j)));
    }
    else{
        res = max(dfs(i,j-1),dfs(i-1,j));
    }
    dp[i][j] = res;
    return res;
}

int main(){
    for(int i=0;i<1001;i++){
        for(int j=0;j<1001;j++){
            dp[i][j] = null;
        }
    }

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        cin >> y;
        int lenx = (int)x.length();
        int leny = (int)y.length();
        //cout << lenx << " " << leny << endl;
        ans = dfs(lenx,leny);
        cout << ans << endl;
        for(int j=0;j<1001;j++){
            for(int k=0;k<1001;k++){
                dp[j][k] = null;
            }
        }
    }
    return 0;

}


Measured memory_bytes: 7144
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,n);
  VEC(int,b,n);

  vector<int> ans;
  while(!b.empty()){
    int tmp=-1;
    REP(i,b.size()){
      if(i+1==b[i]) tmp=i+1;
    }
    if(tmp<0){
      OUT(tmp)BR;
      return 0;
    }
    ans.push_back(tmp);
    b.erase(b.begin()+tmp-1);
  }

  RREP(i,ans.size()){
    OUT(ans[i])BR;
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            int cnt = 0;
            var anser = new int[N];
            for (int i = 11; cnt < N; i += 10)
            {
                if (IsPrime(i))
                {
                    anser[cnt] = i;
                    cnt++;
                }
            }
            Console.WriteLine(string.Join(" ", anser));
        }

        private bool IsPrime(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0) return false;
            }

            return true;
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13268
n = int(input())
monster_life_lst = list(map(int, input().split()))


while True:
    while 0 in monster_life_lst:
        monster_life_lst.remove(0)
    monster_life_lst.sort()
    for i in range(1, len(monster_life_lst)):
        monster_life_lst[i] = monster_life_lst[i] % monster_life_lst[0]
    if len(monster_life_lst) == 1:
        out_flag = monster_life_lst[0]
        break

def out(out_flag):
    print(out_flag)

out(out_flag)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[110][10];

int main() {
    int h, w, k; cin >> h >> w >> k;
    k--;
    int range = w-1;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        for(int bit = 0; bit < (1<<range); ++bit) {
          // 連続なものは除外する
          bool flg = true;
          for(int l = 0; l < range-1; ++l) {
            if((bit&(1<<l)) && (bit&(1<<(l+1)))) flg = false;
          }
          if(!flg)continue;

          if(bit&(1<<j)) dp[i+1][j+1] += dp[i][j];
          else if(j > 0 && (bit&(1<<(j-1)))) dp[i+1][j-1] += dp[i][j];
          else dp[i+1][j] += dp[i][j];
        }
      }
    }

    cout << dp[h][k] << endl;
}

Measured memory_bytes: 3624
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

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

int main()
{
  int n;
  cin >> n;
  vector<p> v(n, {0, 0});
  for (int i = 0; i < n; i++){
  cin >> v[i].first;
  v[i].second = i;
  }

  sort(v.begin(), v.end());
  bool is0 = true;
  for (int i = 0; i < n; i++){
    if (v[i].second != i) {
      is0 = false;
    }
  }
  if (is0) {
    cout << 0 << endl;
    return 0;
  }
  int maxv = -1, count = 0;
  for (int i = 0; i < n - 1; i++){
    count++;
    if (v[i].second >= v[i+1].second) {
      maxv = max(maxv, count);
      count = 0;
    }
  }
  maxv = max(maxv, count);
  cout << n - maxv << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

const int MAX_PRIME = 1000010;
bool isPrime[MAX_PRIME];

void calcPrimes() {
	for (int i = 2; i < MAX_PRIME; i++) isPrime[i] = true;
	for (int i = 2; i < MAX_PRIME; i++) {
		if (!isPrime[i]) continue;
		for (int j = i * i; j < MAX_PRIME; j += i) isPrime[j] = false;
	}
}

signed main() {
	calcPrimes();

	int N;
	cin >> N;

	vector<int> ret;
	int num = 1;
	while (num <= 55555 && ret.size() < N) {
		num++;
		if (!isPrime[num]) continue;
		if (num % 5 != 1) continue;
		ret.push_back(num);
	}

	for (int num : ret) cout << num << " ";
	cout << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		mp[a]++;
	}
	vector<pair<int, int>> v;
	for (auto c : mp) {
		v.push_back(make_pair(c.second, c.first));
	}
	sort(v.begin() , v.end());
	int ans = 0;
	if ((int)mp.size() <= k) {
		return printf("0\n") , 0;
	} else {
		for (int i = 0 ; i < (int)v.size() - k ; i++){
			ans += v[i].first;
		}
	}
	printf("%d\n" , ans);
}


Measured memory_bytes: 14532
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int a, b, t; cin >> a >> b >> t;
  cout << b * (t / a) << endl;
}


Measured memory_bytes: 256
from sys import stdin


def get_result(data):
    N = data[0]
    if N[-1] in ['2', '4', '5', '7', '9']:
        return 'hon'
    elif N[-1] in ['0', '1', '6', '8']:
        return 'pon'
    else:
        return 'bon'


if __name__ == '__main__':
    data = list(map(str, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 8988
# -*- coding: utf-8 -*-
"""
C - March
https://beta.atcoder.jp/contests/abc089/tasks/abc089_c

"""
import sys
from sys import stdin
from itertools import combinations
input = stdin.readline


def main(args):
    N = int(input())
    names = dict()
    for _ in range(N):
        tmp = input().strip()
        if not tmp in names:
            if tmp[0] in 'MARCH':
                names[tmp] = 1

    m_names = [0] * 5
    for k, v in names.items():
        if k[0] == 'M':
            m_names[0] += 1
        elif k[0] == 'A':
            m_names[1] += 1
        elif k[0] == 'R':
            m_names[2] += 1
        elif k[0] == 'C':
            m_names[3] += 1
        elif k[0] == 'H':
            m_names[4] += 1

    if len(names) < 3:
        print(0)
    else:
        ans = 0
        for c in combinations(m_names, 3):
            t = c[0] * c[1] * c[2]
            ans += t
        print(ans)


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


Measured memory_bytes: 17500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,L,absmin=100000,taste=0,minn;
    cin >> N >> L;
    for (int i = 1; i <= N; i++)
    {
        taste += L + i - 1;
        if (abs(L + i - 1) <= absmin){
            minn = L + i - 1;
        }
        absmin = min(abs(L + i - 1), absmin);
        
    }

    cout << taste-minn  << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = []
A.sort()
a = A.pop(0)
b = A.pop()
N -= 2
k = 1
for i in range(N):
    y = A.pop()
    if y<0:k=0
    if k:
        ans.append([a,y])
        a -= y
    else:
        ans.append([b,y])
        b -= y
ans.append([b,a])
print(b-a)
for a in ans: print(*a)

Measured memory_bytes: 21676
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  //固定小数点
  cout<<fixed;
  //桁数固定
  cout<<setprecision(8);
  cout<<(N-N/2)/(double(N))<<endl;
  return 0;
}


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

using namespace std;

int main()
{
	int n,d,x;
	cin >> n >> d >> x;
	vector<int> a(n);
	int ans=0;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
	{
		ans+=((d+a[i]-1)/a[i]);
	}
	ans+=x;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;

int main() {
  int MOD = 1000000007;
  string K; cin >> K;
  int D; cin >> D;
  int L = K.size();
  vvvl dp(10010, vvl(2, vl(D, 0)));
  dp.at(0).at(0).at(0) = 1;
  for (int i = 0; i < L; i++) {
    int Digit = K.at(i) - '0';
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < D; k++) {
        for (int d = 0; d <= (j ? 9 : Digit); d++) {
          dp.at(i+1).at(j || (d < Digit)).at((k + d) % D) += dp.at(i).at(j).at(k);
          dp.at(i+1).at(j || (d < Digit)).at((k + d) % D) %= MOD;
        }
      }
    }
  }
  cout << (dp.at(L).at(0).at(0) + dp.at(L).at(1).at(0) - 1 + MOD) % MOD << endl;
}

Measured memory_bytes: 17024
from functools import reduce


n, k = map(lambda x: int(x), input().split(' '))
l = list(map(lambda x: int(x), input().split(' ')))

def add_num(a, b):
    return int(a) + int(b)

k *= -1
l.sort()
print(reduce(add_num, l[k:]))


Measured memory_bytes: 3700