akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim],B[lim],C[lim];
unordered_map<lld,lld> M;

int main(){
    // lld t = sc();
    lld t = 1;
    while(t--) {
        M.clear();
        lld n = sc(), m = sc();
        lld start = 1, end = n;
        lld half = (n - 1) / 2;
        half = (half + 1) / 2;
        rep(i,1,m) {
            printf("%lld %lld\n", start, end);

            // lld diff = end - start;
            // if(M[diff] == 1) Error(n, m, diff);
            // if(M[n - diff] == 1) Error(n, m, n - diff);
            // if(start >= end) Error("F");
            // M[diff] = M[n - diff] = 1;

            // Error(start, end, diff, n - diff);

            if(i == half and n % 2 == 0) end--;
            start++;
            end--;
        }
    }
    return 0;
}


Measured memory_bytes: 3864
#include <iostream>
#include <cmath>

using namespace std;

int main(){
int cx1 = 0;
int cy1 = 0;
int cx2 = 0;
int cy2 = 0;
int r1 = 0;
int r2 = 0;

cin>>cx1>>cy1>>r1;
cin>>cx2>>cy2>>r2;

int r_a = r1 + r2;
int r_d = abs(r1 - r2);
int dx = abs(cx1 - cx2);
int dy = abs(cy1 - cy2);

double dist = sqrt(dx*dx + dy*dy);

if(dist > (double)r_a)
{
    cout << "4" << endl;
}

if(dist == (double)r_a)
{
    cout << "3" << endl;
}

if(dist < (double)r_a && dist > (double)r_d)
{
    cout << "2" << endl;
}

if(dist == (double)r_d)
{
    cout << "1" << endl;
}

if(dist < (double)r_d)
{
    cout << "0" << endl;
}

return 0;
}



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

void solve(long long A, long long B, long long N){
    cout << (A*min(N,B-1)/B) << endl;

}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3772
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	_, m, x := nextInt(), nextInt(), nextInt()
	l, r := 0, 0
	for i := 0; i < m; i++ {
		a := nextInt()
		if a < x {
			l++
		} else if a > x {
			r++
		}
	}
	puts(min(l, r))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	long long int ans = 0;
	for (int i = 50; i >= 0; i--) {
		int cnt = 0;
		for (auto j : v) {
			if ((j >> i) & 1)cnt++;
		}
		if (cnt < (N + 1) / 2) {
			if (ans + (1LL << i) <= K)ans += 1LL << i;
		}
	}
	for (auto &i : v)i ^= ans;
	cout << accumulate(v.begin(), v.end(), 0LL) << endl;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#define _rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define SF scanf
#define PF printf
int f[10005],t,n;
int  main(){
	SF("%d",&n);
	int x,y,z;
	for(x=1;x*x<n;x++){
		t=x*x+3+x+x;
		if(t>n)break;
		for(y=1;y*y<n;y++){
			t=x*x+y*y+x*y+1+x+y;
			if(t>n)break;
			for(z=1;z*z<n;z++){
				t=x*x+y*y+z*z+x*y+x*z+y*z;
				if(t<=n)f[t]++;else break;
			}
		}
	}
	_rep(i,1,n)PF("%d\n",f[i]);
	return 0;
}

Measured memory_bytes: 1764
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from functools import lru_cache\n"
"@lru_cache(maxsize=None)\n"
"def b(n):\n"
"    if n<1:return 1\n"
"    return b(n-1)*2+3\n"
"@lru_cache(maxsize=None)\n"
"def p(n):\n"
"    if n<1:return 1\n"
"    return p(n-1)*2+1\n"
"def solve(n,x):\n"
"    if n<1:return int(x>0)\n"
"    if x-2<b(n-1):return(solve(n-1,x-1))\n"
"    return p(n-1)+solve(n-1,x-b(n-1)-2)+1\n"
"print(solve(*map(int,input().split())))\n"
"\"";
  system(s);
  return 0;
}            

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

int main()
{
    char a[100]={},b[100]={};
    scanf("%s",&a);
    scanf("%s",&b);
    if(strncmp(a,b,strlen(a))==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1648
/* package whatever; // don't place package name! */

import java.util.*;

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

        int K = sc.nextInt();
        int N = sc.nextInt();
        sc.nextLine();

        int[] len = new int[N];

        int sum = 0;
        int max = 0;

        for (int i = 0; i < N; i++) {
            len[i] = sc.nextInt();
        }

        for (int i = 1; i < N; i++) {
            int sa = Math.abs(len[i]  - len[i-1]);
            sum += sa;
            
            if (sa > max) {
                max = sa;
            }
        }
        
        if (max > len[0] + K - len[N-1]) {
            sum = sum - max + len[0] + K - len[N-1];
        } 

        System.out.println(sum);
        sc.close();
    }
}

Measured memory_bytes: 75184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second


int n;
char s[maxN];

vector<int> v[15];
int main() {
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		int x = s[i]-'0';
		v[x].push_back(i);
	}
	vector<string> p; 
	for(int i=0;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
		{
			for(int k=0;k<=9;k++)
			{
				int ans = 0;
				if(v[i].size()==0)continue;
				int pi = v[i][0];
				int pj = upper_bound(v[j].begin(),v[j].end(),pi)-v[j].begin();
				if(pj<v[j].size())
				{
					int pk = upper_bound(v[k].begin(),v[k].end(),v[j][pj])-v[k].begin();
					if(pk<v[k].size())
					{
						ans=1;
					}
				}
				if(ans>0)
				{
					string x = "";
					x.push_back('0'+i);
					x.push_back('0'+j);
					x.push_back('0'+k);
					p.push_back(x);
				}
			}
		}
	}
	sort(p.begin(),p.end());
	p.erase(unique(p.begin(),p.end()),p.end());
	cout<<p.size()<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int d,t,s; cin>>d>>t>> s;
    if(s*t>=d){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;


}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int d;
    cin >> d;
    if (d == 25)puts("Christmas");
    if (d == 24)puts("Christmas Eve");
    if (d == 23)puts("Christmas Eve Eve");
    if (d == 22)puts("Christmas Eve Eve Eve");
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



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

class Program {
    private static int Main() {
        var str = Console.ReadLine();

        var input = Console.ReadLine();
        int q = int.Parse( input );

        for( int i =0; i < q; ++i){
            input = Console.ReadLine();
            var values = input.Split( ' ' );

            var a = int.Parse( values[ 1 ] );
            var b = int.Parse( values[ 2 ] );
            switch( values[ 0 ] ) {
                case "replace":
                    str = str.Remove( a, b + 1 - a );
                    str = str.Insert( a, values[ 3 ] );
                    break;
                case "reverse":
                    var tmp = str.Substring( a, b + 1 - a );
                    var reverse = new string( tmp.Reverse().ToArray() );
                    str = str.Remove( a, b + 1 - a );
                    str = str.Insert( a, reverse );
                    break;
                case "print":
                    Console.WriteLine( str.Substring( a, b + 1 - a ) );
                    break;

                default:
                    throw new Exception( "Invalid Data." );

            }
            
        }

        return 0;
    }
}

Measured memory_bytes: 20032
N, K = gets.split(' ').map(&:to_i)
R, S, P = gets.split(' ').map(&:to_i)
T = $stdin.read.split('')
# r グー, s チョキ p パー
result = 0

STR_R = "r"
STR_S = "s"
STR_X = "!"

N.times do |i|

  rsp = T[i]
  if i < K || rsp != T[i-K]
    case rsp
    when STR_R
      result += P
    when STR_S
      result += R
    else
      result += S
    end
  else
    T[i] = STR_X
  end
end
puts result

Measured memory_bytes: 6780
#include <cstdio>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)

int a[] = { 1, 5, 10, 50, 100, 500 };
int N[6];
int ret[666667];

int min(int x, int y) { return x < y ? x : y; }

int main()
{
	REP(p, 1, 666667) {
		int t = p;
		rep(i, 6) { int k=t/a[5-i]; ret[p]+=k; t-=k*a[5-i]; }
	}
	int P;
	while (scanf("%d", &P), P) {
		int s = 0;
		rep(i, 6) { scanf("%d", N+i); s += a[i] * N[i]; }

		int res = (1<<29);
		REP(p, P, s+1) {
			int t = p;
			int pay = 0;
			rep(i, 6) {
				int k=min(N[5-i], t/a[5-i]);
				pay+=k;
				if (pay >= res) goto NEXT;
				t-=k*a[5-i];
			}
			if (!t) res = min(res, pay+ret[p-P]);
NEXT:;
		}
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 3364
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr int INF = 1 << 30;

ll n, k, s, MAX = 1e9;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> k >> s;
  vector<ll> a(n + 1);
  ll ume = MAX;
  if (s == MAX) --ume;
  for(int i = 0; i < k; ++i) a[i] = s;
  for(int i = k; i < n; ++i) a[i] = ume;
  for(int i = 0; i < n; ++i) cout << a[i] << " \n"[i == n - 1];
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

const int inf = (int)1e9 + 7;

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

    int n;

    cin >> n;

    vector<int> a (n);

    for (auto &it : a)
        cin >> it;

    int odd = 1, all = 1;

    for (auto it : a)
    {
        if (it % 2 == 0)
            odd *= 2;
        all *= 3;
    }

    cout << all - odd << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int M,D,i,cnt=0;
    scanf("%d %d",&M,&D);
    for(i=22;i<=D;i++){
        if(i%10!=1 && i%10!=0){
            if(M>=(i%10)*(i-(i%10))/10){
                cnt++;
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}

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

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

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;

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

	for(int i=0;i<n;i++){
		vector<int> a(10);
		for(int j=0;j<10;j++) cin>>a[j];

		bool ok=false;

		for(int j=0;j<(1<<10);j++){
			vector<int> b,_b,c,_c;

			for(int k=0;k<10;k++){
				if(j & (1<<k)) b.push_back(a[k]);
				else c.push_back(a[k]);
			}

			_b=b; _c=c;
			sort(_b.begin(),_b.end());
			sort(_c.begin(),_c.end());

//			reverse(_b.begin(),_b.end());
//			reverse(_c.begin(),_c.end());

			if(b==_b && c==_c){
				cout<<"YES"<<endl;


				ok=true; break;
			}

		}

		if(!ok) cout<<"NO"<<endl;

	}

	return 0;
}

Measured memory_bytes: 1216
//In the name of God

#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5+10 , mod = 1e9+7;

int a[N] , b[N];
vector <int> v;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   for(int i = 0 ; i < n ; i++)
      cin >> a[i];
   int ans = 0;
   ll sm = 0;
   for(int i = 0 ; i < n ; i++){
      cin >> b[i];
      if(a[i] > b[i])
         v.push_back(a[i] - b[i]);
      else if(a[i] < b[i])
         ans++ , sm += b[i] - a[i];
   }
   sort(v.rbegin() , v.rend());
   int m = v.size();
   for(int i = 0 ; i < m && sm > 0 ; i++){
      sm -= v[i];
      ans++;
   }
   if(sm > 0)
      ans = -1;
   cout << ans;
   return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int in(){
    double t;
    scanf("%lf",&t);
    return t*(1ll<<50);
}

int K,L,R;
double P;
int E,T;

int w;
int sl,sr;

double dfs(int k,int l,int r){
    if(k==K){
        int m=(l+r)/2;
        if(T-E<=m&&m<=T+E)return 1.0;
        else return 0.0;
    }
    if(r<T-E||T+E<l)return 0.0;
    if(T-E<=l&&r<=T+E)return 1.0;
    int m=(l+r)/2;
    if(m>=T)return (1-P)*dfs(k+1,l,m)+P*dfs(k+1,m,r);
    else return P*dfs(k+1,l,m)+(1-P)*dfs(k+1,m,r);
}

signed main(){
    scanf("%lld",&K);
    L=in();R=in();
    scanf("%lf",&P);
    E=in();T=in();

    printf("%.20f\n",dfs(0,L,R));
    return 0;
}

Measured memory_bytes: 1252
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")
}

//https://onlinejudge.u-aizu.ac.jp/solutions/problem/ALDS1_5_B/review/2709881/arsenic28/Rust
trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let h: usize = read();
    let w: usize = read();
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut grid: Vec<Vec<usize>> = vec![vec![0; w]; h];

    let mut color: Vec<usize> = Vec::new();
    for i in 0..n {
        for _ in 0..a[i] {
            color.push(i + 1);
        }
    }

    let mut k = 0;
    for i in 0..h {
        if i % 2 == 0 {
            for j in 0..w {
                grid[i][j] = color[k];
                k += 1;
            }
        } else {
            for j in (0..w).rev() {
                grid[i][j] = color[k];
                k += 1;
            }
        }
    }

    for i in 0..h {
        println!("{}", grid[i].iter().join(" "));
    }
}


Measured memory_bytes: 2344
#include<bits/stdc++.h>
using namespace std;
struct Union_find{
  vector<int>par;
  vector<int>size;
  Union_find(int n):par(n),size(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      size[i]=1;
    }
  }
  int root(int x){
    return par[x]==x?x:par[x]=root(par[x]);
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  void unit(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(size[x]<size[y]){
      par[x]=y;
      size[y]+=size[x];
    }else{
      par[y]=x;
      size[x]+=size[y];
    }
  }
  int treesize(int x){
    return size[root(x)];
  }
};
int main(){
  int N,K,M;
  cin>>N>>M>>K;
  Union_find uf(N);
  vector<vector<int>>G(N);
  vector<int>block(N,0);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    uf.unit(a,b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0;i<K;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    if(uf.same(a,b)){
      block[a]++;
      block[b]++;
    }
  }
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    //cout<<i<<" "<<block[i]<<endl;
    ans[i]=uf.treesize(i)-G[i].size()-block[i];
    cout<<ans[i]-1<<" ";
  }
}

Measured memory_bytes: 8312
#include <cstdio>
#include <algorithm>

using namespace std;

int memo[300001];

int main()
{
	int n, q;
	int t, m;
	
	scanf("%d %d", &n, &q);
	
	for (int i = 0; i < n; i++){
		scanf("%d", &t);
		memo[t] = t;
	}
	
	for (int i = 1; i < 300001; i++){
		memo[i] = max(memo[i - 1], memo[i]);
	}
	
	for (int i = 0; i < q; i++){
		scanf("%d", &t);
		m = 0;
		for (int j = t - 1; j <= 300000; j += t){
			m = max(m, memo[j] % t);
		}
		m = max(m, memo[300000] % t);
		printf("%d\n", m);
	}
	
	return (0);
}

Measured memory_bytes: 2196
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		char[] P = new char[N];

		int[] table = new int[26];

		for (int i=0; i < table.length;i++)
		{
			table[i]=0;
		}


		int count = 0;
		int open = 0;

		for(int i = 0; i < N ;i++){

			String tmp  = sc.next();

			P[i] = tmp.charAt(0);
			table[(int)P[i] - 65] += 1;

		}

		 Arrays.sort(table);

//		 for (int i = 0; i < 26 ;i++){
//			System.out.println(table[i]);
//		 }


		 for (int j = 0; j < N; j++) {
			 count = 0;
			 Arrays.sort(table);

			 for (int i = 25; i >= 0 ;i--) {

				 if (table[i] > 0){
					 count++;
					 table[i]--;

					 if (count == K){
						 count = 0;
						 open++;

						 break;
					 }
				 }
			 }
		 }








		System.out.println(open);

//		for (int i = 0; i < N ;i++){
//			System.out.println(P[i]);
//		}


		sc.close();
	}


}


Measured memory_bytes: 18648
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,x,y,sum=0,minv,maxv;
  cin>>a>>b>>c>>x>>y;
  minv=min(x,y);
  maxv=max(x,y);
  if(a+b>c*2){
    if(minv*2*c+(x-minv)*a+(y-minv)*b<c*maxv*2){
      sum+=minv*2*c+(x-minv)*a+(y-minv)*b;
    }else{
      sum+=c*maxv*2;
    }
  }else{
    if(x*a+y*b<c*maxv*2){
      sum+=x*a+y*b;
    }else{
      sum+=maxv*2*c;
    }
  }
  cout<<sum<<'\n';
  
  return 0;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input())
for i in range(2):
	for j in range(2):
		for k in range(2):
			if A + B * (i * 2 - 1) + C * (j * 2 - 1) + D * (k * 2 - 1) == 7:
				print (A, "-+"[i], B, "-+"[j], C, "-+"[k], D, "=7", sep='')
				break
		else:
			continue
		break
	else:
		continue
	break

Measured memory_bytes: 3060
from fractions import gcd
def lcm(x, y): return x * y // gcd(x, y)

n, m = map(int, input().split())
a = list(map(int, input().split()))
ha = [x // 2 for x in a]

c = ha[0]
for d in ha[1:]:
    l = lcm(c, d)
    if not (l//c % 2 and l//d % 2): print(0); exit()
    c = l

print((m+c) // (c*2))


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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint factorial(int n){

	mint f=1 ;
	for(int i=2;i<=n;i++){
		f*=(mint)i ;
	}

	return f ;

}


void solve(){


	int n,m ;
	cin>>n>>m ;

	if(abs(n-m)>1){
		cout<<0 ;
		return ;
	}

	int a=max(n,m) ;
	int b=min(n,m) ;

	mint x=factorial(a) ;
	mint y=factorial(b) ;

	if(a==b){
		cout<<x*x*2 ;
	}
	else{
		cout<<x*y ;
 	}


}


int main(){
		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int n, k, m;
ll tree[4*N], lazy[4*N];

void propagate(int node, int start, int end) {
  if(!lazy[node])
    return;
  tree[node] += lazy[node] * (end - start + 1);
  if(start != end) {
    lazy[node * 2] += lazy[node];
    lazy[node * 2 + 1] += lazy[node];
  }
  lazy[node] = 0;
}

void build(int node, int start, int end) {
  if(start == end) {
    tree[node] = k;
    return;
  }
  int mid = (start + end) / 2;
  build(node * 2, start, mid);
  build(node * 2 + 1, mid + 1, end);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
}

ll query(int node, int start, int end, int idx) {
  propagate(node, start, end);
  if(start == end)
    return tree[node];
  int mid = (start + end) / 2;
  if(idx <= mid)
    return query(node * 2, start, mid, idx);
  else
    return query(node * 2 + 1, mid + 1, end, idx);
}

void update(int node, int start, int end, int l, int r, int val) {
  propagate(node, start, end);
  if(start > r || end < l)
    return;
  if(start >= l && end <= r) {
    lazy[node] = val;
    propagate(node, start, end);
    return;
  }
  int mid = (start + end) / 2;
  update(node * 2, start, mid, l, r, val);
  update(node * 2 + 1, mid + 1, end, l, r, val);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  cin >> n >> k >> m;
  build(1, 1, n);
  int a;
  for (int i = 0; i < m; ++i) {
    cin >> a;
    update(1, 1, n, 1, n, -1);
    update(1, 1, n, a, a, 1);
  }
  for (int i = 1; i <= n; ++i) {
    int val = query(1, 1, n, i);
//    cerr << val << endl;
    if(val > 0) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 6784
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int k; cin >> k;
  int n=s.size();
  rep(i,n){
    if(s[i]!='a'&&k>='{'-s[i]){
      k-='{'-s[i];
      s[i]='a';
    }
  }
  if(k>0){
    s[n-1]=char('a'+(s[n-1]-'a'+k)%26);
  }
  cout << s << endl;  
}

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

void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.chomp.to!long).array;
    a.sort();

    auto b = new long[](n);
    auto c = new long[](n);

    foreach (i ; 0 .. n) {
        if (i == 0 || i == n - 1) {
            if (i % 2 == 0) {
                b[i] = 1;
                c[i] = -1;
            }
            else {
                b[i] = -1;
                c[i] = 1;
            }
        }
        else {
            if (i % 2 == 0) {
                b[i] = 2;
                c[i] = -2;
            }
            else {
                b[i] = -2;
                c[i] = 2;
            }
        }
    }

    b.sort();
    c.sort();

    long ans;

    foreach (i ; 0 .. n) {
        ans += a[i] * b[i];
    }

    long ans2;

    foreach (i ; 0 .. n) {
        ans2 += a[i] * c[i];
    }

    writeln(max(ans, ans2));
}















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 5372
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

Graph g;
vector<long long> depth;
void dfs(int u, int p) {
    for (auto &e: g[u]) if (e.first != p) {
        dfs(e.first, u);
        chmax(depth[u], depth[e.first] + e.second);
    }
}
vector<long long> height;
void dfs2(int u, int p, int d_par) {
    vector<pair<long long, int>> d_child;
    d_child.emplace_back(0, -1);        // sentinel
    for (auto &e: g[u]) {
        long long dv = (e.first == p ? d_par : depth[e.first]) + e.second;
        d_child.emplace_back(dv, e.first);
    }
    sort(d_child.rbegin(), d_child.rend());
    height[u] = d_child[0].first;
    for (auto &e: g[u]) if (e.first != p) {
        long long nd_par = d_child[d_child[0].second == e.first].first;
        dfs2(e.first, u, nd_par);
    }
}

int main() {
    int n; cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int s, t, w; cin >> s >> t >> w;
        g[s].emplace_back(t, w);
        g[t].emplace_back(s, w);
    }
    depth.resize(n);
    dfs(0, -1);
    height.resize(n);
    dfs2(0, -1, 0);
    for (auto h: height) cout << h << endl;
    return 0;
}


Measured memory_bytes: 5964
N = int(input())
xy = []
for i in range(N):
    A = int(input())
    xy.append([[int(i) for i in input().split()] for _ in range(A)])
ans = 0
for n in range(2**N):
    b = bin(n)[2:].zfill(N)
    s = 0
    for i, bi in enumerate(b):
        if bi == '0':
            continue
        for x, y in xy[i]:
            if b[x-1] == str(y):
                pass
            else:
                break
        else:
            s += 1
            continue
        break
    else:
        ans = max(ans, s)
print(ans)


Measured memory_bytes: 47596
#pragma optimize("Ofast")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int len[2005];
char s[2005][10005];
bitset<10005> can[2005];
pair<int,int> dp[2][2005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		scanf("%s",s[i]);
		len[i]=strlen(s[i]);
	}
	for(int i=0;i<n;i++){
		can[i].reset();
	}
	can[n]=1;
	for(int i=n-1;i>=0;i--){
		can[i]=can[i+1]|(can[i+1]<<len[i]);
	}
	int cnt=0,ii=0;
	for(int i=0;i<n;i++){
		if(can[i+1][k-len[i]]) dp[0][cnt++]=make_pair(i,0);
	}
	string res;
	pair<int,int> *a=dp[0],*b=dp[1];
	for(int i=1;i<=k;i++){
		char mi='z';
		int cnt2=0;
		for(int j=0;j<cnt;j++){
			mi=min(s[a[j].first][a[j].second],mi);
		}
		res+=mi;
		int miid=1e9;
		for(int j=0;j<cnt;j++){
			int fi=a[j].first,se=a[j].second;
			if(s[fi][se]==mi){
				if(se+1==len[fi]) miid=min(miid,fi);
				else{
					b[cnt2++]=make_pair(fi,se+1);
				}
			}
		}
		for(int j=miid+1;j<n;j++){
			if(k-len[j]-i>=0&&can[j+1][k-len[j]-i]) b[cnt2++]=make_pair(j,0);
		}
		swap(a,b);
		cnt=cnt2;
	}
	cout<<res;
}

Measured memory_bytes: 21504
while True:
    b = int(input())
    if b == 0:
        break
    tmp = 0
    results = {}
    for n in range(1, int((2*b)**(1/2))+1):
        tmp = ((2*b/n) - n + 1) / 2
        if int(tmp) == tmp:
            results[tmp] = n

    results = sorted(results.items(), key=lambda x: x[1], reverse=True)
    a, n = results[0][0], results[0][1]
    print(int(a), int(n))



Measured memory_bytes: 5664
let () =
  let counting_sort a b k =
    let len = (Array.length a) -1 and
        c = Array.make (k+1) 0 in
    Array.iter (fun x -> c.(x) <- c.(x)+1) a;
    for i = 1 to k do
      c.(i) <- c.(i) + c.(i-1)
    done;
    for i = 0 to len do
      let j = len - i in
      b.(c.(a.(j))-1) <- a.(j);c.(a.(j)) <- c.(a.(j))-1
    done;b
  in
  let read x = Scanf.scanf " %d" (fun y -> y) in
  let n = read_int () in
  let a = Array.init n read in
  let res = counting_sort a (Array.make n 0) 10000 in
  print_int res.(0);
  for i = 1 to n-1 do
    print_string  " ";print_int res.(i)
  done;
  print_newline ()
;;

Measured memory_bytes: 36220
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
vector<lli> v, s;
unordered_map<lli, lli> c;
int main() {
  cin >> n >> m; read_n(v, n);
  s = decltype(s)(n);
  s[0] = v[0] % m;
  for (int i=1; i<n; ++i) s[i] = (s[i-1] + v[i]) % m;
  for (lli x : s) {
    auto it = c.find(x);
    if (it == c.end()) c[x] = 1;
    else it->second++;
  }
  lli ans = 0, d = 0;
  for (int l=0; l<n; ++l) {
    d = l>0 ? s[l-1] : 0;
    ans += c[d];
    c[s[l]]--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5260
#include<iostream>

int main(void) {
    int e = 0;
    while(std::cin >> e) {
        int result = 1000000;
        if(e == 0) {
            break;
        }
        for(int z = 0; z <= 100; z++) {
            const int Z = z*z*z;
            if(Z > e) {
                break;
            }
            for(int y = 0; y <= 1000; y++) {
                const int Y = y*y;
                if(Z + Y > e) {
                    break;
                }
                int x = e - Z - Y;
                result = std::min(result, x + y + z);
            }
        }
        std::cout << result << std::endl;
    }
    return 0;
}

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

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> points = new ArrayList<>();
        for(int i=0; i<n; i++) {
            points.add(sc.nextInt());
        }

        int range[] = {0,0,0,0,0,0,0,0,0};

        for(int p: points) {
            if (p < 400) range[0]++;
            else if (p < 800) range[1]++;
            else if (p < 1200) range[2]++;
            else if (p < 1600) range[3]++;
            else if (p < 2000) range[4]++;
            else if (p < 2400) range[5]++;
            else if (p < 2800) range[6]++;
            else if (p < 3200) range[7]++;
            else range[8]++;
        }

        int count = 0;
        int max = 0;

        for(int i=0; i<8; i++) {
            if (range[i] > 0) count++;
        }
        if(count == 0) {
            count = 1;
            max = range[8];
        } else {
            max = count + range[8];
        }
        System.out.println(count + " " + max);
    }
}

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

using namespace std;
using LL = long long;

int main(){
    LL x;
    cin >> x;
    if(x <= 3){
        cout << 1 << endl;
        return 0;
    }
    LL ans = 0;
    for(int i = sqrt(x + 5.0); i >= 2; i--){

        int tmp = i * i;
        while(tmp <= x){
            ans = tmp > ans? tmp:ans;
            tmp *= i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//Author: Suifeng0214
//2020.6.30 19.03
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[100010];
int arr[100010];
signed main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	for (int i = 2; i < n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i]), dp[i-2] + abs(arr[i-2] - arr[i]));
	}
	cout << dp[n-1];
} 

Measured memory_bytes: 5116
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

bool ispal(string &s,int l,int r);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    if(!ispal(s,0,n-1))
    {
        cout<<"No\n";
        return 0;
    }

        if(!ispal(s,0,(n-1)/2-1))
            {
        cout<<"No\n";
        return 0;
    
}
   
        if(!ispal(s,(n+3)/2-1,n-1))
            {
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";


    return 0;   
}

bool ispal(string &s,int l,int r)
{
    while(l<=r)
    {
        if(s[l++]!=s[r--])
            return 0;
    }
    return 1;
}


 
 


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
  int a, b, c, tmp;
  scanf("%d%d%d", &a, &b, &c);
  if ( b > c ) {
    tmp = b; b = c; c = tmp;
  }
  if ( a > b ) {
    tmp = a; a = b; b = tmp;
  }
  if ( b > c ) {
    tmp = b; b = c; c = tmp;
  }
    printf("%d %d %d\n", a, b, c);
  return 0;
}




Measured memory_bytes: 2036
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , x , t ;
    cin >> n >> x >> t ;
    int ans = (n + x - 1) / x * t ;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	ll c;
	cin >> n >> c;
	vector <ll> x(n + 1), v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> v[i];
		v[i] += v[i - 1];
	}
	ll ans = 0;
	vector <ll> pre(n + 1), suf(n + 2);
	for (int i = 1; i <= n; i++) {
		pre[i] = v[i] - x[i];
		ans = max(ans, pre[i]);
	}
	for (int i = n; i >= 1; i--) {
		suf[i] = v[n] - v[i - 1] - (c - x[i]);
		ans = max(ans, suf[i]);
	}
	vector <ll> premx(n + 1), sufmx(n + 2);
	for (int i = 1; i <= n; i++) {
		premx[i] = max(pre[i], premx[i - 1]);
	}
	for (int i = n; i >= 1; i--) {
		sufmx[i] = max(suf[i], sufmx[i + 1]);
	}
	for (int i = 1; i <= n; i++) {
		ans = max(ans, pre[i] - x[i] + sufmx[i + 1]);
		ans = max(ans, suf[n - i + 1] - (c - x[n - i + 1]) + premx[n - i]); 
	}
	cout << ans;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<bool> ok(n + 1, true);
	vector<int> dp(n + 1, 0);
	while(m--)
	{
		int x;
		cin >> x;
		ok[x] = false;
	}
	
	int mod = 1e9 + 7;
	dp[0] = 1;
	FOR(i, 1, n + 1)
	{
		if (!ok[i]) continue;
		dp[i] = dp[i - 1] + (i > 1 ? dp[i - 2] : 0);
		if (dp[i] >= mod) dp[i] -= mod;
	}
	
	cout << dp[n] << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

int main(void){
  int n , m;
  scanf("%d %d",&n,&m);

  int  p[100001] = {0} , t , ac = 0 ,wa = 0;
  char s[100001][2];

  for(int i = 0;i < m;i ++){
    scanf("%d %s",&t ,s[i]);
    if(p[t] >= 0 && p[t] != 1000000){
      if(s[i][0] == 'W'){
        p[t] ++;
      }
      else{
        wa += p[t];
        ac ++;
        p[t] = 1000000;
      }
    }
  }
  for(int i = 1;i <= 100000;i ++){
    if(p[i] < 0){
      wa -= p[i];
    }
    else if(p[i] > 0){
      wa += 0;

    }
  }
 
  printf("%d %d\n",ac,wa);

  return 0;
}

Measured memory_bytes: 768
#include <iostream>

int main()
{
    int a{}, b{}, c{};
    std::cin >> a >> b >> c;
    if (a + b + c > 21) {
        std::cout << "bust" << std::endl;
    } else {
        std::cout << "win" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

L = []



for i in range(10**5):
    M = N // K
    if i == 0:
        N = abs(N - K)
        L.append(N)
    else:
        if N > K:
            N = N - (K * M)
            L.append(N)
        else:
            N = abs(L[i-1] - K)
            L.append(N)


print(min(L))

Measured memory_bytes: 12772
#include <algorithm>
#include <iostream>
#include <utility>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::pair<long long, long long> p[n];
  for (int i = 0; i < n; ++i)
    std::cin >> p[i].first >> p[i].second;

  std::sort(p, p + n, [](const auto &a, const auto &b) {
    if (a.first == b.first)
      return a.second < b.second;
    return a.first < b.first;
  });

  for (int i = 0; i < n; ++i) {
    std::cout << p[i].first << " " << p[i].second << std::endl;
  }
}



Measured memory_bytes: 4696
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x); vector<ll> b(y); vector<ll> c(z);
	for( auto &i : a ) cin >> i;
	for( auto &i : b ) cin >> i;
	for( auto &i : c ) cin >> i;
	vector<ll> candy;
	for( int i = 0; i < x; ++i ){
		for( int j = 0; j < y; ++j ){
			candy.push_back( a[i] + b[j] );
		}
	}
	sort( candy.begin(), candy.end(), greater<ll>() );
	vector<ll> ab;
	int bound = min(k, x*y);
	for( int i = 0; i < bound; ++i ){
		ab.push_back( candy[i] );
	}
	vector<ll> cookie;
	for( int i = 0; i < bound; ++i ){
		for( int j = 0; j < z; ++j ){
			cookie.push_back( ab[i] + c[j] );
		}
	}
	sort( cookie.begin(), cookie.end(), greater<ll>() );
	for( int i = 0; i < k; ++i ){
		cout << cookie[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 43272
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
int main() {
	int s = 0; int x; cin >> x;
	rep(i,1,int(1e9)) {
		s += i;
		if (s >= x) { printf("%d\n",i); return 0; }
	}	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define N 1000

int lcs(char X[N], char Y[N]){
  int i, j, m, n;
  double c[N+1][N+1];
  double maxl = 0.0;
  m = strlen(X);
  n = strlen(Y);
  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(X[i-1] == Y[j-1]) c[i][j] = c[i-1][j-1] + 1;
      else c[i][j] = (int)fmax(c[i-1][j], c[i][j-1]);
    }
  }
  return c[m][n];
}

int main(){
  char s1[N], s2[N];
  int n, i;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",lcs(s1, s2));
  }
  return 0;
}

Measured memory_bytes: 8436
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vector<pll> ab(n);
    for (int i = 0; i < n; ++i) {
        cin >> ab[i].second >> ab[i].first;
    }
    sort(ab.begin(), ab.end()); // smaller b is first
    ll time = ab[0].first - ab[0].second;
    if (time < 0) {
        cout << "No"
             << "\n";
        return 0;
    }
    for (int i = 1; i < n; ++i) {
        time += ab[i].first - ab[i - 1].first;
        time -= ab[i].second;
        if (time < 0) {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    cout << "Yes"
         << "\n";

    return 0;
}

Measured memory_bytes: 3328