akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>

std::vector<int> GetIterArr(int N);
int InsertionSort(int *A, int N, int g);
int ShellSort(int *A, int N, std::vector<int> G);

int main() {
    int n, *A, counter;
    std::vector<int> G;

    std::cin >> n;

    A = (int *)calloc(n + 1, sizeof(int));
    if (!A) {
        std::cout << "ERROR! Could not allocate structure A." << std::endl;
    }

    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }
    
    /* generate and print iteration array */
    G = GetIterArr(n);
    std::cout << G.size() << std::endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) {
            printf(" ");
        } else {
            printf("\n");
        }
    }

    /* shell sort */
    counter = ShellSort(A, n, G);
    printf("%d\n", counter);

    /* print sorted array */
    for (int i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }

    return 0;
}

std::vector<int> GetIterArr(int N) {
    std::vector<int> G;
    int h;

    h = 1;
    while (1) {
        if (h > N) {
            break;
        }
        G.push_back(h);
        h = 3 * h + 1;
    }
    
    return G;
}

int InsertionSort(int *A, int N, int g) {
    int counter, val, j;

    counter = 0;
    for (int i = g; i < N; i++) {
        val = A[i];
        j = i - g;
        while (j >= 0 && A[j] > val) {
            A[j + g] = A[j];
            j -= g;
            counter++;
        }
        A[j + g] = val;
    }

    return counter;
}

int ShellSort(int *A, int N, std::vector<int> G) {
    int counter;

    counter = 0;
    for (int i = G.size() - 1; i >= 0; i--) {
        counter += InsertionSort(A, N, G[i]);
    }

    return counter;
}


Measured memory_bytes: 7204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[200000];
ll b[200000];
int main()
{
    ll n,k,i,j;
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-k;i++)
    {
        if(a[i]<a[i+k])
        {
            puts("Yes");
        }
        else
            puts("No");
    }
    return 0;

}


Measured memory_bytes: 5120
n = int(input())
a = list(map(int,input().split()))
q = int(input())
res = sum(a)
temp = [0]*100001
for x in a:
    temp[x] += 1
for i in range(q):
    b,c = map(int,input().split())
    res -= b*temp[b]
    temp[c] += temp[b]
    res += c*temp[b]
    temp[b] = 0
    print(res)

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

#define int long long

signed main() {
	ios::sync_with_stdio(false);

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

	vector<int> h(n);

	for (int i = 0; i < h.size(); i++) {
		cin >> h[i];
	}

	int count = 0;

	for (int i = 0; i < h.size(); i++) {
		if (h[i] >= k) {
			count++;
		}
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 1024
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let a = scan.word::<usize>();

    println!("{}", a + a * a + a * a * a);
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v

// AGC013 A - Sorted Arrays
int main(){
  ll n;
  cin >> n;
  vector<ll> A(n,0);
  rep(i,n) cin >> A[i];

  ll count = 0; // divided count

  int way = 0;
  ll num = 0;
  ll last = LONG_LONG_MIN;
  rep (i,n) {
    if (num == 0) {
      last = A[i];
      way = 0;
      ++num;
    } else if (num > 0 && way == 0) {
      ++num;
      if (last == A[i]) {
        continue; // 方向性定まらず
      } else if (last < A[i]) {
        way = 1;
        last = A[i];
      } else {
        way = -1;
        last = A[i];
      }
    } else {
      if (way == 1 && last > A[i] || way == -1 && last < A[i]) {
        ++count;
        way = 0;
        num = 1;
        last = A[i];
      } else {
        ++num;
        last = A[i];
      }
    }
  }

  cout << count + 1 << endl;

  return 0;
}


Measured memory_bytes: 4056
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <iostream>
using namespace std;
typedef long long LL;
const int Maxn = 1e5 + 6;
const int inf = 1000000000;
const LL Inf = 1LL<<60;
int main ()
{
	int n,x;
	scanf("%d%d",&n,&x);
	int a[109];
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int t = 0;
	while (x - a[t+1] >= 0 && t < n){
		t++;
		if (t == n){
			if (x - a[t] != 0) t--;
		}
		x -= a[t];
	}
	printf("%d\n",t);
	return 0;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 21:31:40
*/

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


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

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s;
	int cnt = 0;
	for( auto c : s ){
		if( c == 'o' ) ++cnt;
	}
	int win = 15-s.l_ength();
	if( cnt+win >= 8 ) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(){
	int n; cin >> n;
	
	int ans = 0;
	while((1 << ans) <= n) ans++; ans--;
	
	cout << (1 << ans) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	int n,k;
	cin >> n >> k;
	vec_i h(n);
	rep(i,n) cin >> h[i];

	vec_i dp(n, INF);
	dp[0] = 0;
	rep(i,n){
		loop(j, 1, k+1){
			if(i+j < n){
				int a = h[i],b = h[i+j];
				if(a < b) swap(a,b);
				dp[i+j] = min(dp[i+j], dp[i] + a - b);
			}else{
				break;
			}
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
from collections import Counter
H, W, M = map(int, input().split())
count_row = Counter()
count_col = Counter()
count_point = Counter()
for i in range(M):
    h, w = map(int, input().split())
    count_row[h] += 1
    count_col[w] += 1
    count_point[(h, w)] += 1

max_h, max_count_row = count_row.most_common()[0]
max_w, max_count_col = count_col.most_common()[0]
row_iter = [h for h, c in count_row.most_common() if c == max_count_row]
col_iter = [w for w, c in count_col.most_common() if c == max_count_col]
ans = max_count_row + max_count_col - 1
flag = False
for h in row_iter:
    for w in col_iter:
        if count_point[(h, w)] == 1:
            continue
        ans += 1
        flag = True
        break
    if flag:
        break
print(ans)

Measured memory_bytes: 242424
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int inf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s, a[2];
	cin >> s;
	char b[100];
	for (int i = 0; i < s.size(); i++)
		b[i] = s[i];
	sort(b, b + s.size());
	a[0] = "";
	for (int i = 0; i < s.size(); i++)
		a[0] += b[i];
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		b[i] = s[i];
	sort(b, b + s.size());
	reverse(b, b + s.size());
	a[1] = "";
	for (int i = 0; i < s.size(); i++)
		a[1] += b[i];
	if (a[0] < a[1]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc175/abc175_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 0;
  rep(i, N - 2) repi(j, i + 1, N - 1) repi(k, j + 1, N) {
    if (c[i] == c[j] || c[i] == c[k] || c[j] == c[k]) continue;
    vector<ll> a = {c[i], c[j], c[k]};
    sort(a.begin(), a.end());
    if (a[0] + a[1] > a[2]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
h, w = map(int, input().split())
def row_cut(p,q):
    res = 10**5
    for i in range(p):
        a = i * q
        b = ((p - i) // 2) * q
        c = (p * q) - a - b
        res = min(res, max(a,b,c) - min(a,b,c))
    return res 
def row_column_cut(p,q):
    res = 10**5
    for i in range(p):
        a = i * q
        b = (q // 2) * (p - i)
        c = (p * q) - a - b
        res = min(res, max(a,b,c) - min(a,b,c))
    return res
cand = [row_cut(h,w), row_cut(w,h), row_column_cut(w,h), row_column_cut(h,w)]
print(min(cand))

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

using namespace std;


int main()
{
          int n,m;
          int ans=0;
          cin>>n>>m;
          for(int i=0;i<n;i++)
                    for(int j=0;j<m;j++)
                    {
                              char c;
                              cin>>c;
                              ans+=(c=='#');
                    }
          if(ans==n+m-1)
                    cout<<"Possible";
          else
                    cout<<"Impossible";
}


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

// ループによる最大公約数
int gcd(int x, int y) {
  int r;
  if(x < y) swap(x, y);
  
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int n, x;
  cin >> n >> x;
  
  int i;
  vector<int> y(n);
  for(i = 0; i < n; i++){
    cin >> y.at(i);
    y.at(i) = abs(x - y.at(i));
  }
  
  int ans = y.at(0);
  
  for(i = 1; i < n; i++){
    ans = gcd(y.at(i), ans);
  }
  
  cout << ans << endl;
}

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

using namespace std;

vector<vector<long long int>>D;
long long int N;

vector<long long int>solve( long long int now, long long int prev ) {
	for( auto x : D[now] ) {
		if( x == N - 1 ) {
			return vector<long long int>( 1, N - 1 );
		}
		if( x == prev ) {
			continue;
		}
		auto xx = solve( x, now );
		if( xx.size() ) {
			xx.push_back( x );
			return xx;
		}
	}
	vector<long long int >ret;
	return ret;
}

int main() {
	cin >> N;
	D = vector<vector<long long int>>( N );
	for( size_t i = 0; i < N - 1; i++ ) {
		long long int a, b;
		cin >> a >> b;
		a--; b--;
		D[a].push_back( b );
		D[b].push_back( a );
	}

	auto ret = solve( 0, -1 );
	ret.push_back( 0 );

	auto F = ret[ret.size() / 2], S = ret[ret.size() / 2 - 1];

	vector<long long int>lenF( N, LLONG_MAX / 6 ), lenS( N, LLONG_MAX / 6 );

	lenF[S] = -1;
	lenS[F] = -1;

	queue<long long int>Fque, Sque;
	Fque.push( F ); Sque.push( S );


	long long int Fcount = 0, Scount = 0;
	while( Fque.size() ) {
		auto now = Fque.front(); Fque.pop();
		if( lenF[now] == S ) {
			continue;
		}
		if( lenF[now] == LLONG_MAX / 6 ) {
			lenF[now] = 1;
			for( auto x : D[now] ) {
				Fque.push( x );
			}
			Fcount++;
		}
	}


	while( Sque.size() ) {
		auto now = Sque.front(); Sque.pop();
		if( lenS[now] == F ) {
			continue;
		}
		if( lenS[now] == LLONG_MAX / 6 ) {
			lenS[now] = 1;
			for( auto x : D[now] ) {
				Sque.push( x );
			}
			Scount++;
		}
	}

	if( Fcount > Scount ) {
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke" << endl;
	}
}

Measured memory_bytes: 19188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5], k;
  string ans = "Yay!";
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < 5; j++){
      if(abs(a[i]-a[j])>k)ans = ":(";
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define per(i,a,b)  for(ll i=b-1;i>=a;i--)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
#define MOD 998244353
using namespace std;
const int N=2e5+5;
ll lvl[N];
bool vis[N];
/*bool isprime(ll x)
{
    for(ll i=2;(i*i)<=x;i++)
    {
        if(x%i==0) return 0;
    }
    return 1;
}
ll power(ll x,ll n)
{
    ll res=1;
    while(n>0){
    if(n%2) res=(res*x)%mod;
    x=(x*x)%mod;
    n=n/2;}
    return res;
}*/
void solve()
{
            ll n,m,k,l=0,r=0,z,sum1=0,h,res=0,a,b,c,d,x=0,y=0;
            cin>>n>>m;
            vector<int>  adj[n+1];
            rep(i,0,n-1)
            {
                cin>>x>>y;
                adj[x].pb(y);
                adj[y].pb(x);
            }
            rep(i,0,m)
            {
                cin>>x>>y;
                lvl[x]+=y;
            }
            queue<int> q;
            q.push(1);
            vis[1]=1;
            while(!q.empty())
            {
                x=q.front();
                q.pop();
                for(auto k:adj[x])
                {
                    if(!vis[k])
                    {   vis[k]=1;
                        q.push(k);
                        lvl[k]+=lvl[x];
                    }
                }
            }
            rep(i,1,n+1) cout<<lvl[i]<<" ";




            }

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


Measured memory_bytes: 16500
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, M;
    cin >> N >> M;
    long long res = 100 * (N - M);
    res += 1900 * M;
    res *= pow(2, M);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 桁DP, Lを超えないものと保留のもの
MOD = 10 ** 9 + 7
L = sr()
dp_dec = 1 # decide
dp_res = 2 # reserve
length = len(L)
for i in range(1, length):
    x, y = dp_dec, dp_res
    if L[i] == '1':
        dp_dec = x * 3 + y
        dp_res = y * 2
    else:
        dp_dec = x * 3
        dp_res = y

answer = dp_dec + dp_res
print(answer % MOD)


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

#define ll                  long long int
#define llu                 long long unsigned
#define ld                  long double
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define NUM                 1000000
#define PI		            2*acos(0.0)
#define maximum             (-1*INF)
#define READ(f) 	        freopen("f", "r", stdin)
#define WRITE(f) 	        freopen("f", "w", stdout)
const int INF = 1e5 + 10 ;

int main()
{
    ll n, p;
    cin>>n>>p;
    cout<<n-p+1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc,char **argv)
{
  int maxid, n, s, t, max, id;

  while(1){
    cin >> n;
    if(n == 0){
      break;
    }

    maxid = max = -1;
    for(int i = 0; i < n; i++){
      cin >> id >> s >> t;
      if(max < s+t){
	max = s + t;
	maxid = id;
      }
    }
    cout << maxid << " " << max << endl;
  }

  return 0;
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=100005,mod=4000007;
int n,father[N];
queue<PI> q;
ll ycl[N];
vector<int> v[N];
struct has_table{
	bool has[mod]; int b[mod];
	ll a[mod],v[mod];
	inline void insert(int xx,int yy,int jb){
		ll x=ycl[xx]*n+ycl[yy];
		for(int i=x%mod;;i=i+1==mod?0:i+1){
			if(!has[i]||a[i]==x){
				has[i]=1; a[i]=x; b[i]+=jb; return;
			}
		}
	}
	inline void clear(int xx,int yy){
		ll x=ycl[xx]*n+ycl[yy];
		for(int i=x%mod;;i=i+1==mod?0:i+1){
			if(!has[i]||a[i]==x){
				has[i]=1; a[i]=x; b[i]=0; return;
			}
		}
	}
	inline int find(int xx,int yy){
		ll x=ycl[xx]*n+ycl[yy];
		for(int i=x%mod;;i=i+1==mod?0:i+1){
			if(!has[i]||a[i]==x){
				return b[i];
			}
		}
	}
}Ma,er;
inline int getfather(int x){
	return father[x]==x?x:father[x]=getfather(father[x]);
}
int main(){
	srand(time(0));
	n=read();
	for(int i=1;i<=n;i++)ycl[i]=(ll)rand()<<32|rand();
    for(int i=1;i<=n*2-2;i++){
        int x=read(),y=read(); 
        v[x].push_back(y); v[y].push_back(x);
        Ma.insert(x,y,1); Ma.insert(y,x,1);
        if(Ma.find(x,y)==2)q.push(mp(x,y));
    }
    for(int i=1;i<=n;i++)father[i]=i;
    while(!q.empty()){
    	int x=q.front().first,y=q.front().second; q.pop();
		x=getfather(x); y=getfather(y); if(x==y){puts("NO"); return 0;}
		if(v[x].size()<v[y].size()) swap(x,y); 
		er.insert(x,y,1); er.insert(y,x,1); 
		//cout<<x<<" "<<y<<endl;
        for(unsigned i=0;i<v[y].size();i++){ 
            int to=v[y][i]; if(er.find(y,to)){continue;}
            //if(y!=3||to!=3)cout<<x<<" "<<y<<" "<<to<<" "<<er.find(y,to)<<endl;
            er.insert(to,y,1); er.insert(y,to,1); v[to].push_back(x);
            Ma.insert(to,x,1); Ma.insert(x,to,1);
            if(Ma.find(to,x)==2)q.push(mp(to,x));
            v[x].push_back(to); er.clear(x,to);
        }
        father[y]=x; v[y].clear();
    }
    int ans=0;
    for(int i=1;i<=n;i++)ans+=father[i]==i;
    if(ans==1) puts("YES"); else puts("NO");
    return 0;
}

Measured memory_bytes: 113024
import sys
from collections import Counter
def main():
    input = sys.stdin.readline
    N = int(input())
    S = input().rstrip()

    C = Counter(S)
    ans = Mint(1)
    for a in C.values():
        ans *= a+1
    print(ans - 1)

class Mint:
    def __init__(self, value=0, mod=10**9+7):
        self.value = ((value % mod) + mod) % mod
        self.mod = mod

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, self.mod
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        return (u + self.mod) % self.mod

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.val
    def __neg__(self): return Mint(-self.value, self.mod)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % self.mod
        return self
    def __add__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other) + self.mod) % self.mod
        return self
    def __sub__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj -= other
        return new_obj
    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % self.mod
        return self
    def __mul__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other, self.mod)
        self *= other.inverse
        return self
    def __floordiv__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj //= other
        return new_obj
    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj //= self
        return new_obj

if __name__ == '__main__':
    main()



Measured memory_bytes: 39408
N, M, X, Y= map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

z_kouho = [i for i in range(X+1, Y+1) if max(x) < i <= min(y)]
if z_kouho:
    ans = "No War"
else:
    ans = "War"
print(ans)

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

namespace AGC031
{
    class A
    {
        static int _Mod = 1000000007;

        static void Main(string[] args)
        {
            int[] h = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int N = h[0];
            string S = Console.ReadLine();

            Dictionary<char, int> dic = new Dictionary<char, int>();
            for(int i = 0; i < S.Length; i++)
            {
                if (!dic.ContainsKey(S[i])) dic.Add(S[i], 0);
                dic[S[i]]++;
            }

            long sum = 1;
            foreach(int val in dic.Values)
            {
                sum *= val+1; sum %= _Mod;
            }

            sum--;
            if (sum < 0) sum += _Mod;

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13664
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

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

int main(void){
    ll n, a, b, c, d, cnt=0;
    cin >> n >> a >> b >> c >> d;
    for(int i=0; i<n;i++){
        if(i*c-(n-1-i)*d <= b-a && b-a <= d*i-(n-1-i)*c){
            cnt++;
        }
    }
    if(cnt > 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC141 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
a = LI()
h = []
for i in a:
    heappush(h,-i)
for i in range(m):
    x = heappop(h)
    x = -x
    x //= 2
    heappush(h,-x)
print(-sum(h))

Measured memory_bytes: 60952
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 998244353;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, k;
    cin>>n>>k;
    int l[k], r[k];
    loop(i,0,k) cin>>l[i]>>r[i];

    LL ans[n+1], sum[n+1], ans1;
    sum[0] = 0; ans[1] = 1; sum[1] = 1;

    loop(i,2,n+1)
    {
        ans[i] = 0;
        loop(j,0,k)
        {
            if(i - r[j] >= 1)
            {
                ans1 = (sum[i - l[j]] + MOD - sum[i - r[j] - 1]) % MOD;
                ans[i] = (ans[i] + ans1) % MOD;
            }
            else if(i - l[j] >= 1)
            {
                ans[i] = (ans[i] + sum[i - l[j]]) % MOD;
            }
        }

        sum[i] = (sum[i-1] + ans[i]) % MOD;
    }

    cout<<ans[n]<<'\n';

    return 0;
}


Measured memory_bytes: 6760
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int n, r,ans;
    cin >> n >> r;
    if(n>=10){
        ans=r;
    }
    else{
        ans=r+100*(10-n);
    }
    
    
   
    cout << ans << endl;
    

    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b,c;
	cin >> a >> b >> c;
	if (a == b && a!=c&&b!=c) {
		cout << "Yes";
	}
	else if (a == c && c != b && b != a) {
		cout << "Yes";
	}
	else if (c == b && a != b && a != c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
from itertools import combinations
N, K = (list)(map(int, input().split()))
pos_x = []
pos_y = []

for _ in range(N):
    a, b = map(int, input().split())
    pos_x.append(a)
    pos_y.append(b)


def count_point(x, y):
    ret = 0
    x_min = min(x)
    x_max = max(x)
    y_min = min(y)
    y_max = max(y)
    for i in range(N):
        if x_min <= pos_x[i] <= x_max and y_min <= pos_y[i] <= y_max:
            ret += 1
    return ret


def calc_area(x, y):
    ret = (x[1]-x[0])*(y[1]-y[0])
    return (abs)(ret)


set_x = set(pos_x)
set_y = set(pos_y)


area = float('inf')
for cand_x in combinations(set_x, 2):
    for cand_y in combinations(set_y, 2):
        if count_point(cand_x, cand_y) == K:
            area = min(area, calc_area(cand_x, cand_y))
print(area)


Measured memory_bytes: 51932
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        long X = scanner.nextLong();
        long money = 100;
        long rishi = 1;
        long year = 0;

        for(;;){
            year++;
            money = money + rishi;
            rishi = money / 100;
            if(X <= money) {
                System.out.println(year);
                return;
            }
        }

    }
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    int n, x1, x2, sum = 0; cin>>n;
    vector<int> a(n);
    for(int i = 0; i<n; i++){
        cin>>a[i];
        sum += a[i];
    }

    x1 = sum/n;
    x2 = (sum+n-1)/n;
    ll cost1 = 0, cost2 = 0;
    for(int x : a){
        cost1 += (x-x1)*(x-x1);
        cost2 += (x-x2)*(x-x2);
    }
    cout<<min(cost1, cost2)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

template<int mod>
struct mi {
	int val;
	mi() { val = 0; }
	mi(const LL& v) {
		val = (-mod <= v && v <= mod) ? v : v % mod;
		if(val < 0) val += mod;
	}

	friend ostream& operator<<(ostream &os, const mi &a) {
		return os << a.val;
	}
	friend istream& operator>>(istream &is, mi &a) {
		return is >> a.val;
	}

	friend bool operator==(const mi &a, const mi &b) {
		return a.val == b.val;
	}
	friend bool operator!=(const mi &a, const mi &b) {
		return !(a == b);
	}
	friend bool operator<(const mi &a, const mi &b) {
		return a.val < b.val;
	}
	friend bool operator<=(const mi &a, const mi &b) {
		return a.val <= b.val;
	}

	mi operator-() const { return mi(-val); }
	mi& operator+=(const mi &m) {
		if((val += m.val) >= mod) val -= mod;
		return *this;
	}
	mi& operator-=(const mi &m) {
		if((val -= m.val) < 0) val += mod;
		return *this;
	}
	mi& operator*=(const mi &m) {
		val = (LL) val * m.val % mod;
		return *this;
	}
	friend mi qpow(mi a, LL n) {
		if(n == 0) return 1;
		if(n % 2 == 1) return qpow(a, n - 1) * a;
		return qpow(a * a, n / 2);
	}
	friend mi inv(const mi &a) {
		assert(a != 0); return qpow(a, mod - 2);
	}
	mi& operator /=(const mi &m) { 
		return (*this) *= inv(m); 
	}

	friend mi operator+(mi a, const mi &b) { return a += b; }
	friend mi operator-(mi a, const mi &b) { return a -= b; }
	friend mi operator*(mi a, const mi &b) { return a *= b; }
	friend mi operator/(mi a, const mi &b) { return a /= b; }
};
using MI = mi<int(1e9 + 7)>;

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

	int n, c;
	cin >> n >> c;

	vector<int> a(n + 1), b(n + 1);
	FOR(i, 1, n) cin >> a[i];
	FOR(i, 1, n) cin >> b[i];

	int q = 0;
	FOR(i, 1, n) q = max(q, b[i]);

	vector<vector<MI>> pref(c + 1, vector<MI>(q + 1));
	vector<MI> pw(q + 1, 1);
	FOR(i, 0, c) {
		FOR(j, 1, q) pref[i][j] = pref[i][j - 1] + pw[j];
		FOR(j, 1, q) pw[j] *= j;
	}

	vector<vector<MI>> dp(n + 1, vector<MI>(c + 1));
	dp[0][0] = 1;
	FOR(i, 1, n) FOR(j, 0, c) FOR(k, 0, j)
		dp[i][j] += dp[i - 1][j - k] * (pref[k][b[i]] - pref[k][a[i] - 1]);

	cout << dp[n][c] << "\n";
}


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

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  
  int visited[n], ans[n - 1] = {};
  queue<int> q;
  
  for (int i = 0; i < n - 1; ++i) {
    memset(&visited[0], 0, 4 * n);
    int steps(-1);
    q.push(i);
    
    while (!q.empty()) {
      int s(q.size());
      while (s--) {
        int c(q.front());
        q.pop();
        if (visited[c]) continue;
        visited[c] = 1;
        if (c > i) ans[steps]++;
        if (c < n - 1) q.push(c + 1);
        if (c > 0) q.push(c - 1);
        if (c == x) q.push(y);
      }
      steps++;
    }
  }
  for (int i = 0; i < n - 1; ++i)
    cout << ans[i] << '\n';
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        s: chars,
    }
    let mut c = s[0];
    for i in 1..s.len() {
        if c == s[i] {
            println!("Bad");
            return;
        }
        c = s[i];
    }
    println!("Good");
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h, w, n, s=0, sw=0, c1=0, c2=0;
    scanf("%d%d%d", &h,&w,&n);
    for(int j=0; j<h; j++)
    {
        s=s+h;
        c1++;
        if(s>=n)
        {
            break;
        }
    }
    for(int i=0; i<w; i++)
    {
        sw=sw+w;
        c2++;
        if(sw>=n)
        {
            break;
        }
    }
    if(c1<c2)
        printf("%d",c1);
    else
        printf("%d",c2);

}


Measured memory_bytes: 256
#C
import fractions
a,b,c,d = map(int,input().split())

def lcm(x,y):
    return (x*y) // fractions.gcd(x,y)

def div_n(a,b,n):
    if a%n != 0:
        marker1 = a + (n - a%n)
    else:
        marker1 = a
        
    if b%n != 0:
        marker2 = b - (b%n)
    else:
        marker2 = b
    return (marker2 - marker1)//n + 1

all_cnt = (b-a)+1
a_cnt = div_n(a,b,c)
b_cnt = div_n(a,b,d)
c_cnt = div_n(a,b,lcm(c,d))

print(all_cnt - a_cnt - b_cnt + c_cnt)

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

#define ll long long
#define endl "\n"
#define FILEIN freopen("input.txt", "r", stdin)


int main(){
    // FILEIN;
    //ll n, flag = 1, sum = 0, sum2 = 0; cin>>n;
    //while(n--){
    //    ll ar[3] = {};
    //    for(int i = 0; i<3; i++){
    //        cin>>ar[i];
    //    }
    //    sort(ar, ar+3);
    //    if(flag){
    //        sum2 += ar[1];
    //        sum += ar[2];
    //    }else{
    //        sum2 += ar[2];
    //        sum += ar[1];
    //    }
    //    flag = !flag;
    //}
    //if(sum > sum2){
    //    cout<<sum<<endl;
    //}else{
    //    cout<<sum2<<endl;
    //}

    double h, a;cin>>h>>a;
  	cout<<ceil(h/a)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1e18;

int main() {

  int n; cin >> n;
  vector<string> a(n);
  vector<int> c(26, inf);
  for(int i=0; i<n; i++){
    cin >> a[i];
    vector<int> tmp(26, 0);
    for(int j=0; j<a[i].size(); j++){
      tmp[ a[i][j]-'a' ]++;
    }
    for(int j=0; j<26; j++){
      c[j] = min(c[j], tmp[j]);
    }
  }
  string ans = "";
  for(int i=0; i<26; i++){
    ans += string(c[i], 'a'+i);
  }
  cout << ans << endl;




  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc127/tasks/abc127_c
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  int L = 1, R = N;
  
  for (int i = 1; i <= M; i++){
    int newL, newR;
    cin >> newL >> newR;
    if (L < newL) L = newL;
    if (newR < R) R = newR;
    }

  int ans = 0;
  if (R - L >= 0) ans = R - L + 1;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
int main(void){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> b(n,0),c(n,0);
    rep(i,n){
        for(int j=0;j<i;j++){
            if(a[i]>a[j])b[i]++;
        }
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j])c[i]++;
        }
    }
    ll res=0;
    rep(i,n){
        ll buf=(c[i]*k%mod+(b[i]+c[i])*((k-1)*k/2%mod))%mod;
        res=(res+buf)%mod;
        //cout<<res<<endl;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,x,t;
 	cin>>n>>x>>t;
 	ll wh=n/x+(n%x!=0);
 	cout<<(wh)*t<<endl;
    return 0;
}

Measured memory_bytes: 3636
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var n = Console.ReadLine().ToInt32();
        var an = Console.ReadLine().SplittedStringToInt32List();
        var dp = new int[n + 1];

        dp[0] = 0;
        dp[1] = Math.Abs(an[1] - an[0]);
        for (int i = 0; i < n - 2; i++)
        {
            dp[i + 2] = Math.Min(dp[i + 1] + Math.Abs(an[i + 2] - an[i + 1]), dp[i] + Math.Abs(an[i + 2] - an[i]));
        }
        Console.WriteLine(dp[n - 1]);
        Console.ReadLine();
    }


    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    #endregion
}


Measured memory_bytes: 17632
#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) (a).size())

int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%d %d\n", min(a, b), max(0, a + b - n));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll t[105];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	ll ans = 1LL;
	for (int i = 0; i < n; i++) {
		ans = lcm(ans, t[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static class Point {
		double x;
		double y;
		public Point(double x, double y) {
			this.x = x;
			this.y = y;
		}
		public String toString() {
			return String.format("%.8f %.8f", x, y);
		}
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		reader.close();
		Point start = new Point(0, 0);
		Point end = new Point(100, 0);
		System.out.println(start);
		getKochCurve(0, n, start, end);
		System.out.println(end);
	}

	private static void getKochCurve(int i, int n, Point start, Point end) {		
		if (i < n) {
			Point firstPoint = getPoint(start, end, 1.0/3.0);
			Point thirdPoint = getPoint(start, end, 2.0/3.0);
			Point secondPoint = getSecondPoint(start, end, firstPoint, thirdPoint);
			getKochCurve(i + 1, n, start, firstPoint);
			System.out.println(firstPoint);
			getKochCurve(i + 1, n, firstPoint, secondPoint);
			System.out.println(secondPoint);
			getKochCurve(i + 1, n, secondPoint, thirdPoint);
			System.out.println(thirdPoint);
			getKochCurve(i + 1, n, thirdPoint, end);
		}
	}

	private static Point getPoint(Point start, Point end, double d) {
		double deltaX = end.x - start.x;
		double deltaY = end.y - start.y;
		deltaX = deltaX * d;
		deltaY = deltaY * d;				
		return new Point(start.x + deltaX, start.y + deltaY);
	}

	private static Point getSecondPoint(Point start, Point end, Point second, Point third) {
		double deltaX = third.x - second.x;
		double deltaY = third.y - second.y;
		double len = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));		
		double x;
		double y;
		if (deltaY == 0) {
			x = start.x + (end.x - start.x) / 2;
			double height = Math.sqrt((Math.pow(len, 2) - Math.pow(len / 2.0, 2)));
			if (start.x < end.x) {
				y = second.y + height;
			} else {
				y = second.y - height;
			}
		} else if (start.x < end.x && start.y < end.y) {
			x = start.x;
			y = third.y;
		} else if (start.x < end.x && start.y > end.y) {
			x = end.x;
			y = second.y;
		} else if (start.x > end.x && start.y < end.y) {
			x = end.x;
			y = second.y;
		} else {
			x = start.x;
			y = third.y;
		}
		return new Point(x, y);
	}
}



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

int main(void)
{
    char num[1001] = {0} ;
    int i=0 ;
    int number=0 ;
    int mem=0 ;

    while (1){

        scanf("%s",num);

        if (num[0]=='0' && num[1]=='\0') break;

        for (i=0 ;i<1001 ;i++){

            if (num[i]=='\0') break;

            number=number+(num[i]-'0');

        }

        printf("%d\n",number);
        memset(num ,'\0' ,sizeof num);
        number=0;

    }

    return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
int n,ans,t,mx;
string s;
int sum1(string s1,string s2)
{
	int b[200]={0},p=0;
	for (int i=0;i<s1.size();i++)
	{
 		b[s1[i]]++;
		int f=s2.find(s1[i]);
		if (f>=0 && b[s1[i]]==1) p++;
	}
	return p;
}
int main()
{
	cin>>n>>s;
	for (int i=1;i<n;i++)
	{
		string s1=s.substr(0,i);
		string s2=s.substr(i,n-1);
		ans=sum1(s1,s2);
		mx=max(mx,ans);
	}
	cout<<mx;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int main(){
	int x;
	cin >> x;
	
	cout << (x+1)%2 << endl;
	
	return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);

		//????´¢??????????????????????????????
		String w = scan.next();

		//??????????????£????????¨????????????????????????????????¨?????°????????????
		int count = 0;

		while(true){
			//????????????1?????????????????????
			String t = scan.next();

			//???????????¶
			if( t.equals("END_OF_TEXT")){
				break;
			}
			//??§???????°????????????????????????????
			if(t.equalsIgnoreCase(w)){
				//true??????????????????
				count++;
			}
		}
		//???????????¨???
		System.out.println(count);

	}

}

Measured memory_bytes: 26044