akhauriyash/Code-Regression huggingface dataset:
;; -*- coding:utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload :cl-debug-print))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defun make-prime-table (size)
  "Erzeugt die Primzahlentabelle 0 zu SIZE-1."
  (declare (optimize (speed 3) (safety 1)))
  (let ((dict (make-array size :element-type 'bit :initial-element 1)))
    (setf (aref dict 0) 0 (aref dict 1) 0)
    (loop for even-num from 4 below size by 2
          do (setf (aref dict even-num) 0))
    (loop for p from 3 to (ceiling (sqrt size)) by 2
          when (= 1 (aref dict p))
          do (loop for composite from (+ p p) below size by p
                   until (>= composite size)
                   do (setf (aref dict composite) 0)))
    dict))

(defun decompose-to-pow-table (num prime-table)
  (declare (optimize (speed 3) (safety 1))
           (fixnum num) ; Beachte!
           ((simple-array bit (*)) prime-table))
  (let ((factor-table (make-array (length prime-table)
                                  :element-type '(unsigned-byte 7)
                                  :initial-element 0)))
    (when (= 1 (aref prime-table 2))
      (setf (aref factor-table 2)
            (loop while (evenp num)
                  count t
                  do (setf num (ash num -1)))))
    (loop for prime from 3 to (min num (- (length prime-table) 1)) by 2
          when (= 1 (aref prime-table prime))
          do (setf (aref factor-table prime)
                   (loop while (zerop (mod num prime))
                         count t
                         do (setf num (floor num prime))))
          finally (return factor-table))))

(defmacro println (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))

;; Hauptteil

;; Sei gcd(a1, ..., aN) = 2^f(2)*3^f(3)*....
;; Da P = a1* ... *aN, gilt gcd(a1, ..., aN)^N | P und somit
;; 2^(f(2)*N)*3^(f(3)*N)*... | P
;; Wir müssen nur so ein f finden, so dass jedes f(k) maximal ist.
;; Nun sei 2^g(2)*3^g(3)*.... die Primfaktorzerlegung von P.
;; Dann muss f Folgendes erfüllen:
;; f(2)* N <= g(2)
;; f(3)* N <= g(3)...

(defun main ()
  (let* ((n (read))
         (p (read))
         (size 100001)
         (prime-dict (make-prime-table size))
         (factor-table (decompose-to-pow-table p prime-dict)))
    (if (= n 1)
        (println p)
        (loop for prime from 2 below size
              with product = 1
              when (>= (aref factor-table prime) 1)
              do (setf product
                       (* product (expt prime (floor (aref factor-table prime) n))))
              finally (println product)))))

#-swank(main)


Measured memory_bytes: 15328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, M;
vector<int> E[1010];
//---------------------------------------------------------------------------------------------------
int col[1010];
pair<int, int> dfs(int cu = 0, int c = 0) {
    pair<int, int> res = { 0, 0 };

    col[cu] = c;
    if (c == 0) res.first++;
    else res.second++;

    fore(to, E[cu]) {
        if (col[to] < 0) {
            auto p = dfs(to, 1 - c);
            if (p.first < 0) return { -1, -1 };

            res.first += p.first;
            res.second += p.second;
        }
        else {
            if (col[cu] == col[to]) return { -1, -1 };
        }
    }

    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    while (cin >> N >> M) {
        if (N == 0) return;
        rep(i, 0, N) E[i].clear();
        rep(i, 0, N) col[i] = -1;

        rep(i, 0, M) {
            int a, b; cin >> a >> b;
            a--; b--;
            E[a].push_back(b);
            E[b].push_back(a);
        }

        auto p = dfs();
        if (p.first < 0) {
            printf("0\n");
            continue;
        }

        set<int> ans;
        if(p.first % 2 == 0) ans.insert(p.first / 2);
        if (p.second % 2 == 0) ans.insert(p.second / 2);

        int n = ans.size();
        printf("%d\n", n);
        fore(i, ans) printf("%d\n", i);
    }
}



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

int main()
{
    char x[1010];

    while(1)
    {        
        int i=0, sum = 0;

        scanf("%s",x);

        while(x[i] != 0)
        {
            sum += x[i] - '0';
            i++;
        }
        if(x[0] == '0') break;
        cout << sum << endl;
        
    }

    return 0;
}


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

int countTwo(int number){
  int total = 0;
  while(1){
    if(number%2){
      return total;
    }
    else{
      number /= 2;
      total++;
    }
  }
}

int main(){
  int N;

  
  cin >> N;
  if(N<1 || N>200){
    return 0;
  }
  vector<int> numbers(N);
  for(int i=0; i<N; ++i){
    int num;
    cin >> num;
    if(N<1 || N>1000000000){
      return 0;
    }
    numbers.at(i) = num;
  }
  int times = INT_MAX;
  for(auto i: numbers){
    int p = countTwo(i);
    // cout << i << " " << p << endl;
    if(times > p){
      times = p;
    }
  }
  cout << times << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int WD;
struct Point {
    int x, y;
    bool operator < (const Point &tmp) const { return x == tmp.x ? y < tmp.y : x < tmp.x; }
};

const int maxn = 200000 + 10;

Point p[maxn];

int main() {
    int n;  scanf("%d", &n);
    for (int i = 1; i <= n; i++)    scanf("%d %d", &p[i].x, &p[i].y);
    sort(p + 1, p + 1 + n);
    int y1 = p[1].y, y2 = p[1].y, x = p[1].x, ans = 0;
    for (int i = 2, j; i <= n; i = j) {
        j = i;
        int dx = p[i].x - x, _y1 = y1 - dx, _y2 = y2 + dx;
        int __y1 = p[i].y, __y2 = p[i].y;
        while (j <= n && p[j].x == p[i].x) {
            ans = max(ans, max(abs(p[j].y - y1), abs(p[j].y - y2)) + dx);
            _y1 = min(p[j].y, _y1);
            __y1 = min(p[j].y, __y1);
            _y2 = max(p[j].y, _y2);
            __y2 = max(p[j].y, __y2);
            j++;
        }
        ans = max(ans, __y2 - __y1);
        x += dx;
        y1 = _y1;
        y2 = _y2;
    }
    cout << ans;
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 5324
N,M = list(map(int, input().split()))

A = list(map(int, input().split()))

Asum = sum(A)

for i in range(M):
    Amax =  max(A)
    max_index = A.index(Amax)
    A.pop(max_index)
    

if Amax < Asum/4/M:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(int[]);

    int cnt, last, d;
    foreach (a; AS) {
        if (last) {
            if (d == 0) {
                if (last > a) {
                    d = -1;
                } else if (last < a) {
                    d = 1;
                }
            } else if ((d == -1 && a > last) || (d == 1 && a < last)) {
                ++cnt;
                d = 0;
            }
        }
        last = a;
    }
    writeln(cnt+1);
}

Measured memory_bytes: 4404
def get_primes(n):
  lst = []
  for x in xrange(2, n+1):
    is_prime = True
    for i in xrange(len(lst)):
      if x % lst[i] == 0:
        is_prime = False
        break
      if x < lst[i]*lst[i]:
        break
    if is_prime:
      lst.append(x)
  return lst

n = int(raw_input())
lst = get_primes(10 ** 5)
answer = str(n) + ":"
for i in xrange(len(lst)):
  while True:
    if n % lst[i] == 0:
      answer += " " + str(lst[i])
      n /= lst[i]
    else:
      break
  if n == 1:
    break

if n != 1:
  answer += " " + str(n)

print answer

Measured memory_bytes: 6728
# ABC 135 C
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

s = A[0]
ans = 0
for i in range(N):
    t = s if B[i] >= s else B[i]
    u = A[i+1] if A[i+1] <= (B[i] - t) else B[i] - t
    ans += t + u
    s = A[i+1] - u

print(ans)

Measured memory_bytes: 25444
import java.util.*;

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

    if(N == M) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    string s,t;
	    cin >> s >> t;
	    int n1=s.length();
	    int n2=t.length();
	    int ans=n2+1;
	    for(int i=0 ; i<=(n1-n2) ; i++){
	        int tem=0;
	        for(int j=i ; j<(i+n2) ; j++){
	            if(s[j]!=t[j-i]){
	                tem++;
	            }
	        }
	        ans=min(ans,tem);
	    }
	    cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>

int main(){
  int A ,B;
  std::cin >> A >> B;

  if((A + B)%2==0){
    std::cout << (A + B) /2 <<std::endl;
  }
  if((A+B)%2!=0){
    std::cout << "IMPOSSIBLE" << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		long x = nl();

		long o = 100;
		int i = 0;

		for (;;) {
			i++;
			o = (long) ((long) o * 1.01);
			if (o >= x) {
				out(i);
				break;
			}
		}

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


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

using namespace std;

vector<vector<int> > gr;
vector<int> dp(100010, -1);
vector<int> v;

int solve(int index) {
    if(dp[index] != -1)
        return dp[index];
    if(gr[index].size() == 0) {
        dp[index] = 0;
        return 0;
    }
    int mxi = -1;
    for(int i = 0; i < gr[index].size(); i++) {
        mxi = max(mxi, solve(gr[index][i]));
    }
    dp[index] = mxi+1;
    return dp[index];
}

int main() {
    int n, m, x, y, mx = -1;
    cin >> n >> m;
    gr.resize(n);
    v.resize(n, 0);
    for(int i = 0; i < m; i++) {
        cin >> x >> y;
        v[y-1] = 1;
        gr[x-1].push_back(y-1);
    }
    for(int i = 0; i < n; i++) {
       mx = max(mx, solve(i));
    }
    cout << mx << "\n";
}

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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans;
  if (n <= k) ans = n*x;
  else {
    ans = x*k;
    ans += (n-k)*y;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

int main()
{
  ll W, a, b;
  std::cin >> W >> a >> b;

  ll ans = 0LL;
  if (b > a + W) ans = b - (a + W);
  if (b + W < a) ans = a - (b + W);

  std::cout << ans << std::endl;
  return 0;
}


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

int main() {
    long long int n, y;
    cin >> n >> y;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n; ++j) {
            if(n-i-j < 0) continue;
            if(10000*i + 5000*j + 1000*(n-i-j) == y) {
                cout << i << " " << j << " " << (n-i-j) << '\n';
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, m, i, j, mod = 1e9 + 7, a[100005], b[100005];
vector<pair<int, int> > v;
vector<int> all;
struct bit
{
	int lowbit(int x) { return x & (-x); }
	int a[100005];
	void add(int x, int y)
	{
		int i;
		for (i = x; i <= 100002; i += (lowbit(i))) (a[i] += y) %= mod;
	}
	int query(int x)
	{
		int s = 0, i;
		for (i = x; i; i -= lowbit(i)) (s += a[i]) %= mod;
		return s;
	}
}c;
int main()
{
	cin >> n >> m;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (i = 1; i <= m; i++)
	{
		cin >> b[i];
	}
	for (i = 1; i <= n; i++)
	{
		int t = lower_bound(b + 1, b + m + 1, a[i]) - b;
		if (t >= 2 && t <= m)
		{
			v.push_back(make_pair(a[i] - b[t - 1], -(b[t] - a[i])));
			all.push_back(b[t] - a[i]);
		}
	}
	c.add(1, 1);
	sort(v.begin(), v.end());
	sort(all.begin(), all.end());
	all.resize(unique(all.begin(), all.end()) - all.begin());
	for (i = 0; i < v.size(); i++)
	{
		if (!i || v[i] != v[i - 1])
		{
			int t = upper_bound(all.begin(), all.end(), -v[i].second) - all.begin();
			c.add(t + 1, c.query(t));
		}
	}
	cout << c.query(100002);

	return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 300001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    cout << c - min(a - b, c) << endl;
  
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double L;
    cin >> L;
    printf("%.9lf\n",L/3*L/3*L/3);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
double x[10], y[10], ans, tmp; int n, p[10];
double calc(){
	for (int i = 1; i < n; i++)
		ans += 1.0 * sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) + (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]])) / tmp;
}
bool vis[10];
void dfs(int dep){
	if (dep == n + 1){
		calc(); return;
	}
	for (int i = 1; i <= n; i++){
		if (!vis[i]){
			p[dep] = i; vis[i] = 1;
			dfs(dep + 1); vis[i] = 0;
		}
	}
}
int main(){
	scanf("%d", &n); tmp = 1.0; for (int i = 2; i <= n; i++) tmp *= 1.0 * i;
	for (int i = 1; i <= n; i++) scanf("%lf%lf", x + i, y + i);
	dfs(1); printf("%lf\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 3e5+5;
int hb[N],wb[N];
map<pii,int> mp;
vector<int> v1,v2;

int main(){
    ios::sync_with_stdio(0);
    int h,w;cin>>h>>w;
    int m;cin>>m;
    int maxhidx=0,maxwidx=0,maxhb=0,maxwb=0;
    int ans = 0;
    rep(i,1,m){
        int hi,wi;cin>>hi>>wi;
        mp[{hi,wi}] = 1;
        ++hb[hi];++wb[wi];
        if(maxhb<hb[hi]){
            maxhb = hb[hi]; maxhidx = hi;
        }
        if(maxwb<wb[wi]){
            maxwb = wb[wi]; maxwidx = wi;
        }
        
    }


    //v1.push_back(maxhidx);v2.push_back(maxwidx);
    // for(auto v:mp){
    //     pii tmp = v.first; int hi = tmp.first,wi = tmp.second;
    //     if(maxhb==hb[hi]){
    //         v1.push_back(hi);
    //     }
    //     if(maxwb==wb[wi]){
    //         v2.push_back(wi);
    //     }
    // }
    rep(i,1,h){
        if(hb[i]==maxhb) v1.push_back(i);
    }
    rep(j,1,w){
        if(wb[j]==maxwb) v2.push_back(j);
    }
    // if(!mp[{maxhidx,maxwidx}]){
    //     ans = maxhb+maxwb; cout<<ans;return 0;
    // }
    int siz1 = v1.size(),siz2 = v2.size(),fg =0;
    rep(i,0,siz1-1){
        rep(j,0,siz2-1){
            if(!mp[{v1[i],v2[j]}]){
                fg=1;break;
            }
        }
        if(fg) break;
    }
    if(fg){
        ans = maxhb+maxwb;
    }else{
        ans = maxhb+maxwb-1;
    }

    cout<<ans;
}


Measured memory_bytes: 28464
N,K,Q=map(int,input().split())
M = {i:K for i in range(N)}
# print(M)
for q in range(Q):
    M[int(input())-1] += 1

for n in range(N):
    M[n] -= Q

for k in M:
    if M[k] > 0:
        print("Yes")
    else:
        print("No")

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

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];

    private T Convert<T>(string s)
    {
        return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(s);
    }

    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public T Next<T>()
    {
        return Convert<T>(Next());
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public string[] StringArray()
    {
        Line = Console.ReadLine().Split(Separator);
        Index = Line.Length;
        return Line;
    }

    public T[] Array<T>()
    {
        var l = StringArray();
        var res = new T[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = Convert<T>(l[i]);
        }
        return res;
    }

    public int[] IntArray()
    {
        var l = StringArray();
        var res = new int[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = int.Parse(l[i]);
        }
        return res;
    }

    public long[] LongArray()
    {
        var l = StringArray();
        var res = new long[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = long.Parse(l[i]);
        }
        return res;
    }
}

class Program
{
    private int N;
    private int[] C, S, F;
    private int[] Ans;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        C = new int[N - 1];
        S = new int[N - 1];
        F = new int[N - 1];
        for (int i = 0; i < N - 1; i++)
        {
            C[i] = sc.NextInt();
            S[i] = sc.NextInt();
            F[i] = sc.NextInt();
        }
    }


    public void Solve()
    {
        Scan();
        Ans = new int[N];
        for (int i = 0; i < N; i++)
        {
            Ans[i] = Calc(i, 0);
        }
        Console.WriteLine(string.Join("\n", Ans));
    }

    private int Calc(int pos, int time)
    {
        if (pos == N - 1)
        {
            return time;
        }

        if (time <= S[pos])
        {
            return Calc(pos + 1, S[pos] + C[pos]);
        }
        else
        {
            int d = S[pos] % F[pos];
            int t = time % F[pos];
            return Calc(pos + 1, time + ((d - t + F[pos])) % F[pos] + C[pos]);
        }
    }


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

Measured memory_bytes: 13268
#include <cstdio>
#include <vector>
#include <iostream>

int main(void)
{
    int n = 0;
    std::cin >> n;

    std::vector<int> S(n);
    for (int i = 0; i < n; i++) {
        std::cin >> S[i];
    }

    int q = 0;
    std::cin >> q;

    std::vector<int> T(n);
    for (int i = 0; i < q; i++) {
        std::cin >> T[i];
    }


    int C = 0;

    for (int i = 0; i < q; i++) {
        int left = 0;
        int right = n;
        while (left < right) {
            int mid = (right + left) / 2;
            if (T[i] == S[mid]) {
                C++;
                break;
            }
            if (T[i] < S[mid]) {
                right = mid;
            } else {
                left = mid+1;
            }
        }
    }

    std::cout << C << "\n";

    return 0;
}


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

using namespace std;

int n, cnt[10][10];

int main() {
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++) {
		int ed = i % 10;
		int st = 0;
		int tmp = i;
		while (tmp) {
			st = tmp % 10;
			tmp /= 10;
		}
		cnt[st][ed]++;
	}
	
	long long res = 0;
	
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			res += cnt[i][j] * cnt[j][i];
		}
	}
	
	printf("%lld\n", res);
}


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

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] xArr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] yArr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            double D1 = 0;
            double D2 = 0;
            double D3 = 0;
            double DInf = 0;
            for (int i = 0; i < n; i++)
            {
                double abs = Math.Abs(xArr[i] - yArr[i]);
                D1 += abs;
                D2 += abs * abs;
                D3 += abs * abs * abs;
                DInf = Math.Max(DInf, abs);
            }

            Console.WriteLine(D1);
            Console.WriteLine(Math.Pow(D2, 1 / 2.0));
            Console.WriteLine(Math.Pow(D3, 1 / 3.0));
            Console.WriteLine(DInf);

            Console.ReadLine();
        }
    }
}

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

struct UnionFind {
    vector<int> par, rnk, cnt;
    UnionFind(int N) : par(N), rnk(N), cnt(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
            cnt[i] = 1;
        }
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y)
            return;
        if (rnk[x] < rnk[y])
            swap(x, y);
        if (rnk[x] == rnk[y])
            rnk[x]++;
        par[y] = x;
        cnt[x] += cnt[y];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int rcnt(int x) {
        return cnt[root(x)];
    }
};

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

    UnionFind uf(n);
    int ans = n - 1;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (!uf.same(a, b))
            ans--;
        if (b > a)
            swap(a, b);
        uf.unite(a, b);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4580
use std::collections::HashSet;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let K: usize = read();

    if K % 2 == 0 {
        let a = N / K;
        let b = (N + (K / 2)) / K;
        println!("{}", a * a * a + b * b * b);
    } else {
        let a = N / K;
        println!("{}", a * a * a);
    }
}


Measured memory_bytes: 2064
N=int(input())
class Lucky:
    def __init__(self,N):
        self.N=N
        self.N_1=int(N/100)
        self.N_2=int((N - 100*self.N_1)/10)
        self.N_3=int((N-100*self.N_1-10*self.N_2))
        
    def Lucky_7(self):
        if self.N_1==7 or self.N_2==7 or self.N_3==7:
            return print("Yes")
        else:
            return print('No')

Lucky(N).Lucky_7()

Measured memory_bytes: 9132
n = int(input())
list1 = list(map(int, input().split()))
index =0
count=0
while index < n:
    if index ==0:
        beforeC = list1[index]
        index+=1
    else:
        if beforeC != list1[index]:
            beforeC = list1[index]
            index+=1
        else:
            count+=1
            beforeC = "a"
            index+=1
print(count)


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

struct table {
    int i, j, t;
};

int n, m;
bool visited[1001][1001];
char a[1001][1001];
int dx[] = {-1, 1,  0, 0};
int dy[] = { 0, 0, -1, 1};
queue <table> q;

bool check(int i, int j) {
    bool ok = 0;
    if (i && j && i <= n && j <= m) {
        ok = 1;
        if(visited[i][j]) {
            ok = 0;
        }
        visited[i][j] = 1;
    }
    return ok;
}

signed main() {
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> a[i][j];
            if(a[i][j] == '#') {
                visited[i][j] = 1;
                q.push({i, j, 0});
            }
        }
    }
    while(1) {
        int i = q.front().i, j = q.front().j, t = q.front().t;
        q.pop();
        for(int c = 0; c < 4; c++) {
            if(check(i + dx[c], j + dy[c])) {
                q.push({i + dx[c], j + dy[c], t + 1});
            }
        }
        if(q.empty()) {
            return cout << t << '\n', 0;
        }
    }
}

Measured memory_bytes: 14352
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

for i in range(n):
    p[i]-=1
    q[i]-=1

com=list(permutations(range(n)))
# print(p,q)
a=0
b=0
for i in range(len(com)):
    # print(com[i])
    if com[i]==tuple(p):
        a=i
    if com[i]==tuple(q):
        b=i
print(abs(a-b))

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

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

	int a = 0, b = 0, c = 0;
	for (int i = 0, end = s.size(); i < end; ++i) {
		auto ss = s[i];

		switch (ss)
		{
		case 'a':
			++a;
			break;
		case 'b':
			++b;
			break;
		default:
			++c;
			break;
		}
	}

	auto m = std::max({ std::abs(a - b),std::abs(b - c),std::abs(c - a) });
	if (m > 1)
		std::cout << "NO" << std::endl;
	else
		std::cout << "YES" << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main() {
  ll X, Y;
  cin >> X >> Y;
  ll ans= 0;
  while(X<=Y){
    ans++;
    X*=2;
  }
  
  cout << ans << endl;
  return 0;
}
  



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

int main() {
  const int INF = 10000;
  int N, T, A, check = 0;
  double min = INF;
  cin >> N >> T >> A;
  vector<double> h(N);
  vector<double> d(N);

  for(int i = 0; i < N; i++) {
    cin >> h.at(i);
    double t = T - h.at(i) * 0.006;
    d.at(i) = abs(A - t);
  }
  for(int i = 0; i < N; i++) {
    if(d.at(i) < min) {
      min = d.at(i);
      check = i + 1;
    }
  }

  cout << check << endl;
}


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

h, w = map(int, input().split())
a = [map(int, input().split()) for _ in range(h)]
b = [map(int, input().split()) for _ in range(h)]
g = [list(abs(x - y) for x, y in zip(l1, l2)) for l1, l2 in zip(a, b)]
poss = [[0] * w for _ in range(h)]
poss[0][0] |= 1 << 6400 + g[0][0]
poss[0][0] |= 1 << 6400 - g[0][0]
for i in range(h):
	for j in range(w - 1):
		poss[i][j + 1] |= poss[i][j] << g[i][j + 1]
		poss[i][j + 1] |= poss[i][j] >> g[i][j + 1]
	if i != h - 1:
		for j in range(w):
			poss[i + 1][j] |= poss[i][j] << g[i + 1][j]
			poss[i + 1][j] |= poss[i][j] >> g[i + 1][j]
res = poss[-1][-1]
for i in range(6400):
	if res & (1 << 6400 + i) or res & (1 << 6400 - i):
		print(i)
		exit()


Measured memory_bytes: 15220
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int Q=1<<18;
int tl=0;
int ls[Q*36],rs[Q*36];
int mx[Q*36];
void MDF(int lst,int &now,int l,int r,int x,int v)
{
    now=++tl;
    mx[now]=-998244353;
    if(l==r){
        mx[now]=max(mx[now],v);
        return;
    }
    ls[now]=ls[lst],rs[now]=rs[lst];
    int mid=(l+r)>>1;
    if(x<=mid)MDF(ls[lst],ls[now],l,mid,x,v);
    else MDF(rs[lst],rs[now],mid+1,r,x,v);
    mx[now]=max(mx[ls[now]],mx[rs[now]]);
}
int GM(int now,int l,int r,int x,int y)
{
    if(x<=l&&y>=r)return mx[now];
    int mid=(l+r)>>1;
    if(y<=mid)return GM(ls[now],l,mid,x,y);
    if(x>mid)return GM(rs[now],mid+1,r,x,y);
    return max(GM(ls[now],l,mid,x,y),GM(rs[now],mid+1,r,x,y));
}
int rt0[Q],rt1[Q];
int p[Q];
int imp[Q];
int n;
int c0=0,c1=0;
int res=0;
int mxa,mxb;
int Ch(int st)
{
    int ra=c0-c1+res,rb=c1-c0+res;
    int pa=GM((ra&1?rt1:rt0)[st],1,n,mxb,n),pb=GM((rb&1?rt1:rt0)[st],1,n,mxa,n);
    if(ra>=0&&pa>=ra)return 1;
    if(rb>=0&&pb>=rb)return 1;
    return 0;
}
void Ga(int x)
{
    if(imp[x])--res;
}
int main()
{
    mx[0]=-998244353;
    scanf("%d",&n);
    for(int i=1,mx=0;i<=n;i++){
        scanf("%d",&p[i]);
        if(mx<p[i])mx=p[i],imp[i]=1,++res;
    }
    MDF(rt0[n+1],rt0[n+1],1,n,n,0);
    for(int i=n;i;--i){
        int f0=GM(rt0[i+1],1,n,p[i],n)+imp[i]+1;
        int f1=GM(rt1[i+1],1,n,p[i],n)+imp[i]+1;
        // printf("%d %d ???\n",imp[i]?f0:f1,imp[i]?f1:f0);
        MDF(rt0[i+1],rt0[i],1,n,p[i],imp[i]?f0:f1);
        MDF(rt1[i+1],rt1[i],1,n,p[i],imp[i]?f1:f0);
    }
    if(!Ch(1))return puts("-1")&0;
    mxb=0,mxa=0;
    for(int i=1;i<=n;i++){
        int cc=c0,ra=mxa;
        if(imp[i])--res;
        if(p[i]>mxa)++c0,mxa=p[i];
        int fin=Ch(i+1);
        if(!fin){
            c0=cc;mxa=ra;
            if(p[i]>mxb)mxb=p[i],++c1;
            putchar('1');
        }
        else putchar('0');
    }
    return 0;
}
/*
c0+(tl-k)==c1+k+had
c0-c1+tl==2*k+had;
*/

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


using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] != i) {
			ans++;
		}
	}
	if (ans > 2) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}
}

Measured memory_bytes: 3616
n, T = list(map(int, input().split()))
ans = 10000
for i in range(n):
    c, t = list(map(int, input().split()))
    if t > T:
        continue
    else:
        ans = min(ans, c)
if ans == 10000:
    print('TLE')
else:
    print(ans)


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

int main() {
	int n,a,b,i; char c;
	cin >> n >> a >> b;
	for(i=0; i<n; i++){
		cin >> c;
		if(c=='a'){
			if(a>0){
				cout << "Yes" << endl;
				a--;
			}else if(b>0){
				cout << "Yes" << endl;
				b--;
			}else{
				cout << "No" << endl;
			}
		}else if(c=='b' && b>0){
			cout << "Yes" << endl;
			b--;
		}else{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(int n){
    stringstream ss;
    ss << bitset<3>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    string s; cin >> s;
    rep(i,3)if(s[i] == '7'){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string S;
    cin >> S;
    
    int sum=0;
    for(int i=0; i<S.length(); i++){
        char s = S[i];
        if(s == '+') sum++;
        else sum--;
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t a[29][200'000], b[29][200'000];

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

    rep(i, n)
    {
        int aa;
        cin >> aa;

        rep(j, 29)
        {
            int mask = 1 << (j + 1);

            a[j][i] = aa % mask;
        }
    }

    rep(i, n)
    {
        int bb;
        cin >> bb;
        rep(j, 29)
        {
            int mask = 1 << (j + 1);

            b[j][i] = bb % mask;
        }
    }

    int64_t result = 0;
    rep(i, 29)
    {
        sort(a[i], a[i] + n);
        sort(b[i], b[i] + n);

        int64_t lb1 = 1 << i;
        int64_t ub1 = lb1 << 1;
        int64_t lb2 = (lb1 << 1) + lb1;
        int64_t ub2 = ub1 << 1;

        int64_t ones = 0;
        rep(j, n)
        {
            ones += lower_bound(b[i], b[i] + n, ub1 - a[i][j]) - lower_bound(b[i], b[i] + n, lb1 - a[i][j]);
            ones += lower_bound(b[i], b[i] + n, ub2 - a[i][j]) - lower_bound(b[i], b[i] + n, lb2 - a[i][j]);
        }
        ones %= 2;
        int flag = ones << i;

        result |= flag;
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 90880
#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;
    if (n == 1)
        cout << "Hello World" << endl;
    else
    {
        int a, b;
        cin >> a >> b;
        int ans = a + b;
        cout << ans << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
#define fastio ios::sync_with_stdio(0);cin.tie(0); cout.tie(0)

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(1e6+5);

int n,t;

void solve() {

}

int main() {
  fastio;
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
  //cin>>t;rep(i,t)solve();

  cin>>n;
  vector<int> a(n);
  rep(i,n)  cin>>a[i];

  sort(a.begin(),a.end(),greater<int>());

  int cur = n-2;
  ll ans = a[0];

  repi(i,1,n-1) {
    if(cur >= 2)  {
      cur -= 2;
      ans += 2*a[i];
      continue;
    }
    if(cur <= 1) {
      ans += cur*a[i];
      break;
    }
  }
  cout<<ans;

  return 0;
}


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

namespace ABC153
{
	class Program
	{
		static double n = 0;

		static void Main(string[] args)
		{
			decimal h = decimal.Parse(Console.ReadLine());

			CalcHeight(h);

			Console.WriteLine(Math.Pow(2, n) - 1);
		}

		static void CalcHeight(decimal h)
		{
			if(h <= 0)
			{
				return;
			}

			if(h % 2 != 0)
			{
				h--;
			}

			h /= 2;

			n++;

			CalcHeight(h);
		}
	}
}

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

int main(){
    int n,x,t; cin >> n >> x >> t;
    if (n%x==0){
        cout << n/x*t << "\n";
    }
    else{
        cout << (n/x+1)*t << "\n";
    }
}



Measured memory_bytes: 3584
use std::error::Error;
use std::io;

fn main() {
    if let Err(e) = run() {
        println!("{}", e);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut s = String::new();
    io::stdin().read_line(&mut s)?;
    let s: Vec<i32> = s.trim().split(" ").map(|x| x.parse().expect("")).collect();
    if (s[0]-s[1]).abs() < (s[0]-s[2]).abs() {
        println!("A");
    } else {
        println!("B");
    }
    Ok(())
}


Measured memory_bytes: 4352
def calc_cost(list, num, str)
  a = str.split("").map{|i|list[i.to_i]}
#  p a
  c = (a.size-1)*10
  c += (a.inject(:+)-num).abs
  return c
end

l = gets.chomp.split.map(&:to_i)
n=l[0]
a = l[1]
b = l[2]
c = l[3]
list = []
max_cost = 1000000000
n.times do
  list.push(gets.chomp.to_i)
end
(4**n).times do |i|
  tri = i.to_s(4).rjust(n,"0")
  if(tri.include?("0") && tri.include?("1") && tri.include?("2"))
    trilist = ["","","",""]
    n.times do |j|
      trilist[tri[j].to_i]+=j.to_s
    end
    #p trilist
    cost = calc_cost(list, a, trilist[0]) + calc_cost(list, b, trilist[1]) + calc_cost(list, c, trilist[2])
  #  p cost
    if cost < max_cost
      max_cost = cost
    end
#    puts "-------"
#    p tri
#    p trilist
  end
end

puts max_cost


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

#define f(i,x,y)			for(int i=x; i<y; i++)
#define ll 					long long 
#define mp 					make_pair
#define F 					first
#define S 					second
#define N 					100005
#define mod 				1000000007

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	f(i,0,n)
		cin>>a[i];

	ll dp[n+1][k+1];
	memset(dp,0,sizeof(dp));

	f(j,0,k+1)
		dp[1][j] = (j<=a[0]) ? 1 : 0; 

	f(i,2,n+1)
		f(j,0,k+1)
		{
			if(j==0)
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = (mod + dp[i][j-1] + dp[i-1][j] - ((j-1-a[i-1]>=0) ? dp[i-1][j-1-a[i-1]] : 0) )%mod;
		}

cout<<dp[n][k]%mod;


	return 0;
}

Measured memory_bytes: 79104
# coding: utf-8
N=int(input())
#A,B=map(int, input().split())
#List=list(map(int, input().split()))
List=[1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
for i in range(10):
    if List[i]-N >= 0:
        print(List[i]-N)
        quit()



Measured memory_bytes: 9160
I = [int(_) for _ in open(0).read().split()]
N, T = I[:2]
A, B = I[2::2], I[3::2]
dp = [-1] * 6001
dp[0] = 0
for a, b in sorted(zip(A, B)):
    for k in range(T - 1, -1, -1):
        if dp[k] == -1:
            continue
        dp[k + a] = max(dp[k + a], dp[k] + b)
print(max(dp))


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);
  sort(P.begin(), P.end());
  cout << accumulate(P.begin(), P.begin() + K, 0L) << "\n";
}

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

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int K;

int main() {
    cin >> K;

    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[K-1] << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;

typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define REP(i,l,r) for(int i=l;i>=r;i--)
#define fi first
#define se second
#define eb emplace_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define int ll
const int mod = 1e9+7 ;

int n,m,a,b;
int fft[199999], fft_sz = 1;
int fact(const int& n){
	for(;n > fft_sz; ++fft_sz) fft[fft_sz+1] = (fft[fft_sz]*(fft_sz+1)) % mod;
	return fft[n];
}
int mul (const int& a, const int& b){
	return a * b %mod;
}
int mi(const int& a, const int& b){
	int ans = (a-b) % mod;
	return (ans < 0 ? ans + mod : ans);
}
int binpow(int a, int b){
	int res = 1;
	while(b){
		if (b & 1) res = mul(res,a);
		a = mul(a,a), b >>= 1;
	}
	return res;
}
int divide(const int& a, const int& b){
	assert(b > 0);
	return mul(a,binpow(b,mod-2)); 
}
int c(const int& a, const int& b){
	assert(b >= a);
	return divide(fact(b), mul(fact(a), fact(b-a)));
}
int path0(const int& n, const int& m){
	return c(n-1, n+m-2);
}
int path(const int& r, const int& c, const int& row, const int& col){
	return path0(row-r+1, col-c+1);
}

signed main() {
	fastio ;
	fft[0] = fft[1] = 1LL;
	cin >> n >> m >> a >> b;
	int ans = path0(n,m);
	for(int i = 0, r = n, c = b; i < a; ++i, --r){
		ans = mi(ans, mul(path(1,1 ,r,c), path(r,c+1, n,m)));
	}
	cout << (ans % mod) << endl;
}



Measured memory_bytes: 5216
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    set<string> st;
    rep(i,0,n){
        string s; cin >> s;
        st.insert(s);
    }

    cout << (st.size() == 3 ? "Three" : "Four") << "\n";
}

Measured memory_bytes: 3640