akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> str(W);
  
  for (int i = 0; i <= W + 1; i++){
    cout << "#";
  }
  cout << endl;

    for (int i = 0; i < H; i++){
    cout << '#';
    
    for (int i = 0; i < 1; i++){
      cin >> str.at(i);
      cout << str.at(i);
    }
    cout << '#' << endl;
  }
  
  for (int i = 0; i <= W + 1; i++){
    cout << "#";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
    char ch=nc();int sum=0;
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum;
}
struct E{
	int t,xt;
}e[N<<1];

int h[N],cnt;

void adge(int f,int t){
	e[++cnt]=(E){t,h[f]};h[f]=cnt;
}

int dp[N][2],dan[N];

void dfs1(int u,int fa){	
	for(int i=h[u];~i;i=e[i].xt) if(e[i].t!=fa){
		dfs1(e[i].t,u);
		if(dan[e[i].t]) dp[u][1]++;
		else dp[u][0]++;
	}
	if(dp[u][1]+dp[u][0]==0){
		dan[u]=1;
	}
	else if(dp[u][1]>1){
			puts("First");
			exit(0);
	}
	else if(dp[u][1]==1){
		dan[u]=0;
	}
	else if(dp[u][1]==0){
		dan[u]=1;
	}
}
			
void dfs2(int u,int fa){
	if(dp[u][1]!=1){
		puts("First");
		exit(0);
	}
	for(int i=h[u];~i;i=e[i].xt) if(e[i].t!=fa){
		int t[2];
		t[0]=dp[u][0]-(!dan[e[i].t]);
		t[1]=dp[u][1]-dan[e[i].t];
		if(t[1]+t[0]==0){
			dp[e[i].t][1]++;
		}
		else if(t[1]==1){
			dp[e[i].t][0]++;
		}
		else if(t[1]==0){
			dp[e[i].t][1]++;
		}
		dfs2(e[i].t,u);	
	}
}
		
int main(){
	memset(h,cnt=-1,sizeof(h));
	int n;
	n=read();
	for(int i=1;i<n;i++){
		int a,b;
		a=read();
		b=read();
		adge(a,b);
		adge(b,a);
	}
	dfs1(1,1);
	dfs2(1,1);
	puts("Second");
	return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
 #define max 44

int F[max];
 
int fibonacci(int n){
 
  if(n == 0 || n == 1)
    return F[n]=1;
 
  if(F[n] > 0)
    return F[n];
 
  return F[n] = fibonacci(n -2) + fibonacci(n - 1);
}

int main(){
  int n, x;
  scanf("%d", &n);
 
  x = fibonacci(n);
 
  printf("%d\n", x);
 
  return 0;
}
 

Measured memory_bytes: 1816
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
const long INF = 1e9 + 7;

using namespace std;
int main() {
  int N;
  cin >> N;

  vector<int> v;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    v.push_back(stoi(s));
  }

  //  sort(v.begin(), v.end());
  int ans = INF;
  for (int i = 0; i < N; i++) {
    vector<int> head;
    copy(v.begin(), v.begin() + i, back_inserter(head));
    vector<int> tail;
    copy(v.begin() + i, v.end(), back_inserter(tail));

    int s1 = accumulate(head.begin(), head.end(), 0);
    int s2 = accumulate(tail.begin(), tail.end(), 0);
    ans = min(abs(s1 - s2), ans);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
   ll a, b;
   cin >> a >> b;
   ll out = abs(a-b);
   if(out&1){
       cout << "IMPOSSIBLE";
       return 0;
   }
   out/=2;
   if(a > b)cout << a-out;
   else cout << b-out;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
	
	cin.tie(0);
    ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	int ans =n;
	for(int i=0;i<n;i++){
		ll input;
		cin >> input;
		if(input == 2 || input == 3)continue;
		if(input == 1){
			ans--;
			continue;
		}
		
		for(ll j=(ll)pow(input,0.5)+2;j>1;j--){
			if(input%j==0){
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int K;
queue<string> que;

int main(){
    cin>>K;
    for(int i=1;i<=9;++i){ 
        string tmp="";
        tmp.push_back('0'+i);
        que.push(tmp);
    }
    int cnt=0;
    string  lnum;
    while(cnt<K){
        lnum=que.front();
        que.pop();
        int dig=lnum[lnum.size()-1]-'0';
        for(int i=max(dig-1,0);i<=min(dig+1,9);++i){
            string lnum_n=lnum;
            lnum_n.push_back(i+'0');
            que.push(lnum_n);
        }
        cnt++;
    }
    cout<<lnum<<endl;
}

Measured memory_bytes: 13824
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int segment_sieve(int a, int b) {
		int p = 0;
		int square_b = (int)Math.sqrt(b);
		boolean[] is_small_prime = new boolean[square_b+1];
		boolean[] is_prime = new boolean[b-a+1];
		is_small_prime[0] = is_small_prime[1] = true;
		for (int i = 2; i <= square_b; i++) {
			if (!is_small_prime[i]) {
				for (int j = 2*i; j <= square_b; j += i)
					is_small_prime[j] = true;
				for (int j = Math.max(2,(a+i-1)/i)*i; j <= b; j += i)
					is_prime[j-a] = true;
			}
		}
		
		for (boolean f: is_prime)
			if (!f) p++;
		
		return p;
	}
	
	void run() {
		int n; 
		while (true) {
			n = sc.nextInt();
			if (n == 0) break;
			out.println(segment_sieve(n+1, 2*n));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 27368
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <numeric>
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<ull> a(n);
  _for(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int numbers = 0;
  int count = 0;
  ull last = 0;
  _for(i,n) {
    if (a[i]!=last) {
      last = a[i];
      if(count%2==1) numbers ++;
      count = 1;
    }
    else {
      count++;
    }
  }
  if(count%2==1) numbers ++;
  cout << numbers << endl;

  return 0;
}

Measured memory_bytes: 1024
MOD = 10 ** 9 + 7


def solve(n, k):
    cum_left = [0] * (n + 2)
    cum_right = [0] * (n + 2)
    for i in range(n + 1):
        cum_left[i + 1] = cum_left[i] + i
        cum_right[i + 1] = cum_right[i] + n - i
    # print(cum_left, cum_right)
    res = 0
    for i in range(k, n + 2):
        res += cum_right[i] - cum_left[i] + 1
        res %= MOD
    return res


def main():
    n, k = map(int, input().split())
    res = solve(n, k)
    print(res)


def test():
    assert solve(3, 2) == 10
    assert solve(200000, 200001) == 1
    assert solve(141421, 35623) == 220280457


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 27200
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  int a[26] = {0};
  
  for(int i = 0; i < s.length(); i++){
    a[s[i] - 'a']++;
  }
  
  for(int i = 0; i < 26; i++){
    if(a[i] > 1){
      cout << "no" << endl;
      return 0;
    }
  }
  
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,n,count = 0,prime[10001]={2};
	long x;
	
	for( x = 3; count < 10000; x += 2 ){
		for( i = 0; prime[i] < x; i++ ){
			if( prime[i] == 0 ){
				prime[i] = x;
				count++;
				break;
			}
			if( x % prime[i] == 0 ) break;
		}
	}
	
	while( scanf(" %d", &n), n != 0 ){
		long total = 0;
		for( i = 0; i < n; i++ ) total += prime[i];
		printf("%ld\n", total);
	}
	return 0;
}

Measured memory_bytes: 644
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private static final long M = 998_244_353;

    // 13:29-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int[] times = new int[5];
            int[] actual = new int[5];
            int maxDiff = Integer.MIN_VALUE;
            int diffPos = -1;
            for (int i = 0; i < 5; i++) {
                int x = sc.nextInt();
                actual[i] = x;
                int sum = 0;
                sum += x / 10 * 10;
                if (x % 10 > 0) sum += 10;
                times[i] = sum;
                int diff = sum - x;
                if (diff > maxDiff) {
                    maxDiff = diff;
                    diffPos = i;
                }
            }

            int total = 0;
            for (int i = 0; i < times.length; i++) if (i != diffPos) total += times[i];

            out.println(total + actual[diffPos]);
        }
    }
}


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

void solve(long long N, vector<long long> a){
	set<long long> as(a.begin(),a.end());
	if( as.size() >= 3 ){
		cout << "No" << endl;
		return;
	}

	if( as.size() == 1 ){
		int n = *as.begin();
		if( n == N-1 ){
			cout << "Yes" << endl;
		}else if( n <= N / 2 ){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		return;
	}else{
		int mi = *as.begin();
		int mx = *as.rbegin();

		if( mi+1 != mx){
			cout << "No" << endl;
			return;
		}
		int cnt_mi = count(a.begin(),a.end(),mi);
		int need = mx - cnt_mi;

		if( need <= 0 ){
			cout << "No" << endl;
			return;
		}
		if( need > (N - cnt_mi) / 2 ){
			cout << "No" << endl;
			return;
		}
		cout << "Yes" << endl;
	}
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



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

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

    int N_tmp = N;
    int sum = 0;
    int tmp;

    for(int i=0; N > 0; i++){
        tmp = N % 10;
        sum += tmp;
        N = N / 10;
    } 

    if((N_tmp % sum) == 0) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;   
}

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

using namespace std;

long long n,m,k,l,i,j,a,b,dp1[100005],dp2[100005],dpm1[100005],dpm2[100005];
vector<int>v[100005],vv;

void dfs1(int x,int par){
    for(int i=0;i<v[x].size();i++){
        int to=v[x][i];
        if(to==par) continue;
        dfs1(to,x);
        dp1[x]=(dp1[x]*(dp1[to]+1))%m;
    }
}

void dfs2(int x,int par){
    vector<int>vv;
    for(int i=0;i<v[x].size();i++){
        int to=v[x][i];//cout<<x<<" "<<to<<endl;
        if(to==par) continue;
        dpm1[to]=dpm2[to]=dp1[to]+1;dp2[to]=1;
        vv.push_back(to);
    }
    if(vv.size()>1)
    for(int i=1;i<vv.size();i++)
        dpm1[vv[i]]=(dpm1[vv[i-1]]*dpm1[vv[i]])%m;
    if(vv.size()>1)
    for(int i=vv.size()-2;i>=0;i--)
        dpm2[vv[i]]=(dpm2[vv[i+1]]*dpm2[vv[i]])%m;

    for(int i=0;i<vv.size();i++){
        if(i)            dp2[vv[i]]=(dp2[vv[i]]*dpm1[vv[i-1]])%m;
        if(i<vv.size()-1)dp2[vv[i]]=(dp2[vv[i]]*dpm2[vv[i+1]])%m;
        dp2[vv[i]]=(dp2[vv[i]]*(dp2[x]+1))%m;
        //cout<<vv[i]<<" "<<dp2[i]<<"\n";
    }   // cout<<x<<" "<<vv.size()<<"\n"<<endl;
    for(int i=0;i<vv.size();i++)
        dfs2(vv[i],x);
}

main(){

cin>>n>>m;

for(i=0;i<n-1;i++){
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
}

for(i=1;i<=n;i++)
    dp1[i]=1;

dfs1(1,0);
dfs2(1,0);

for(i=1;i<=n;i++){
   // cout<<dp1[i]<<" "<<dp2[i]<<" "<<dpm1[i]<<" "<<dpm2[i]<<" ";
    cout<<(dp1[i]*(dp2[i]+1))%m<<endl;
}
}


Measured memory_bytes: 19968
from sys import stdin
import numpy as np

n, m = map(int, stdin.readline().rstrip().split())
x = [int(x) for x in stdin.readline().rstrip().split()]

if n >= m:
    print('0')
else:
    p = np.sort(np.array(x))
    dif = p[1:] - p[:-1]
    dif = np.sort(dif)
    if n == 1:
        print(np.sum(dif))
    else:
        print(np.sum(dif[: 1 - n]))


Measured memory_bytes: 23024
A, B, C, X, Y = map(int, input().split())
money = 0
if A + B > C * 2:
    money += (C * 2) * min(X, Y)
    if X == Y:
        pass
    elif X > Y:
        money += (X - Y) * min(A, C * 2)
    elif X < Y:
        money += (Y - X) * min(B, C * 2)
else:
    money += A * X + B * Y

print(money)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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

Measured memory_bytes: 256
<?php
// $N と $D をドブに捨てる
fgets(STDIN);
$data = [];
while($line = fgets(STDIN)) {
    $data[] = explode(" ", trim($line));
}
$ans = 0;
$cnt = count($data);
for ($i = 0; $i < $cnt - 1; $i++) {
    for ($j = $i + 1; $j < $cnt; $j++) {
        $tmp = 0;
        foreach ($data[$i] as $k => $v) {
            $tmp += pow($v - $data[$j][$k], 2);
        }
        if (sqrt($tmp) == intdiv(sqrt($tmp), 1)) {
            $ans++;
        }
    }
}
echo $ans;


Measured memory_bytes: 4604
#include<stdio.h>

#define abs(a) ((a) < 0?(-(a)):(a))

long long solve(int x){
    int ans[] = {9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0};
    long long now = -909090909090;
    now = (long long)x - now;
    int p = 11, i;
    while(now){
	ans[p] = abs(ans[p] - (now % 10));
	p--;now/=10;
    }
    char res[100];
    for(i = 0;i < 12;i++)res[i] = ans[i] + '0';
    res[12] = 0;
    sscanf(res, "%lld", &now);
    return now;
}


int main(){
    int n;
    while(scanf("%d", &n), n)
	printf("%lld\n", solve(n));
    return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vec_rep(itr,v) for(auto itr = v.begin(); itr != v.end(); ++itr)

int main(void){
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5])cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int h[] = new int[N];
        for(int i=0;i<N;i++){
            h[i]=sc.nextInt();
        }
        Arrays.sort(h);
        int min=(int)Math.pow(10,9);
        for(int i=0;i<=N-K;i++){
            min=Math.min(min,h[i+K-1]-h[i]);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 47668
// ------------------------------------
// Date:2018/ 2/27
// Problem:AGC 013 AntsOnACircle re_c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

using ll = long long;

#define MOD 1000000007

int main()
{
  int N, L, T;
  cin >> N >> L >> T;
  vector< int > X(N);
  vector< int > W(N);
  REP(i, N) {
    cin >> X[i] >> W[i];
  }
  
  int collistionNum = 0;
  REP(i, N) {
    if (W[i] == 1) {
      // clockwise
      collistionNum += (T + X[i]) / L;
      X[i] = (X[i] + T) % L;
    } else {
      // anti-clockwise
      collistionNum -= (T - X[i] + L - 1) / L;
      X[i] = ((X[i] - T) % L + L) % L;
    }
  }
  
  sort(ALL(X));
  collistionNum = (collistionNum % N + N) % N;
  
  REP(i, N) {
    cout << X[(collistionNum + i) % N] << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
# -*- coding: utf-8 -*-

# 整数の入力
#a = int(input())

# スペース区切りの文字列の入力
st = input().split()
#商
div = int(st[0]) // (int(st[1]) + int(st[2]))
#余り
rem = int(st[0]) % (int(st[1]) + int(st[2]))

if(rem < int(st[1])):
  print(div * int(st[1]) + rem)
else:
  print(div * int(st[1]) + int(st[1]))
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int S;
    cin >> S;
    int h = S / 3600;
    S = S % 3600;
    int m = S / 60 ;
    int s = S % 60 ;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  ll sum = 0;
  int n_negative = 0;
  ll mi = 1e9 + 3;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    if (A[i] > 0) {
      sum += A[i];
      mi = min(mi, A[i]);
    }
    else {
      sum += (A[i] * -1);
      n_negative++;
      mi = min(mi, (A[i] * -1));
    }
  }
  if (n_negative % 2 == 0) {
    cout << sum << endl;
  } else {
    cout << sum - (mi * 2) << endl;
  }
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

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

int n, a;
vector<int> v;
vector<int> p;

int main () {

	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> a;
		v.push_back(a);
	}
	
	while (v.size() > 0) {
		int da = 0;
		for (int i = (int)v.size()-1; i >= 0; i --) {
			if (v[i] == i+1) {
				p.push_back(i+1);
				v.erase(v.begin() + i);
				da = 1;
				break;
			}
		}
		
		if (da == 0) {
			cout << -1;
			return 0;
		}
	}
	
	for (int i = p.size()-1; i >= 0; i --) cout << p[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=2020,M=4004000,P=1000000007;
int i,j,k,n,m,ans;
int f[N][N];
int Jc[M],Jc_[M];
int ksm(int x,int y) {
	int z=1;
	for (;y;y>>=1,x=(ll) x*x%P) if (y&1) z=(ll) z*x%P;
	return z;
}
void pre(int n) {
	int i;
	Jc[0]=Jc_[0]=1;
	for (i=1;i<=n;i++) Jc[i]=(ll) Jc[i-1]*i%P;
	Jc_[n]=ksm(Jc[n],P-2);
	for (i=n-1;i;i--) Jc_[i]=(ll) Jc_[i+1]*(i+1)%P;
}
int C(int n,int m) {
	if (n<m) return 0;
	return (ll) Jc[n]*Jc_[m]%P*Jc_[n-m]%P;
}
int main() {
	scanf("%d%d",&n,&m);
	if (m==1) return puts("1"),0;
	pre(n*m);
	f[0][0]=1;
	for (i=0;i<=n;i++)
		for (j=0;j<=i;j++) {
			if (j<i) f[i][j+1]=(f[i][j+1]+f[i][j])%P;
			f[i+1][j]=((ll) f[i][j]*C((i+1)*(m-1)+j-1,m-2)+f[i+1][j])%P;
		}
	ans=(ll) f[n][n]*Jc[n]%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 47232
#include <iostream>
#include <map>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

map< int64_t, int64_t > prime_factor(int64_t n) {
    map< int64_t, int64_t > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
        ret[i]++;
        n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

const int64_t MAX = 110000;
int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int64_t i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    COMinit();

    int64_t ans = 1;
    auto p = prime_factor(M);
    for(auto itr=p.begin(); itr!=p.end(); itr++) {
        ans *= COM(N + itr->second - 1, N-1);
        ans %= MOD;
    }

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


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int sum[200003]={0};
void dfs(vector<int>adj[],int root,int parent)
{
	sum[root]=sum[root]+sum[parent];
	for(int i=0;i<adj[root].size();i++)
		if(adj[root][i]!=parent)
			dfs(adj,adj[root][i],root);
}
int32_t main()
{
	sync
	int n,q;
	cin>>n>>q;
	vector<int>adj[200003];
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	while(q--)
	{
		int a,b;
		cin>>a>>b;
		sum[a]+=b;
	}
	dfs(adj,1,0);
	for(int i=1;i<=n;i++)
		cout<<sum[i]<<" ";
}	

Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B&&B!=C){
        cout<<"Yes"<<endl;
    }
    else if(B==C&&C!=A)cout<<"Yes"<<endl;
    else if(C==A&&A!=B)cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    long long asum = 0, bsum = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        asum += a[i];
        bsum += b[i];
        cnt += max(0, (int)((b[i] - a[i] + 1) / 2.0));
    }
    if(bsum - asum < cnt){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N = int(input())
job = {}
for i in range(0, N):
    a, b = map(int, input().split())
    if b not in job:
        job[b] = []
    job[b].append(a)

# print(job)
job_sorted = sorted(job.items(), key=lambda x: x[0])
# print(job_sorted)

time = 0
for value in job_sorted:
    # for deadline, require in job_sorted.items():
    deadline = value[0]
    require = value[1]
    require.sort()
    for i in range(0, len(require)):
        time += require[i]
        # print('dead = {} : time = {}'.format(deadline, time))
        if time > deadline:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 65936
#include <iostream>

using namespace std;

int
main()
{
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << (double(W) * H) / 2.0 << ' ' << ((x * 2 == W && y * 2 == H) ? 1 : 0) << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

namespace DPF
{
	struct DIM
	{
		ll i;
		ll j;
		void Set(ll si, ll sj)
		{
			i = si;
			j = sj;
		}
	};
	struct DP
	{
		ll value;
		DIM from;			// どこから遷移したかのメモ
		bool update_value;	// valueを更新したかどうか
	};

	void Run()
	{
		string s, t;
		cin >> s >> t;
		s += " "; t += " ";
		s.insert(0, " ");
		t.insert(0, " ");

		vector<vector<DP>> dp(size(s), vector<DP>(size(t)));
		rep(i, 1, size(s) - 1)
		{
			rep(j, 1, size(t) - 1)
			{
				if (s[i] == t[j] && dp[i - 1][j].value == dp[i - 1][j + 1].value)
				{
					dp[i][j + 1].value = dp[i - 1][j].value + 1;
					dp[i][j + 1].from.Set(i - 1, j);
					dp[i][j + 1].update_value = true;
				}
				else
				{
					if (dp[i][j].value < dp[i - 1][j + 1].value)
					{
						dp[i][j + 1].value = dp[i - 1][j + 1].value;
						dp[i][j + 1].from.Set(i - 1, j + 1);
						dp[i][j + 1].update_value = false;
					}
					else
					{
						dp[i][j + 1].value = dp[i][j].value;
						dp[i][j + 1].from.Set(i, j);
						dp[i][j + 1].update_value = false;
					}
				}
			}
		}

		string ans;
		DIM dim; dim.Set(size(s) - 2, size(t) - 1);
		while (dp[dim.i][dim.j].value != 0)
		{	// DPの最後から前に向かってLCSを構築する
			if (dp[dim.i][dim.j].update_value)
				ans += s[dim.i];

			dim = dp[dim.i][dim.j].from;
		}
		reverse(all(ans));
		cout << ans;
	}
}

int main(void)
{
	DPF::Run();
	return 0;
}

Measured memory_bytes: 282112
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    char s;
    cin >> s;

    if (isupper(s))
    {
        cout << 'A';
    }
    else
    {
        cout << 'a';
    }

    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    double R;
    cin >> R;
    cout << fixed << setprecision(15) << 2 * M_PI * R << endl;
}


Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Resale
            int n = int.Parse(Console.ReadLine());
            var v = ReadLine();
            var c = ReadLine();
            int sum = 0;

            for(int i = 0; i < n; i++)
            {
                if (v[i] - c[i] > 0)
                {
                    sum += v[i] - c[i];
                }
            }

            Console.WriteLine(sum);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define MOD2 1000000009
#define endl "\n"
#define pii pair <int, int>
#define pll pair <ll, ll>
#define F first
#define S second



int main()
{   
    IOS;
        #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
        #endif

    
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's') {
        s += 'e';
        s += 's';
    }
    else
        s += 's';

    cout << s << endl;
    

return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

ll defeat(int& l, int& h) {
    if (l > h) {
        l -= h;
        int val = h;
        h = 0;
        return val;
    } else {
        h -= l;
        int val = l;
        l = 0;
        return val;
    }
}

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

    int n; cin >> n;
    vector<int> a(n + 1); for (int& x : a) cin >> x;
    vector<int> b(n); for (int& x : b) cin >> x;

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += defeat(a[i], b[i]);
        ans += defeat(a[i + 1], b[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    map<int, int> mp;
    for(int i=0; i<3; i++){
        int a; cin >> a;
        mp[a]++;
    }

    cout << mp.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl

void Dead(){
    cout << 0 << endl;
    exit(0);
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    sort ALL(A);
    if(N == 1){
        if(A[0] == 0) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    int MOD = 1000000007,ans = 1;
    if(N % 2 == 1){
        if(A[0] == A[1] || A[0] != 0) Dead();
        REPP(i,1,N){
            if(i % 2 == 0 && A[i] != i) Dead();
            else if(i % 2 == 1 && A[i] != i+1) Dead();
        }
        REP(i,(N-1)/2){
            ans *= 2;
            ans %= MOD;
        }
    }
    else{
        REP(i,N){
            if(i % 2 == 0 && A[i] != i+1) Dead();
            else if(i % 2 == 1 && A[i] != i) Dead();
        }
        REP(i,N/2){
            ans *= 2;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;

#define int ll
const int mod = 1e9+7;
const int N = 2e5+7;

int n, a, b;

VI roznia, curr;

int get(int a, int b, int curr, int typ)
{
	if(typ&1)
		curr ^= 1<<a;

	if(typ&2)
		curr ^= 1<<b;

	return curr;
}

void powieksz2(int a, int b)
{
	VI nast;

	nast.pb(get(a, b, curr[0], 0));
	nast.pb(get(a, b, curr[0], 1));
	nast.pb(get(a, b, curr[0], 3));
	nast.pb(get(a, b, curr[0], 2));

	nast.pb(get(a, b, curr[1], 2));
	nast.pb(get(a, b, curr[1], 0));
	nast.pb(get(a, b, curr[1], 1));
	nast.pb(get(a, b, curr[1], 3));

	for(int i = 2; i < siz(curr); i += 2)
	{
		nast.pb(get(a, b, curr[i], 3));
		nast.pb(get(a, b, curr[i], 1));
		nast.pb(get(a, b, curr[i], 0));
		nast.pb(get(a, b, curr[i], 2));

		nast.pb(get(a, b, curr[i+1], 2));
		nast.pb(get(a, b, curr[i+1], 0));
		nast.pb(get(a, b, curr[i+1], 1));
		nast.pb(get(a, b, curr[i+1], 3));
	}

	curr = nast;
}

void powieksz1(int a)
{	
	VI nast;

	for(int i = 0; i < siz(curr); i += 2)
	{	
		nast.pb(curr[i]);
		nast.pb(curr[i]^(1<<a));
		nast.pb(curr[i+1]^(1<<a));
		nast.pb(curr[i+1]);
	}

	curr = nast;
}

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

	cin >> n >> a >> b;

	for(int i = 0; i < n; ++i)
	{
		if((a^b)&(1<<i))
			roznia.pb(i);
	}

	if(siz(roznia)%2==0)
	{
		cout << "NO" << endl;
		return 0;
	}

	curr.pb(0);
	curr.pb(1<<roznia[0]);

	for(int i = 1; i < siz(roznia); i += 2)
	{
		powieksz2(roznia[i], roznia[i+1]);
	}

	for(int i = 0; i < n; ++i)
	{
		if(!((a^b)&(1<<i)))
			powieksz1(i);
	}

	for(int i = 0; i < n; ++i)
	{
		if((a&(1<<i))!=(curr[0]&(1<<i)))
		{
			for(auto &it:curr)
			{
				it ^= 1<<i;
			}
		}
	}

	for(int i = 0; i+1 < 1<<n; ++i)
	{
		assert(__builtin_popcount(curr[i]^curr[i+1])==1);
	}

	cout << "YES" << endl;

	for(auto it:curr)
		cout << it << " ";

	cout << endl;
}

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

using namespace std;

int main(){
    int N,kesu;
    cin >> N;
    vector<int> b(N),ans(N);
    for(int i=0;i<N;i++){
        cin >> b[i];
    }
    for(int i=0;i<N;i++){
        kesu = -1;
        for(int j=0;j<N-i;j++){
            if(b[j]==j+1){
                kesu = j;
            }
        }
        if(kesu==-1){
            break;
        }
        b.erase(b.begin()+kesu);
        ans[i] = kesu+1;
    }


    if(!b.empty()){
        cout << -1 << endl;
    }else{
        for(int i=0;i<N;i++){
            cout << ans[N-1-i] << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
 
int main(){
  int n ;
  cin >>n;
  vector<double> a(n);
  for (int i=0;i<n;i++){
    cin>>a[i];
    }
    double  b = 0;
    for (int i=0;i<n;i++){
      b+=1/a[i];
     }
     cout<<setprecision(16)<<1/b<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int k, s; cin >> k >> s;
	int sum = 0;
	for (int i = 0; i <= k; i++){
		for (int j = 0; j <= k; j++){
			if (0 <= s - i - j&&s - i - j <= k)sum++;
		}
	}
	cout << sum << endl;
	char c; cin >> c;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
  var A int
  var B int 
  var sum int
  var diff int 
  var mult int
  
  fmt.Scan(&A)
  fmt.Scan(&B)
  
  sum = A + B
  diff = A - B
  mult = A * B
  
  if(sum >= diff && sum >= mult){
    fmt.Print(sum)
  }else if(diff >= sum && diff >= mult){
    fmt.Print(diff)
  }else if(mult >= sum && mult >= diff){
    fmt.Print(mult)
  }
}
  

Measured memory_bytes: 512
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a < b:
    oni = a + t * v
    child = b + t * w
    if oni >= child:
        print('YES')
    else:
        print('NO')
elif a > b:
    oni = a - t * v
    child = b - t * w
    if oni <= child:
        print('YES')
    else:
        print('NO')
else:
    print('YES')

Measured memory_bytes: 9228
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<ll,ll>
typedef long long ll;
const int maxn=3e4+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(n==m)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>=k;i--)
int main(){
    string s,t,a;
    cin>>s;
    cin>>t;
    a=t[t.size()-1];
    s+=a;
    if(s==t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
function main(){
  var waitTime = calc();
  for(var i = 0, len = input.length - 1; i < len;i++){
    console.log(waitTime[parseInt(input[i], 10)]);
  }
}
 
function calc(){
  var seats = new Int32Array(17);
  var groupMembers = new Int32Array([2,5,2,2,2]);
  var eatTimes = new Int32Array([19,39,25,36,22,42]);
   
  var headGroup = -1;
  var pastMinutes = 0;
  var waitTime = new Int32Array(100);
  var lastMembers = 100;
   
  while(true){
    // たべおわる
    var i;
    for(i = 17; i--;){
      seats[i] = max(--seats[i], 0);
    }
     
    // 来店
    if(headGroup == -1 && pastMinutes % 5 == 0){
      headGroup = pastMinutes / 5;
    }
     
    // ちゃくせき
    while(headGroup != -1 && i != 17){
      var needsSequencialSeats = groupMembers[headGroup % 5];
      var sequencialSeats = 0;
      var startIndex = -1;
       
      for(i = 0; i < 17; i++){
        sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;
         
        if(sequencialSeats == needsSequencialSeats){
          var eatTime = eatTimes[headGroup % 6];
 
          startIndex = i - (needsSequencialSeats - 1);
          // すわれるみたい
          waitTime[headGroup] = pastMinutes - (headGroup * 5);
          for(var j = startIndex, len = (needsSequencialSeats + startIndex); j < len; j++){
            seats[j] = eatTime;
          }
           
          headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
          if(!(--lastMembers)){
            // 100グループ着席
            return waitTime;
          }
          break;
        }
      }
    }
     
    pastMinutes++;
  }
   
}
 
function max(a, b){
  var t = (a - b);
  return a - (t & (t >> 31));
}

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

int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int cnt=0;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while(b>=c){
        c*=2;
        cnt++;
    }
    if(cnt<=k){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int x, t;
    cin >> x >> t;

    OP(max(0, x - t));
    return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    long long sum = 0;
    for(int i=0;i<N;i++){
        cin >> H.at(i);
    }
    sort(H.begin(),H.end(),greater<int>());
    // for(int i=0;i<N;i++){
    //     cout << H.at(i);
    // }
    if(K>=N){
        cout << 0 << endl;
    }
    else{
        for(int i=K;i<N;i++){
            sum += H.at(i);
        }
        cout << sum << endl;
    }
 
    // if(sum>=H){
    //     cout << "Yes" << endl;
    // }
    // else{
    //     cout << "No" << endl;
    // }

    // int max = 0;
    // int tmp;
    // int score;
    // for(int j=1;j<N;j++){
    //     tmp = 
    // }
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
const int MAX_N=100000;

int n;
vector<int> dat(4*MAX_N,INT_MAX);

void init(int N){
	n=1;
	while(n<N){
		n*=2;
	}
}

void update(int i, int y){
	int k;
	k=n-1+i;
	dat[k]=y;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[2*k+1],dat[2*k+2]);
	}
}

int find(int x, int y, int k,int l,int r){
	if(r <= x || l >= y){
		return INT_MAX;
	}
	if(r <= y && l >= x){
		return dat[k];
	}else{
		int vl = find(x,y,2*k+1,l,(l+r)/2);
		int vr = find(x,y,2*k+2,(l+r)/2,r);
		return min(vl,vr);
	}
}

int main(){
	int N,q,command,x,y;
	
	cin >> N >> q;
	init(N);
	
	for (int i=0;i<q;i++){
		cin >> command >> x >> y;
		if(command){
			cout << find(x,y+1,0,0,n) << endl;
		}else{
			update(x,y);
		}
	}
	return 0;
}

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

int main(){
    int a,b,k;
    bool res;
    cin >> k >> a >> b;
    for(int i = a;i<=b;i++){
        if(i %k== 0){
            cout << "OK" <<endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


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


int main(){
    int r;
    cin >> r;
    
    if(r<1200){
        cout << "ABC" << endl;
    }
    else if(r<2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
n,k = map(int,input().split())
L = list(map(int,input().split()))
L.sort()

sum1 = 0
cnt = 0
if k < L[0]:
    print(0)
    exit()
for i in range(n):
    sum1 +=L[i]
    if sum1 <=k:
        cnt +=1
        if i == n-1 and sum1 != k:
            cnt -=1
    else:
        break
print(cnt)

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

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

  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == S.at(i) - '0') {
      // 黒色スタート時の塗り替え数を検証
      ans1++;
    } else {
      // 白色スタート時の塗り替え数を検証
      ans2++;
    }
  }

  printf("%d", min(ans1, ans2));
  return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n,m,k = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(m)]
cd = [list(map(int,input().split())) for i in range(k)]

from bisect import bisect_left

#unifind木の実装

class UniFindTree():
    def __init__(self,n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size_of_group = [0] * n
    def find_root(self,i):
        if self.par[i]==i:
            #if root
            return i
        else:
            self.par[i] = self.find_root(self.par[i])
            return self.par[i]

    def unite(self,x,y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x==y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x]=y
        else:
            self.par[y] = x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1
    def same(self,x,y):
        return self.find_root(x)==self.find_root(y)
    def set_size_of_group(self):
        for i in self.par:
            self.size_of_group[i]+=1
    def shukuyaku(self):
        for i in range(len(self.par)):
            self.find_root(i)
uni = UniFindTree(n+1)
for a,b in ab:
    uni.unite(a,b)
uni.shukuyaku()
uni.set_size_of_group()
ret = [uni.size_of_group[i]-1 for i in uni.par]
for a,b in ab:
    if uni.same(a,b):
        ret[a]-=1
        ret[b]-=1

for c,d in cd:
    if uni.same(c,d):
        ret[c]-=1
        ret[d]-=1

print(" ".join(map(str,ret[1::])))

Measured memory_bytes: 65388
#include <cstdio>
#include <iostream>
using namespace std;
char s[1001];
int n,pos,maxn;
int main()
{
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;++i)
    {
        if(s[i]=='I') ++pos;
        else --pos;
        maxn=max(maxn,pos);
    }
    cout<<maxn;
    return 0;
}

Measured memory_bytes: 256
import itertools

H, W, K = [int(s) for s in input().split()]
MAP = [[s for s in input()] for _ in range(H)]

l_h = list(range(H))
l_w = list(range(W))


def count(h, w):
    cnt = 0
    for i in range(H):
        if i in h:
            continue
        for j in range(W):
            if j in w:
                continue
            if MAP[i][j] == '#':
                cnt += 1
    return cnt == K


c = 0

for ch in range(H+1):
    for hs in itertools.combinations(l_h, ch):
        for cw in range(W + 1):
            for ws in itertools.combinations(l_w, cw):
                c += count(list(hs), list(ws))


print(c)

Measured memory_bytes: 9224
import java.util.*;

public class Main{
    public static void main(String[] args){
      	final int A = 1000005;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //与えられる整数を格納する配列
      	int a[] = new int [n];
        //与えられた整数iの個数を数える配列cを用意し、c[i]に格納する
        int c[] = new int [A];
        int b;
        String ans = "pairwise coprime";
        for(int i = 0; i < A; i++){
            c[i] = 0;
        }
        for(int i = 0; i < n; i++){
            b = sc.nextInt();
            c[b] += 1;
        }

        //配列cを使って公約数を調べる。
        //iの倍数である数がいくつあるかを数える。cnt==n であればnot coprime
        //n > cnt > 1ならばsetwise coprime
        for(int i = 2; i < A; i++){
            int cnt = 0;
            for(int j = i; j < A; j += i){
                cnt += c[j];
            }
            if(cnt == n){
                ans = "not coprime";
                break;
            }else if(cnt > 1){
                ans = "setwise coprime";
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 63708
#include<stdio.h>
# define N 10

int main(){
    int i,j,t,d[N];
    for(i=0;i<N;scanf("%d",&d[i]),i++);
    for(i=0;i<N-1;i++)
        for(j=N-1;j>i;j--)
            if(d[j-1]>d[j])
                {t=d[j-1]; d[j-1]=d[j]; d[j]=t;}
    for(i=N-1;i>N-4;printf("%d\n",d[i]),i--);         
    return 0;
}

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a > b) cout << a*2-1 << endl;
  else if(a < b) cout << b*2-1 << endl;
  else cout << a*2 << endl;
  
  
}


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

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  vector<int> color(8,0);
  int king=0;
  for(int i=0;i<N;i++){
    int x=a.at(i)/400;
    if(x<8){
      color.at(x)=1;
    }else{
      king++;
    }
  }

  int sum=0;
  for(int i=0;i<8;i++){
    sum+=color.at(i);
  }
  if(sum==0){
    cout<<1<<" "<<king<<endl;
  }else{
    cout<<sum<<" "<<sum+king<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    char s[5];
    scanf("%s",s);
    if(s[0]==s[1] && s[1]==s[2]){
        printf("No");
        return 0;
    }
    else {
        printf("Yes");
        return 0;
    }
}

Measured memory_bytes: 128
/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const let eps = 1e-8;

int sign(let x) { return (x < -eps) ? -1 : (x > eps ? 1 : 0); }

struct Point {
  let x, y;
  let dist() {
    return sqrt(x * x + y * y);
  }
  Point Rotate(let sink, let cosk) {
    return (Point) {
      x * cosk - y * sink, x * sink + y * cosk
    };
  }
  Point Rotate(Point v) {
    let z = v.dist();
    return Rotate(v.y / z, v.x / z);
  }
  friend Point operator + (Point a, Point b) {
    return (Point) {a.x + b.x, a.y + b.y};
  }
  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }
  Point operator ~ () {
    return (Point) {x, -y};
  }
  friend bool operator < (Point a, Point b) {
    if (sign(a.x - b.x) == 0) return sign(a.y - b.y) < 0;
    return sign(a.x - b.x) < 0;
  }
  void EchoWith(char c) {
    printf("%.8Lf %.8Lf", x, y);
    putchar(c);
  }
};

typedef Point Vec;

struct Circle {
  Point o;
  let r;
  friend pair<Point, Point> Cross(Circle a, Circle b) {
    Vec v = b.o - a.o;
    let r1 = a.r, r2 = b.r, d = (b.o - a.o).Rotate(~v).x;
    if (sign(r1 + r2 - d) == 0) {
      Point p = ((Point) {r1, 0}).Rotate(v) + a.o;
      return make_pair(p, p);
    }

    let x = d / 2 + (r1 * r1 - r2 * r2) / (2 * d),
        y = sqrt(r1 * r1 - x * x);
    Point p1 = ((Point) {x, y}).Rotate(v) + a.o, 
          p2 = ((Point) {x, -y}).Rotate(v) + a.o;
    if (p2 < p1) swap(p1, p2);
    return make_pair(p1, p2);
  }
};

Point ReadPoint() {
  Point p;
  scanf("%Lf%Lf", &p.x, &p.y);
  return p;
}

Circle ReadCirle() {
  let c;
  Point p = ReadPoint();
  scanf("%Lf", &c);
  return (Circle) {p, c};
}

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_7_E.in", "r", stdin);
//   freopen("CGL_7_E.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_7_E.log", "w", stderr);
// #endif
  Circle c1 = ReadCirle(), c2 = ReadCirle();
  pair<Point, Point> res = Cross(c1, c2);
  res.first.EchoWith(' '), res.second.EchoWith('\n');
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_7_E CGL_7_E.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_7_E CGL_7_E.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_7_E < CGL_7_E.in > CGL_7_E.out
==================
}}} */



Measured memory_bytes: 3276