akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1}; 
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r','u','l','d'};
int MDT[N2][N2];

struct Puzzle { int f[N2], space, MD; };

Puzzle state;
int limit; /* 深さの制限*/
int path[LIMIT];

int getAllMD(Puzzle pz) {
    int sum = 0;
    for ( int i = 0; i < N2; i++ ) {
        if ( pz.f[i] == N2 ) continue;
        sum += MDT[i][pz.f[i] - 1]; }
    return sum;
}

bool isSolved() {
    for ( int i = 0; i < N2; i++ ) if ( state.f[i] != i + 1 ) return false;
    return true;
}

bool dfs(int depth, int prev) {
    if ( state.MD == 0 ) return true;
    if ( depth + state.MD > limit ) return false;
    
    int sx = state.space / N;
    int sy = state.space % N;
    Puzzle tmp;
    
    for ( int r = 0; r < 4; r++ ) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
        if ( max(prev, r)-min(prev, r) == 2 ) continue;
        tmp = state;
        
        state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
        state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
        swap(state.f[tx * N + ty], state.f[sx * N + sy]);
        state.space = tx * N + ty;
        if ( dfs(depth + 1, r) ) { path[depth] = r; return true; }
        state = tmp;
    }
    return false;
}

string iterative_deepening(Puzzle in) {
    in.MD = getAllMD(in);
    for ( limit = in.MD; limit <= LIMIT; limit++ ) {
        state = in;
        if ( dfs(0, -100) ) {
            string ans = "";
            for ( int i = 0; i < limit; i++ ) ans += dir[path[i]];
            return ans;
        }
    }
    
    return "unsolvable";
    
}
int main() {
    for ( int i = 0; i < N2; i++ )
        for ( int j = 0; j < N2; j++ )
            MDT[i][j] = abs(i / N - j / N ) + abs(i % N - j % N);
    Puzzle in;
    
    for ( int i = 0; i < N2; i++ ) {
        cin >> in.f[i];
        if ( in.f[i] == 0 ) {
            in.f[i] = N2;
            in.space = i;
            
        }
    }
    string ans = iterative_deepening(in);
    cout << ans.size() << endl;
    return 0;
    
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  
  ll asum=0, ans=0;
  rep(i, n) (asum += a[i]) %= MOD;
  ans = (asum * asum) % MOD;
  rep(i, n) (((ans -= a[i]*a[i]) %=MOD) += MOD) %= MOD;
  if(ans%2==1) ans += MOD;
  ans /= 2;
  cout << ans << newl;
  return 0; 
}

Measured memory_bytes: 4780
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



int main() {
    //
    int N, K;
    cin >> N >> K;

    //
    int lengths[N];
    for (int i = 0; i < N; ++i) {
        cin >> lengths[i];
    }

    //
    sort(lengths, lengths + N, greater<int>());
    int sum = 0;
    for (int j = 0; j < K; ++j) {
        sum += lengths[j];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int n;

	while( cin >> n ){
		int answer = n % 39;
		if( answer == 0 ) answer = 39;

		cout << "3C" << (( answer > 0 && answer < 10 ) ? "0" : "" ) << answer << endl;
	}
	return 0;
}

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

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

using namespace std;

typedef vector<int> vi;

int main() {
	int cache[1000001];
	int x, y;
	while(cin >> x >> y && x) {
		REP(i,1000001) cache[i] = -1;
		int start, end;
		REP(i,10000000) {
			if (x == 0) {
				start = i;
				end = 0;
				break;
			}
			if (cache[x] >= 0) {
				start = cache[x];
				end = i - cache[x];
				break;
			}
			cache[x] = i;
			x *= 10;
			//z = x / y;
			x %= y;
		}
		cout << start << ' ' << end << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4776
n = int(input())
tree = [0] * n
root = set(range(n))
def type(i, parent, sibling, depth):
    if i == -1:
        return -1
    node = tree[i]
    l, r = node[0], node[1]
    node[2], node[3], node[5] = parent, sibling, depth
    node[4] = (l != -1) + (r != -1)
    h = node[6] = max(type(l, i, r, depth + 1), type(r, i, l, depth + 1)) + 1
    return h
 
while n:
    i, l, r = list(map(int, input().split()))
    tree[i] = [l, r] + [0] * 5
    root -= {l, r}
    n -= 1
type(root.pop(), -1, -1, 0)
for i, node in enumerate(tree):
    l, r, p, s, deg, dep, h = node
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(i, p, s, deg, dep, h, 'root' if not dep else 'internal node' if deg else 'leaf'))


Measured memory_bytes: 5604
import java.util.*;
import java.lang.*;

class Main {

	public static void main(String[] args) {
		new Main().solution();
	}

	public void solution() {
		Scanner sc= new Scanner(System.in);
		int op_num= sc.nextInt();
		Node root = null;
		int k, p;
		

		for(int i = 0; i < op_num; i++) {
			String op = sc.next();

			if(op.equals("insert")) {
				k = sc.nextInt();
				p = sc.nextInt();
				root = insert(root, k, p);
			} else if(op.equals("find")) {
				k = sc.nextInt();
				System.out.println(find(root, k) ? "yes" : "no");
			} else if(op.equals("delete")) {
				k = sc.nextInt();
				root = Delete(root, k);
			} else if(op.equals("print")) {
				Print(root);
			}
		}
	}

	public Node right_rotate(Node t) {
		Node s = t.left;
		t.left = s.right;
		s.right = t;
		return s;
	}

	public Node left_rotate(Node t) {
		Node s = t.right;
		t.right = s.left;
		s.left = t;
		return s;
	}

	public Node insert(Node t, int key, int pri) {
		if(t == null)
			return new Node(key, pri);

		if(key == t.key)
			return t;

		if(key < t.key) {
			t.left = insert(t.left, key, pri);
			if(t.pri < t.left.pri)
				t = right_rotate(t);
		} else {
			t.right = insert(t.right, key, pri);
			if(t.pri < t.right.pri)
				t = left_rotate(t);
		}

		return t;
	}

	public Node Delete(Node t, int key) {
		if(t == null)
			return null;

		if(key == t.key) {
			if(t.left == null && t.right == null)
				return null;
			else if(t.left == null)
				t = left_rotate(t);
			else if(t.right == null)
				t = right_rotate(t);
			else {
				if(t.left.pri > t.right.pri)
					t = right_rotate(t);
				else 
					t = left_rotate(t);
			}

			return Delete(t, key);
		}

		if(key < t.key)
			t.left = Delete(t.left, key);
		else
			t.right = Delete(t.right, key);

		return t;
	}

	public boolean find(Node root, int target) {
		if(root == null)
			return false;

		if(root.key == target)
			return true;
		else if(root.key < target)
			return find(root.right, target);
		else
			return find(root.left, target);
	}

	public void Print(Node root) {
		inorder(root);
		System.out.println();
		preorder(root);
		System.out.println();
	}

	private void inorder(Node root) {
		if(root != null) {
			inorder(root.left);
			System.out.print(" " + root.key);
			inorder(root.right);
		}
	}

	private void preorder(Node root) {
		if(root != null) {
			System.out.print(" " + root.key);
			preorder(root.left);
			preorder(root.right);
		}
	}

	class Node {
		int key;
		int pri;
		Node left;
		Node right;

		public Node(int k, int p) {
			key = k;
			pri = p;
			left = null;
			right = null;
		}
	}
}


Measured memory_bytes: 184992
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, b = 0, z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if (a >= b) z++;
        b = max(b, a);
    }
    cout << z;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    ll a = 1;
    ll ans = 1;
    map<int, int> m;
    
    reps(i, 2, n + 1) {
        int multi = i;
        
        reps(ii, 2, i + 1) {
            while ((multi % ii) == 0) {
                m[ii]++;
                multi /= ii;
            }
        }
    }
    
    for (auto u : m) {
        ans = ans * (u.second + 1) % mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#include <numeric>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n, r;
    cin >> n >> r;
    
    if(n >= 10){
        COUT(r);
    }else{
        COUT(r + 100 * (10 - n));
    }

    return 0;
}

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

int c[110][110];

int main() {
  int N;
  cin >> N;
  for (auto i=0; i<N; i++) {
    for (auto j=0; j<N; j++) {
      cin >> c[i][j];
    }
  }
  long long ans = 0;
  for (auto i=0; i<N; i++) {
    for (auto j=i+1; j<N; j++) {
      ans += min(c[i][j], c[j][i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647

//long gcd(long m, long n);
//long lcm(long m, long n);

int main(void) {

	string ans = "No";
	int n;
	cin >> n;
	vector<int> v;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	int min = 0;
	for (int i = 0; i < n - 1; i++) {
		min += v[i];
	}
	if (min > v.back()) ans = "Yes";



	cout << ans << endl;
	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  
#if 0
//最大公倍数
long gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
long lcm(long m, long n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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 main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;cin>>n;
    vec a(n);
    rep(i,n) cin>>a[i];
    int s=0;
    rep(i,n) s^=a[i];
    rep(i,n) a[i]^=s;
    rep(i,n) cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 3904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e6 + 5;
const int M=1e5 + 5;

ll mod_exp(ll cur,ll power)
{
    ll res=1;
    while(power>0){
        if(power%2==0){
            cur=(cur*cur)%mod;
        }
        else{
            res=(res*cur)%mod;
            cur=(cur*cur)%mod;  
        }
        power/=2;
    }
    return res;
}

ll fa[N];
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    fa[0]=1;
    ll i,f;
    for(i=1;i<N;i++){
        fa[i]=(fa[i-1]*i)%mod;
    }
    ll x,y;
    cin>>x>>y;
    bool ok = false;
    for(i=0;i<=x;i++){
        
        if(((x-i)>=0) && (x-i)%2==0){
            f=(x-i)/2;

        }
        else continue;
        ll foo = i*2 + f;
        if(foo == y){
            ok=true;
            break;
        }
        else continue;

    } 
    if(!ok){
        cout << 0 << endl;
        return 0;
    }

    ll tot = i+f;
    ll ans = fa[tot];
    ll den = (fa[i]*fa[f])%mod;
    den = mod_exp(den,mod-2);
    ans=(ans*den)%mod;
    cout << ans << endl;

 
    return 0;
}

Measured memory_bytes: 8064
M, D = list(map(int, input().split()))

cnt = 0
for m in range(1,M+1,1):
    for d in range(1,D+1,1):
        d1 = d//10
        d2 = d%10
        if m == d1*d2 and  d1>1 and d2>1:
            cnt += 1
        
print(cnt)

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

int main() {
 
int64_t N,M,L;
cin >>N>>M>>L;
// vector<int> A(N);
// for(int i=0; i<N; i++){cin>>A[i];}
// vector<vector<int>> A(N,vector<int>(M));
// for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
//sort(A.begin(),A.end());
  if(N%2==0||M%2==0||L%2==0)cout<<0<<endl;
  else if(N==max(max(M,N),L))cout<<M*L<<endl;
  else if(M==max(max(M,N),L))cout<<N*L<<endl;
  else cout<<N*M<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nab = Input.ar;
        var h = Enumerable.Repeat(0, nab[0]).Select(v => Input.numL).ToArray();
        var left = 0;
        var right = (int)1e9;
        while (right - left > 1)
        {
            var mid = (right + left) / 2;
            var ct = 0L;
            for (var i = 0; i < nab[0]; i++)
            {
                var l = -1L;
                var r = h[i];
                while (r - l > 1)
                {
                    var m = (r + l) / 2;
                    var point = m * nab[1] + (mid - m) * nab[2];
                    if (point >= h[i]) r = m;
                    else l = m;
                }
                ct += r;
            }
            if (ct > mid) left = mid;
            else right = mid;
        }
        WriteLine(right);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 19932
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_M=100000;
int a[MAX_M];

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

ll sum;
ll kosu;

void InclusionExclusion(ll n,ll m){
    ll res=0;
    for(int i=1;i<(1<<m);i++){
        ll num=0;
        for(int j = i;j!=0;j>>=1)
            num+=j&1;
        ll lcm=1;
        for(int j = 0; j <m; j++){
            if((i>>j)&1){
                lcm=lcm/gcd(lcm,a[j])*a[j];
                if(lcm>n)
                    break;
            }
        }
        if(num%2==0){
            int t=n/lcm;
            sum-=lcm*t*(t+1)/2;
            res-=n/lcm;
        }
        else{
            res+=n/lcm;
            ll t=n/lcm;
            sum+=lcm*t*(t+1)/2;
        }
    }
    kosu=n-res;
    sum=n*(n+1)/2-sum;
}

void solve(){
    ll n,m;
    while(cin>>n>>m&&!(n==0&&m==0)){
        for(int i = 0; i < m; i++)
            cin>>a[i];
        sum=0;
        InclusionExclusion(n,m);
        if(kosu==0){
            sum=0;kosu=1;
        }
        printf("%.7f\n",(double)sum/kosu);
    }
}
int main(){

    solve();

    return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

class WeightUnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.weight = [0] * n

    # xの根を求める
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            px = self.find(self.parents[x])
            self.weight[x] += self.weight[self.parents[x]]
            self.parents[x] = px
            return px
    
    # xの根から距離
    def dist(self, x):
        self.find(x)
        return self.weight[x]

    # w[y] = w[x] + wとなるようにxとyを併合
    def unite(self, x, y, w):
        w += self.weight[x] - self.weight[y]
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            # sizeの大きいほうがx
            if self.parents[x] > self.parents[y]:
                x, y = y, x
                w = -w
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            self.weight[y] = w
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

    def diff(self, x, y):
        return self.dist(y) - self.dist(x)


    


def main():
    N, M = map(int, input().split())
    uni = WeightUnionFind(N)
    for _ in range(M):
        L, R, D = map(int, input().split())
        L -= 1
        R -= 1
        if uni.same(L, R):
            if D != uni.diff(L, R):
                print('No')
                exit()
        else:
            uni.unite(L,R,D)

    print('Yes')
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 101848
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	string s;
	cin>>s;
	bool check=true;
	rep(i,s.size()/2){
		if(s[i]!=s[s.size()-1-i]){
			check=false;
			break;
		}
	}
	cout<<((check)?"Yes":"No")<<endl;
	return 0;
}

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


typedef long long ll;
ll N,K;
ll ans = 0;
int main(){
	cin >> N >> K;
	for(int i=0;K+i<=N;i++){
		ans += N-(K+i);
	}
	//cout << ans << endl;
	if(K!=0){
		for(ll b=K+1;b<=N-K;b++){
			if(N%b==0) ans += (b-K)*(N/b-1);
			else ans += (b-K)*(N/b-1) + max(N%b-K+1,N%b-N%b);
		}
	}else{
		ans = N*N;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
	int h,w;
	while(1){
		cin>> h >> w;
		if(h == 0 && w == 0){
			break;
		}
	for (int j=0; j<h ; j++){
		for (int i=0; i<w ; i++){
			cout<< "#";
		}
		cout << endl;
	}
	cout << endl;
	}
    return 0;
    }




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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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 main(){
    
    int n;
    cin >> n;
    V<string> s(n);
    string t = "MARCH";
    map<char, ll> mp;
    rep(i,n) {
        string s;
        cin >> s;
        mp[s[0]]++;
    }

    ll ans = 0;
    for(int i = 0; i <= 2; i++) {
        for(int j = i+1; j <= 3; j++) {
            for(int k = j+1; k <= 4; k++) {
                ans += mp[t[i]] * mp[t[j]] * mp[t[k]];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	bool a;
	bool b;
} P;
int main( void ){
	string s, str;
	cin >> s;
	int N = s.size();
	// char[N] = '\n';
	int index = 0;
	rep( i, 0, N ){
		str[ i ] = 0;
	}
	rep( i, 0, N ){
		if (s[ i ] == 'B'){
			if (str.size() != 0)
			str.pop_back();
		}
		else {
			str.push_back(s[i]);
		}
	}
	cout << str << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
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;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//The Number of the Real Roots of a Cubic Equation
public class Main{

	int a, b, c, d;
	double EPS = 1e-8;
	List<Double> ans;
	
	double f(double x){
		return a*x*x*x + b*x*x + c*x + d;
	}
	double df(double x){
		return 3*a*x*x + 2*b*x + c;
	}
	void bs(double L, double R, boolean up){
		if(f(L)==0){
			ans.add(L); return;
		}
		if(f(R)==0){
			ans.add(R); return;
		}
		if(L <= 0 && 0 <= R && f(0)==0)return;
		if(up && (0 < f(L) || f(R) < 0))return;
		if(!up && (f(L) < 0 || 0 < f(R)))return;
		while(R-L > 1e-12){
			double M = (L+R)/2;
			if(0 < f(M)){
				if(up)R=M;
				else L=M;
			}
			else if(f(M) < 0){
				if(up)L=M;
				else R=M;
			}
			else{
//				System.out.println("M:"+M);
				ans.add(M); return;
			}
		}
//		System.out.println("L:"+L+" "+f(L));
		if(Math.abs(f(L)) < EPS)ans.add(L);
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int INF = 1000000;
		while(T--!=0){
			a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt();
			int D = b*b-3*a*c, rm = 0, rp = 0;
			ans = new ArrayList<Double>();
			if(0 <= D){
				double x0 = (-b-Math.sqrt(D))/3/a, x1 = (-b+Math.sqrt(D))/3/a;
				if(x1 < x0){
					double tmp = x1;
					x1 = x0;
					x0 = tmp;
				}
//				System.out.println(x0+" "+x1);
				bs(-INF, x0, 0 < df((x0-INF)/2));
//				System.out.println(ans.size());
				bs(x0, x1, 0 < df((x0+x1)/2));
//				System.out.println(ans.size());
				bs(x1, INF, 0 < df((x1+INF)/2));
//				System.out.println(ans.size());
			}
			else{
				bs(-INF, INF, 0 < df(0));
			}
			for(double d:ans){
//				System.out.println("D:"+d);
				if(Math.abs(d) <= 0)continue;
				if(0 < d)rp++;
				else rm++;
			}
			System.out.println(rp+" "+rm);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: String,
        b: String,
    }
    let s = format!("{}{}", a, b);
    let c: i32 = s.parse().unwrap();
    let d = (c as f32).sqrt() as i32;
    let ans = if c == d * d { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
	int in[1000],out[1000],incn=0,outcn=0,n,i;
	//printf("start\n");
	while(1){
		if( scanf("%d",&n) == EOF)break;
		//printf("nyuryoku %d\n",n);
		if(n != 0){
			in[incn] = n;
			incn++;
			//printf("in %dban %d\n",incn,in[incn-1]);
		}else{
			incn--;
			out[outcn] = in[incn];
			outcn++;
		}
	}
	for(i = 0;i < outcn;i++){
		printf("%d\n",out[i]);
	}
	return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

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

		for (int i = 0; i < n - 2; i++) {
			total += Math.min(b[i], b[i + 1]);
		}

		System.out.println(total + b[n - 2]);
		sc.close();
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

ll AC[maxn], WA[maxn];

void solve(){
    ll n, m;
    cin >> n >> m;
    ll c = 0, w = 0;
    for(ll i = 0; i < m; i++){
        ll x; string s;
        cin >> x >> s;
        if(AC[x]) continue;
        if(s == "AC"){
            c++;
            w += WA[x];
            AC[x] = 1;
        }
        else WA[x]++;
    }cout << c << " " << w << endl;
}

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


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

int main() {
  int N, Y;
  cin >> N >> Y;
  
  int ans = 1;
  
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N-i; j++){
      if(i*10000 + j*5000 + (N-i-j)*1000 == Y){
        cout << i << " " << j << " " << N-i-j <<endl;
        ans = 0;
        break;
      }
    }
    if(ans == 0){
      break;
      }
  }
  
  if(ans){
    cout<< "-1 -1 -1" << endl;
  }
}

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

using namespace std;

int main(){
	long long a;
	string s;
	cin >> a >> s;
	int n = (s[0] - '0') * 100 + (s[2] - '0') * 10 + s[3] - '0';
	cout << a * n / 100;
 	return 0;
}


Measured memory_bytes: 3600
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
ll permutation(ll n,ll r)
{
    ll a=1;
    for(ll i=n-r+1;i<=n;i++)
    {a*=i;a%=MOD;}
    return a;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,h;cin>>n>>h;
    vector<ll>a(n),b(n);
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    ll ans=0;
    if(h%a[0]==0)
        ans=h/a[0];
    else
        ans=h/a[0]+1;
    ll useda=ans;
    ll damage=ans*a[0];
    vector<ll>usedb;
    ll cntb=0;
    for(ll i=0;i<min(ans,n);i++){
        if(b[i]>a[0]){
            damage=damage-a[0]+b[i];
            usedb.pb(b[i]);
            cntb++;
            useda--;
        }
        else break;
    }
    while(damage-a[0]>=h&&useda--){
        damage-=a[0];
        ans--;
    }
    ll i=0;
    sort(all(usedb));
    if(cntb==0){
        cout<<ans<<endl;
        return 0;
    }
    while(damage-usedb[i]>=h){
        damage-=usedb[i];
        i++;
        ans--;
        if(i>=cntb)break;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







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

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  for (int i=0; i<n; i++){
    cin >> p.at(i);
  }
  
  int cnt = 0;
  
  for (int i=1; i<n-1; i++){
    if ((p.at(i) < p.at(i-1) && p.at(i) > p.at(i+1))||(p.at(i) < p.at(i+1) && p.at(i) > p.at(i-1))){
          cnt++;
        }
  }
        
        cout << cnt << endl;
}


Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
int a,b=0,c=0,d=0;
cin>>a;
for(int i=0;i<a;i++)
{int x,y,z;
 cin>>x>>y>>z;
 int abc=abs(c-y)+abs(d-z);
 if(x<abc ||(x-b)%2 !=abc%2)
 {cout<<"No";
  system("pause");
  return 0;}}
cout<<"Yes";
system("pause");
return 0;
} 

Measured memory_bytes: 504
N, L = map(int, input().split())
X = [L + i - 1 for i in range(1, N + 1)]
sum_X = sum(X)

ret = -1
ans = 1e100
for x in X:
    if abs(x) <= ans:
        ans = min(ans, abs(x))
        ret = sum_X - x
print(ret)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a == 1){
			a += 13;
		}
		if(b == 1){
			b += 13;
		}
		if(a == b){
			System.out.println("Draw");
		}else if(a > b){
			System.out.println("Alice");
		}else{
			System.out.println("Bob");
		}
	}
}


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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

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

const int M=1e4+5;
const ll INF=1e15;
const int MOD=1e9+7;

int h,w;
ll dp[M][M];
char t[M][M];

ll DP(int i,int j){
	if (t[i][j] != '.') return 0;
	if (i == h && j == w) return 1;
	if (dp[i][j] != -1) return dp[i][j];
	dp[i][j] = (DP(i+1,j) + DP(i,j+1)) % MOD;
	return dp[i][j];
}

int main(){

	fastio;
	cin >> h >> w;
	fp(i,0,M)
		fp(j,0,M) dp[i][j] = -1;

	fp(i,1,h+1)
		fp(j,1,w+1) cin >> t[i][j];

	cout << DP(1,1) << "\n";

	return 0;
}


Measured memory_bytes: 790624
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main(void) {
    int n, a, b;
    std::scanf("%d %d %d", &n, &a, &b);
    std::printf("%d\n", n * a < b ? n * a : b);
    return 0;
}

Measured memory_bytes: 256
//abc130_e.cpp
//Fri Oct  4 22:22:10 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
ll MOD=1000000007;

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

	int s[n+1],t[m+1];
	s[0] = -1;
	t[0] = -1;
	for (int i=1;i<n+1;i++){
		cin >> s[i];
	}
	for (int i=1;i<m+1;i++){
		cin >> t[i];
	}

	int dp[n+1][m+1];
	for (int i=0;i<n+1;i++){
		dp[i][0] = 1;
	}

	for (int j=1;j<m+1;j++){
		for (int i=0;i<n+1;i++){
			dp[i][j] = 0;
			if (i==0){
				dp[i][j] = dp[i][j-1];
			}else {
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= MOD;
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= MOD;
				dp[i][j] -= dp[i-1][j-1];
				dp[i][j] = (dp[i][j]+MOD)%MOD;
				if (s[i]==t[j]){
					dp[i][j] += dp[i-1][j-1];
					dp[i][j] %= MOD;
				}
			}
		}
	}

	cout << dp[n][m] << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 15872
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	int n,k;
	cin>>n>>k;
	deque<int> v;
	vector<int> S(n+1,0);
	rep(i,n){
		int a;cin>>a;
		v.push_back(a);
	}
	int ans=-LLONG_MAX;
	rep(i,min(n+1,k+1)){//i個の宝石を取る
		rep(j,i+1){//左からj個、右からi-j個取る
			multiset<int> juwel;
			int cost=0;
			rep(l,j){ 
				juwel.insert(v[l]);
				cost+=v[l];
			}
			rep(l,i-j){
				juwel.insert(v[n-l-1]);
				cost+=v[n-l-1];
			}
			itr(l,juwel){//最大k-i個の宝石を詰める
				if(*l>=0||distance(juwel.begin(),l)>=k-i) break;
				cost-=*l;
			}
		    ans=max(ans,cost);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n,x,t; cin >> n >> x >> t;
  int val = (n / x) + ((n % x) != 0);
    cout << val * t;    
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
    int N;

    scanf("%d", &N);

    switch(N % 10){
        case 2:
        case 4: 
        case 5: 
        case 7: 
        case 9:
            printf("hon\n");
            break;
        case 0:
        case 1:
        case 6:
        case 8: 
            printf("pon\n");
            break;
        case 3:
            printf("bon\n");
            break;
    }

    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;


int main(){
    int a,b,c;
    while(cin>>a>>b>>c){
        if(a+c==b*2) cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int N = 200000+10;
int cnt[N];
bool cmp(const int &a,const int &b){
	if(cnt[a]<cnt[b])return true;
	if(cnt[a]==cnt[b])return a<b;
	return false;
}
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	int p=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(!cnt[a[i]])p++;
		cnt[a[i]]++;
	}
	sort(a,a+n,cmp);
	//for(int i=0;i<n;i++)cout<<a[i]<<" ";
	//cout<<endl;
	if(p<=k){
		cout<<0;
		return 0;
	}
	int prev=-1;
	int s=0;
	int ans=0;
	p++;
	for(int i=0;i<n;i++){
		if(a[i]!=prev){
			ans+=s;
			prev=a[i];
			s=1;
			p--;
			if(p<=k)break;
		}else if(a[i]==prev)s++;
		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int k=sc.nextInt();
			int s=sc.nextInt();
			int ans=0;
			for(int i=0;i<=k;i++) for(int j=0;j<=k;j++) if(s-i-j>=0 && s-i-j<=k) ans++;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 9804
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut ans = 0;
    loop {
        ans += 1;
        if n < k.pow(ans) {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main (){
  string s,t,u;   cin >> s >> t;
  int a , b;    cin >> a >>b;
  cin >> u ;

  if(s==u){
      a--;
  }

  if(t==u){
      b--;
  }
  cout << a <<" "<< b;
}


Measured memory_bytes: 256
N,Q = [int(i) for i in input().split()]
L = list(range(N))
for _ in range(Q):
  n,u,v = [int(i) for i in input().split()]
  while u != L[u]:
    u = L[u]
  while v != L[v]:
    v = L[v]
  u,v = [max(u,v),min(u,v)]
  if n == 0:
    L[u] = v
  else:
    if u == v:
      print(1)
    else:
      print(0)

Measured memory_bytes: 75536
n, k = map(int, input().split())
a_i = list(map(int, input().split()))

def f(n):
    cnt = 0
    for a in a_i:
        cnt += (a - 1) // n
    if cnt > k: return False
    else: return True

l, r = 0, max(a_i)
while True:
    if r - l <= 1: break
    val = (l + r) // 2
    if f(val) == True: r = val
    else: l = val
print(r)

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

typedef long long ll;

int main(){
	int n,m;
	cin>>n>>m;
	
	if(n<=m){
		string s[12];
		vector<int> t;
		t.push_back((1<<(m-1))-1);
		for(int i=0;i<m;i++){
			for(int j=0;j<(1<<m)-1;j++){
				s[i]+='0';
			}
			vector<int> t_;
			for(int x: t){
				s[i][x]='1';
				if(i+1<m){
					t_.push_back(x-(1<<(m-2-i)));
					t_.push_back(x+(1<<(m-2-i)));
				}
			}
			t=t_;
		}
		for(int i=1;i<=(1<<n)-1;i++){
			int t=0;
			while(((i>>t)&1)==0)t++;
			cout<<s[t]<<endl;
		}
	}
	else {
		swap(n,m);
		string s[12];
		vector<int> t;
		t.push_back((1<<(m-1))-1);
		for(int i=0;i<m;i++){
			for(int j=0;j<(1<<m)-1;j++){
				s[i]+='0';
			}
			vector<int> t_;
			for(int x: t){
				s[i][x]='1';
				if(i+1<m){
					t_.push_back(x-(1<<(m-2-i)));
					t_.push_back(x+(1<<(m-2-i)));
				}
			}
			t=t_;
		}
		char ret[2000][2000];
		for(int i=1;i<=(1<<n)-1;i++){
			int t=0;
			while(((i>>t)&1)==0)t++;
			for(int j=1;j<=s[t].size();j++){
				ret[i][j]=s[t][j-1];
			}
		}
		for(int i=1;i<=(1<<m)-1;i++){
			for(int j=1;j<=(1<<n)-1;j++){
				printf("%c",ret[j][i]);
			}
			printf("\n");
		}
	}
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int n, A[50];
int dp[30][3000];

int solve(int i, int m) {
    //if (m == 0) return 1;
    //if (i >= n) return 0;
    //int res = solve(i+1,m) || solve(i+1, m-A[i]);
    //return res;

    if (dp[i][m] != 0) return dp[i][m];

    if (m == 0) dp[i][m] = 1;
    else if(i >= n) dp[i][m] = -1;
    else if(solve(i+1, m) == 1) dp[i][m] = 1;
    else if(solve(i + 1, m - A[i]) == 1) dp[i][m] = 1;
    else dp[i][m] = -1;
    
    return  dp[i][m];
}

int main()
{
    int q, M, i;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &M);
        if (solve(0,M)==1) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 3336