akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<int> h(N);
    for (int i = 0; i < N; i++) {
        std::cin >> h[i];
    }

    int count = 0;
    bool flag = true;

    bool to = false;
    while(flag) {
        for (int i = 0; i < N; i++) {
            if (h[i] != 0) {
                break;
            }
            if (i == N-1 && h[N-1] == 0) {
                to = true;
                break;
            }
        }

        if (to) {
            break;
        }

        int zero_count = 0;

        for (int i = 1; i < N; i++) {
            if (h[i-1] == 0 && h[i] != 0) {
                zero_count++;
            }
        }

        if (h[0] != 0) {
            zero_count++;
        }

        for (int i = 0; i < N; i++) {
            if (h[i] > 0) {
                h[i]--;
            }
        }

        if (zero_count == 0 || zero_count == 1) {
            count++;
        } else {
            count += zero_count;
        }

        for (int i = 0; i < N; i++) {
            if (h[i] != 0) {
                break;
            }
            if (i == N-1) {
                if (h[i] == 0) {
                    flag = false;
                }
            }
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define YES 1
#define NO 0

int tri_judge(int x, int y, int z);
int pow2(int x);

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

    int side1, side2, side3;
    while (dataset--){
        scanf("%d %d %d", &side1, &side2, &side3);
        int yn = tri_judge(side1, side2, side3);
        if (yn == YES){
            printf("YES\n");
        } else {
            printf("NO\n");
        }

    }

    return 0;
}

int tri_judge(int x, int y, int z)
{
    int yn;
    if (pow2(x) == pow2(y) + pow2(z)){
        yn = YES;
    } else if (pow2(y) == pow2(z) + pow2(x)){
        yn = YES;
    } else if (pow2(z) == pow2(x) + pow2(y)){
        yn = YES;
    } else {
        yn = NO;
    }

    return yn;
}

int pow2(int x)
{
    return x * x;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,i,j,n,m,ans,minn,pos,k;
    cin>>n;
    minn=n+1;
    for(i=0; i<5; i++)
    {
        cin>>a;
        if(a<minn)
        {
            minn=a;
        }
    }
    k=n/minn;
    if(n%minn!=0)k++;
    ans=k+4;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
poker = [2,3,4,5,6,7,8,9,10,11,12,13,1]
alise, bob = gets.split(" ").map(&:to_i)
a = poker.index(alise)
b = poker.index(bob)
puts "Alice" if a > b
puts "Bob" if a < b
puts "Draw" if a == b



Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long n,t;
    cin>>n>>t;
    long long c=0;
    long long a[200000];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n-1;i++){
        c+=min(t,a[i+1]-a[i]);
    }
    cout<<c+t<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
using namespace std;
int head2[131072],last2[131072],to2[131072],cnt2=0;
void add2(int u,int v)
{
	cnt2++;
	last2[cnt2]=head2[u];
	head2[u]=cnt2;
	to2[cnt2]=v;
}
int a[131072],b[131072];
long long s[131072],ans[131072];
long long dfs(int u)
{
	s[u]=a[u]-b[u];
	for(int i=head2[u];i;i=last2[i])
	{
		int v=to2[i];
		dfs(v);
		s[u]+=s[v];
	}
	ans[u]=s[u]+b[u];
	for(int i=head2[u];i;i=last2[i])
	{
		int v=to2[i];
		long long a2=s[u]-s[v];
		if(ans[v]>b[u])
		{
			a2+=ans[v];
		}
		else
		{
			a2+=b[u];
		}
		if(a2<ans[u])
		{
			ans[u]=a2;
		}
	}
	return ans[u];
}
int head[131072],last[262144],to[262144],cnt=0;
void add(int u,int v)
{
	cnt++;
	last[cnt]=head[u];
	head[u]=cnt;
	to[cnt]=v;
}
struct node{
	int u;
	int a;
	int b;
	bool operator<(node c) const
	{
		return b<c.b;
	}
};
node nn[131072];
bool vis[131072];
int fa[131072];
int findroot(int x)
{
	if(fa[x]==x)
	{
		return x;
	}
	return fa[x]=findroot(fa[x]);
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		nn[i].u=i+1;
		int a,b;
		scanf("%d%d",&a,&b);
		if(a<b)
		{
			a=b;
		}
		nn[i].a=a;
		nn[i].b=a-b;
	}
	sort(nn,nn+n);
	while(m--)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		vis[i]=false;
	}
	for(int t=0;t<n;t++)
	{
		int u=nn[t].u;
		vis[u]=true;
		a[u]=nn[t].a;
		b[u]=nn[t].b;
		for(int i=head[u];i;i=last[i])
		{
			int v=to[i];
			if(!vis[v])
			{
				continue;
			}
			v=findroot(v);
			if(v!=u)
			{
				add2(u,v);
				fa[v]=u;
			}
		}
	}
	int root=nn[n-1].u;
	printf("%lld\n",dfs(root));
	return 0;
}

Measured memory_bytes: 10880
N = int(input())
P = list(map(int, input().split()))

'''
参考
https://cocoinit23.com/abc152/
すべての(i, j)を調べていると制限時間を超過してしまう。
listの2つ目の要素(index=1)から順に見ていって、最小値が更新されたら解をカウントアップする。
ただし、解の最小値は常に1となるので、解の初期値は1にしておくこと。
'''
ans = 1
min_p = P[0]

for i in range(1, N):
    if P[i] <= min_p:
        min_p = P[i]
        ans += 1

print(ans)


Measured memory_bytes: 24744
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        a: u64,
        b: u64,
    }

    if a % 2 == 0 || b % 2 == 0 {
        println!("{}", "Even")
    } else {
        println!("{}", "Odd")
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>
#include <array>
#include <cstdio>

using namespace std;

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

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

    double x = L / 3.0;

    printf("%.10f", x*x*x);

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define mo 998244353
#define N 310
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
ll a[N][N],p[N][N];
ll m,n,sum;
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
int main(){
	read(n);read(m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)read(a[i][j]);
	for (int i=1;i<=n;i++){
		for (int j=m;j>=1;j--){
			if (p[j][j]==0){
				if (a[i][j]==1){
					for (int k=1;k<=j;k++) p[j][k]=a[i][k];
					sum++;
					break;
				}
			}else{
				if (a[i][j]==1)for (int k=1;k<=j;k++) a[i][k]^=p[j][k];
			}
		}
	}
	cout<<((po(2,n)-po(2,n-sum)+mo)%mo)*po(2,m-1)%mo<<endl;
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);


    String S = sc.next();
    int n = S.length();
    String tmp="R";
    int size[] =new int[n];
    int bound[] =new int[n];
    int cntR[] =new int[n];
    int cntL[] =new int[n];
    int tmpsize=0;
    int tmpcntR=0;
    int tmpcntL=0;
    int cntBlock=0;
    int ans[] = new int[n];
    //RR..RL....Lのブロックを集めて大きさと境界の場所とRの数とLの数を管理する
    
    for(int i=0;i<S.length();i++){
      if(tmp.equals(S.substring(i,i+1))){
        tmpsize++;
        if(tmp.equals("R")){
          tmpcntR++;
        }else{
          tmpcntL++;
        }
      }else if(tmp.equals("R")){
        tmpsize++;
        bound[cntBlock]=i;
        tmpcntL++;
        tmp="L";
      }else{
        cntR[cntBlock]=tmpcntR;
        cntL[cntBlock]=tmpcntL;
        size[cntBlock]=tmpsize;
        cntBlock++;
        tmpsize=1;
        tmpcntR=1;
        tmpcntL=0;
        tmp="R";
      }
    }
    cntR[cntBlock]=tmpcntR;
    cntL[cntBlock]=tmpcntL;
    size[cntBlock]=tmpsize;

    for(int i=0;i<n;i++){
      ans[i]=0;
    }
    for(int i=0;i<=cntBlock;i++){
      ans[bound[i]-1]=(cntL[i]/2)+((cntR[i]+1)/2);
      ans[bound[i]]=size[i]-ans[bound[i]-1];
    }
    for(int i=0;i<n;i++){
      System.out.print(ans[i]);
      System.out.print(" ");
    }




  }
  

  
}


Measured memory_bytes: 45180
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    long ans = (a * c);
    ans = Math.max(ans, a * d);
    ans = Math.max(ans, b * c);
    ans = Math.max(ans, b * d);
    System.out.println(ans);
  }
}

Measured memory_bytes: 35760
#include <iostream>
#include <string>
#include <complex>
#include <cstdlib>

int main(){
    long int n, k, t1, t2=0, ans;
    std::cin >> n >> k;
    t1 = n%k;
    if(t1 > k){
        t2 = t1 - k;
    }else{
        t2 = k - t1;
    }

    if(t1 > t2){
           std::cout << t2 << std::endl;
    }else{
        std::cout << t1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	cnt := 0
	for i := 0; i < n; i++ {
		mini := i
		for j := i; j < n; j++ {
			if a[j] < a[mini] {
				mini = j
			}
		}
		if i != mini {
			a[i], a[mini] = a[mini], a[i]
			cnt++
		}
	}
	fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	fmt.Println(cnt)
}



Measured memory_bytes: 1212
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int cs[5];
    while(scanf("%d,%d,%d,%d,%d",&cs[0],&cs[1],&cs[2],&cs[3],&cs[4])!=-1){
        sort(cs,cs+5);
        if((cs[0]==cs[1] && cs[1]==cs[2] && cs[2]==cs[3]) || (cs[1]==cs[2] && cs[2]==cs[3] && cs[3]==cs[4])) printf("four card\n");
        else if((cs[0]==cs[1] && cs[2]==cs[3] && cs[3]==cs[4]) || (cs[0]==cs[1] && cs[1]==cs[2] && cs[3]==cs[4])) printf("full house\n");
        else if(cs[0]==1 && cs[1]==10 && cs[2]==11 && cs[3]==12 && cs[4]==13) printf("straight\n");
        else if(cs[0]==cs[1]-1 && cs[1]==cs[2]-1 && cs[2]==cs[3]-1 && cs[3]==cs[4]-1) printf("straight\n");
        else if((cs[0]==cs[1] && cs[1]==cs[2]) || (cs[1]==cs[2] && cs[2]==cs[3]) || (cs[2]==cs[3] &&cs[3]==cs[4])) printf("three card\n");
        else{
            int ps=0;
            if(cs[0]==cs[1]) ps++;
            if(cs[1]==cs[2]) ps++;
            if(cs[2]==cs[3]) ps++;
            if(cs[3]==cs[4]) ps++;
            if(ps==2) printf("two pair\n");
            else if(ps==1) printf("one pair\n");
            else printf("null\n");
        }
    }
}

Measured memory_bytes: 0
n, t = map(int, input().split())
_list = [input() for i in range(n)]
costs, times = [], []
for elem in _list:
    # print(elem)  # debug
    cost, time = map(int, elem.split())
    costs.append(cost)
    times.append(time)

min_cost = 1001  # 最小コストを入れる変数。初期値は制約上のMAX + 1 にしておく
for cost, time in zip(costs, times):
    if time <= t and cost < min_cost:
        min_cost = cost  # 時間内 and costがこれまでの最小コストより小さければ更新

if min_cost <= 1000:
    print(min_cost)
else:
    print('TLE')


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 998244353;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


const ll MAXN=3001;
const ll MAXS=3001;
ll dp[MAXN][MAXS];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,s;
  cin>>n>>s;
  vll a(n);
  REP(i,n)cin>>a[i];

  dp[0][0]=1;
  REP(i,n){
    for(ll j=0; j<MAXS; j++)
      dp[i+1][j]=2*dp[i][j]%MOD;

    for(ll j=0; j+a[i]<=MAXS-1; j++)
      dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%MOD;

  }

  ll ans=dp[n][s];
  cout<<ans<<endl;
}



Measured memory_bytes: 74020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
 
using namespace std;
typedef long long ll;
typedef pair<int, ll> pil;
 
const ll INF = 1e17;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n, m;
	ll L;
	cin >> n >> m >> L;
 
	ll dist[n][n];
	rep(i, n) rep(j, n) dist[i][j] = INF;
	rep(i, n) dist[i][i] = 0;
 
	rep(i, m){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
 
		dist[a][b] = c;
		dist[b][a] = c;
	}
 
	rep(k, n) rep(i, n) rep(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
 
	ll dist2[n][n];
	rep(i, n) rep(j, n) {
		if(i == j) dist[i][j] = 0;
		dist2[i][j] = dist[i][j] <= L ? 1 : INF;
	}
 
	rep(k, n) rep(i, n) rep(j, n) dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
 
	int q;
	cin >> q;
	rep(_, q){
		int s, t;
		cin >> s >> t;
		s--; t--;
		cout << (dist2[s][t] == INF ? -1 : dist2[s][t] - 1) << endl;
	}
 
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(100010, 0);
    
    int ans = 0;

    rep(i, N){
        int a;
        cin >> a;
        if(a > 100000) ans++;
        else A[a]++;
    }

    for(int i = 1; i <= 100000; i++){
        if(A[i] < i) ans += A[i];
        else {
            ans += A[i] - i;
        }
    }

    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(void) {
	long long h, n, len = -1, sum = 0;
	cin >> n;
	while (n > 0) {
		sum += n % 10;
		len++;
		h = n;
		n /= 10;
	}
	cout << max(h + 9 * len - 1, sum) << "\n";
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
counter = 0
space = [[-1 for i in range(w+2)]]
for i in range(1,h+1):
    r = input()
    s = list("#"+r+"#")
    counter += r.count("#")
    space.append([])
    for j,moji in enumerate(s):
        if moji == ".":
            space[i].append(0)
        elif moji =="#":
            space[i].append(-1)
space.append([-1 for i in range(w+2)])

sx,sy = 1,1
ex,ey = h,w

watch_space = [[sx,sy]]
decided_space = [[sx,sy]]
flag = 0
while(True):
    tmp = list()
    for [i,j] in watch_space:
        if [i-1,j] not in decided_space and space[i-1][j] == 0:
            space[i-1][j] = space[i][j]+ 1
            decided_space.append([i-1,j])
            tmp.append([i-1,j])
        if [i+1,j] not in decided_space and space[i+1][j] == 0:
            space[i+1][j] = space[i][j]+ 1
            decided_space.append([i+1,j])
            tmp.append([i+1,j])
        if [i,j+1] not in decided_space and space[i][j+1] == 0:
            space[i][j+1] = space[i][j]+ 1
            decided_space.append([i,j+1])
            tmp.append([i,j+1])
        if [i,j-1] not in decided_space and space[i][j-1] == 0:
            space[i][j-1] = space[i][j]+ 1
            decided_space.append([i,j-1])
            tmp.append([i,j-1])
    watch_space = tmp
    if [ex,ey] in decided_space:
        break
    elif len(watch_space) < 1:
        flag = -1
        break
if flag == 0:
    ans = (w*h)-(space[ex][ey]+1) - counter
    print(ans)
else:
    print(-1)


Measured memory_bytes: 3316
import java.util.Scanner;

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

        int N = sc.nextInt();
        String S = sc.next();
        int K = sc.nextInt();

        char atchar = S.charAt(K-1);

        char charExtract = 'A';
        for (int i=0; i<N; i++) {
            charExtract = S.charAt(i);
            if (atchar != charExtract) {
                S = S.replace(charExtract, '*');
            }
        }
        System.out.println(S);
    }
}

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

using namespace std;

template <class T> inline T updmax(T& a, T b) { return a = max(a, b); }
template <class T> inline T updmin(T& a, T b) { return a = min(a, b); }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(12);
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	double s = 0.0;
	for (auto v : a) s += 1.0 / v;
	cout << 1.0 / s << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	int N, K;
	
	cin>>N>>K;
	
	cout<<YN(K <= (N+1)/2)<<endl;
	
	return 0;
}

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

using namespace std;

typedef long long int ll;


int main()
{
	ll n;scanf("%lld", &n);
	ll num,den;scanf("%lld %lld", &num, &den);
	for(ll i = 1; i<n; ++i)
	{
		ll x,y;scanf("%lld%lld", &x, &y);
		ll rt = max((num+x-1)/x, (den+y-1)/y);
		num = x*rt, den = y*rt;
		//cerr << "deb: " << rt << ' ' << num << ' ' << den << endl;
	}	
	printf("%lld\n", num+den);
	
  	return 0;
}


Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())
    k = int(input())
    f = False
    cnt = 0
    while b <= a:
        b *= 2
        cnt += 1
    while c <= b:
        c *= 2
        cnt += 1
    if cnt <= k:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,sa[105],rnk[105];
ll k,h[105],s[105],f0;
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
bool cmp(int a,int b)
{
	return h[a]<h[b];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&h[i]);
	for(int i=1;i<=n;i++)
	{
		sa[i]=i;
		if(n!=1&&h[i]>max(h[i-1],h[i+1]))
		{
			k+=h[i]-max(h[i-1],h[i+1]);
			h[i]=max(h[i-1],h[i+1]);
		}
	}
	sort(sa+1,sa+n+1,cmp);
	for(int i=1;i<=n;i++)rnk[sa[i]]=i;
	f0=1;
	h[0]=1;
	for(int i=1;i<=n;i++)
	{
		if(rnk[i]<rnk[i-1])f0=(f0*2+(s[rnk[i-1]]-s[rnk[i]]+MOD)*2)%MOD;
		else
		{
			for(int j=1;j<=rnk[i-1];j++)
			  s[j]=s[j]*quick_pow(2,h[i]-h[i-1])%MOD;
			for(int j=rnk[i-1]+1;j<=rnk[i];j++)
			  s[j]=(s[j-1]+f0*2*(quick_pow(2,h[i]-h[sa[j-1]])-quick_pow(2,h[i]-h[sa[j]])+MOD))%MOD;
			f0=f0*2%MOD;
		}
	}
	ll ans=s[rnk[n]]+f0;
	ans=ans%MOD*quick_pow(2,k)%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int k, a, b;

    cin >> k;
    cin >> a >> b;

    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        N: usize,
        AB: [(i64, i64); N],
    }
    use std::cmp::Ordering;
    use std::collections::BTreeMap;
    let mut bmap = BTreeMap::new();
    for (a, b) in AB {
        bmap.entry(b).or_insert_with(Vec::new).push(a);
    }

    let mut cur = 0;
    for (deadline, times) in bmap {
        let t_sum = times.iter().sum::<i64>();
        if cur + t_sum > deadline {
            println!("No");
            return;
        }
        cur += t_sum;
    }
    println!("Yes");
}


Measured memory_bytes: 24828
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		boolean[] arg = null;
		int length=0;
        int i=0;
        boolean first=true;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	if(first){
            		length=Integer.parseInt(line);
            		arg=new boolean[length];
            		first=false;
            	}else{
            		String[] tokens = line.split(" ");
            		int max,mid,min;
            		int a= Integer.parseInt(tokens[0]);
            		int b = Integer.parseInt(tokens[1]);
            		int c = Integer.parseInt(tokens[2]);
            		max=Integer.max(Integer.max(a, b),Integer.max(c, b));
            		min=Integer.min(Integer.min(a, b),Integer.min(c, b));
            		if(max!=a&&min!=a){
            			mid=a;
            		}else if(max!=b&&min!=b){
            			mid=b;
            		}else if(max!=c&&min!=c){
            			mid=c;
                	}else{
                		mid=a;
                	}
            		arg[i]=max*max==min*min+mid*mid;
            		i++;
            		if(i==length){
            			break;
            		}
            	}
            }
            for(int j=0;j<i;j++){
            	System.out.println(arg[j]?"YES":"NO");
            }
        }
	}

}

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

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

int n;

int main(){
    cin >> n;
    int p = 0, q = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a % 2){
            ++p;
        }
        if(a % 4 == 0){
            ++q;
        }
    }
    cout << (q >= p || (q >= p - 1 && p + q == n) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	}
}

Measured memory_bytes: 23124
N, a, b = map(int,input().split())
p = pow(10,9) + 7
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
print((pow(2,N, p) - 1 - comb(N,a) - comb(N,b)) % p)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[]a = new int[n];
        int i=0;

        for(i=0;i<n;i++){
            a[i]=sc.nextInt();
        }

        for(i=(n-1);i>=0;i--){
            System.out.printf("%d",a[i]);
            if(i != 0){
            System.out.printf(" ");
            }else{
                System.out.println(); 
            
            }
        }
    }
}


Measured memory_bytes: 26628
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

using ll = long long;
using ld = long double;
using vll = std::vector< ll >;
using pll = std::pair< ll, ll >;
using vvll = std::vector<vll>;
using vpll = std::vector< pll >;


#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for(__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define cntll(a) __builtin_popcountll((a))
#define ff first
#define ss second
#define mk make_pair
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it){}
template<typename T , typename... Args>
void err(istream_iterator<string> it , T a , Args... args)
{
	cerr << *it << " = " << a << endl;
	err(++it , args ... );
}

ll sum(){ return 0; }
template<typename T, typename... Args>
auto sum(T a, Args... args){ return a + sum(args...);}
const ll MOD = 1e9+7;
////////////////////////////////////////////////////////////////////////////////////////////////////////



signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////


	ll n , m;
	cin >> n >> m;
	vector<pll> a;
	rep(i,0,n) {
		ll e;
		cin >> e;
		a.eb(e , 1);
	}

	rep(i,0,m) {
		ll b , c;
		cin >> b >> c;
		a.eb(c , b);
	}

	sort(rall(a));

	// for(auto it: a){
	// 	cout<<it.ff<<" "<<it.ss<<endl;
	// }
	ll cnt = n;
	ll ans = 0;
	ll i = 0;
	while(cnt){
		ll x = min(a[i].ss , cnt);
		ans += a[i].ff * x;
		cnt-=x;
		i++;
	}

	cout<<ans<<endl;

	
	return 0;
}




Measured memory_bytes: 6256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)

# N: ノードの数
# Q: 数値をノードに付与する回数
N, Q = map(int, input().split())

links =  [[] for _ in range(N)]
values = [0] * N

for i in range(N - 1):
    edge1, edge2 = [x - 1 for x in map(int, input().split())]
    links[edge1].append(edge2)
    links[edge2].append(edge1)

for i in range(Q):
    node, val = map(int, input().split())
    values[node - 1] += val

# 値の計算
stack = deque()
stack.append((0, -1))
while stack:
    node = stack.pop()

    for linked_node in links[node[0]]:
        if linked_node == node[1]:  # link が親ノード向けでなければ
            continue

        values[linked_node] += values[node[0]]
        stack.append((linked_node, node[0]))

print(*values)

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

int main()
{
  int n, m;
  cin >> n >> m;
  long long a[n], b[n], c[m], d[m];
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < m; i++) cin >> c[i] >> d[i];

  long long match[n];
  int num[n];
  for (int i = 0; i < n; i++) match[i] = 1e9;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if(match[i] > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
        num[i] = j + 1;
        match[i] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      }
    }
  }

  for (int i = 0; i < n; i++) cout << num[i] << endl;

  return 0;
}


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

int main(){
  vector<string> vec{"SUN","MON","TUE","WED","THU","FRI","SAT"};
  reverse(vec.begin(), vec.end());
  string c;
  cin >> c;
  auto itr = std::find(vec.begin(), vec.end(), c);
  size_t index = std::distance( vec.begin(), itr );
  cout << index+1 << 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[] cnt = new int[26];
		Arrays.fill(cnt, 100);
		for(int i=0; i<N; i++) {
			int[] temp = new int[26];
			char[] s = sc.next().toCharArray();
			for(char c : s) {
				temp[c-'a']++;
			}
			for(int j=0; j<26; j++)
				cnt[j] = Math.min(cnt[j], temp[j]);
		}
		String ans = "";
		for(int i=0; i<26; i++)
			for(int j=0; j<cnt[i]; j++)
				ans += String.valueOf((char)('a'+i));
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N >= 3) {
		// r = p(N) >= 7, (10^(r - 1) - 1) / 9 mod r = (1 - 1) / 9 mod r = 0
		cout << 0 << endl;
	}
	else {
		cout << vector<int>({ 1, 2, 1 })[N] << endl;
	}
	return 0;
}


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

const ll mod = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 1ll;
    for (ll i = k; i <= n; i++) {
        ll lb = i * (i - 1) / 2;
        ll rb = i * n - lb;
        if (lb > rb) break;
        ans += rb - lb + 1ll;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int H,W,N; cin>>H>>W>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    vector<vector<int>> Ans(H,vector<int>(W));
    bool rForward=true;
    int idx=0,cnt=0,color=1;
    rep(h,0,H){
        if(rForward){
            rep(w,0,W){
                cnt++;
                if(cnt>A.at(idx)){
                    cnt=1;
                    idx++;
                    color++;
                }
                Ans.at(h).at(w)=color;
            }
        }else{
            _rep(w,W-1,0){
                cnt++;
                if(cnt>A.at(idx)){
                    cnt=1;
                    idx++;
                    color++;
                }
                Ans.at(h).at(w)=color;
            }
        }

        rForward=!rForward;
    }

    rep(h,0,H){
        rep(w,0,W) cout<<Ans.at(h).at(w)<<" ";
        cout<<endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    string s; cin >> s;
    cout << ((s == "AAA" || s == "BBB") ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int A, B; cin >> A >> B;
    cout << A * B << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;


int main(){
  int n,m,c;cin>>n>>m>>c;
  int b[m];
  fol(i,m)cin>>b[i];
  int a[n][m];
  fol(i,n){
    fol(j,m){
      cin>>a[i][j];
    }
  }
  int ans = 0;
  int buf;
  fol(i,n){
    buf = c;
    fol(j,m){
      buf += b[j]*a[i][j];
    }
    if(buf>0)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = n
c = s[1:]
d = c.count('E')
ans = d
count = d
for i in range(1,n):
    a = s[i-1]
    b = s[i]
    if a == 'W' and b == 'W':
        count += 1
    elif a == 'E' and b == 'E':
        count -= 1
    ans = min(ans,count)
print(ans)

Measured memory_bytes: 3672
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    n:i64,m:i64,k:i64,
     }
    let (fact, invfact) = fact_inv_table(MX, MOD);
    let mut xsum = 0;
    let mut ysum = 0;
    for i in 0..m {
        xsum += i * (m - i) * n * n;
    }
    xsum %= MOD;
    xsum *= mod_comb(n * m - 2, k - 2, MOD, &fact);
    for i in 0..n {
        ysum += i * (n - i) * m * m;
    }
    ysum %= MOD;
    ysum *= mod_comb(n * m - 2, k - 2, MOD, &fact);
    println!("{}", (xsum + ysum) % MOD);
}
const MOD: i64 = 1000000007;
const MX: usize = 1010101;
/// (gcd, x, y)
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}
/// x ^ n % m
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
pub fn mod_inverse(a: i64, m: i64) -> i64 {
    let (_, x, _) = extgcd(a as i64, m as i64);
    ((m as i64 + x) as i64 % m) % m
}
pub fn fact_table(len: usize, m: i64) -> Vec<i64> {
    let mut res = vec![1; len + 1];
    for i in 1..len + 1 {
        res[i] = (i as i64 * res[i - 1]) % m;
    }
    res
}
/// Factorial and Inverse factorial table
pub fn fact_inv_table(size: usize, m: i64) -> (Vec<i64>, Vec<i64>) {
    let mut fact = vec![1; size];
    let mut fact_inv = vec![1; size];
    for i in 2..size {
        fact[i] = fact[i - 1] * i as i64 % m;
        fact_inv[i] = m - ((m / i as i64) * fact_inv[(m % i as i64) as usize] % m);
    }
    for i in 1..size {
        fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % m;
    }
    (fact, fact_inv)
}
/// (a mod p, e when n! = a p\^e)
pub fn mod_fact(n: i64, p: i64, fact: &[i64]) -> (i64, i64) {
    if n == 0 {
        (1, 0)
    } else {
        let (a, b) = mod_fact(n / p, p, fact);
        let pow = b + n / p;
        if n / p % 2 != 0 {
            (a * (p - fact[(n % p) as usize]) % p, pow)
        } else {
            (a * fact[(n % p) as usize] % p, pow)
        }
    }
}
/// C(n, k) % p
pub fn mod_comb(n: i64, k: i64, p: i64, fact: &[i64]) -> i64 {
    if n < k {
        0
    } else {
        let (a1, e1) = mod_fact(n, p, fact);
        let (a2, e2) = mod_fact(k, p, fact);
        let (a3, e3) = mod_fact(n - k, p, fact);
        if e1 > e2 + e3 {
            0
        } else {
            a1 * mod_inverse(a2 * a3 % p, p) % p
        }
    }
}
/// H(n, k) % p
pub fn mod_comb_repetition(n: i64, k: i64, p: i64, fact: &[i64]) -> i64 {
    mod_comb(n - 1 + k, n - 1, p, fact)
}


Measured memory_bytes: 17872
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readi()
	k := readi()
	a := make([]int, n)
	// idx := 0
	for i := 0; i < n; i++ {
		a[i] = readi()
		if a[i] == 1 {
			// idx = i
		}
	}

	if n == k {
		fmt.Println(1)
		return
	}

	// prev := len(a[:idx])
	// rest := prev % (k - 1)
	// back := len(a[idx+1:]) - rest

	// color.Blue("%d", prev)
	// color.Yellow("%d", rest)
	// color.Red("%d", back)

	// fmt.Println(int(math.Ceil(float64(prev)/float64(k-1)) + math.Ceil(float64(back)/float64(k-1))))

	tmp := math.Ceil(float64(n-k) / float64(k-1))
	fmt.Println(1 + tmp)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

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

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

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
 
int main(){
   int n;
   int m;
   std::cin >> n >> m;
   int maxl = 0;
   int minr = std::numeric_limits<int>::max();
   for(int i=0;i<m;++i){
      int l,r;
      std::cin >> l >> r;
      maxl = std::max(l,maxl);
      minr = std::min(r,minr);
   }


   int r=0;
   for(int i = 1;i<=n;++i){
      if(i >= maxl && i <= minr ){
         r++;
      }
   }
   std::cout << r << std::endl;
}

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

struct point{double px; double py;};

double x, y, s;
int i,j;

int main(){
	point p[21];	
	char k;

	while(cin>>x>>k>>y){
		if(cin.eof())break;
		p[i].px = x;
		p[i].py = y;
		i++;
	}
	p[i].px = p[0].px;
	p[i].py = p[0].py;

	for(; j<i; j++)	s += (p[j].px-p[j+1].px)*(p[j].py+p[j+1].py);

	cout<<setiosflags(ios::fixed)<<setprecision(6)<<s/2<<"\n";
	return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll MOD = (ll) 1e9 + 7;

ll modFactional (int n) {
	ll ret = 1;
	for(int i = 1; i <= n; i++)
	{
		ret *= i;
		ret %= MOD;
	}
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	ll modN, modM, modNM;
	modN = modFactional(N);
	modM = modFactional(M);
	modNM = (modN * modM) % MOD;
	if(abs(N - M) == 1) {
		cout << modNM << endl;
	}else if (abs(N - M) == 0) {
		cout << (2 * modNM) % MOD << endl;
	}else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 


int main() {
    int a, b;
    cin >> a >> b; 
    rep(i, 2000) {
        int ac = i*0.08;
        int bc = i * 0.1;
        if (ac == a && bc == b) {
            cout << i << endl;
            return 0;
        } 
    } 
    cout << -1 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<vector<int>> dist(N + 1, vector<int>(N + 1, INF));
  vector<vector<int>> pred(N + 1, vector<int>(N + 1, -1));
  int a, b, c;
  vector<pair<pair<int, int>, int>> edges;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    dist[a][b] = dist[b][a] = c;
    edges.push_back(make_pair(make_pair(a, b), c));
  }
  for (int i = 0; i <= N; ++i) { dist[i][i] = 0; }
  for (int k = 1; k <= N; ++k) {
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = M;
  for (int i = 0; i < M; ++i) {
    bool need = false;
    int a = edges[i].first.first, b = edges[i].first.second, c = edges[i].second;
    for (int j = 1; j <= N; ++j) {
      if (dist[j][b] == dist[j][a] + c) {
        need = true;
        break;
      }
    }
    if (need) { --ans; }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384