akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#define LL long long
using namespace std;
stack<int> b;
string a; 
int read()
{
	int _=0,__=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}
	return _*__;
}
int main()
{
	cin>>a;
	int x;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='S')
		x=1;
		else if(a[i]=='T')
		x=2;
		if(!b.empty()&&b.top()==1&&x==2)
		b.pop();
		else
		b.push(x);
	}
	printf("%d\n",b.size());
	return 0;
}


Measured memory_bytes: 1284
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:35:39 2020

@author: Paras
"""

n = int(input())

sides = list(map(int, input().split()))
l = len(sides)
cnt=0
for i in range(l):
    for j in range(i+1,l):
        if sides[j]!=sides[i]:
            k = j+1
            while k<l:
                if (sides[k]>abs(sides[i]-sides[j]) and sides[k]<abs(sides[i]+sides[j])) and (sides[k]!=sides[i] and sides[k]!=sides[j]):
                    cnt+=1
                k+=1

print(cnt)

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

int main(){
    int N; cin >> N;
    map<string,int> A;
    for(int i=0;i<N;i++){
        string S; cin >> S;
        if(A.count(S)){
            A[S]++;
        }else{
            A[S]=1;
        }
    }
    int M = 0;
    for(auto p : A){
        auto key = p.first;
        auto value = p.second;
        M = max(M,value);
    }
    for(auto p : A){
        auto key = p.first;
        auto value = p.second;
        if(value == M){
            cout << key << endl;
        }
    }

}


Measured memory_bytes: 25216
//................ DON'T WISH IT WERE EASIER, WISH YOU WERE BETTER........................
//............ WHEN LIFE PUTS YOU IN TOUGH SITUATIONS, DONT SAY "WHY ME" SAY "TRY ME".......

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define endl "\n"
#define f first
#define mp make_pair
#define s second
#define int long long
#define delrep(v)  (v).erase(unique((v).begin(),(v).end()),(v).end());
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define sz(x)   (int)x.size()
#define lll __int64
const int N=1e6+10; const int M=100000;
const int mod=998244353;
using namespace std;
typedef long long ll;
const long long MAX_SIZE = 3000003;
vector<pair<int,int>>v[N]; map<int,int>hashx;
vector<int>a(N); vector<int>b(N); int pref[N]; int suff[N]; int sum[N];
vector<ll>dp(N);
ll n,k;
int mindis(ll x)        // top down dp
{
    if(x==0) return 0;
    if(dp[x]!=-1) return dp[x]; int ans=INT_MAX;
     for(int i=1;i<=k;i++) 
         {
            if(x-i>=0) 
             { 
                int ans2=mindis(x-i)+abs(a[x]-a[x-i]); 
                ans=min(ans,ans2); dp[x]=ans;  
             }
           }
  return dp[x];
}

int32_t main()
{
   int n,cap; cin>>n>>cap; while(n--)
   {
     int capx,value; cin>>capx>>value; 
    // for(int weight=0;weight<=cap-capx;weight++)
     for(int weight=cap-capx;weight>=0;weight--)
     {
        dp[weight+capx]=max(dp[weight+capx],dp[weight]+value);
     }
   }
   int ans=0;
   for(int i=1;i<=cap;i++) ans=max(ans,dp[i]);
   cout<<ans<<endl; return 0;
}
 
 

Measured memory_bytes: 48000
#include <stdio.h>

int a[105], n;

int main()
{
	scanf("%d", &n);
	int i, cnt;
	int selection_sort();
	for(i = 0; i < n; i++)
	{
		scanf("%d", a + i);
	}
	cnt = selection_sort();
	for(i = 0; i < n; i++)
	{
		if(i > 0)
		{
			printf(" ");
		}
		printf("%d", a[i]);
	}
	printf("\n%d\n", cnt);
	
	return 0;
}

int selection_sort()
{
	int i, j, cnt, flag;
	for(i = 0; i < n - 1; i++)
	{
		flag = i;
		for(j = i + 1; j < n; j++)
		{
			if(a[flag] > a[j])
			{
				flag = j;
			}
		}
		if(flag != i)
		{
			int tmp = a[i];
			a[i] = a[flag];
			a[flag] = tmp;
			cnt++;
		}
	}
	
	return cnt;
}


Measured memory_bytes: 2076
// https://atcoder.jp/contests/abc062/tasks/abc062_b
#include <bits/stdc++.h>
using namespace std;

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

int main() {
  int H, W;
  cin >> H >> W;

  rep(i, H + 2) {
    if (i == 0 || i == H + 1) {
      rep(i, W + 2) putchar('#');
      putchar('\n');
    } else {
      string s;
      cin >> s;
      cout << '#' << s << "#\n";
    }
  }

  return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!(n: usize, ca: [(char, proconio::marker::Usize1); 2 * n]);
    let mut b = vec![0; n];
    let mut w = vec![0; n];
    for (i, &(c, a)) in ca.iter().enumerate() {
        match c {
            'B' => {
                b[a] = i;
            }
            'W' => {
                w[a] = i;
            }
            _ => panic!(),
        }
    }

    let cal_cnt = |a: &Vec<usize>| {
        let mut ans = vec![vec![0; 2 * n + 1]; n + 1];
        for i in 0..n {
            ans[i + 1] = ans[i].clone();
            for j in 0..a[i] {
                ans[i + 1][j] += 1;
            }
        }
        ans
    };
    let cnt_b = cal_cnt(&b);
    let cnt_w = cal_cnt(&w);

    let mut dp = vec![vec![std::u32::MAX; n + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..=n {
        for j in 0..=n {
            if i < n {
                let x = dp[i][j] + cnt_b[i][b[i]] + cnt_w[j][b[i]];
                if x < dp[i + 1][j] {
                    dp[i + 1][j] = x;
                }
            }
            if j < n {
                let x = dp[i][j] + cnt_b[i][w[j]] + cnt_w[j][w[j]];
                if x < dp[i][j + 1] {
                    dp[i][j + 1] = x;
                }
            }
        }
    }
    println!("{}", dp[n][n]);
}


Measured memory_bytes: 80396
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int

ll all_1_xor( ll num_1) {
 if (num_1 % 2) return 0;
  else return 1;  
}

ll xor_02n( ll n ) {
  ll num_1;
  if ( ( n % 2 ) == 0 ) 
  {
    num_1 = n / 2;
    return all_1_xor(num_1) ^ n;
  } 
  else 
  {
    num_1 = ( n + 1 )/ 2;
    return all_1_xor(num_1);
  }
}
int main() {
  ll a,b;
  cin >> a >> b;
  ll ans = xor_02n(a - 1) ^ xor_02n(b);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>H>>W>>K;
    vector<string> grid(H);
    rep(i,H) cin>>grid[i];
    mat dp(H+1, vec(W+1,0));
    rep(i,H){
        rep(j,W){
            dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j] - dp[i][j] + (grid[i][j] == '#');
        }
    }
    mat ans(H,vec(W,0));
    vector<P> wid(0);
    ll L = 0, R = 1, lastL = 0, lastR = -1;
    rep(i,W){
        if(dp[H][i+1] - dp[H][i] > 0){
            if(lastR != -1) {
                wid.emplace_back(lastL,lastR);
            }
            lastL = L;
            lastR = R;
            L = R;
        }
        ++R;
    }
    wid.emplace_back(lastL,R - 1);
    ll temp = 1;
    for(P p : wid){
        L = p.fi;
        R = p.se;
        //cout<<L<<' '<<R<<endl;
        bool f = false;
        rep(i,H){
            if((dp[i+1][R] - dp[i+1][L]) - (dp[i][R] - dp[i][L]) > 0){
                if(!f) f = true;
                else ++temp;
            }
            reps(j,L,R) ans[i][j] = temp;
        }
        ++temp;
    }
    rep(i,H){
        rep(j,W) {
            cout<<ans[i][j];
            //cout<<dp[i+1][j+1];
            (j == W - 1 ? cout<<endl : cout<<' ');
        }
    }
}

Measured memory_bytes: 2432
import numpy as np


k, q = map(int, input().split())
d = np.array(list(map(int, input().split()))).astype(np.int64)
queries = [tuple(map(int, input().split())) for _ in range(q)]

for n, x, m in queries:
    d_mod = d % m
    quotient, rem = divmod(n - 1, k)
    rem_d_mod = d_mod[:rem]
    print(quotient * np.count_nonzero(d_mod) + np.count_nonzero(rem_d_mod)
          - (x % m + quotient * np.sum(d_mod) + np.sum(rem_d_mod)) // m)


Measured memory_bytes: 13320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, h;
    cin>>n>>h; int cnt = 0;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin>>x;
        if(x>=h) cnt++;
    }
    cout<<cnt<<endl;
}



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

int main(){
    list<int> result;

    int n;
    cin >> n;

    int a;
    cin >> a;
    result.push_front(a);

    bool way = (n%2 == 0);
    for(int i = 1; i < n; i++){
        cin >> a;
        if(way) result.push_front(a);
        else    result.push_back(a);
        way = !way;
    }

    bool first = true;
    for(list<int>::iterator it = result.begin(); it != result.end(); it++){
        if(first)   first = false;
        else        cout << " ";
        cout << *it;
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


int N,A[200005];
int cnt[1000005];
signed main(){
	cin>>N;
	rep(i,N){
		cin>>A[i];cnt[A[i]]++;
	}
	int ans=0;
	rep(i,N){
		int memo=0;
		for(int j=1;j*j<=A[i];j++){
			if(A[i]%j)continue;
			memo+=cnt[j];
			if(j*j!=A[i])memo+=cnt[A[i]/j];
		}
		if(memo==1)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 12760
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(A * B // 100)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = next(tokens)
    b = int(B.replace(".", ""))
    solve(A, b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9080
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>H(N);
	rep(i, N)cin >> H[i];
	int mx = H[0];
	int cnt = 1;
	for (int i = 1; i < N; i++) {
		if (mx <= H[i])cnt++;
		mx = max(mx, H[i]);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

ll a_sum[100000];
map<int, ll> app_count;
int main() {
	cin >> N >> M;
	int num;
	cin >> a_sum[0];
	app_count[0] = 1;
	a_sum[0] %= M;
	if (a_sum[0] != 0) {
		app_count[a_sum[0]] = 0;
	}
	app_count[a_sum[0]]++;

	rep(i, N-1) {
		cin >> num;
		a_sum[i + 1] = (a_sum[i] + num) % M;
		if (app_count.count(a_sum[i + 1]) == 0) {
			app_count[a_sum[i + 1]] = 0;
		}
		app_count[a_sum[i + 1]]++;
	}
	
	ll count_sum = 0;
	
	for(auto i = app_count.begin(); i != app_count.end(); i++){
		count_sum += (i->second - 1) * (i->second)/ 2;
	}
	cout << count_sum;
}



Measured memory_bytes: 4992
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <list>
#include <cstring>
#include <stdio.h>
using namespace std;

int x, n, p;
list<int> pList;

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

	for(int i=0; i<n; ++i){
		cin >> p;
		pList.push_back(p);
	}
	pList.sort();

	int tmpx = x;
	int i = 0;

	while(1){
		auto pos = lower_bound(pList.begin(), pList.end(), x-i);
		if (*pos != x-i){
			tmpx = x-i;
			break;
		}
		++i;
	}

	for(int j=1; j<i; ++j){
		auto pos = lower_bound(pList.begin(), pList.end(), x+j);
		if (*pos != x+j){
			tmpx = x+j;
			break;
		}
	}

	cout << tmpx << endl;

	return 0;

}


Measured memory_bytes: 3644
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,k,i,j,ans
    integer(int64), allocatable:: gcn(:)
    integer(int64),parameter:: md = 1000000007

    read*, n,k
    allocate(gcn(k))

    do i=1,k
        gcn(i) = calc_rj(k/i, n)
    end do

    do i=k,1,-1
        j=2
        do while(i*j <= k)
            gcn(i) = gcn(i) - gcn(i*j)
            j=j+1
        end do
    end do

    ans=0
    do i=1,k
        ans=mod(ans+gcn(i)*i,md)
    end do

    print*, ans

contains
    function calc_rj(x,y) result(ret)
        integer(int64):: x,y,ret
        integer(int64):: num, nx
        ret = 1
        num = y
        nx = x
        do while(num > 0)
            if (btest(num,0)) then
                ret=mod(ret*nx,md)
            end if
            nx=mod(nx*nx,md)
            num=rshift(num,1)
        end do
    end function
end program name    


Measured memory_bytes: 3584
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

t,x = li()
print(t/x)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[100005];
ll sum1, sum2;
int main() {
	cin >> n;
	int i;
	for(i = 1; i <= n; ++i) cin >> a[i];
	sort(a + 1, a + 1 + n);
	int hed = 1, til = n;
	while(til - hed + 1 > 2) {
		sum1 += a[til] * 2;
		--til;
		if(til - hed + 1 == 2) break;
		sum1 -= a[hed] * 2;
		++hed;
		if(til - hed + 1 == 2) break;
	}//cout << sum1 << endl;
	if(n & 1) sum1 -= a[til] + a[hed];
	else sum1 += a[til] - a[hed];
	hed = 1, til = n;
	while(til - hed + 1 > 2) {
		sum2 -= a[hed] * 2;
		++hed;
		if(til - hed + 1 == 2) break;
		sum2 += a[til] * 2;
		--til;
		if(til - hed + 1 == 2) break;
	}
	if(n & 1) sum2 += a[til] + a[hed];
	else sum2 += a[til] - a[hed];//cout << sum1 << " " << sum2 << endl;
	cout << max(sum1, sum2);
	return 0; 
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{

	int a,b,c[2000],i,j;
	char op;
	i=1;
	while(1)
	{
		scanf("%d %c %d",&a,&op,&b);
		
		if(op=='+')
		{
			c[i]=a+b;
		}
		else if(op=='-')
		{
			c[i]=a-b;
		
		}
		else if(op=='*')
		{
			c[i]=a*b;
		
		}
		else if(op=='/')
		{
			c[i]=a/b;
		}
		else
		{
			break;
		}
		i++;
	}

	for(j=1;j<i;j++)
	{
		printf("%d\n",c[j]);
	}
	
	return 0;	
}

Measured memory_bytes: 608
#include <iostream>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::max;
using std::min;

int
main()
{
  int W, H, N;
  cin >> W >> H >> N;
  int x_top = 0;
  int x_bot = W;
  int y_top = 0;
  int y_bot = H;
  for (int n = 0; n < N; n++)
  {
    int x, y, a;
    cin >> x >> y >> a;
    switch (a)
    {
    case 1: x_top = max(x_top, x); break;
    case 2: x_bot = min(x_bot, x); break;
    case 3: y_top = max(y_top, y); break;
    case 4: y_bot = min(y_bot, y); break;
    }
  }
  cout << ((x_top < x_bot && y_top < y_bot) ? (x_bot - x_top) * (y_bot - y_top) : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long a, b;
	cin >> a >> b;
	long long c = (b + a - 1) / a;
	c *= a;
	long long geko = 1 + (c - b) / a + (c - b) % a; // donyoku
	geko -= c/a;//uso
	if (geko > 0) {
		cout << c << endl;
	}
	else {
		cout << -1 << endl;
	}
}


Measured memory_bytes: 3104
n = int(input())

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

mountain = int(1)
for i in range(1, n):
    for j in range(i):
        if int(L[j]) > int(L[i]):
            break
        if int(L[j]) <= int(L[i]) and j == i-1:
            mountain += 1
            break
        if int(L[j]) <= int(L[i]):
            continue

print(mountain)


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

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

  int ans = 0;
  char c = '_';
  rep(i, N) {
    if (S[i] != c) {
      c = S[i];
      ans++;
    }
  }

  cout << ans << endl;
}

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

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	
	if (a == 1) a += 20;
	if (b == 1) b += 20;
	
	if (a > b) printf("Alice");
	else if (b > a) printf("Bob");
	else printf("Draw");
	return 0;
}

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

int gcd(int, int);

int main()
{
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;
	return 0;
}

int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


vector<int> g[100010];
map<pair<int,int>, int> mp;
bool seen[100010];
int A[100010], B[100010];


int main(){
    int n;
    cin >> n;
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
        A[i] = a;
        B[i] = b;
    }
    int mx = 0;
    rep(i, n){
        int s = g[i].size();
        mx = max(mx, s);
    }
    int ini;
    rep(i, n) if (g[i].size() == mx) ini = i;

    queue<pair<int,int>> que; // node, color of edge
    que.push(make_pair(ini, 0));

    while(!que.empty()){
        pair<int,int> p = que.front();
        int v = p.first;
        int c = p.second;
        seen[v] = true;
        que.pop();
        int cnt = 1;
        for (auto nv : g[v]) {
            if (seen[nv]) continue;
            if (cnt == c) cnt++; //if the path is same
            mp[make_pair(v,nv)] = cnt;
            mp[make_pair(nv,v)] = cnt;
            que.push(make_pair(nv, cnt));
            cnt++;
        }
    }

    cout << mx << endl;
    rep(i, n - 1){
        cout << mp[make_pair(A[i], B[i])] << endl;
    }

    return 0;
}

Measured memory_bytes: 19456
#include<iostream>
#include<string>
using namespace std;
int main() {
	int A, B;	cin >> A >> B;
	for (int i = 1; i <= 3; ++i) {
		if (A*B*i % 2 == 1) {
			cout << "Yes" << endl;
			cin >> A;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

// POJ 3264 Balanced Lineup
// AOJ 2431 House Moving
template <class T, class Compare>
struct SegmentTree/*{{{*/
{
  vector<T>& mem;
  vector<int> indexes;
  Compare cmp;
  SegmentTree(vector<T>& cs)
    : mem(cs), indexes(4*cs.size(), -1)
  {
    build(0, 0, cs.size());
  }

  void build(int idx, int left, int right)
  {
    if (left+1 == right) {
      indexes[idx] = left;
    } else {
      const int mid = (left + right)/2;
      build(2*idx+1, left, mid);
      build(2*idx+2, mid, right);
      // minimum in [left, right)
      if (cmp(mem[indexes[2*idx+1]], mem[indexes[2*idx+2]])) {
        indexes[idx] = indexes[2*idx+1];
      } else {
        indexes[idx] = indexes[2*idx+2];
      }
    }
  }

  inline T query_value(int left, int right) const { return mem[query_index(left, right)]; }

  inline int query_index(int left, int right) const { return query_index(left, right, 0, 0, mem.size()); }

  int query_index(int left, int right, int i, int a, int b) const
  {
    // [a, b) is the range of indexes[i]
    if (b <= left || right <= a) {
      // does not intersect
      return -1;
    } else if (left <= a && b <= right) {
      // contains
      return indexes[i];
    } else {
      const int m = (a+b)/2;
      const int l = query_index(left, right, 2*i+1, a, m);
      const int r = query_index(left, right, 2*i+2, m, b);
      if (l == -1) {
        return r;
      } else if (r == -1) {
        return l;
      } else {
        if (cmp(mem[l], mem[r])) {
          return l;
        } else {
          return r;
        }
      }
    }
  }

  void update(int idx, T val)
  {
    mem[idx] = val;
    update_index(0, mem.size(), 0, idx);
  }

  void update_index(int left, int right, int i, int idx)
  {
    if (left+1 == right) {
      //indexes[i] = idx;
    } else {
      const int mid = (left+right)/2;
      if (idx < mid) {
        update_index(left, mid, 2*i+1, idx);
      } else {
        update_index(mid, right, 2*i+2, idx);
      }
      if (cmp(mem[indexes[2*i+1]], mem[indexes[2*i+2]])) {
        indexes[i] = indexes[2*i+1];
      } else {
        indexes[i] = indexes[2*i+2];
      }
    }
  }

};/*}}}*/

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

    int N;
    cin >> N;
    vector<long long> v(N+1, 0);
    SegmentTree<long long, greater<long long> > segtree(v);
    for(int i = 0; i < N; ++i) {
        int X;
        cin >> X;
        long long best = segtree.query_value(0, X);
        segtree.update(X, best + X);
    }
    long long sum = 0;
    for(int i = 1; i <= N; ++i) {
        sum += i;
    }
    cout << sum - segtree.query_value(1, N+1) << endl;
    return 0;
}

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


public class Main {
   
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    List<String> D = new ArrayList<>();
    for (int i = 0;i < K ;i++) {
        D.add(Integer.toString(sc.nextInt()));
    }
    boolean key = true;
    int ans = 0;
    for (int i = 0; key ;i++) {
        ans = N+i;
        key = cycle(ans,D);
    }
    System.out.println(ans);
    }

    public static boolean cycle(int N, List<String> D) {
        List<String> st = new ArrayList<>();
        for (String n:Integer.toString(N).split("")) {
            st.add(n);
        }
        for (String d : D) {
            if (!st.contains(d)) {
                continue;
            } else {
                return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 59496
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  auto p = mvec<ll>(N);
  for(auto&& i : p){
    cin >> i;
  }
  rep(i, 0, N){
    rep(j, i, N){
      auto q = p;
      swap(q[i], q[j]);
      if(is_sorted(all(q))){
        cout << "YES" << rt;
        return 0;
      }
    }
  }
  cout << "NO" << rt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
const int N=1e5+5;
vector<int> dp(N,-1),n[N]; 
 
int lp(int i) {
  if(dp[i] != -1) 
    return dp[i];
  dp[i] = 0; 
  for(auto p:n[i])
    dp[i]=max(dp[i],lp(p)+1);
  return dp[i];
} 
int main() { 
  int N, M,x,y;
  cin >> N >> M; 
  for(int i = 0; i < M; i++) 
    cin >> x >> y, n[x].push_back(y); 
  int rez = 0; 
  for(int i = 1; i <= N; i++) 
    rez  = max(rez, lp(i)); 
  cout << rez; 
  return 0; 
}

Measured memory_bytes: 8192
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}
 
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll modpow(ll f, ll s){
    ll res = 1;
    for(int i = 0; i < s; i++){
        res *= f;
        res %= MOD;
    }
    return res;
}

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll maxa = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        maxa = max(maxa, a[i]);
    }

    vector<vector<pair<ll,ll>>> primefact(n);

    vector<ll> ma(maxa + 1);

    for(int i = 0; i < n; i++){
        ll tmp = a[i];
        for(int j = 2; j * j <= a[i]; j++){
            ll cnt = 0;
            while(tmp % j == 0){
                cnt++;
                tmp /= j;
            }
            primefact[i].push_back(make_pair(j, cnt));
        }

        if(tmp != 1){
            primefact[i].push_back(make_pair(tmp, 1));
        }

        for(int j = 0; j < primefact[i].size(); j++){
            ma[primefact[i][j].first] = max(ma[primefact[i][j].first], primefact[i][j].second);
        }

    }

    ll totallcm = 1;
    for(ll i = 2; i <= maxa; i++){
        totallcm *= modpow(i, ma[i]);
        totallcm %= MOD;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll x, y;
        ll g = extGCD(a[i], MOD, x, y);
        while(x < 0) x += MOD;
        x %= MOD;
        ans += (totallcm * x) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

}

Measured memory_bytes: 168576
n,x = map(int,input().split())
s = list(map(int,input().split()))

u = []

for i in range(n):
	u.append(abs(s[i]-x))
import math

m = u[0]


s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(m//(i+1))
s.sort()

x = 0

for i in range(len(s)):
	for j in range(n):
		if u[j]%s[i]!=0:
			break
	else:
		x = max(x,s[i])
print(x)

Measured memory_bytes: 14480
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 1e9
for i in range(n-k+1):
    l, r = i, i+k-1
    d = min(abs(x[l]) + abs(x[l]-x[r]), abs(x[r]) + abs(x[l]-x[r]))
    ans = min(ans, d)
print(ans)


Measured memory_bytes: 14532
S=int(input())
#1729,294867501
maxlen=S//3
maxlist=[[0] * (S-2) for i in range(maxlen)]
suml=0
for i in range(1,maxlen+1):
  for j in range(3*i,S+1):
    if i==1 or j==3*i:
      maxlist[i-1][j-3]=1
    else:
      maxlist[i-1][j-3]=maxlist[i-1][j-4]+maxlist[i-2][j-6]

for i in range(1,maxlen+1):
  suml+=maxlist[i-1][S-3]
suml=suml%(10**9+7)
  
print(suml)

Measured memory_bytes: 89004
#include <bits/stdc++.h>
using namespace std;
int partition(int *Array, int p, int last)
{
    int x = Array[last];           //11
    int i = p - 1;                 //-1
    for (int j = p; j < last; ++j) //j=0;j<11;++j
    {
        if (Array[j] <= x) //Array[j]<=Array[11]
        {
            i += 1;
            swap(Array[i], Array[j]);
        }
    }
    swap(Array[i + 1], Array[last]);
    return i + 1;
}
int main()
{
    int n;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; ++i)
        cin >> A[i];
    int ans = partition(A, 0, n - 1);
    for (int i = 0; i < n; ++i)
    {
        if (i == ans)
            cout << "[" << A[i] << "]" << ' ' << flush;
        else
        {
            cout << A[i] << flush;
            if (i < n - 1)
                cout << ' ' << flush;
        }
    }
    cout << endl;
}


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

#ifdef YUCHIKIDEBUG
  #define dump(x)  cerr << #x << " = " << (x) << endl;
  #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#else
  #define dump(x) ;
  #define debug(x) ;
#endif // YUCHIKIDEBUG

#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _repr(i,n) repir(i,n,0)
#define repir(i,a,b) for(int i=int(a);i>=int(b);--i)
#define repr(...) _overload3(__VA_ARGS__,repir,_repr,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define CINV(x,n) rep(i,n){int x##temp; cin >> x##temp; x.push_back(x##temp);}
#define REV(x) reverse(all(x))
#define SORT(x) sort(all(x))
#define PUTS(x) cout<<(x)<<endl;

inline int sqr(int x) { return x * x; }
inline int sqrti(int x) {return (int)sqrt(x); }

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

#define put PUTS

signed main(){
    int N; cin >> N;
    put(sqr(sqrti(N)));
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class AOddsOfOddness {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    cout << (n + 1) / 2 / double(n) << endl;
}
};

int main() {
	AOddsOfOddness solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

i64 a,b;

string op;

int main()
{
    cin >> a >> op >> b;

    if(op.front() == '+')
    {
        cout << a + b;
    }
    else
    {
        cout <<a - b;
    }

}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = []
res = []
for k in range(K):
    d = input()
    for l in list(map(int, input().split())):
        a.append(int(l))
for i in range(1, N + 1):
    if a.count(i) == 0:
        res.append(i)
print(len(res))

Measured memory_bytes: 9248
using static System.Console;

class Program {
	static void Main() {
		var N = int.Parse(ReadLine());
		if (N % F(N) == 0) {
			WriteLine("Yes");
		} else {
			WriteLine("No");
		}
	}

	static int F(int n) {
		var result = 0;
		for (; n != 0; n /= 10) {
			result += n % 10;
		}
		return result;
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	int v[n+1],dp[n+1]{0};
	cin>>v[1];
	for(int i=2;i<=n;++i){
		cin>>v[i];
		if(i==2) {dp[i]=dp[i-1]+abs(v[i]-v[i-1]); continue;}
		dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	cout<<dp[n];
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

VI n{6,2,5,5,4,5,6,3,7,6};

int main(void){
    int N, M; cin >> N >> M;
    VI A(M);
    REP(i,M) cin >> A[i];
    SORT(A); REVERSE(A);

    VI dp(N+1,-100000); dp[0] = 0;
    REP(i,N){
        REP(j,M) if(i+1-n[A[j]] >= 0) chmax(dp[i+1], dp[i+1-n[A[j]]]+1);
    }

    string ans = "";
    int now = N;
    REP(i,dp[N]){
        REP(j,M){
            if(now-n[A[j]] >= 0 && dp[now-n[A[j]]] == dp[now]-1){
                ans += A[j]+'0';
                now -= n[A[j]];
                break;
            }
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int[] arrA = new int[n];
		int[] arrB = new int[n];
		for (int i = 0; i < n; i++) {
			arrA[i] = sc.nextInt();
			arrB[i] = sc.nextInt();
		}
		Arrays.sort(arrA);
		Arrays.sort(arrB);
		int count = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (arrB[i] <= arrA[n - 1]) {
				break;
			}
			h -= arrB[i];
			count++;
			if (h <= 0) {
				break;
			}
		}
		if (h > 0) {
			count += h / arrA[n - 1];
			if (h % arrA[n - 1] != 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

string S[] = {"Sunny", "Cloudy", "Rainy"};

string s;

int main()
{
    cin >> s;
    for (int i = 0; i < 3; i++)
        if (s == S[i]) {
            int ni = (i + 1) % 3;
            printf("%s\n", S[ni].c_str());
        }
    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();

    // input
    let h: usize = read(&mut stdin_lock, &mut buf, b' ');
    let a: usize = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    while ans * a < h {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
class Program
 {
        static void Main(string[] args)
        {
          string[] str = Console.ReadLine().Split(' ');
          int A = int.Parse(str[0]); 
          int B = int.Parse(str[1]);
 
          if(A >= 13)
          {
            Console.Write(B);
          }
          else if(A >= 6)
          {
            Console.Write(B/2);
          }
          else
          {
            Console.Write(0);
          }
        }
 }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

using vec = vector<int>;
using mat = vector<vec>;

int standard_mat(mat &A){
    int m = sz(A), n = sz(A[0]);
    int now = 0;
    rep(j, n){
        int pivot = now;
        rep2(i, now, m-1){
            if(A[i][j] > A[pivot][j]) pivot = i;
        }
        swap(A[now], A[pivot]);
        if(A[now][j] == 0) continue;
        rep(i, m){
            if(i == now) continue;
            rep2(k, j+1, n-1) A[i][k] ^= A[i][j]*A[now][k];
            A[i][j] = 0;
        }
        now++;
        if(now == m) break;
    }
    rep(i, m){
        bool flag = true;
        rep(j, n-1) if(A[i][j] == 1) flag = false;
        if(A[i][n-1] == 0) flag = false;
        if(flag) return 0;
    }
    return 1;
}

int main(){
    vector<int> ans;
    while(true){
        int H, W, D;
        cin >> W >> H >> D;
        if(H == 0 && W == 0 && D == 0) break;
        int s[H][W];
        rep(i, H){
            rep(j, W) cin >> s[i][j];
        }
        mat A(H*W, vec(H*W+1, 0));
        rep(i, H){
            rep(j, W){
                rep(k, H){
                    rep(l, W){
                        if(abs(k-i)+abs(l-j) == D) A[i*W+j][k*W+l] = 1;
                    }
                }
                A[i*W+j][i*W+j] = 1;
                A[i*W+j][H*W] = s[i][j];
            }
        }
        ans.pb(standard_mat(A));
    }
    for(auto &e: ans) cout << e << endl;
}


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

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define LL long long
#define ULL unsigned long long
#define LB lower_bound
#define MOD1 1000000007
#define MOD2 1000000009
#define INF LONG_MAX
#define pr(i, x, n)                    \
    for (int ii = i; ii < n + i; ii++) \
    {                                  \
        cout << x[ii] << " ";          \
    }                                  \
    cout << endl;
#define ip(i, x, n)                    \
    for (int ii = i; ii < n + i; ii++) \
    {                                  \
        cin >> x[ii];                  \
    };
#define db(x, y) cout << x << " " << y << endl;
#define LD long double
#define PR pair<LD, LL>

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

int main()
{
    static const int _ = []() {
        ios::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        return 0;
    }();
    int a,b;
  cin >> a >> b;
  
  string as = to_string(a), bs = to_string(b);
  
  
  string one = to_string(a) , two = to_string(b);
  
  for(int i = 1; i < b; i++)
  {
   	one = one + as; 
   	// cout << "hel";
  }
  
  for(int i = 1; i < a; i++){
    two += bs;
  }
//   cout << one << " " << two << " ";
  string ans = one > two ? two : one;
  
  cout << ans;


    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import heapq


INF = 10 ** 6


def check(N, adj_nodes, costs, from_node, to_node):
    # calculate shortest distances on a graph without a edge (from_node, to_node)
    dists = [INF for _ in range(N)]
    dists[from_node] = 0
    frontier = [(0, from_node)]
    while len(frontier) > 0:
        d, node = heapq.heappop(frontier)
        for next_node in adj_nodes[node]:
            if (from_node, to_node) == (node, next_node):
                continue
            next_d = costs[node][next_node] + dists[node]
            if dists[next_node] > next_d:
                dists[next_node] = next_d
                heapq.heappush(frontier, (next_d, next_node))
    return costs[from_node][to_node] > dists[to_node]


def main():
    N, M = list(map(int, input().split(' ')))
    adj_nodes = defaultdict(list)
    costs = [[INF for _ in range(N)] for _ in range(N)]
    edges = list()
    for _ in range(M):
        a, b, c = list(map(int, input().split(' ')))
        a -= 1
        b -= 1
        adj_nodes[a].append(b)
        adj_nodes[b].append(a)
        costs[a][b] = c
        costs[b][a] = c
        edges.append((a, b))
    ans = 0
    for edge in edges:
        from_node, to_node = edge
        if check(N, adj_nodes, costs, from_node, to_node):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3564
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  while(true){
    LL x, y;
    cin >> x >> y;
    if(x==0&&y==0){
      break;
    }
    cout << min(x, y) << " " << max(x, y) << endl;
  }
}



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


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
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, m;
    cin >> n >> m;
    vector<int> jobs[100100];
    rep(i,n){
        int a, b;
        cin >> a >> b;
        jobs[a].push_back(b);
    }

    int ans = 0;
    priority_queue<int> pq;
    for(int i = 1; i <= m; i++){
        for(auto b : jobs[i]){
            pq.push(b);
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5632
n = int(input())
k = int(input())

min_ans = 10**10
for i in range(2 ** n):
    ans = 1
    for j in range(n):
        if i & 2 ** j:
            ans += k
        else:
            ans *= 2
    min_ans = min(min_ans, ans)
print(min_ans)



Measured memory_bytes: 39536
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int* c = new int[m];
	for (int i = 0;i < m;i++) {
		cin >> c[i];
	}
	int* maisuu = new int[n + 1];
	maisuu[0] = 0;
	for (int i = 1;i <= n;i++) {
		maisuu[i] = i;
		for (int j = 0;j < m;j++) {
			if (c[j] > i)continue;
			maisuu[i] = min(maisuu[i], 1 + maisuu[i - c[j]]);
		}
	}
	cout << maisuu[n] << endl;
}


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

int main(){
    int n;
    cin>>n;
    int a[100];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(0<=j && a[j] > v){
        	a[j+1]=a[j];
		j--;
	}
	a[j+1]=v;
        for(int o=0;o<n;o++){
	  if(o) cout<<" ";
	  cout<<a[o];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088