akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define MAX 1000000000000000000
#define test int t; cin>>t;
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()

using namespace std;

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

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll res = 0;
    ll n = nxt();
    vector<ll>a(n);
    generate(all(a),nxt);
    for(int i = 0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k = j+1; k<n; k++){
                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
                    res++;
                }
            }
        }
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
inline void fin(bool b = true, ll e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    LL(n, a, b);
    print(max(0ll, (b - a) * (n - 2) + 1));
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  sort(a.begin(), a.end());
  
  cout << a.at(0) << " " << a.at(n-1) << " " << sum << endl;
}


Measured memory_bytes: 3232
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_to_string(&mut buf);
    let mut it = buf.split_whitespace();
    let a: i32 = it.next().unwrap().parse().unwrap();
    let b: i32 = it.next().unwrap().parse().unwrap();
    let x: i32 = it.next().unwrap().parse().unwrap();
    if x-a<0 || x-a>b {
        println!("NO");
    } else {
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#define N 110000
using namespace std;
int n,c,k;
long long t[N];
long long s[N];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>t[i];
    sort(t+1,t+n+1);
    int ff=0;
    for(int i=1;i<n;i++)
    {
        s[i]=s[i-1]+t[i];
        if(s[i]*2<t[i+1])ff=i;
    }
    cout<<n-ff;
}


Measured memory_bytes: 2424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	int h=0,w=0,h2=0,w2=0,ans=0;

	cin >> h >> w >> h2 >> w2;

	ans=h*w;
	ans=ans-((w*h2+h*w2)-h2*w2);

	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

int main(){
    int n;
    string s;

    cin >> s;
    n = s.length();
    //vector<char> vec(n);

    /*for(int i = 0; i < n; i++){
        vec[i] = s[i];
    }*/

    int ans = 0;
    for(int i = 1; i < n; i++){
        char c = s[i];
        if(s[i] == s[i - 1]){
            if(s[i] == '0') s[i] = '1';
            else if(s[i] == '1') s[i] = '0';
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
N, K = map(float, input().split())
N_ = N

ans = 0
cout = 0
while True:
  if N - K >= 0:
    ans += (N-K+1) / (2**cout)
    N = K - 1
  if K == 1:
    break
  K = (K+1) // 2
  cout += 1
print(ans / N_)


Measured memory_bytes: 2940
#include<stdio.h>
 
int main(void){
    int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
            min=a;
        if(max<a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int h[n];
    REP(i,n) cin >> h[i];
    int dp[n+4];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    FOR(i,2,n){
        dp[i] = min( dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs( h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;
}

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

const int DIM = 1e5 + 5;

int arr[DIM];

int main( void ) {
    
    int n, a, b;
    cin >> n >> a >> b;
    
    long long ans = 0;
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i];
        
        if( i >= 2 )
            ans += min( 1LL * b, 1LL * a * (arr[i] - arr[i - 1]) );
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# 
# a, b = list(map(int, input().split()))
# s = input()

H = int(input())
W = int(input())
N = int(input())

hoge = max(H, W)
print((N + hoge-1) // hoge)


Measured memory_bytes: 3060
def main():
    s = input()
    t = input()
    s_len = len(s)
    t_len = len(t)
    if s==t:
        print(0)
        exit()

    max_match = 0
    for k1 in range(s_len - t_len + 1):
        match = 0
        for k2 in range(t_len):
            if s[k1+k2]==t[k2]:
                match+=1
        max_match = max(match, max_match)
    print(t_len - max_match)

if __name__=="__main__":
    main()


Measured memory_bytes: 8988
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)
let rec for_all_iter a b f = if a >= b then true else f a && for_all_iter (a+1) b f

let list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])
let array_of_string str = Array.init (String.length str) (fun i -> str.[i])

let () =
  let s = read_line () in
  (if for_all_iter 0 (String.length s) (fun i -> s.[i] = s.[String.length s - 1 - i])
  then "Yes" else "No") |> printf "%s\n"


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <stack>
#include <set>

using namespace std;

int is_nibu(const int n, const vector<vector<int>>& e){
    // no -> -1
    vector<int> color(n);
    int black = 0;
    stack<int> next;
    color[0] = 1;
    black++;
    for(auto && node : e[0]){
        color[node] = color[0] == 1 ? 2 : 1;
        next.push(node);
    }
    while(!next.empty()){
        int np = next.top();
        next.pop();
        int cl = color[np] == 1 ? 2 : 1;

        for(auto && node : e[np]){
            if(color[node] == 0) {
                color[node] = cl;
                if(cl == 1)
                    black++;
                next.push(node);
            }
            else if(color[node] != cl){
                return -1;
            }
        }
    }
    return black;
}

int main() {
    int N, M;
    while(cin >> N >> M){
        if(N == 0) break;
        vector<vector<int>> e(N, vector<int>());
        for (int i = 0; i < M; ++i) {
            int u, v;
            std::cin >> u >> v;
            u--;v--;
            e[u].push_back(v);
            e[v].push_back(u);
        }
        int L = is_nibu(N, e);
        if(L == -1){
            cout << 0 << '\n';
            continue;
        }
        set<int> ans;
        if(L % 2 == 0){
            ans.insert(L/2);
        }
        L = N - L;
        if(L % 2 == 0){
            ans.insert(L/2);
        }
        cout << ans.size() << '\n';
        for (auto p : ans){
            cout << p <<'\n';
        }

    }
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <bitset>
#include <string>
#include <array>
#include <queue>
#include <set>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i=0; i<n; ++i){
        cin >> h[i];
    }
    int ans = 0;
    for (int j=0; j<101; ++j){
        int p = 0;
        bool flag;
        for (int k=0; k<n; ++k){
            if(k == 0){
                if(h[0] > 0){
                    p = 1;
                    flag = true;
                    h[0]--;
                }
                else if(h[0] == 0){
                    p = 0;
                    flag = false;
                }
            }
            else if(h[k] > 0){
                if(!flag){
                    p++;
                    flag = true;
                }
                h[k]--;
            }
            else if(h[k] == 0){
                if(flag){
                    flag = false;
                }
            }
            // cout << h[k] << " ";
        }
        ans += p;
        // cout << "ans -> " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long d = sc.nextInt();
		if (a>=0&&c>=0) {
			System.out.println(b*d);
		} else if (b<=0&&d<=0) {
			System.out.println(a*c);
		} else {
			long t[] = new long[4];
			t[0] = a*c;
			t[1] = a*d;
			t[2]= b*c;
			t[3] = b*d;
			Arrays.sort(t);
			if (t[3]>=0) {
				System.out.println(t[3]);
			} else {
				if ((b>0&&a<0)||(d>0&&c<0)) {
					System.out.println(0);
				} else {
					System.out.println(t[3]);
				}
			}
		}
	}
}

Measured memory_bytes: 35820
package main

import (
	"fmt"
)

func gcd(a int64, b int64) int64 {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a int64, b int64) int64 {
	return (a / gcd(a, b)) * b
}

func main() {
	var n int
	var m int64
	fmt.Scan(&n, &m)
	var b []int64
	lcmAll := int64(1)
	for i := 0; i < n; i++ {
		var a int64
		fmt.Scan(&a)
		bi := a / 2
		b = append(b, bi)
		lcmAll = lcm(lcmAll, bi)
		if lcmAll > m {
			fmt.Println(0)
			return
		}
	}
	for i := 0; i < n; i++ {
		if (lcmAll/b[i])%2 == 0 {
			fmt.Println(0)
			return
		}
	}
	ans := (m/lcmAll + 1) / 2
	fmt.Println(ans)
}


Measured memory_bytes: 5504
package main

import "fmt"

func main() {
	var w, h, x, y float64
	fmt.Scan(&w, &h, &x, &y)
	max := w * h / 2.0
	multipleWay := 0
	if x == w/2 && y == h/2 {
		multipleWay = 1
	}
	fmt.Printf("%f %d", max, multipleWay)
}



Measured memory_bytes: 512
#include <cstdio>
#define max(a,b) (a>b?a:b)

const int N=105;
char a[N];
int n,now,ans;

int main(){
	scanf("%d",&n);
	scanf("%s",a+1);
	for(int i=1;i<=n;i++){
		if(a[i]=='I') now++;
		else now--;
		ans=max(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

vector <string> M;
int w, h;

void search( int x, int y, char c )
{
	M[y][x] = '.';
	for ( int i = -1; i < 2; i++ )
	{
		for ( int j = -1; j < 2; j++ )
		{
			if ( i != j && ( i == 0 || j == 0 ) )
			{
				int nx = x+i;
				int ny = y+j;
				if ( nx < 0 || nx >= w || ny < 0 || ny >= h )
					continue;
				if ( c == M[ny][nx] )
					search( nx, ny, c );
			}
		}
	}
}

int main( void )
{
	while ( cin >> h >> w && h != 0 && w != 0 )
	{
		M = vector <string>( h );
		for ( int i = 0; i < h; i++ )
			cin >> M[i];

		int kotae = 0;
		for ( int i = 0; i < h; i++ )
		{
			for ( int j = 0; j < w; j++ )
			{
				if ( M[i][j] != '.' )
				{
					kotae++;
					search( j, i, M[i][j] );
				}
			}
		}
		cout << kotae << endl;
	}

	return 0;
}

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

#define MOD (int)(1e9+7)

long long mod_pow(long long x, long long n, int p) {
	if (n == 0)return 1;
	if (n == 1)return x%p;

	long long y = mod_pow(x,n/2,p);

	if (n % 2 == 0)return (y*y) % p;
	else return (x*((y*y) % p))%p;
}

vector<long long>factor;
vector<long long>rfactor;
void Factorial(vector<long long>&vec, int n, int p) {
	vec.assign(n+1,0);
	vec[0] = 1;
	for (int i = 1; i <= n; i++) {
		vec[i] = vec[i - 1] * i;
		vec[i] %= p;
	}
}
void rFactorial(vector<long long>&vec, int n, int p, int n_fac) {
	vec.assign(n + 1, 0);
	vec[n] = mod_pow(n_fac,p-2,p);
	for (int i = 1; i <= n; i++) {
		vec[n-i] = vec[n-i+1]*(n-i+1);
		vec[n-i] %= p;
	}
}

void nCr_ready(int n, int p) {
	Factorial(factor, n, p);
	long long n_fac = factor[n];
	rFactorial(rfactor, n, p, n_fac);
}

long long nCr(int n, int r, int p) {
	if (n < r)return 0;
	long long n_fac = factor[n];
	long long r_fac = rfactor[r];
	long long n_r_fac = rfactor[n - r];

	long long ans = 1;
	ans *= n_fac;
	ans %= p;
	ans *= r_fac;
	ans %= p;
	ans *= n_r_fac;
	ans %= p;

	return ans;
}

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


	vector<int>a(n+1);
	vector<int>pos(n+1);
	int first;
	int second;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
		if (pos[a[i]]) {
			first = pos[a[i]] - 1;
			second = i;
		}
		pos[a[i]] = i+1;
	}

	nCr_ready(n+1, MOD);

	for (int i = 1; i <= n+1; i++) {
		cout << (nCr(n+1,i,MOD) - nCr(n-second+first,i-1,MOD) + MOD)%MOD << endl;
	}

    return 0;
}



Measured memory_bytes: 3584
#include <stdio.h>
int main(void){
  int n,i,a[2][100],w[100],max;
  scanf("%d",&n);
  for (i=0;i<n;i++) scanf("%d",&a[0][i]);
  for (i=0;i<n;i++) scanf("%d",&a[1][i]);
  w[0]=a[0][0];
  for (i=0;i<n;i++) w[0]+=a[1][i];
  max=w[0];
  for (i=1;i<n;i++){
    w[i]=w[i-1]+a[0][i]-a[1][i-1];
    if (max<w[i]) max=w[i];
  }
  printf("%d\n",max);
  return 0;
}

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

const int maxn = 1e6;
int dp[maxn];

int solve(int a[], int i, int n){
	// reach a last
	if(i==(n-1)) return 0;
	// not reachable
	if(i>=n) return INT_MAX;
	
	if(dp[i] != -1)
		return dp[i];
	
	int left=INT_MAX, right=INT_MAX;
	left = abs(a[i]-a[i+1])+solve(a, i+1, n);
	
	if(i+2 < n){
		right=abs(a[i]-a[i+2]) + solve(a, i+2, n);
	}
	
	return dp[i] = min(right, left);
}

int bottomup(int a[], int n){
	const int INF = 1e9+5;
	vector<int> ddp(n, INF);
	ddp[0]=0;
	for(int i=0; i<n; i++) {
		for(int j : {i+1, i+2}) {
			if(j<n) {
				ddp[j]=min(ddp[j], ddp[i] + abs(a[i] - a[j]) );
			}
		}
	}
	
	cout << ddp[n-1] << "\n";
}

int solve(int a[], int n){
	if(n==0)
		return 0;
	
	if(n<0)
		return INT_MAX;
	
	if(dp[n]!=-1)
		return dp[n];
			
	int one = INT_MAX, two = INT_MAX;
	
	if(n-1 >= 0)
		one = abs(a[n]-a[n-1]) + solve(a, n-1);
	
	if(n-2 >= 0)
		two = abs(a[n]-a[n-2]) + solve(a, n-2);
	
	return dp[n] = min(one, two);
}

void solve(){
	int n; cin >> n;
	int a[n]={};
	for(int i=0; i<n; i++)
		cin >> a[i];
	bottomup(a, n);
	
//	memset(dp, -1, sizeof(dp));			
//	cout << solve(a, n-1) << "\n";	
}

int main(){
	solve();
}

Measured memory_bytes: 1024
#include <iostream>
#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 <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    string s[1001]; int n;
    while(cin >> n) {
        if(n == 0) break;
        rep(i,0,n) cin >> s[i];
        int ans = 0;

        int dp[1001][1001];
        rep(i,0,n) dp[i][0] = (s[i][0] == '.' ? 1 : 0);
        rep(j,0,n) dp[0][j] = (s[0][j] == '.' ? 1 : 0);

        rep(i,1,n) {
            rep(j,1,n) {
                if(s[i][j] == '.')
                    dp[i][j] = min(min(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]) + 1;
                else dp[i][j] = 0;
                ans = max(ans, dp[i][j]);
            }
        }

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

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

Q = int(input())
A = []
ans = []

for _ in range(Q):
    q = list(map(int,input().split()))
    if q[0] == 0:
        A.append(q[1])
    elif q[0] == 1:
        ans.append(A[q[1]])
    else:
        A.pop()

print(*ans,sep='\n')


Measured memory_bytes: 13624
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int H, W, i, j;
	for (;;) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if ((i + j) & 1) putchar('.');
				else putchar('#');
			}
			putchar('\n');
		}
		putchar('\n');
	}

	return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class BSortingASegment {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, k;
    cin >> n >> k;
    vector<int> P(n);
    for (auto &p: P) cin >> p;

    int ans = 1;
    set<int> S;
    for (int i = 0; i < k; i++)
        S.insert(P[i]);

    for (int i = 0; i < n - k; i++){
        if (!(S.find(P[i]) == S.begin() and *--S.end() < P[i + k]))
            ans++;
        S.erase(P[i]);
        S.insert(P[i + k]);
    }

    int cnt = 0;
    for (int i = 0; i < k - 1; i++){
        if (P[i] < P[i + 1])
            cnt++;
    }

    int cnt_order = 0;
    bool prev = false;
    for (int i = 0; i < n - k; i++){
        if (cnt >= k - 1 and !prev){
            cnt_order++;
        }
        prev = cnt >= k - 1;
        if (P[i + k - 1] < P[i + k])
            cnt++;
        if (P[i] < P[i + 1])
            cnt--;
    }

    if (cnt >= k - 1 and !prev)
        cnt_order++;

    cout << ans - max(0, cnt_order - 1) << endl;
}
};

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


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

ll dfs(ll s) {
}

int main() {
  ll n;
  cin >> n;
  vector<ll> vec;
  ll six_n = 6, nine_n = 9;
  vec.push_back(1);
  while(six_n <= n) {
    vec.push_back(six_n);
    six_n *= 6;
  }

  while(nine_n <= n) {
    vec.push_back(nine_n);
    nine_n *= 9;
  }

  vector<ll> ans(100010, 100010);
  ans[0] = 0;
  for(int i=0;i<=n;i++) {
    for(auto ele : vec) {
      if(i-ele >= 0) {
        ans[i] = min(ans[i], ans[i-ele]+1);
      }
    }
  }

  cout << ans[n] << endl;


}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-max
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// max-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=max(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return -INF; // max
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return max(lv,rv); // max
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmax(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};

int main() {
  ll n,m;
  cin >> n >> m;
  segtree dp(n+1);
  dp.Set(0,n+1,0);
  vector<vector<pll>> G(n+1);
  for(ll i=0;i<m;i++) {
    ll l,r,a;
    cin >> l >> r >> a;
    G[r].push_back({l,a});
  }
  for(ll i=1;i<=n;i++) {
    dp.Set(i,i+1,dp.Getmax(0,i));
    for(auto p:G[i]) {
      dp.Add(p.first,i+1,p.second);
    }
  }
  cout << dp.Getmax(0,n+1) << endl;
}

Measured memory_bytes: 30644
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
ll a[100];
int main()
{
	dhoom;
	int n;
	cin >> n;
	int a , b;
	cin >> a >> b;
	int cnt = 0;
	for(int i = 0 ; i <= n ; i++){
		int x = i;
		int sum = 0;
		while(x != 0){
			sum += (x%10);
			x/=10;
		}
		if(sum >= a && sum <= b)
			cnt += i;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
N,M = map(int,input().split())

sc = []
for i in range(M) :
    sc.append([int(i) for i in input().split()])

low = pow(10,N-1)
high = pow(10, N)

if (N == 1 and M == 0) :
    print(0)
elif (N == 1 and M == 1) :
    s = sc[0][0]
    c = sc[0][1]
    print(c)
else :
    for i in range(low,high) :
        numstr = str(i)
        is_match = True
        for item in sc :
            s = item[0]
            c = item[1]
            if (int(numstr[s-1]) != c) :
                is_match = False
                break
        
        if (is_match) :
            print(numstr)
            break

    if (not is_match) :
        print(-1)


Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 45

int main(void){
  int n,i,a[MAX];

  scanf("%d",&n);

  for(i=0; i<=n; i++){
    a[i]=1;
    if(i<2) continue;
    a[i]=a[i-1]+a[i-2];
  }
  printf("%d\n",a[n]);
  return 0;
}

Measured memory_bytes: 596
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()



n=ii()
a=lmi()
S=0
for i in a:
  S=S^i

b=[]
for i in a:
  a_=S^i
  b.append(a_)

print(' '.join(map(str,b)))

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

using namespace std;

#define debug(x) cout << #x << "::" << x << endl;
#define debug2(x, y) cout << #x << "::" << x << " " << #y << "::" << y << endl;
#define debug3(x, y, z) cout << #x << "::" << x << " " << #y << "::" << y <<" "<< #z << "::" << z << endl;

#define For(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
const ll mod = 1e9 + 7;
const int MAX = 5 * 1e3 + 5;
typedef pair<int, int> pii;

void add(ll &a, ll b)
{
    a = (a + b) % mod;
    if (a < 0) a += mod;
}

int main() {

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

    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];

    vector<int> dp(n+1,mod);
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        for(int j=i-1;j>=1 && j >= i - k;j--){ 
            dp[i] = min(abs(a[i] - a[j]) + dp[j],dp[i]);
        }
    }

    cout<<dp[n]<<endl;

    return 0;
    
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
n=int(input())
Edge=[[] for i in range(n)]
XY=[]
append=XY.append
for i in range(n):
  x,y=map(int,input().split())
  append([i,x,y])
XY.sort(key=lambda x:x[1])
for i in range(1,n):
  n1,x1,y1=XY[i-1][0],XY[i-1][1],XY[i-1][2]
  n2,x2,y2=XY[i][0],XY[i][1],XY[i][2]
  Edge[n1].append([min(abs(x2-x1),abs(y2-y1)),n2])
  Edge[n2].append([min(abs(x2-x1),abs(y2-y1)),n1])
XY.sort(key=lambda x:x[2])
for i in range(1,n):
  n1,x1,y1=XY[i-1][0],XY[i-1][1],XY[i-1][2]
  n2,x2,y2=XY[i][0],XY[i][1],XY[i][2]
  Edge[n1].append([min(abs(x2-x1),abs(y2-y1)),n2])
  Edge[n2].append([min(abs(x2-x1),abs(y2-y1)),n1])
import heapq
def prim_heap():
  used=[True]*n
  Edgelist=[]
  for e in Edge[0]:
    heapq.heappush(Edgelist,e)
  used[0]=False
  res=0
  while len(Edgelist)!=0:
    minedge=heapq.heappop(Edgelist)
    if not used[minedge[1]]:
      continue
    v=minedge[1]
    used[v]=False
    for e in Edge[v]:
      if used[e[1]]:
        heapq.heappush(Edgelist,e)
    res+=minedge[0]
  return res
print(prim_heap())


Measured memory_bytes: 122800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

																	  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
																	<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
																	 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>
*/

int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
	int x ,n;
	cin>>x>>n;
	vector<int>v(n);
	map<int,int>mp;
	for(int i=0;i<n;i++){
	cin>>v[i];
	mp[v[i]] = 1;
	}
	int mn = 1e5 , ans = x;
	for(int i = 0 ; i <= x*2 ; i++){
		if(mp[i]==0){
			if(mn > abs(x - i)){
				mn = abs(x - i);
				ans = i;
			}
			else if(mn == abs(x - i)){
				ans = min(ans , i);
			}
		}
	}	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>

using ll = long long;
using ull = unsigned long long;

using namespace std;
int main()
{
  ll n, m;
  cin >> n >> m;
  ull sum = 0;
  map<ull, ull> memo;
  ll tmp = 0;
  memo.insert(make_pair(0, 1));
  for (auto i = 0; i < n; i++) {
    cin >> tmp;
    sum = (sum + tmp) % m;
    auto q = memo.find(sum);
    if (q == memo.end()) memo.insert(make_pair(sum, 1));
    else q->second++;
  }
  ll res = 0;
  for (auto q: memo) {
    if (q.second > 1) {
      res += (q.second * (q.second-1)) / 2;
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+10,MAXM=2e6+10;
const int INF=INT_MAX,MOD=1e9+7;
const ll llINF=~(1ll<<63);

int head[MAXN],val[MAXN],to[MAXN],_next[MAXN],cnt;

void add_Edge(int u,int v,int w)
{
    _next[++cnt]=head[u];
    to[cnt]=v;
    val[cnt]=w;
    head[u]=cnt;
}

int co[MAXN],vis[MAXN];

void dfs(int u)
{
    vis[u]=1;
    for(int i=head[u];i;i=_next[i])
    {
        int v=to[i];
        if(!vis[v])
        {
            co[v]=co[u]^val[i];
            dfs(v);
        }
    }
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        add_Edge(u,v,w&1);
        add_Edge(v,u,w&1);
    }
    dfs(1);
    for(int i=1;i<=n;i++)cout<<co[i]<<endl;
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	bool ok = true;
	for (int i = 0; i < n; i++)
	{
		int x; cin >> x;
		if (x % 2 == 0)
		{
			if (x % 3 == 0)	continue;
			if (x % 5 == 0)	continue;
			ok = false;
		}
	}
	if (ok)	puts("APPROVED");
	else	puts("DENIED");
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b, c;
  cin >> a >> b >> c;
  ll d = c - a - b;
  if (d > 0 && 4 * a * b < d * d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] n = sc.next().toCharArray();
		for (int i = 0; i < n.length; i++) {
			if (n[i] == '1') {
				n[i] = '9';
			} else if (n[i] == '9') {
				n[i] = '1';
			}
		}
		System.out.println(String.valueOf(n));
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
map<string,bool> m;
string s;
char ch;
int n;
int main()
{
	scanf("%d",&n);
	cin>>s;
	m[s]=true;
	ch=s[s.size()-1];
	for(int i=1;i<n;i++)
	{
		cin>>s;
		if(s[0]!=ch||m[s]==true)
		{
			puts("No");
			return 0;
		}
		ch=s[s.size()-1];
		m[s]=true;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int H, W, h, w, masu, siro;

	scanf("%d %d", &H, &W);
	scanf("%d %d", &h, &w);

	masu = H * W;
	siro = (H - h)*(W - w);

	printf("%d\n", siro);

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321
#define MAXV 3000500


#define MOD 1234567

int N,M,T,K;
int p[5][1000];
int dp[5][1000];
int main(){
	geti(M);
	repp(i,2) repp(j,M) geti(p[i][j]);

	repp(i,2){
		repp(j,M){
			dp[i][j] = max(dp[i-1][j], dp[i][j-1] );
			dp[i][j] += p[i][j];
		}
	}
	printf("%d\n",dp[2][M]);

}



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

using namespace std;

int main() {
	int ans = 0;

	string  s;

	cin >> s;
	
	int N = s.size();
	
	int g = 0, k = 0;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0 && s[i] == '1')	g++;
		else if(i % 2 == 1 && s[i] == '1') k++;
	}
	if (g > k) {
		if(N % 2 == 0) 
			ans = N / 2 - g + k;
		
		else
			ans = (N+1 )/ 2 - g + k;
	}
	else {
		if (N % 2 == 0)
			ans = N / 2 - k+g;

		else
			ans = (N - 1) / 2 - k + g;
	}


	cout << ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 hh, aa, as, ii = 1;
	cin >> hh >> aa;
	as = aa;
	while(hh > as)
	{
		ii++;
		as = aa * ii;
	}
	cout << ii << endl;
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  cin >> a;
  if (a == "A")
    cout << "T";
  else if (a == "T")
    cout << "A";
  else if (a == "C")
    cout << "G";
  else if (a == "G")
    cout << "C";
}

Measured memory_bytes: 3576
#include <iostream>
#define MOD 1000000007
typedef long long ll;

using namespace std;

// n^(exponent)を計算 O(logN)
ll pow(ll n, ll exponent) {
    ll pow = 1;
    while(exponent > 0) {
        if((exponent & 1) == 1) {
            pow *= n;
        }
        n *= n;
        
        // 桁をずらす
        exponent >>= 1;
    }
    return pow;
}

ll mod_pow(ll n, ll exponent, ll mod) {
    ll pow = 1;
    while(exponent > 0) {
        if((exponent & 1) == 1) {
            pow *= n;
            pow %= mod;
        }
        n *= n;
        n %= mod;
        
        // 桁をずらす
        exponent >>= 1;
    }
    return pow;
}

// 階乗計算
ll factorial(ll n) {
    ll factorial = 1;
    for(ll i = 1; i <= n; i++) {
        factorial *= i;
    }
    return factorial;
}

ll mod_factorial(ll n, ll mod) {
    ll factorial = 1;
    for(ll i = 1; i <= n; i++) {
        factorial *= i;
        factorial %= mod;
    }
    return factorial;
}

// xCn を計算
ll conbination(ll x, ll n) {
    if(x < n) {
        return -1;
    }
    
    return factorial(x) / (factorial(n) * factorial(x - n));
}

ll mod_conbination(ll x, ll n, ll mod) {
    if(x < n) {
        return -1;
    }
    
    ll conbination = mod_factorial(x, mod);
    conbination *= mod_pow(mod_factorial(n, mod), mod - 2, mod);
    conbination %= mod;
    conbination *= mod_pow(mod_factorial(x - n, mod), mod - 2, mod);
    return conbination % mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    
    for(int i = 1; i <= k; i++) {
        if(i - 1 <= n - k) {
            cout << (mod_conbination(k - 1, i - 1, MOD) * mod_conbination(n - k + 1, i, MOD)) % MOD << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int n;
	double x;
	string s;
	double sum = 0;

	cin >> n;
	rep(i, n){
		cin >> x;
		cin >> s;

		if(s == "BTC")
			sum += x * 380000;
		else
			sum += x;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 50;

vector<ll> get_div(ll x) {
    vector<ll> res;
    for (ll i = 1; i * i <= x; ++i) {
        if (x % i) continue;
        res.push_back(i);
        if (i * i != x) res.push_back(x / i);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> divs = get_div(N);
    ll ans = INF;
    for (int i = 0; i < divs.size(); ++i) {
        ans = min(ans, divs[i] + N / divs[i] - 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <deque>
#include <cstring>

using std::deque;

const int MAXK=1e5+5;
int k;

inline int BFS_Dijkstra(){
	static int dis[MAXK];
	static deque<int> dq;
	memset(dis,0x7f,sizeof(dis));
	dis[1]=0;
	dq.push_back(1);
	int u,v,d;
	while(dq.size()){
		u=dq.front();
		dq.pop_front();
		if(u==0) return dis[u]+1;
		v=(u+1)%k,d=dis[u]+1;
		if(dis[v]>d){
			dis[v]=d;
			dq.push_back(v);
		}
		v=(u*10)%k,d=dis[u];
		if(dis[v]>d){
			dis[v]=d;
			dq.push_front(v);
		}
	}
}

int main(){
	scanf("%d",&k);
	printf("%d",BFS_Dijkstra());
	return 0;
}

Measured memory_bytes: 768
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)
	var n, q int
	fmt.Scan(&n, &q)

	// n, q := nextInt(), nextInt()
	// n++
	var s string
	fmt.Scan(&s)
	slice := strings.Split(s, "")

	l := make([]int, q)
	r := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&l[i], &r[i])
	}

	ans := make([]int, n+1)
	ans[0] = 0

	for i := 0; i < n-1; i++ {
		if (slice[i] + slice[i+1]) == "AC" {
			ans[i+1] = ans[i] + 1
		} else {
			ans[i+1] = ans[i]
		}
	}

	for i := 0; i < q; i++ {
		right := ans[r[i]-1]
		left := ans[l[i]-1]
		fmt.Println(right - left)
	}

	// for i := 0; i < q; i++ {
	// 	// var tmp string
	// 	count := 0
	// 	// fmt.Println(s[l[i]-1 : r[i]])
	// 	ss := slice[l[i]-1 : r[i]]

	// 	for i := 0; i < len(ss)-1; i++ {

	// 		if ss[i] != "A" {
	// 			continue
	// 		}
	// 		// fmt.Println(ss[i] + ss[i+1])

	// 		if (ss[i] + ss[i+1]) == "AC" {
	// 			count++
	// 		}

	// 	}
	// fmt.Println(count)

}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b;
  cin >> a >>b;
  cout << a - b + 1 << endl;
}


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

#define int long long
#define mp make_pair
#define pb push_back
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define EPS 0.00000001

const int inf = 4e18; ///
const int mod2 = 1e9+7;

using namespace std;
void print(vector<int> & v){
    for(auto it:v) cout << it << " ";
    cout << "\n";
}

signed main(){
    int a,n;
    cin >> a >> n;
    int s = 0;
    for(int i = 0;i<n;i++){
        int x;
        cin >> x;
        s += x;
    }
    cout << ((a-s) < 0 ? -1 : (a-s));
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N;
    long long B, A;
    cin >> N >> A >> B;
    vector<int> h(N);
    repeat(i, N) cin >> h[i];

    long long ng = 0, ok = 1e9 + 7;
    while (abs(ok - ng) > 1) {
        long long mid = ng + (ok - ng) / 2;
        //cout << "ng: " << ng << " mid: " << mid << " ok: " << ok << endl;
        // mid回攻撃を行う
        long long T = 0;
        repeat(i, N) {
            if (mid * B <= h[i]) {
                T += (h[i] - mid * B + A - B - 1) / (A - B);
            }
        }
        if (T <= mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {

  ll N, K;
  cin >> N >> K;

  vector<ll> H;
  ll temp;
  REP(i, 0, N) {
    cin >> temp;
    H.push_back(temp);
  }

  sort(H.begin(), H.end(), greater<ll>());
  // debug
  // REP(i, 0, N) {
  //   cout << H[i] << " ";
  // }
  // cout << endl;

  ll ans = 0;
  REP(i, 0, N) {
    if (i < K) {
      // do nothing (use hissatu)
    }
    else {
      ans = ans + H[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
/*
int main(){
	int n;
	int count=0;
	string name;
	cin >> n >> name;
	vector<string> signs(n);
	for(int i=0; i<n; ++i){
		cin >> signs[i];
		cout << signs[i].size() << "\n";
	}
	for(int m=0; m<n; ++n){

		for(unsigned int i=0; i<signs[m].size(); ++i){
			for(unsigned int j=1; i+(name.size()-1)*j<signs[m].size(); ++j){
				for(unsigned int k=0; k<name.size(); ++k){
					if(signs[m][i+k*j]!=name[k]){
						goto fail;
					}
				}
				count++;
				goto naxtk;
fail:;
			}
		}
naxtk:;
	}
	cout << count << "\n";
	return 0;
}
*/

int main(){
	int n;
	while(cin >> n&&n!=0){
	vector<int> Taro(2*n+1);
	vector<int> Hanako(2*n+1);
	int tc=n, hc=n;
	int max=0;
	bool ok=false;
	for(int i=0; i<n; ++i){
		int m;
		cin >> m;
		Taro[m]=1;
	}
	for(int i=1; i<2*n+1; ++i){
		if(Taro[i]==0) Hanako[i]=1;
	}
	/*for(int i=1; i<2*n+1; ++i){
			if(Taro[i]==1){
				cout << i << " ";
			}
	}*/
	while(1){
		if(tc==0 || hc==0) break;
		for(int i=1; i<2*n+1; ++i){
			if(max<i && Taro[i]==1){
				max=i;
				Taro[i]=0;
				ok=true;
				--tc;
				break;
			}
		}/*
		for(int i=1; i<2*n+1; ++i){
			if(Taro[i]==1){
				cout << i << " ";
			}
		}*/
		//cout << "\n";
		if(ok==false) max=0;
		ok=false;
		if(tc==0 || hc==0) break;
		for(int i=1; i<2*n+1; ++i){
			if(max<i && Hanako[i]==1){
				max=i;
				Hanako[i]=0;
				ok=true;
				--hc;
				break;
			}
		}/*
		for(int i=1; i<2*n+1; ++i){
			if(Hanako[i]==1){
				cout << i << " ";
			}
		}*/
		//cout << "\n";
		if(ok==false) max=0;
		ok=false;
	}
	cout << hc <<  "\n" << tc << "\n";
	}
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    int a[n/2],b[n/2+1],cnt=0,ans=0,r=0,l=0,t;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        if(i%2==0)
        {
          b[r]=t;
          cnt++;
          r++;
        }
        else
        {
            a[l]=t;
            ans++;
            l++;
        }
    }
     if(n%2==0)
     {
         REV(a,ans);
         for(int i=0;i<ans;i++)
         {
             cout<<a[i]<<" ";
         }
         for(int i=0;i<cnt;i++)
         {
             cout<<b[i]<<" ";
         }
         return 0;
     }
     else
     {
         REV(b,cnt);
         for(int i=0;i<cnt;i++)
         {
             cout<<b[i]<<" ";
         }
         for(int i=0;i<ans;i++)
         {
             cout<<a[i]<<" ";
         }
     }
    return 0;
}


Measured memory_bytes: 2944