akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

// えびちゃんの make_vector (ここから)
template <typename Tp, size_t N>
std::vector<Tp> make_vector_detail(std::vector<size_t>& sizes, typename std::enable_if<(N == 1), const Tp&>::type x) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector_detail(std::vector<size_t>& sizes, typename std::enable_if<(N > 1), const Tp&>::type x) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector_detail<Tp, N-1>(sizes, x))>(size, make_vector_detail<Tp, N-1>(sizes, x));
}

template <typename Tp, size_t N>
auto make_vector(const size_t(&sizes)[N], const Tp& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return make_vector_detail<Tp, N>(s, x);
}
// えびちゃんの make_vector (ここまで)

signed main(){
    
    int a, b; cin >> a >> b;
    if(a <= 5) cout << 0 << endl;
    else if(a <= 12) cout << b/2 << endl;
    else cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int m, f, r;
	
	while(1){
		
		cin >> m >> f >> r;
		
		if ( m == -1 && f == -1 && r == -1 ) 
			break;
		else if ( m == -1 || f == -1)
			cout << 'F' << endl;
		else if ( m + f >= 80 ) 
			cout << 'A' << endl;
		else if ( m + f >= 65 && m + f < 80 ) 
			cout << 'B' << endl;
		else if ( ( m + f >= 50 && m + f < 65 ) || ( r >= 50 )) 
			cout << 'C' << endl;
		else if ( m + f >= 30 && m + f < 50 )
			cout << 'D' << endl;
		
		else if ( m + f < 30 ) 
			cout << 'F' << endl;
	
	}
	
	return 0;
}

Measured memory_bytes: 1152
struct Combination {
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
}

impl Combination {
    const MOD: usize = 1_000_000_007;

    fn new(n: usize) -> Combination {
        let mut fact = vec![0; n + 1];
        let mut inv_fact = vec![0; n + 1];
        fact[0] = 1;
        for i in 1..=n {
            fact[i] = fact[i - 1] * i % Self::MOD;
        }
        inv_fact[n] = Self::pow(fact[n], Self::MOD - 2);
        for i in (1..=n).rev() {
            inv_fact[i - 1] = inv_fact[i] * i % Self::MOD;
        }

        Combination { fact, inv_fact }
    }

    fn pow(mut a: usize, mut n: usize) -> usize {
        let mut res = 1;
        while n > 0 {
            if n & 1 > 0 {
                res = res * a % Self::MOD;
            }
            a = a * a % Self::MOD;
            n >>= 1;
        }
        res
    }

    fn p(&self, n: usize, r: usize) -> usize {
        self.fact[n] * self.inv_fact[n - r] % Self::MOD
    }
    
    fn c(&self, n: usize, r: usize) -> usize {
        if n < r { return 0; }
        let tmp = self.inv_fact[n - r] * self.inv_fact[r] % Self::MOD;
        self.fact[n] * tmp % Self::MOD
    }
}

fn main() {
    const MOD: usize = 1_000_000_007;

    let (n, m): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let comb = Combination::new(m);
    let mut res = comb.p(m, n);
    for i in 1..=n {
        if i % 2 == 1 {
            res += MOD;
            res -= comb.p(m - i, n - i) * comb.c(n, i) % MOD;
            res %= MOD;
        } else {
            res += comb.p(m - i, n - i) * comb.c(n, i) % MOD;
            res %= MOD;
        }
    }
    let ans = res * comb.p(m, n) % MOD;
    println!("{}", ans);
}

Measured memory_bytes: 9604
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
ll xx(ll x){
    return x*x*x*x*x;
}
int main()
{
    ll x;
    cin >> x;
    for(ll a = -100; a <= 7000;a++){
        for(ll b = -100; b <= 7000;b++){
            if(xx(a)-xx(b) == x){
                cout << a << ' ' << b<< endl;
                exit(0);
            }
        }
    }
    
}

Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int a,b,M,m,g;
	
	while(cin>>a>>b){
		if(a>b){M=a;m=b;} else{M=b;m=a;}
		for(int i=1;i<=M;i++){
			if(M%i==0&&m%(M/i)==0){g=M/i;break;}
			}
		cout<<g<<" "<<a/g*b<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
string s;
cin>>s;
int ans=0;
for(int i=0;i+1<n;i++)
{
int j=i+1;
while(s[j]==s[j-1] && j<n)
{
j++;
}
ans++;
i=j-1;
}
if(s[n-1]!=s[n-2])
{
ans++;
}
cout<<ans<<endl;
}


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

int main(){
	int k,a;
	char s[101]={};
	cin>>k;
	cin>>s;
	a=strlen(s);
	if(a<=k){
		for(int i=0; i < a ;i++){
			cout<<s[i];
		}
		cout<<endl;
	}else{
		for(int i=0; i < k ;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	//cout<<a<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#define FOR(x) for(int x=0;x<4;x++)
using namespace std;

int main(){
  int a[4]={};
  int b[4]={};
  while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
    cin>>b[0]>>b[1]>>b[2]>>b[3];
    int hit = 0;
    int blow = 0;
    FOR(i){
      FOR(j){
	if(a[i]==b[j]){
	  if(i==j) hit++;
	  else blow++;
	}
      }
    }
    cout<<hit<<" "<<blow<<endl;
  }
  return 0;
}

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

int main(){
	string s;
	cin>>s;
	cout<<s[0]<<(s.size()-2)<<s[s.size()-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
gene = ["A","T","G","C"]
ans=0
counter=0
for i in range(len(s)):
	for j in range(i,len(s)):
		if(s[j] in gene):
			counter += 1
		else:
			if(counter > ans):
				ans=counter
			counter=0
			break
	if(counter > ans):
		ans=counter
	counter=0
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
	int A,B,T;
	cin >> A >> B >> T;

	int sum=0;

	for(int i=1; i<=T; i++){
		if(i%A==0){
			sum+=B;
		}
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prl puts("\n------------------\n")
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prl 
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}




int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif

    string s;
    sf(s);
    int n = s.size();
    ll ans = 0, cnt = 0;
    rep(i, 0, n - 1) {
        if (s[i] == 'A') ++cnt;
        else if (i + 1 < n && s[i] == 'B' && s[i + 1] == 'C') {
            ans += cnt;
            ++i;
        }else cnt = 0;
    }
    cout << ans << endl;

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 640
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A, B = sorted(A), sorted(B)
m1 = A[N//2] + A[(N-1)//2]
m2 = B[N//2] + B[(N-1)//2]
print((m2 - m1) // (N % 2 + 1) + 1)

Measured memory_bytes: 28596
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>

//AOJ0073
#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

int main(void){

int x,h;
char k;
	while(cin >> x >> h){
		if(x==0 && h==0 || cin.eof()) break;
		double trg = sqrt(x*x/4.00 + 1.00*h*h) * x * 0.5;
		
		printf("%.8f\n",trg*4+x*x*1.00);
	}
	return 0;
	
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

vector<int> path[100010];
ll dp[2][100010];
// white, black
bool visited[100010];

void dfs(int v) {
    visited[v] = true;

    dp[0][v] = dp[1][v] = 1;

    for (int sv : path[v]) {
        if (visited[sv]) continue;
        dfs(sv);
        dp[0][v] *= dp[0][sv] + dp[1][sv];
        dp[1][v] *= dp[0][sv];

        for (int i = 0; i < 2; ++i) {
            dp[i][v] %= MOD;
        }
    }

    return;
}

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

    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        path[u].push_back(v);
        path[v].push_back(u);
    }

    dfs(0);
    cout << (dp[0][0] + dp[1][0]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 11520
fun main(args: Array<String>) {
    val (n, l) = readLine()!!.split(' ').map(String::toLong)
    val aji = (1..n).map { l + it - 1 }
    val ajiSum = aji.sum()

    var sa = Long.MAX_VALUE
    var aji2 = ajiSum
    for (i in 0 until n) {
        val ajiSum2 = aji.filterIndexed { index, l -> index.toLong() != i }.sum()
        val tsa = Math.abs(ajiSum - ajiSum2)
        if (tsa < sa) {
            sa = tsa
            aji2 = ajiSum2
        }
    }
    println(aji2)
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  int N;
  ll K;
  std::cin >> N >> K;
  std::vector<ll> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }

  std::sort(A.begin(), A.end());
  ll l = - INF, r = INF;
  while(l + 1 < r) {
    ll x = (l + r) / 2;
    bool ok = [&] {
      ll tot = 0;
      rep(i, N) {
        if(A[i] < 0) {
          int l = -1, r = N;
          while(l + 1 < r) {
            int c = (l + r) / 2;
            if(A[c] * A[i] < x) {
              r = c;
            } else {
              l = c;
            }
          }
          tot += N - r;
        } else {
          int l = -1, r = N;
          while(l + 1 < r) {
            int c = (l + r) / 2;
            if(A[c] * A[i] < x) {
              l = c;
            } else {
              r = c;
            }
          }
          tot += r;
        }
        if(A[i] * A[i] < x) {
          --tot;
        }
      }
      tot /= 2;
      return tot < K;
    }();
    if(ok) {
      l = x;
    } else {
      r = x;
    }
  }
  std::cout << l << '\n';
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cntw = 0;
    int cnte = 0;
    vi w(n+1, 0);
    vi e(n+1, 0);
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'W') cntw++;
        else cnte++;
        w[i+1] = cntw;
        e[i+1] = cnte;
    }
    int idx;
    int mn = INF;
    for(int i = 1; i <= n; i++){
        int op = w[i-1] + e[n] - e[i];
        if(op < mn){
            mn = op;
            idx = i;
        }
    }
    cout << mn;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int n, s, e;
vector<vector<int>> g;

vector<bool> marked;
vector<int> route;

bool find_route(int u, int v) {
	marked[u] = true;
	route.push_back(u);
	if (u == v)
		return true;
	bool found = false;
	for (int w: g[u]) {
		if (marked[w]) continue;
		found = found || find_route(w, v);
		if (found)
			break;
	}
	if (!found) {
		route.pop_back();
	}
	return found;
}

vector<int> height;

int find_height(int v, int parent) {
	height[v] = 0;
	for (int u: g[v]) {
		if (u == parent) continue;
		height[v] = max(find_height(u, v) + 1, height[v]);
	}
	return height[v];
}

int main() {
	cin >> n >> s >> e;
	s--, e--;
	g.assign(n, {});
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	route.clear();
	marked.assign(n, false);
	find_route(s, e);

	int mid = route[(int)route.size() / 2 - 1];
	int mid_parent = route[(int)route.size() / 2];
	
	height.resize(n, -1);
	find_height(mid, mid_parent);

	cout << height[mid] + ((int)route.size() + 1) / 2 - 1 << '\n';

	return 0;
}


Measured memory_bytes: 13912
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <atcoder/all>

// g++-10 c.cpp -std=c++17 -I .

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,m,a,b;
	std::cin >> n >> m;
	atcoder::dsu uf(n);
	while(m--){
		std::cin >> a >> b;
		--a; --b;
		uf.merge(a,b);
	}
	std::cout << (uf.groups().l_ength()-1) << std::endl;
	return 0;
}



Measured memory_bytes: 8972
def main2():
    N = int(input())
    R = []

    for _ in range(N):
        R.append(int(input()))
    
    maxv = -10**10 
    minv = R[0]
    for i in range(1, N):
        maxv = max(maxv, R[i]-minv)
        minv = min(minv, R[i])

    print(maxv)

main2()


Measured memory_bytes: 13592
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

const int maxn=1e6;
int a[maxn];
int b[maxn];
int cnt;

void merge(int l,int mid,int r)
{
	int p1=l,p2=mid+1;//双指针
	int pos=l;//当前位置 
	while(p1<=mid&&p2<=r){
		cnt++;
		if(a[p1]<a[p2]){
			b[pos++]=a[p1++];
		}else{
			b[pos++]=a[p2++];
		}
	}
	while(p1<=mid){
		cnt++;
		b[pos++]=a[p1++];
	}
	while(p2<=r){
		cnt++;
		b[pos++]=a[p2++];
	}
	for(int i=l;i<=r;i++)a[i]=b[i];
}

void merge_sort(int l,int r)
{
	if(l<r){
		int mid=(l+r)/2;
		merge_sort(l,mid);
		merge_sort(mid+1,r);
		merge(l,mid,r);
	}
}

int main()
{
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	int n;
	cin>>n;
	cnt=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	merge_sort(1,n);
	for(int i=1;i<=n;i++){
		if(i>1)cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<cnt<<endl;
	return 0;
}




Measured memory_bytes: 10904
#include<stdio.h>
#include<assert.h>
typedef long long ll;
const int mod=998244353;
int mul(int a,int b){return(ll)a*b%mod;}
void inc(int&a,int b){(a+=b)%=mod;}
int pow(int a,int b){
	int s=1;
	while(b){
		if(b&1)s=mul(s,a);
		a=mul(a,a);
		b>>=1;
	}
	return s;
}
int fac[4010],rfac[4010];
int C(int n,int k){
	if(!(0<=k&&k<=n))return 0;
	return mul(fac[n],mul(rfac[k],rfac[n-k]));
}
int main(){
	int k,n,i,m,p,q,s;
	scanf("%d%d",&k,&n);
	fac[0]=1;
	for(i=1;i<=k+n;i++)fac[i]=mul(fac[i-1],i);
	rfac[k+n]=pow(fac[k+n],mod-2);
	for(i=k+n;i>0;i--)rfac[i-1]=mul(rfac[i],i);
	for(i=2;i<=k*2;i++){
		s=0;
		if(i&1){
			if(i<=k)
				p=i/2;
			else
				p=(k-(i-k)+1)/2;
			m=k-2*p;
			for(q=0;q<=p;q++)inc(s,mul(mul(C(p,q),pow(2,q)),C(n+m-1,q+m-1)));
		}else{
			if(i<=k)
				p=i/2-1;
			else
				p=(k-(i-k))/2;
			m=k-2*p-1;
			for(q=0;q<=p;q++){
				inc(s,mul(mul(C(p,q),pow(2,q)),C(n+m-1,q+m-1)));
				inc(s,mul(mul(C(p,q),pow(2,q)),C(n+m-2,q+m-1)));
			}
		}
		printf("%d\n",s);
	}
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n, x, t;
    cin >> n >> x >> t;

    cout << (n + x - 1) / x * t << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
//using std::stdin;
//using std::stdout;
//using std::freopen;

const int MXN=100010;
const int MXL=400060;
const int M=26;

int trie[MXL][M],sum[MXL],len[MXL],equal[MXL],tot=1;
bool end[MXL];
int n,q;
string str[MXN];

inline void ins(const string &s)
{
  int p=0;
  //++sum[p];
  for(string::size_type i=0;i!=s.size();++i)
    {
      if(trie[p][s[i]-'a']==0)
	trie[p][s[i]-'a'] = ++tot;
      p=trie[p][s[i]-'a'];
      ++sum[p];
      len[p]=i+1;
      equal[p]=p;
    }
  end[p]=true;
}

void clean(int p)
{
  for(int i=0;i!=M;++i)
    if(trie[p][i]!=0)
      {
	clean(trie[p][i]);
	if(sum[trie[p][i]]==sum[p])
	  equal[p]=equal[trie[p][i]];
      }
}

inline int find(const string &s,const string &o)
{
  int p=0,res=0;
  for(string::size_type i=0;i<s.size();)
    {
      for(string::size_type j=0;o[j]!=s[i];++j)
	res+=sum[trie[p][o[j]-'a']];
      res+=(int)end[p];
      p=equal[trie[p][s[i]-'a']];
      i=len[p];
    }
  return res;
}

int main()
{
  cin>>n;
  for(int i=0;i!=n;++i)
    cin>>str[i];
  for(int i=0;i!=n;++i)
    ins(str[i]);
  clean(0);

  cin>>q;
  while(q--)
    {
      int k;string order;
      cin>>k>>order;
      cout<<find(str[k-1],order)+1<<endl;
    }
}


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

int f(long long int n,int keta){

  int mi=keta;

  for(long long int i=1;i*i<=n;i++){
    if(n%i==0){
      long long int k=n/i;
      int ketak=0;
      while(k){
	k/=10;
	ketak++;
      }

      mi=min(mi,ketak);
    }
  }
  return mi;
}

int main(){
  long long int n;cin>>n;
  int keta=0;

  { long long int k=n;
  

  while(k){
    k/=10;
    keta++;
  }
  } 

  cout<<f(n,keta)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

vector<ll> U;
void dfs(ll a, int digit){
  if (digit>10) return;

  U.push_back(a);
  // cout << a << endl;

  int start = a ? max(0,(int)(a%10-1)) : 1, stop = a ? min(9,(int)(a%10+1)) : 9;
  for (int i=start;i<=stop;i++){
    dfs(a*10+i,digit+1);
  }
}

int main(){
  int K; cin >> K;
  dfs(0,0);
  sort(all(U));
  // cout << U.size() << endl;
  cout << U[K] << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 5308
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
		x=p * a;
	if(p < c){
		y=b;
	}
	else{
		y=b + (p - c) * d;
	}
	if(x < y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}
 


Measured memory_bytes: 2060
#include<iostream>
#include<cstdio>
#include<sstream>
#include<vector>
#include<algorithm>

using namespace std;
int n,m;
long long cnt;

void dfs(vector<int>& a,vector<int>& pos,string& ID,int p,long long total)
{
  if(p == pos.size())
    {
      if(total%10 == 0)
	cnt++;
      return;
    }

  for(int i=0;i<a.size();i++)
    {
      char c = ID[pos[p]];
      ID[pos[p]] = a[i];
      int d = a[i];
      if((1+pos[p])%2 == 0)
	{
	  d *= 2;
	  if(d >= 10)
	    d = d-10+1;
	}
      
      dfs(a,pos,ID,p+1,(total+d)%10);
      ID[pos[p]] = c;
    }
}

int main()
{
  string ID;
  long long total = 0;
  vector<int> a,pos;
  scanf("%d",&n);
  cin >> ID;
  reverse(ID.begin(),ID.end());
  cnt = 0;
  for(int i=0;i<ID.size();i++)
    {
      if(ID[i] == '*')
	{
	  pos.push_back(i);
	  continue;
	}
      if((i+1)%2 == 0)
	{
	  int a = (ID[i]-'0')*2;
	  if(a >= 10)
	    total += a-10+1;
	  else
	    total += a;
	  total %= 10;
	}
      else
	total += ID[i]-'0',total %= 10;
    }

  scanf("%d",&m);
  a.resize(m);
  for(int i=0;i<m;i++)
    cin >> a[i];
  dfs(a,pos,ID,0,total);
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1396
a = int(input())
b = int(input())
c = int(input())
x = int(input())

n = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      y = 500 * i + 100 * j + 50 * k
      if y == x:
        n += 1
print(n)


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  char s[11];
  int ab = 0, b_ = 0, _a = 0;
  int b_a = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s[0] == 'B') b_++;
    for (int j = 0; j < strlen(s) - 1; j++) {
      if (s[j] == 'A' && s[j+1] == 'B') ab++;
    }
    if (s[strlen(s)-1] == 'A') _a++;
    if (s[0] == 'B' && s[strlen(s)-1] == 'A') b_a++;
  }
  int result = 0;
  result += ab;
  result += min(b_, _a);
  if (result > 0 && (b_a == n || (b_a != 0 && b_a == max(b_, _a)))) result--;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int H, W, A, B; cin >> H >> W >> A >> B;
  for (int r = 0; r < B; ++r) {
    for (int c = 0; c < A; ++c) {
      cout << 0;
    }
    for (int c = A; c < W; ++c) {
      cout << 1;
    }
    cout << endl;
  }
  for (int r = B; r < H; ++r) {
    for (int c = 0; c < A; ++c) {
      cout << 1;
    }
    for (int c = A; c < W; ++c) {
      cout << 0;
    }
    cout << endl;
  }
}


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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);

    vector<string> cp(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s.at(i) >> p.at(i);
        cp.at(i) = s.at(i);
    }
    sort(s.begin(), s.end());
    int x;
    for (int i = 0; i < n; i++)
    {
        int memo = 0;

        for (int j = 0; j < n; j++)
        {
            if (s.at(i) == cp.at(j))
            {
                memo = max(p.at(j), memo);
                if (memo == p.at(j))
                {
                    x = j;
                }
            }
        }
        p.at(x) = -1;
        cout << x + 1 << endl;
    }
}


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

typedef long long int llint;

int main(){
	int N,M;
	cin >> N >> M;
	bool AC[N];
	int WA[N];
	int ACCnt=0;
	int WACnt=0;
	for(int i=0;i<N;i++){
		AC[i]=false;
		WA[i]=0;
	}
	for(int i=0;i<M;i++){
		int p;
		string S;
		cin >> p >> S;
		p-=1;
		if(!AC[p]){
			if(S=="AC"){
				AC[p]=true;
				ACCnt++;
				WACnt+=WA[p];
			}else{
				WA[p]++;
			}
		}
	}
	cout << ACCnt << " " << WACnt << endl;
	return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, t, e, a[100005], last;
long long ans[100005], minn = 1LL << 60;
int main()
{
	n = read();
	e = read();
	t = read();
	for (int i = 1; i <= n; i++)
	a[i] = read();
	ans[0] = 0;
	ans[1] = t;
	for (int i = 2; i <= n; i++)
	{
		while (2LL * (a[i] - a[last + 1]) > t)
		{
			long long now = ans[last] - 2LL * a[last + 1];
			minn = min (minn, now);
			last++;
		}
		ans[i] = ans[i - 1] + t;
		if (last > 0)
		ans[i] = min (ans[i], minn + 2LL * a[i]);
		ans[i] = min (ans[i], ans[last] + t);
	}
	printf ("%lld\n", ans[n] + e);
	return 0;
}

Measured memory_bytes: 1408
N = int(input())
cnt = 0
SB = 0
EA = 0
SBEA = 0

for i in range(N):
    s = input()
    cnt += s.count("AB")
    if s.startswith("B"):
        if s.endswith("A"):
            SBEA += 1
        else:
            SB += 1
    elif s.endswith("A"):
        EA += 1

if SBEA > 0:
    cnt += SBEA - 1
    if SB > 0:
        cnt += 1
        SB -= 1
    if EA > 0:
        cnt += 1
        EA -= 1

cnt += min(SB,EA)

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>

int main(void) {
	// in
	int w, h, x, y;
	std::cin >> w >> h >> x >> y;

	// calc
	double sq = 0.5 * h * w;

	// is there another way ?
	bool is_another = false;
	if(w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2) is_another = true;

	std::cout << std::setprecision(12) << sq << " " << (is_another ? 1 : 0) << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i,j,h,w,a,b;
	cin>>h>>w>>a>>b;
	if(a>w/2||b>h/2)
	{
		cout<<-1<<endl;
	}
	else
	{
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				if(i<b&&j<a||i>=b&&j>=a)
				{
					cout<<0;
				}
				else
				{
					cout<<1;
				}
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using Pa = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

ll dp[110][10][4][2] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    int K;
    cin >> S >> K;
    int N = S.size();
    
    dp[0][0][0][0] = 1;
    for(int i=0;i<N;i++) for(int j=0;j<10;j++) for(int k=0;k<=K;k++) for(int l=0;l<2;l++){
        for(int nj=0;nj<10;nj++){
            if(!l && (S[i]-'0')<nj) continue;
            int nk = k+(nj!=0);
            if(nk>K) continue;
            bool nl = (l || nj<(S[i]-'0'));
            dp[i+1][nj][nk][nl] += dp[i][j][k][l];
        }
    }
    ll ans = 0;
    for(int j=0;j<10;j++) for(int l=0;l<2;l++) ans += dp[N][j][K][l];
    cout << ans << "\n";
}

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

#define INF 1e9
using namespace std;
#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

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

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

const ll MOD = 1e9 + 7;

int main() {
    // bitの個数を記録するtbl
    vector<ll> bit_tbl(61, 0);
    int N;
    cin >> N;
    vector<ll> As(N);
    REP(i, N) cin >> As[i];
    REP(i, N){
        cin >> As[i];
        REP(j, 61){
            bit_tbl[j] += (As[i] >> j) & 1;
        }
    }
    ll score = 0;
    REP(shift, 61) {
        score+=(((ll)1<<shift)%MOD*(N-bit_tbl[shift])%MOD*bit_tbl[shift])%MOD;
    }
    score %=MOD;
    cout << score << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int a, b, c;
    bool isOK = false;
    cin >> a >> b >> c;
    rep(i, 100){
        if(a*(i+1) % b == c) isOK = true;
    }
    if(isOK) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

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

	int ans=0, cnt=0, hprev=-1;
	for(int i=0; i<N; ++i){
		int h; cin >> h;
		if(hprev >= h){
			++cnt;
			ans = max(cnt, ans);
		}else{
			cnt = 0;
		}
		hprev = h;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
/*
memo
????????°??????

*/

#include<iostream>
#include<cstring>
#include<vector>
using namespace std;

int m, n;
int ma[300];
//int ka[300][300];
vector<int> g[300];
bool go[300], ba[300];
void iki(int x)
{
	//????????§????????¨????????????????????????

	//????????????????????´??????????????????????????°?????¨??????
	//????????´??????????????°???????????????
	//???????????????????????§??????????????¶???????????????????????????????????£???
	//??????????????°????????????????????°????????????????????°?????¨???????????????????????????
	//?????????????????????????????°?????¨??°?????°????????´???????¨???????????????????
	//????????????????????´???????????£???????????´???????????????????????????????????????
	//??´?????????????????????????????´??????????§???????????????????????????????????????´????????????????????¨??????????????°????????????????????????????????????

	int i;

	if (go[x]) return;
	go[x] = true;				//????????°??????
	if (x == n + 1) return;
	for (i = 1; i <= m; i++)
	{
		int y = x + i;
		if (y <= n+1)
		{
			y = y + ma[y];
			if (y>0)
			{
				if (y > n + 1) y = n + 1;
				//if (ka[y][x] == 1)continue;
				//ka[y][x] = 1;

				g[y].push_back(x);
				iki(y);
			}
		}

	}
	return;
}

void kae(int x)
{
	//????????§?????°?????¨????????´???????????????????????????????????¨???????????????????????????

	//????????????????????´?????????????§??????¨??????????????????????????°????????????????????§???????????´?????????????????????
	//??????????????§?????£?????´??????????????¨?????????????????°???????????????


	int i;
	if (ba[x]) return;
	ba[x] = true;
	if (x == 0) return;
	for (i = 0; i<g[x].size(); i++)
	{
		kae(g[x][i]);
	}
	return;
}

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

		//---------------?????????--------------------//
		for (i = 0; i<300; i++)
		{
			g[i].clear();
			ma[i] = 0;
			//for (int j = 0; j<300; j++)
			//{
			//	ka[i][j] = 0;
			//}
		}
		memset(go, 0, sizeof(go));
		memset(ba, 0, sizeof(ba));


		for (i = 1; i <= n; i++)
		{
			cin >> ma[i];
		}
		ma[0] = ma[n + 1] = 0;

		iki(0);
		kae(n + 1);


		/*
		for (i = 0; i <= n + 1; i++)
		{
			cout << "  " << go[i] << "  " ;
		}
		cout << endl;
		for (i = 0; i <= n + 1; i++)
		{
			cout << "  " << ba[i] << "  ";
		}
		*/



		for (i = 0; i <= n + 1; i++)
		{
			if (go[i])
			{
				if (ba[i] == 0)
				{
					cout << "NG\n";
					break;
				}
			}
			if (i == n + 1) cout << "OK\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3152
#include <cstdio>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int n;
  cin >> n;
  int res = 0;
  for(int i = 1; i <= n; ++i) {
    if(i % 2 == 0) {
      continue;
    }
    int cur = 0;
    for(int j = 1; j <= i; ++j) {
      if(i % j == 0) {
        ++cur;
      }
    }
    if(cur == 8) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u){
        cout<<a-1<<" "<<b<<endl;
    }else if(t==u){
        cout<<a<<" "<<b-1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
 
  // input matrix size
  int n,m;
  cin>>n>>m;
 
  // input matrix A
  vector<vector<int>> matA(n, vector<int>(m,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>matA.at(i).at(j);
    }
  }
  // input vector B
  vector<int> vecB(m);
  for(int i=0;i<m;i++){
    cin>>vecB.at(i);
  }
  
  // calc A*B
    for(int i=0;i<n;i++){
    int ci=0;
    for(int j=0;j<m;j++){
      ci+=matA.at(i).at(j)*vecB.at(j);
    }
      cout<<ci<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

	int N = 50;

	vector<int>v(N, N - 1 + K / N);

	K %= N;
	rep(i, 0, K) {
		sort(all(v));
		v[0] += N;
		rep(j, 1, v.size())v[j]--;
	}
	cout << N << endl;
	rep(i, 0, v.size())cout << v[i] << (i == v.size() - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 555555;
int n;Vi e[N];bool vis[N];
void dfs(int u, int fa){
	rep(i,0,SZ(e[u])-1)if(e[u][i]!=fa){
		dfs(e[u][i],u);if(!vis[e[u][i]]&&!vis[u])vis[e[u][i]]=vis[u]=1;
	}
}
int main() {
	read(n);rep(i,2,n){int u,v;read(u);read(v);e[u].pb(v);e[v].pb(u);}
	dfs(1,0);bool bo=0;rep(i,1,n)bo|=!vis[i];
	if(bo)puts("First");else puts("Second");
	return 0;
}


Measured memory_bytes: 16640
#if 1

#include <bits/stdc++.h>
using namespace std;
int n;
char a[100005];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> a+1;
    int ans = 0;
    a[0] = '!';
    for(int i = 1;i <= n;i++) {
        if(a[i] != a[i-1]) ans++;
    }
    cout << ans;
}

#endif


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    long long N,i,j,m,s;
    cin>>N;
    long long a[N],b[N];
    for(i=0;i<N;i++){
        cin>>a[i];
    }
    for(i=N;i>0;i--){
        m=0;
        for(j=2;j*i<N+1;j++){
            m+=b[j*i-1];
        }
        b[i-1]=(m+a[i-1])%2;
    }
    m=0;
    for(i=0;i<N;i++){
        m+=b[i];
    }
    cout<<m<<endl;
    j=0;
    for(i=0;i<N;i++){
        if(b[i]>0){
            if(j==0){
                cout<<i+1;
                j++;
            }else{
                cout<<" "<<i+1;
            }
        }
    }
    cout<<endl;
}


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

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    int ans=a;
    if (a>b) {
        ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.abs

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (x, n) = readIntegerList()
    if (n == 0) {
        println(x)
        return
    }
    
    val pSet = readIntegerList().toSet()
    var abs = abs(x - 0)
    var ans = 0
    for (i in 1..101) {
        if (pSet.contains(i)) {
            continue
        }

        val tmp = abs(x - i)
        if (tmp < abs) {
            ans = i
            abs = tmp
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36696
#include <iostream>
#include <vector>

using namespace std;
#define ll long long

vector<int> par, rnk, mem;
int g;
void init(int n) {
    g = n;
    par.clear();
    rnk.clear();
    mem.clear();
    par.resize(n);
    rnk.resize(n);
    mem.resize(n);
    for(int i = 0; i < n; i++) {
        par[i] = i;
        rnk[i] = 0;
        mem[i] = 1;
    }
}
int find(int x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) {
        return;
    } else {
        if(rnk[x] < rnk[y]) {
            par[x] = y;
            mem[y] += mem[x];
        } else {
            par[y] = x;
            mem[x] += mem[y];
            if(rnk[x] == rnk[y]) rnk[x]++;
        }
    }
    g--;
}
bool same(int x, int y) {
    return find(x) == find(y);
}
int size(int x) {
    return mem[find(x)];
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    vector<ll> ans(M + 1, 0);
    ans[M] = (ll)N * ((ll)N - 1) / 2;
    init(N);
    for(int i = M - 1; i >= 0; i--) {
        if(same(A[i], B[i])) {
            ans[i] = ans[i + 1];
        } else {
            ans[i] = ans[i + 1] - (ll)size(A[i]) * (ll)size(B[i]);
            unite(A[i], B[i]);
        }
    }
    for(int i = 0; i < M; i++) {
        cout << ans[i + 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 5892
#include <bits/stdc++.h>
using namespace std;
int INF=100000000;

struct SegmentTree{
  private:
  int n;  vector<int> node;
  
  public:
  SegmentTree(vector<int> v){
    int sz=v.size();
    n=1; while(n<sz)n*=2;
    node.resize(2*n-1,0);
    for(int i=0;i<sz;i++)node[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)node[i]=node[2*i+1]+node[2*i+2];
  }
  void update(int x,int val){
    x+=(n-1);
    node[x]+=val;
    while(x>0){
      x=(x-1)/2;
      node[x]=node[2*x+1]+node[2*x+2];
    }
  }
  int getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b)return node[k];
    int vl=getmin(a,b,2*k+1,l,(l+r)/2);
    int vr=getmin(a,b,2*k+2,(l+r)/2,r);
    return vl+vr;
  }
};

int main(){
  int n,q;
  cin >> n >> q;
  SegmentTree seg(vector<int>(n,0));
  for(int i=0;i<q;i++){
    int c,x,y;
    cin >> c >> x >> y;
    if(c==0){seg.update(x-1,y);}
    else{cout << seg.getmin(x-1,y) << endl;}
  }
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
int main()
{
      ll a,b;
      cin>>a>>b;
      ll g = __gcd(a,b);
      ll ans = 1;
      ll temp = 0;
      while(g%2==0)   
      {
           g=g/2;
           if(temp==0)   temp=1,ans++;
      }
      for(ll i=3;i<=sqrt(g);i+=2)
      {
           temp = 0;
           while(g%i==0)
           {
                g=g/i;
                if(temp==0)   temp=1,ans++;
           }
      }
      if(g!=1)   ans++;
      cout<<ans;
}

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

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

int main(void) {
    int n;
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> s;
    REP(i, s.length()) {
        s[i] = (n + (s[i] - 'A')) % 26 + 'A';
    }

    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }


struct UnionFind {
    vector<int> data;

    UnionFind(int n) {
        data.resize(n);
        rep(i, n) data[i] = -1;
    }

    int root(int x) {
        if (data[x] < 0) return x;
        return data[x] = root(data[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }

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

    int size(int x) {
        return -data[root(x)];
    }
};

int n;
int idx[200010], xy[200010], yx[200010];
int ans[200010];

int main() {
    cin >> n;
    rep(i, n) {
        int x, y; cin >> x >> y;
        x--; y--;
        idx[x] = i;
        xy[x] = y;
        yx[y] = x;
    }

    UnionFind uf(n);
    stack<int> st;
    for (int x = 0; x < n; x++) {
        int t = xy[x];
        while (st.size() && xy[x] > st.top()) {
            uf.unite(idx[x], idx[yx[st.top()]]);
            chmin(t, st.top());
            st.pop();
        }
        st.push(t);
    }

    rep(i, n) cout << uf.size(i) << endl;
}


Measured memory_bytes: 6320
function MainC(input){
    let [[N], [...Ai]] = input.split('\n').map(a=>a.split(' ').map(Number));
    let answer = 0;
    for(let i=0; i<N-1; i++){
        let box = Ai[i+1] - Ai[i];
        if(box < 0) {
            answer += -box;
            Ai[i+1] += -box; 
        }
    }
    console.log(answer);
}
MainC(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

int n, w;
int a[110];
int b[110];
int dp[100010];

int main () {
	
	cin >> n >> w;
	memset(dp, -1, sizeof dp);
	for (int i = 0; i < n; i ++) {
		cin >> a[i] >> b[i];
	}
	
	dp[0] = 0;
	int maxi = 0;
	for (int i = 0; i < n; i ++) {
		for (int j = 100000; j >= 0; j --) {
			if (j - b[i] >= 0 && dp[j - b[i]] != -1 && dp[j - b[i]] + a[i] <= w && (dp[j] == -1 || dp[j] > dp[j - b[i]] + a[i])) {
				dp[j] = dp[j - b[i]] + a[i];
				maxi = max(maxi, j);
			}
		}
	}
	
	cout << maxi;
	
	return 0;
}

Measured memory_bytes: 640