akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include<cstring>
using namespace std;
typedef long long LL;
set<pair<int,int> > the_blacks;
LL freq[10];
LL H, W, n; 
void update(int x, int y, int as)
{
	for(int i = max(1,x-2); i <= min(H-2,(LL)x); i++)
		for(int j = max(1,y-2); j <= min(W-2,(LL)y); j++)
		{
			int ctr = 0;
			for(int di = 0; di <= 2; di++)
				for(int dj = 0; dj <= 2; dj++)
					ctr += the_blacks.count({i+di,j+dj});
			freq[ctr] += as;
		}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> H >> W >> n;
	memset(freq,0,sizeof freq);
	freq[0] = (H-2)*(W-2);

	while(n--)
	{
		int a, b; cin >> a >> b;
		update(a,b,-1);
		the_blacks.insert({a,b});
		update(a,b,1);
	}

	for(int i = 0; i <= 9; i++)
		cout<<freq[i]<<endl;


	return 0;
}

Measured memory_bytes: 4992
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
ch,cw = na()
dh,dw = na()
ch,cw = ch-1,cw-1
dh,dw = dh-1,dw-1
s = []
for i in range(h):
  s.append(ns())

from collections import deque

g = [[10000000000]*w for i in range(h)]
g[ch][cw] = 0
d = deque([(ch,cw,0)])

while d:
  x,y,num = d.popleft()
  pq = [(-1,0),(0,1),(1,0),(0,-1)]
  for p,q in pq:
    if not (0<=x+p<h and 0<=y+q<w):
      continue
    u = s[x+p][y+q]
    if u == '.':
      if num < g[x+p][y+q]:
        g[x+p][y+q] = num
        d.appendleft((x+p,y+q,num))

  for i in range(-2,3):
    for j in range(-2,3):
      if not (0<=x+i<h and 0<=y+j<w):
        continue
      p = s[x+i][y+j]
      if p == '.':
        if num+1 < g[x+i][y+j]:
          g[x+i][y+j] = num+1
          d.append((x+i,y+j,num+1))

ans = g[dh][dw]

print('-1' if ans == 10000000000 else ans)

Measured memory_bytes: 130896
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M, S = map(int, input().split())
adj = [[] for _ in range(N)]
for i in range(M):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append((v, a, b))
    adj[v].append((u, a, b))
C = [0] * N
D = [0] * N
for i in range(N):
    C[i], D[i] = map(int, input().split())

MAX = 50 * 50 + 5
dp = [[INF] * (MAX + 1) for _ in range(N)]
q = []
def push(x, v, s):
    if s < 0:
        return
    if dp[v][s] <= x:
        return
    dp[v][s] = x
    heappush(q, (x, v, s))
s = min(MAX, S)
push(0, 0, s)
while len(q) > 0:
    x, v, s = heappop(q)
    if dp[v][s] != x:
        continue
    # 換金
    ns = min(s + C[v], MAX)
    push(x + D[v], v,  ns)
    # 隣の駅へ移動
    for u in adj[v]:
        push(x + u[2], u[0], s - u[1])

for i in range(1, N):
    print(min(dp[i]))

Measured memory_bytes: 97552
#include <stdio.h>
#include <string.h>

int main(void){
  char s[3];
  scanf("%s",s);
  if(strcmp(s,"ABC") == 0){
    printf("%s","ARC\n");
  }else if(strcmp(s,"ARC") == 0){
    printf("%s","ABC\n");
  }
  return 0;
}

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

int main() {
    set<int> ss;
    int q;
    cin >> q;
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t) {
            cout << ss.count(x) << endl;
        } else {
            ss.insert(x);
            cout << ss.size() << endl;
        }
    } 
}


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

int main() {
  string S;
  cin >> S;
  S.push_back('R');
  int N = S.size();
  vector<int> va, vb;
  int cnta = 0;
  for (int i = 0; i < N-1; i++) {
    cnta++;
    if(S.at(i) != S.at(i+1)) {
      va.push_back(cnta);
      cnta = 0;
    }
  }
  for (int i = 0; i < va.size() / 2; i++) {
    vb.push_back(va.at(2*i)+va.at(2*i + 1));
  }
  vector<int> vv(N-1);
  int cnt = 0;
  for (int i = 0; i < va.size()-1; i++) {
    cnt += va.at(i);
    if (i % 2 == 0) {
      if (vb.at(i / 2) % 2 == 0) {
        vv.at(cnt-1) = vb.at(i / 2) / 2;
        vv.at(cnt) = vb.at(i / 2) / 2;
      }
      else {
        if (va.at(i) % 2 == 0) {
          vv.at(cnt-1) = vb.at(i / 2) / 2;
          vv.at(cnt) = vv.at(cnt-1) + 1;
        }
        else {
          vv.at(cnt) = vb.at(i / 2) / 2;
          vv.at(cnt-1) = vv.at(cnt) + 1;
        }
      }
    }
  }
  for (int i = 0; i < vv.size(); i++) {
    cout << vv.at(i) << " ";
  }
}

Measured memory_bytes: 1784
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m, p;
        cin >> n >> m >> p;
        if(n == 0)
            return 0;

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

        if(x[m-1] == 0){
            cout << 0 << endl;
        }else{
            int ret = accumulate(x.begin(), x.end(), 0);
            ret *= 100 - p;
            ret /= x[m-1];
            cout << ret << endl;
        }
    }
}

Measured memory_bytes: 1196
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}
		Sort(num);

	}
	static void Sort(int[] num){
		int v,j;
		for(int i=0;i<num.length;i++){
			v = num[i];
			j = i-1;
			while(j>=0 && num[j]>v){
				num[j+1] = num[j];
				j--;
			}
			num[j+1] = v;
			Print(num);
		}

	}

	static void Print(int[] a){
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<a.length;i++){
			sb.append(a[i]);
			if(i<a.length-1)sb.append(" ");
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 27984
x, k, d = list(map(int, input().split()))

# プラス側だけで考える
x = abs(x)

# xがDより小さくなるまで0に近づける
move_near_0 = min(x // d, k)
x -= d * move_near_0
k -= move_near_0

# kが偶数ならそこで往復、kが奇数なら-D
if k % 2 == 0:
    print(x)
else:
    print(abs(x - d))

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int L;cin>>L;
	int n = 0;int cnt = 0;
    int temp = L;
	while(temp){
        n++;
        cnt += temp % 2;
        temp /= 2;
    }
    cout<<n<<" "<<2 * (n - 1) + cnt - 1<<endl;
	Rep(i,1,n){
		cout<<i<<" "<<i + 1<<" "<<0<<endl;
		cout<<i<<" "<<i + 1<<" "<<(1<<i-1)<<endl;
	}
	int t = (1<<n-1);
	for(int i = n-2; i>=0; i--){
		if(L & (1<<i)){
			cout<<i + 1<<" "<<n<<" "<<t<<endl;
			t += (1<<i);
		}
	}
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <bitset>

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

constexpr int N = 8;
constexpr int K = 1 << N;
bool P[N][N];
int A[N][K];

int n;

int compute(int v, int t){
    if(A[v][t] != -1) return A[v][t];
    if(!((t >> v) & 1)) return A[v][t] = 0;
    A[v][t] = 0;
    int nt = t ^ (1 << v);
    REP(i, n) if(P[i][v]) A[v][t] += compute(i, nt);
    return A[v][t];
}

int main(void){
    int m; scanf("%d%d", &n, &m);
    REP(i, n) REP(j, n) P[i][j] = false;
    REP(_, m){
        int a, b; scanf("%d%d", &a, &b); a--; b--;
        P[a][b] = P[b][a] = true;
    }
    int k = 1 << n;
    REP(i, n) REP(j, k) A[i][j] = -1;
    REP(i, n) A[i][1 << i] = 1;
    printf("%d\n", compute(0, k - 1) );
    /*
    REP(i, n) REP(j, k){
      printf("A[%d][", i);
      REP(s, n) putchar('0' + ((j >> s) & 1));
      printf("] = %d\n", A[i][j]);
    }
    */
  
  
    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>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i, N){
    cin >> A[i];
    if(i > 0){
      if (A[i-1] < A[i]) B[i] = 1;
      else if (A[i-1] == A[i]) B[i] = 0;
      else B[i] = -1;
    }
  }
  B[0] = 0;

  ll money = 1000;
  ll kabu = 0;

  ll ans = 0;

  rep(i, N-1){
    if(B[i] != 1 && B[i+1] == 1){
      kabu = money / A[i];
      money -= kabu * A[i];
    }
    if(B[i] == 1 && B[i+1] != 1){
      money += kabu * A[i];
      kabu = 0;
    }
    ans = max(ans, money);
    //cout << kabu<< " " << money << endl;
  }

  money += kabu * A[N-1];
  //cout << money << endl;
  ans = max(ans, money);

  cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define maxn 1000086

using namespace std;

int n, x;
int y;

int a[maxn];
int p[maxn], cnt;
bool tag[maxn];
bool suc = true;

int main(){
	for(int i = 2;i < 1001;i++){
		if(!tag[i]) p[++cnt] = i;
		for(int j = 1;j <= cnt && p[j] * i < 1001;j++){
			tag[p[j] * i] = true;
			if(i % p[j] == 0) break;
		}
	}
	//printf("%d--\n", cnt);
	memset(tag, 0, sizeof(tag));
	scanf("%d", &n);
	int tot = 0;
	for(int i = 1;i <= n;i++){
		scanf("%d", &a[i]);
		if(a[i] ^ 1) tot++;
	}
	if(tot > 78503) suc = false;
	for(int j = 1;j <= n;j++){
		int x = a[j];
		if(!y) y = x;
		else y = __gcd(y, x);
		if(!suc) continue;
		for(int i = 1;i <= cnt;i++){
			if(x % p[i] == 0){
				if(tag[p[i]]) suc = false;
				else tag[p[i]] = true;
			}
			while(x % p[i] == 0) x /= p[i];
		}
		if(x ^ 1){
			if(tag[x]) suc = false;
			else tag[x] = true;
		}
	}
	if(suc) printf("pairwise coprime");
	else if(y == 1) printf("setwise coprime");
	else printf("not coprime");
}

Measured memory_bytes: 8564
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			String a=s.next();
			int sum=0;
			int table[]=new int[a.length()];
			for(int i=0;i<a.length();i++){
				switch(a.charAt(i)){
					case 'I':
						table[i]=1;
						break;
					case 'V':
						table[i]=5;
						break;
					case 'X':
						table[i]=10;
						break;
					case 'L':
						table[i]=50;
						break;
					case 'C':
						table[i]=100;
						break;
					case 'D':
						table[i]=500;
						break;
					case 'M':
						table[i]=1000;
						break;
				}
			}
			for(int i=0;i<a.length();i++){
				if(i<a.length()-1&&table[i]<table[i+1])sum-=table[i];
				else sum+=table[i];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
using System;

class Program{
	static void Main(){
		string s;
		while((s = Console.ReadLine()) != null){
			int w = int.Parse(s);
			for(int n = 1;; n *= 2){
				if(w % (n*2) != 0){
					Console.Write(n);
					w -= n;
					if(w == 0) break;
					Console.Write(" ");
				}
			}
			Console.WriteLine();
		}
	}
}

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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> a(n);
    rep(i,n)
    {
        cin >> a[i];
    }
    int ans = x;
    rep(i,n+1)
    {
        int ok = 0;
        rep(j,n)
        {
            if(a[j] == x-i)
            {
                ok += 1;
            }
            if(a[j] == x+i)
            {
                ok += 2;
            }
        
            if(ok == 3)
                break;
        }
        
        if(ok != 3)
        {
            if(ok == 0)
                ans = x-i;
            else if(ok == 1)
                ans = x+i;
            else
                ans = x-i;
            break;
        }
    }
    pri(ans);
    return 0;
}


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

  //#include <tuple>

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

  int char_to_int(char c)
  {
    if (c == '0') return 0;
    if (c == '1') return 1;
    if (c == '2') return 2;
    if (c == '3') return 3;
    if (c == '4') return 4;
    if (c == '5') return 5;
    if (c == '6') return 6;
    if (c == '7') return 7;
    if (c == '8') return 8;
    if (c == '9') return 9;
    else return -1;
  }

  int main() {
    string N;
    cin >> N;
    // 一桁ずつに修正する
    vector<int> a;

    a.push_back(0);
    for(char c: N){
      char r = char_to_int(c);
      a.push_back(r);
    }
    int digit = N.size();
    // rep(i, digit+1){
    //   cout << a[i] << endl;
    // }

    ll ans = 0;

    for(int i = digit; i >= 1; i--) {
      if (a[i] >= 10) {
        a[i-1]++;
        a[i] = a[i] - 10;
      }

      if (a[i] == 5 && a[i-1] < 5){
        ans += a[i];
        // cout << a[i] << " ";
      } else if(a[i] >= 5) { // 5以上なら一つ上のお金に払ってもらう
        ans += 10 - a[i];
        // cout << 10 - a[i] << " ";
        a[i-1]++;
      } else { // ５より小さい場合はこのお金ではらう
        ans += a[i];
        // cout << a[i] << " ";
      }
    }
    ans += a[0]; 
    
    cout << ans << endl;

  }


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

int main () {
    string s;
    cin >> s;
    int n = s.length(), ret = 0;
    for (int i = 0; i < n/2; ++i) {
        if (s[i] != s[n-i-1]) ret += 1;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.io.*;

class Main {

	public static void main(String[] args) throws Exception{
		        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		        String tests = br.readLine();
				if(tests.length()%2!=0){
		          System.out.println("No");
		        } else{
		          
		            int i=0;
		            while(i<tests.length()){
		              String temp=tests.substring(i,i+2);
		              if(!temp.equals("hi")){
		                break;
		              }
		              i=i+2;
		            }
		            if(i>=tests.length()){
		               System.out.println("Yes");
		            } else {
		            
		     
		            System.out.println("No");
		            }
		          
		          
		        }
		                             
		    }

}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pp pair< ll, pair<ll,ll> >

ll p(ll b, ll p){
    ll ret = 1;
    for(ll i = 0; i < p; i++) ret *= b, ret %= MOD;
    return ret;
}

int main()
{
    ll n; cin>>n;
    ll ans = p(10, n);
    ans -= p(9,n);
    ans = (ans + MOD) % MOD;
    ans -= p(9,n);
    ans = (ans+MOD)%MOD;
    ans += p(8,n);
    ans = (ans+MOD)%MOD;
    cout << (ans + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 3632
c = []
for _ in range(3):
    ci = list(map(int, input().split()))
    c.append(ci)

r = [sum([c[j][i] for i in range(3)]) for j in range(3)]
q = [sum([c[i][j] for i in range(3)]) for j in range(3)]
if (r[2]-r[1]) % 3 == 0 and (r[1]-r[0]) % 3 == 0 and (q[2]-q[1]) % 3 == 0 and (q[1]-q[0]) % 3 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val mod = 1000000007
    val (H,W) = readIntList()

    var tmpX = 0
    var tmpY = 0
    var hasCoin = false
    val ansList = mutableListOf<String>()

    for (h in 1..H) {
        var line = readIntList().withIndex()
        if (h % 2 == 0)
            line = line.reversed()

        for ((i, c) in line) {
            val w = i+1
            var coin = c

            if (hasCoin) {
                ansList.add("$tmpY $tmpX $h $w")
                coin++
                hasCoin = false
            }

            if (coin%2 == 1) {
                hasCoin = true
                tmpX = w
                tmpY = h
            }
        }
    }

    println(ansList.size)
    println(ansList.joinToString("\n"))
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 65148
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{

    static void Main(string[] args)
    {
        long[] arr1 = Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        long n = arr1[0];
        long k = arr1[1];
        long[] arr = Console.ReadLine().Split(' ').Select(v => long.Parse(v)).OrderBy(v => v).ToArray();
        long sum = 0;
        if(arr.Length <= k)
        {
            Console.WriteLine(0);
        }
        else
        {
            for(long i = 0; i < arr.Length - k; i++)
            {
                sum += arr[i];
            }
            Console.WriteLine(sum);
        }

    }




}

Measured memory_bytes: 51340
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();
		int[] c = new int[27];
		for (int i = 1; i < 27; i++) {
			c[i] = sc.nextInt();
		}
		int[][] s = new int[d + 1][27];
		for (int i = 1; i < d + 1; i++) {
			for (int j = 1; j < 27; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		int[] t = new int[d + 1];
		for (int i = 1; i <= d; i++) {
			t[i] = sc.nextInt();
		}
		sc.close();

		int[] last = new int[27];
		int v = 0;
		for (int i = 1; i <= d; i++) {
			int type = t[i];
			last[type] = i;
			v += s[i][type];
			int downSatis = 0;
			for (int j = 1; j < 27; j++) {
				downSatis += (c[j] * (i - last[j]));
			}
			v -= downSatis;
			System.out.println(v);
		}
	}
}


Measured memory_bytes: 37872
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
      	String[] list = s.split("");
      	if(s.length()==3){
          System.out.println(list[2]+list[1]+list[0]);
        }else{
          System.out.println(s);
        }
	}
}

Measured memory_bytes: 39176
n,m=map(int,input().split())
A=[[0]*2 for i in range(m)]
for i in range(m):
  A[i]=list(map(int,input().split()))
A.sort(key=lambda x:x[1])
B=[A[0][1]-1]
for i in range(m):
  if A[i][0]<=B[-1] and B[-1]<A[i][1]:
    pass
  else:
    B.append(A[i][1]-1)
print(len(B))

Measured memory_bytes: 29096
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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

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




void solve(){
	int h, a;
	cin >> h >> a;
	cout << (h+a-1)/a << endl;
}

int main(){
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	int a[40]={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};
	scanf("%d",&n);
	printf("%d",a[n-1]);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
    vector<int> v;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    
    auto minmax = minmax_element(v.begin(), v.end());
    long long sum = accumulate(v.begin(), v.end(), 0LL);
    
    cout << *minmax.first << " " << *minmax.second << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース

*/
//main.cpp----------------------------
#define max_n 100000

void solve();

ll n;
ll a[max_n+1];

int main() {
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }

  solve();

  return 0;
}

void solve() {
  ll uclid = my_gcd(a[0], a[1]);
  for(int i=2; i<n; ++i) {
    uclid = my_gcd(uclid, a[i]);
  }

  cout << uclid << endl;
}


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

int main() {
    int n, x, i=1;
    cin >> n;
    while(1){
        x = i;
        if(x%3==0){
            cout << " " << i;
        } else {
            while(1){
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
                if(x) continue;
                break;
            }
        }
        if(++i>n) break;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <algorithm>
using namespace std;

const int MAXN = (int)1e5 + 5;
const int INF = (int)1e9;

int h[MAXN];
int dp[MAXN];

int main(void) {
    int n;

    scanf(" %d", &n);
    for (int i = 1; i <= n; i++) {
        scanf(" %d", &h[i]);
    }

    dp[n] = 0;
    for (int i = n - 1; i >= 1; i--) {
        dp[i] = INF;
        for (int j = i + 1; j <= i + 2; j++) {
            if (j <= n) {
                dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
            }
        }
    }
    printf("%d\n", dp[1]);


    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(void){
	int i, j;	//ループ用変数
	int yama[10];
	int pose;	//入れ替え用変数

	for (i = 0; i < 10; i++){
		scanf("%d", &yama[i]);
	}

	for (i = 0; i < 9; i++){	//このループで降順に並び替える
		for (j = i + 1; j < 10; j++){
			if (yama[i]<yama[j]){
				pose = yama[i];
				yama[i] = yama[j];
				yama[j] = pose;
			}
		}
	}
	printf("%d\n%d\n%d\n", yama[0], yama[1], yama[2]);
	return 0;
}

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

using namespace std;

static const int N=100;

int main()
{
  int n,P[N+1],M[N+1][N+1];
  cin>>n;

  for(int i=1;i<=n;i++)
    cin>>P[i-1]>>P[i];

  for(int i=1;i<=n;i++)
    M[i][i]=0;

  for(int l=2;l<=n;l++)
    {
      for(int i=1;i<=n-l+1;i++)
	{
	  int j = i+l-1;
	  M[i][j]=(1<<21);
	  for(int k=i;k<=j-1;k++)
	    {
	      M[i][j]=min(M[i][j],M[i][k]+M[k+1][j]+P[i-1]*P[k]*P[j]);
	    }
	}
    }

  cout<<M[1][n]<<endl;

  return 0;
}



Measured memory_bytes: 3144
use proconio::*;
use proconio::marker::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        A: [Usize1; N - 1]
    }
    let mut anss: Vec<usize> = vec![0; N];
    for &a in A.iter() {
        anss[a] += 1;
    }
    for &ans in anss.iter() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 6276
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int res = 0;
        for (int i = 1; i <= N; i += 2) {
            int counter = 0;
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    counter++;
                }
            }
            if (counter == 8) {
                res++;
            }
        }
        System.out.println(res);
        sc.close();
    }
}

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


    int n, k;
    cin >> n >> k;

    vector<int>l(n);
    for(int i = 0; i < n; ++i){
        cin >> l.at(i);
    }

    sort(l.begin() , l.end());
    reverse(l.begin(), l.end());
int ans = 0;
    for(int i= 0; i < k; ++i){
ans += l.at(i);
    }

cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]


def main():
    h,w = inpm()
    maze = []
    for _ in range(h):
        s = list(input())
        maze.append(s)
    ans = 0
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    key = 0
    for sx in range(h):
        for sy in range(w):
            if maze[sx][sy] == '#':
                continue
            else:
                d = [[-1 for _ in range(w)] for _ in range(h)]
                que = []
                d[sx][sy] = 0
                que.append([sx,sy])
                M = 0
                while que:
                    [qx,qy]=que[0]
                    que.pop(0)
                    for i in range(4):
                        nx=qx+dx[i]
                        ny=qy+dy[i]
                        if nx>=0 and h>nx and ny>=0 and w>ny and maze[nx][ny]=="." and d[nx][ny]==-1:
                            d[nx][ny]=d[qx][qy]+1
                            if d[qx][qy]+1>M:
                                M= d[qx][qy]+1
                            que.append([nx,ny])
                ans = max(ans,M)
    print(ans)
 

if __name__ == "__main__":
    main()

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

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

	long mod = 1000000007;
	vector<vector<long> > dp(s.size()+1, vector<long>(4, 0));

	int n = s.size();
	for(int i=n; i >= 0; i--) {
		for(int j=3; j >= 0; j--) {
			if(i == n) {
				dp.at(i).at(j) = (j == 3) ? 1 : 0;
			}else{
				int m = (s.at(i) == '?') ? 3 : 1;
				string str = "ABC";
				dp.at(i).at(j) = m * dp.at(i+1).at(j);
				if(j < 3 && (m == 3 || s.at(i) == str.at(j)))
					dp.at(i).at(j) += dp.at(i+1).at(j+1);
				dp.at(i).at(j) %= mod;
			}
		}
	}
	cout << dp.at(0).at(0) << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, m, x;
	cin >> n >> m >> x;
	int c[12];
	int a[12][12] = {};
	for(int i = 0; i < n; ++i)
	{
		cin >> c[i];
		for(int j = 0; j < m; ++j)
		{
			cin >> a[i][j];
		}
	}

	const ll initial_num = 1000000000000;
	ll ans = initial_num;
	for(int i = 0; i < 1 << n; ++i)
	{
		int total[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
		ll cost = 0;
		for(int j = 0; j < n; ++j)
		{
			if (i & 1 << j)
			{
				for(int k = 0; k < m; ++k)
				{
					total[k] += a[j][k];
				}
				cost += c[j];
			}
		}
		bool ok = true;
		for(int j = 0; j < m; ++j)
		{
			ok = ok & total[j] >= x;
		}
		if (ok)
		{
			ans = min(ans, cost);
		}

	}

	if (ans == initial_num)
	{
		ans = -1;
	}
	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

int i[256];
int main()
{
	map<char,string>a;
	cin>>a['a']>>a['b']>>a['c'];
	
	char c='a',p;
	while(1)
	{
		if(a[c].size()==i[c]){cout<<(char)toupper(c)<<endl;return 0;}
		p=a[c][i[c]];
		i[c]++;
		c=p;
		
	
	}
	
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast;
	ll a,b,c; cin>>a>>b>>c; if(b-a == c-b) cout << "YES" << endl; else cout << "NO" << endl;
  	return 0; 
}

Measured memory_bytes: 256
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && 0<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

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

    vi ans;

    REP(i,15) if(n&(1<<i)) ans.pb(1<<i);

    cout<<ans<<endl;

  }

  return 0;

}



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

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define rep(i, n) for(LL i = 0; i < n; i++)

int A, B, K;

void input()
{
  cin >> A >> B >> K;
}

void solve()
{
  int num = 100;
  int cnt = 0;
  for(; 0 < num; num--)
  {
    if(A%num == 0 && B%num == 0)
    {
      cnt++;
      if(cnt == K)
      {
        cout << num;
        return;
      }
    }
  }
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll a,b; cin >> a >> b;
  cout << (b%a==0 ? a+b : b-a) << endl;
  return 0;
}


Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, f[maxN];
vector<int> g[maxN];

void DFS(int u, int p) {
    for(int v: g[u]) {
        if (v == p) continue;
        DFS(v, u);
        f[u] ^= (f[v]+1);
    }
}

int main () {
    scanf("%d", &n);
    fto(i, 1, n-1) {
        int u, v; scanf("%d%d", &u, &v);
        g[u].pb(v); g[v].pb(u);
    }

    DFS(1, -1);

    puts((f[1]) ? "Alice" : "Bob");

    return 0;
}


Measured memory_bytes: 12416
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself
        
*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"

/*
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int lcm(int a, int b)  
{  
    return (a*b)/gcd(a, b);  
}  
*/

/*
int powermod(int A, int p, int MOD = mod){
    A%=MOD;
    int res  = 1;
    while(p){
        if(p&1)
            res = ((__int128)res*A)%MOD;
        
        A = ((__int128)A*A)%MOD;
        p>>=1;
    }

    return res;
}
*/

/*
const int MAX = 100000; 
int prefix[MAX + 1]; 

void buildPrefix() 
{ 
	bool prime[MAX + 1]; 
	memset(prime, true, sizeof(prime)); 

	for (int p = 2; p * p <= MAX; p++) { 
		if (prime[p] == true) { 
			for (int i = p * 2; i <= MAX; i += p) 
				prime[i] = false; 
		} 
	} 
	prefix[0] = prefix[1] = 0; 
	for (int p = 2; p <= MAX; p++) { 
		prefix[p] = prefix[p - 1]; 
		if (prime[p]) 
			prefix[p]++; 
	} 
} 

int query(int L, int R) 
{ 
	return prefix[R] - prefix[L - 1]; 
}
*/

/*

//Find all paths from a to b in an undirected graph
vector<int> g[100000];
int visited[100000];
 //count of all the paths from 1 to n;
vector<string> ans;

void dfs(int visited[10000],int u,int v,vector<int> path)
{
    visited[u]=1;
    if(u==v)
    {
        string temp="";
        for(int i=0;i<path.size();i++)
        {
            temp+=to_string(path[i]);
        }
        ans.pb(temp);
    }
    else
    {
        for(int i=0;i<g[u].size();i++)
        {
            int y=g[u][i];

            if(visited[y]==0)
            {
                visited[y]=1;
                path.pb(y);
                dfs(visited,y,v,path);
                path.pop_back();
            }

        }
    }

    visited[u]=0;

}
*/

vector<pair<int,string>> vp;

void solve()
{
    int n,x,t;
    cin>>n>>x>>t;
    //int a[n],b[n];
    //for(int i=0;i<n;i++)
    //cin>>a[i];
    int k;
    if(n%x==0)
    k=n/x;
    else
    k=n/x+1;
    
    cout<<k*t<<"\n";
    
}

int32_t main(void)
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; i++)
#define rrep(i, j, k) for (int i = j; i > k; i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define end "\n"
#define endl "\n"
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int main() {
    io;
    
    ll n;
    cin>>n;
    ll a[n];
    ll sum = 0;
    rep(i,0,n){
    cin>>a[i];
    sum+=a[i];
    }   

    ll mini=sum,l_sum=0;
    
    rep(i,0,n+1)
    {    
        l_sum+=a[i];
        mini = min(mini, abs(l_sum-(sum-l_sum)));
    }

    cout<<mini<<endl;
 
 
 
    
 
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
const int MOD=1e9+7;
const int N=1e3+10;
int main(){
  int n,m;
  string s[N];
  long long int dp[N][N];
  cin>>n>>m;
  for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)dp[i][j]=0;
  for(int i=1;i<=n;i++)cin>>s[i];
  dp[1][1]=1;
  for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(s[i][j-1]=='.'){
    dp[i][j]+=dp[i-1][j]+dp[i][j-1];
    dp[i][j]%=MOD;
//    cout<<"i="<<i<<" j="<<j<<" dp[i][j]="<<dp[i][j]<<endl;
  }
  cout<<dp[n][m]<<endl;
}


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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcoder
//abc165

int main()
{
    int k, a, b;
    cin>>k;
    cin>>a>>b;

    for (int i = b; i >=a; i--)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }    

    cout<<"NG"<<endl;
}

Measured memory_bytes: 3632
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    dic = {}
    for s in S:
        if not(s in dic.keys()):
            dic[s] = 1
        else:
            dic[s] += 1

    max = 0
    ans = []
    for s, count in dic.items():
        if count > max:
            ans = [s]
            max = count
        elif count == max:
            ans.append(s)

    print("\n".join(sorted(ans)))



if __name__ == "__main__":
  main()


Measured memory_bytes: 44708
#include <bits/stdc++.h>
#define N 101
using namespace std;
int m,c,n;
vector<int> shelf[32];

int pop(int nx){
  for(int i=0;i<m;i++)
    for(int j=0;j<(int)shelf[i].size();j++)
      if(shelf[i][j] == nx){
	shelf[i].erase(shelf[i].begin()+j);
	return i+1;
      }
  return m+1;
}

int push(int nx){
  int res = m+1;
  for(int i=0;i<m;i++){
    if((int)shelf[i].size()>=c) continue;
    shelf[i].push_back(nx);
    if(i==0) return 1;
    res = i+1;
    break;
  }

  int last = shelf[0][0];shelf[0].erase(shelf[0].begin());
  res++;
  for(int i=1;i<=m;i++){
    if(i==m) {res+=m+1;continue;}
    if((int)shelf[i].size()>=c) continue;
    shelf[i].push_back(last);
    res += i+1;
    break;
  }

  res+=pop(nx);
  shelf[0].push_back(nx);
  return res+1;
}

int main(){
  while(1){
    cin>>m>>c>>n;
    if(!m&&!n&&!c)return 0;
    
    vector<int> A[N];
    for(int i=0,k;i<n;i++){
      cin>>k;
      A[i].resize(k);
      for(int j=0;j<k;j++) cin>>A[i][k-1-j];
    }
    
    queue<int> Q;
    for(int i=0;i<n;i++) Q.push(i);
    
    
    int ans = 0;
    for(int i=0;i<=30;i++)shelf[i].clear();
    
    while(!Q.empty()){
      int t = Q.front();Q.pop();
      int nx = A[t].back();A[t].pop_back();
      if(!A[t].empty()) Q.push(t);
      
      int cost = pop(nx);
      cost +=push(nx);
      ans+=cost;
    }
    
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int n,a,b;
    cin >> n >> a >> b;

    if(abs(a-b)%2 == 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#CODEFESTIVAL2017-B
from collections import Counter
s = input()
c = Counter(s)
if len(s) == 1:
    print('YES')
else:
    if abs(c['a']-c['b']) <= 1 and abs(c['b']-c['c']) <= 1 and abs(c['c']-c['a']) <= 1:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
const int N = 200010;
int main()
{
  int n;
  cin>>n;
  int number[N];
  for(int i = 2 ; i <= n ;i++)cin>>number[i];
  map <int,int > mp;
  for(int i = 1 ; i <= n ;i++){
    mp[i]=0;
  }
  for(int i = 2 ; i <= n ;i++){
    mp[number[i]]++;
  }
  map<int,int>::iterator itr;
  //int count=0;
  for(itr = mp.begin();itr !=mp.end();++itr){
    cout<<itr->second<<'\n';
  //  count++;
  }
//  int i =count;
  return 0;
}


Measured memory_bytes: 13780