akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main(string[] args)
    {

        var N = long.Parse(Console.ReadLine());
        Console.WriteLine(Calc(N));
    }

    static int Calc(long num)
    {
        var max = Math.Floor(Math.Sqrt(num)) + 1;
        var result = LengthOf(num);
        for (var i = 1; i < max; ++i)
        {
            if (num % i != 0)
                continue;
            result = Math.Min(result, LengthOf(Math.Max(i, num / i)));
        }

        return result;
    }

    static int LengthOf(long num)
    {
        return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
    }
}



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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		400010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];


//
int main(){
	int m1,m2,d1,d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;

	cout << ( m1==m2 ? 0 : 1 ) << endl;

	return 0;
}




Measured memory_bytes: 256
s=input()
k=int(input())
ans=[]
for i in range(len(s)):
  for j in range(max(0,len(s)-5),len(s)):
    ans.append(s[j:])
  s=list(s)
  s.pop()
  s=''.join(s)
ans=list(set(ans))
ans.sort()
print(ans[k-1])

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

tuple<int, int, int> getNumberofBills(int N, int Y){
  for(int x=0; x<=N; x++){
    for(int y=0; y<=N-x; y++){
      for(int z=0; z<=N-x-y; z++){
        if( 10000*x + 5000*y + 1000*z == Y && x+y+z == N){
          return forward_as_tuple(x, y, z);
        }
      }
    }
  }
  return forward_as_tuple(-1, -1, -1);
}

int main() {
  int N,Y,x,y,z;
  cin >> N >> Y;
  tie(x, y, z) = getNumberofBills(N,Y);
  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
		// new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] d = new int[N];// d[i]: = | x[i] - x[i-1] |
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextInt();
			d[i] = x[i] - (i > 0 ? x[i - 1] : 0);
		}
		int M = sc.nextInt();
		long K = sc.nextLong();
		int[] a = new int[M];
		int[] comb = new int[N];// comb[i]:=i番目の数がcomb[i]に移動
		for (int i = 0; i < N; ++i) {
			comb[i] = i;
		}
		for (int i = 0; i < M; ++i) {
			a[i] = sc.nextInt();
			--a[i];
			// swap[ d[i] , d[i+1] ]
			{
				int tmp = comb[a[i]];
				comb[a[i]] = comb[a[i] + 1];
				comb[a[i] + 1] = tmp;
			}
		}

		int[] cur = new int[N];
		for (int i = 0; i < N; ++i) {
			cur[i] = i;
		}
		for (; K > 0; K >>= 1, comb = mul2(comb)) {
			if (K % 2 == 1) {
				cur = mul(cur, comb);
			}
		}
		long L = 0;
		for (int i = 0; i < N; ++i) {
			L += d[cur[i]];
			System.out.println(L);
		}
	}

	int[] mul(int[] ord1, int[] ord2) {
		int n = ord1.length;
		if (ord1.length != ord2.length) {
			throw new AssertionError();
		}
		int[] ret = new int[n];
		for (int i = 0; i < n; ++i) {
			ret[i] = ord1[ord2[i]];
		}
		return ret;
	}

	int[] mul2(int[] ord) {
		int n = ord.length;
		int[] ret = new int[n];
		for (int i = 0; i < n; ++i) {
			ret[i] = ord[ord[i]];
		}
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 98172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	string s;
	cin >> s;
	int size = s.size();
	for (int i = 1; i < s.size() - 1; i++) {
		int d = size - i -1;
		if (d % 2 == 0) {
			if (s.substr(0, d / 2) == s.substr(d / 2, d / 2)) {
				cout << d  << endl;
				return 0;
			}
		}
	}
	
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String nl = System.getProperty("line.separator");
		StringBuilder p = new StringBuilder(1000);
		StringBuilder d = new StringBuilder(".");
		StringBuilder s = new StringBuilder("#");
		Scanner r = new Scanner(System.in);
		int h, w, i, ww;
		String t, u;
		for (i = 0; i < 4; ++i) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while ((h = r.nextInt()) + (w = r.nextInt()) > 0) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			p.append(u = s.substring(0,w));
			p.append(nl);
			t = d.substring(2, w);
			for (i = h - 2; i > 0; --i) {
				p.append('#');
				p.append(t);
				p.append('#');
				p.append(nl);
			}
			p.append(u);
			p.append(nl);
			p.append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18400
N,M,X,Y = list(map(int,input().split(" ")))
x = list(map(int,input().split(" ")))
y = list(map(int,input().split(" ")))
f = True
for i in range(X+1,Y+1):
  r =  [j for j in x if j < i]
  r2 = [j for j in y if j >= i]
  if len(r) == N and len(r2) == M:
      print("No War")
      f = False
      break
        
if f:
    print("War")


Measured memory_bytes: 3064
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){

    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;

    auto a = Sa.begin(), b = Sb.begin(), c = Sc.begin();

    char next = 'a';

    REP(i,3000){
        if(next == 'a'){if(a==Sa.end()){cout << 'A' << endl; break;} next = *a; a++;}
        else if(next == 'b'){if(b==Sb.end()){cout << 'B' << endl; break;} next = *b; b++;} 
        else{if(c==Sc.end()){cout << 'C' << endl; break;} next = *c; c++;}
    }

    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt=0;
	FOR(i, 0, n - 3) {
		if (s.substr(i, 3) == "ABC") {
			cnt++;
		}
	}
	pv(cnt)
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
random_device rnd;
mt19937 mt(rnd());
uniform_int_distribution<> rand365(1,365);
uniform_int_distribution<> rand26(1,26),rand100(0,100);
ll D,c[30];
vec s[400];
vec ans(400);
double start_temp=0,end_temp=0;
double start_time,TIME_LIMIT=1.95;
ll score(vec A){
    ll ans=0,last[30]={0};
    rep1(i,D){
        ans+=s[i][A[i]];
        last[A[i]]=i;
        rep1(j,26) ans-=c[j]*(i-last[j]);
    }
    return ans;
}

double getTime(){
    return (double)clock()/CLOCKS_PER_SEC;
}

void input(){
    cin>>D;
    rep1(i,26) cin>>c[i];
    int S;
    rep1(i,D){
        s[i].push_back(0);
        rep(j,26) cin>>S,s[i].push_back(S);
    }
}


void solve(){
    rep1(i,D){
        ans[i]=max_element(all(s[i]))-s[i].begin();
    }
    start_time=getTime();
    ll now=score(ans);
    while(true){
        double now_time=getTime();
        if (now_time - start_time > TIME_LIMIT) break;
        double temp = start_temp + (end_temp - start_temp) * (now_time-start_time) / TIME_LIMIT;
        int d=rand365(mt),q=rand26(mt),preq;
        preq=ans[d];
        ans[d]=q;
        ll a=score(ans);
        if(a>now) now=a;
        else{
            if(temp>rand100(mt)) now=a;
            ans[d]=preq;
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    input();
    solve();
    rep1(i,D) cout<<ans[i]<<"\n";
}


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

int a, b, c, d, n, judg = 0, sub = 0, Ans = 0, i, j, k = 0;
int A[100];
string S[10000];
int main()
{
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> S[i];
		if (S[i].front() == 'B')
			judg += 1;
		if (S[i].back() == 'A')
			sub += 1;
		if (S[i].front() == 'B'&&S[i].back() == 'A')
			k += 1;
		for (j = 0; j < S[i].length() - 1; j++) {
			if (S[i][j] == 'A'&&S[i][j + 1]=='B')
				Ans += 1;
		}
	}
	if (k == judg && sub == k&&sub!=0)
		Ans -= 1;
	if (judg <= sub)
		cout << Ans + judg << endl;
	else
		cout << Ans + sub << endl;
	return 0;	
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>

int main()
{
	int N = 0, M = 0;
	std::cin >> N >> M;

	int p;
	std::string S;
	std::vector<std::pair<bool, int>> c(N);
	for (int i = 0; i < N; i++)
	{
		c[i].first = false;
		c[i].second = 0;
	}

	std::pair<int, int>ans;
	for (int i = 0; i < M; i++)
	{
		std::cin >> p >> S;
		if (c[p - 1].first) continue;
		if (S == "AC")
		{
			c[p - 1].first = true; 
			ans.first++;
          	ans.second += c[p - 1].second;
		}
		else if (S == "WA") c[p - 1].second++;
	}

	std::cout << ans.first << " " << ans.second << std::endl;

	return 0;
}

Measured memory_bytes: 1024
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn main() {
    input! { n, a: [[isize; n]; n] };
    let mut dp = vec![0; 1 << n];
    for x in 1..(1 << n) {
        for i in 0..(n - 1) {
            for j in (i + 1)..n {
                if (x >> i) & 1 == 1 && (x >> j) & 1 == 1 {
                    dp[x] += a[i][j];
                }
            }
        }
        let mut y = (x - 1) & x;
        while y > 0 {
            dp[x] = max(dp[x], dp[y] + dp[x ^ y]);
            y = (y - 1) & x;
        }
    }
    println!("{}", dp.last().unwrap());
}


Measured memory_bytes: 4352
"""
N = int(input())
A, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

S_cnt = list(Counter(S).items())
#print(S_cnt)

lst = []
for i in range(len(S_cnt)):
  point = S_cnt[i][1]
  for j in range(len(T)):
    if T[j] == S_cnt[i][0]:
      point -= 1
  lst.append(point)
ans = max(0, max(lst))
print(ans)

Measured memory_bytes: 3316
#include<cstdio>
long long const p=1000003;
template<typename T>
T power(T a,long long k){
    if(k==0)return T(1);
    T sqrta=power(a,k/2);
    return sqrta*sqrta%p*((k%2==0)?1:a)%p;
}
long long ext_gcd(long long a,long long b,long long &x,long long &y){
    if(b==0){x=1;y=0;return a;}
    long long q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;
    x=y; y=z;
    return g;
}
long long inv(long long value){
    long long x,y;
    ext_gcd(value,p,x,y);
    return (x+p)%p;
}
long long fact[p];
long long factinv[p];
int main(){
    int q;
    scanf("%d",&q);
    fact[0]=1;
    for(int i=1;i<p;i++){
        fact[i]=(fact[i-1]*i)%p;
        factinv[i]=inv(fact[i]);
    }
    for(int i=0;i<q;i++){
        long long x,d,n;
        scanf("%lld%lld%lld",&x,&d,&n);
        if(x==0){
            printf("0\n");
        }else if(d==0){
            printf("%lld\n",power(x,n));
        }else{
            long long xdinv=(x*inv(d))%p;
            int maxnum=xdinv+n-1;
            if(maxnum >= p){
                printf("0\n");
            }else{
                int minnum=(xdinv+p-1)%p;
                printf("%lld\n",power(d,n)*fact[maxnum]%p*factinv[minnum]%p);
            }
        }
    }
    return 0;
}

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

int main() {
    int s;
    cin >> s;
    int b = s/100;
    int e = s%100;
    
    if(((b > 12 && e > 12)or(b == 0 && e == 0) or (b == 0 && e > 12) or (e == 0 && b > 12))){
        cout << "NA" << endl;
    }else if((b > 0 && b <=12) && (e > 0 && e <= 12)){
        cout << "AMBIGUOUS" << endl;
    }else if((b == 0 or b >=12) && (e > 0 && e <= 12)){
        cout << "YYMM" << endl;
    }else if((e == 0 or e >=12) && (b > 0 && b <= 12)){
        cout << "MMYY" << endl;
    }
    
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] a = new int[n + 2];
        for (int i = 0; i < m; i++) {
            int l = sc.nextInt(), r = sc.nextInt();
            a[l] += 1;
            a[r + 1] -= 1;
        }
        int cnt = 0;
        for (int i = 1; i <= n + 1; i++) {
            a[i] += a[i - 1];
            if (a[i] == m) cnt++;
        }
//        debug(a);
        System.out.println(cnt);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 65356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n >> s;
    int sum[n];
    int a = 0;
    for(int i = 0;i < n; i ++){
        if(s[i] == '#') {
            a++;
            sum[i]= a;
        }
        else sum[i] = a;
    }
    int b;
    a = 0;
    int ans = n;
    if (sum[n-1] ==0 || sum[n-1] == n) cout << "0" <<endl;
    else{
        for(int i = 0; i < n; i++){
            a = sum[i];
            if(i != n-1){
                b = (n - i - 1) - (sum[n-1]-sum[i]);
            }
            else{
                b = s[i] == '#' ? 0 : 1;
            }
            ans = min(ans, a+b);
        }
        if(ans > sum[n-1]) cout << sum[n-1] <<endl;
        else if(ans>n - sum[n-1]) cout << n - sum[n-1] <<endl;
        else cout<< ans <<endl;
    }
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  string T=S;
  bool ok=false;int ol=0;
  int cnt=0;
  for(int i=0;i<50;i++){
    ok=false;
    rep(j,S.size()){
      if(S[j]=='('){
        ok=true;
        ol=j;
      }
      else if(S[j] ==')'&&ok){
           S[ol]='a';
           S[j]='a';
           
          break;
      }
    } 
  }
  int cl=0,cr=0;
  rep(i,S.size()){
    if(S[i]=='(')cl++;
    else if(S[i]==')')cr++;
  }
  rep(i,cr){
    T='('+T;
  }
  rep(i,cl){
    T=T+')';
  }
  cout<<T<<endl;
 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef set<ll> Set;

const ll max_N=500009;
ll n;
char s[max_N];
ll q;
Set mp[26];

int main(){
    cin >> n;
    rep(i,n) cin >> s[i+1];
    cin >> q;
    rep(i,26) mp[i].insert(n+1);
    rep(i,n){
        mp[s[i+1]-'a'].insert(i+1);
    }
    while(q--){
        ll tes;
        cin >> tes;
        if(tes==1){
            ll iq;
            char cq;
            cin >> iq >> cq;
            if(s[iq]==cq) continue;
            else{
                mp[s[iq]-'a'].erase(iq);
                mp[cq-'a'].insert(iq);
                s[iq]=cq;
            }
        }
        else{
            ll ans=0;
            ll l,r;
            cin >> l >>r;
            rep(i,26){
                if(*mp[i].lower_bound(l)<=r) ans++;
            }
            kaku(ans);
        }
    }
}



Measured memory_bytes: 24192
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod = 998244353;
typedef pair<int, int> P;
struct edge {
	int to, dir;
};
int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
signed main() {
	int k; cin >> k; cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
string s;

void solve(){
    cin >> n;
    cin >> s;
    s="a"+s+"a";
    int wp=0,rp=n+1;
    int ans=0;
    vector<char> S(n+2);
    rep(i,n+2){
        S[i]=s[i];
    }
    while(wp<rp){
        //cout << wp << " " << rp << endl;
        while(S[wp]!='W' && wp<n+1) {
            //cout << S[wp] << endl;
            wp+=1;
        }
        //cout << wp << endl;
        while(S[rp]!='R' && rp>0) rp-=1;
        swap(S[wp],S[rp]);
        ans+=1;
    }
    cout << ans-1 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3872
<?php
$sc = new Scanner();

$in_count = $sc->nextInt();
$num_arr = array();

for ($i = 0; $in_count > $i; $i++) {
    array_push($num_arr, $sc->nextInt());
}

$exe_count = 0;
$end = false;
while (!$end) {
    $ret = in_odd_check($num_arr);
    if ($ret === true) {
        $end = true;
    } else {
        $num_arr = $ret;
        $exe_count++;
    }
}

out::println($exe_count);

function in_odd_check($arr)
{
    $ret = array();
    foreach ($arr as $k => $v) {
        if ($v % 2 != 0) {
            $ret = true;
            break;
        } else {
            $ret[$k] = $v / 2;
        }
    }
    return $ret;
}

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function println($str = "")
    {
        echo $str . PHP_EOL;
    }
}

Measured memory_bytes: 4604
#include <stdio.h>
int main(){
  int a, n,i,j,k,x,y,z,w;
  int count[4][3][10];
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	count[i][j][k]=0;
      }
    }
  }


  scanf("%d",&n);
  for(i=0;i < n;i++){
    
    scanf ("%d %d %d %d",&x,&y,&z,&w);
    count[x-1][y-1][z-1] += w;
  }



  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",count[i][j][k]);
	 
	  }
      printf("\n"); }
    if(i!=3)printf("####################\n");
  }
  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, m, n) for (int i = m; i < n; ++i)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// vvi data(n, vi(m));
using vll = vector<long long>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
  int t, x;
  cin >> t >> x;
  cout << t / (double)x << endl;
}


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

using namespace std;
long long A,B;
vector<long long> dive;
vector<long long> div2;

bool div(long long a){
    int lim = sqrt(a);
    for (int i = 1 ; i <= lim ; i++){
        if (a % i == 0){
            if (i == a/i)dive.push_back(i);
            else {
            dive.push_back(i);
            dive.push_back(a/i);
            }
        }
    }

}


int main()
{

    cin >> A >> B;

    div(min(A,B));
    for (int i = 0 ; i < dive.size(); i++){
        if ((max(A,B)) % dive[i] == 0)div2.push_back(dive[i]);
    }

    sort(div2.begin(),div2.end());

    int cont =0;

    for (int i = 0 ; i < div2.size() ; i++){
        for (int j = i + 1 ; j < div2.size() ; j++){
            if ((div2[i] == -1)||(div2[j] == -1))continue;
            else if (__gcd(div2[i],div2[j]) > 1){
                cont++;
                div2[j] = -1;
            }
        }
    }

    cout << div2.size() - cont << endl;

    return 0;
}


Measured memory_bytes: 384
public class Main {

	private static void solve() {
		int n = ni();
		int[][] a = ntable(2, n);
		int ret = 0;
		for (int i = 0; i < n; i ++) {
			int now = 0;
			for (int j = 0; j <= i; j ++) {
				now += a[0][j];
			}
			for (int j = i; j < n; j ++) {
				now += a[1][j];
			}
			ret = Math.max(now, ret);
		}
		System.out.println(ret);
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n;
int main(){
    cin>>n;
    vector<P> p(n);
    rep(i,n){
        p[i].second=i;
        cin>>p[i].first;
    }
    /*
    for(int i = 0;i < n; i++){
        cout<<p[i].first<<" "<<p[i].second<<endl;
        
    }
    */
    sort(p.begin(),p.end());
    for(int i = 0;i < n; i++){
        cout<<p[i].second+1<<endl;
    }
    return 0;
}

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

int main()
{
    ll N,K;
    cin >> N >> K;
    map<ll,ll> mp;
    for(ll i = 0; i < N; i++)
    {
        ll tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        mp[tmp1] += tmp2;
    }

    ll count = 0;

    for(auto e:mp)
    {
        count += e.second;
        if(count >= K)
        {
            cout << e.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
# -*- coding: utf-8 -*-
import itertools

# スペース区切りの整数の入力
h = map(int, input().split())

hlist = list(itertools.combinations(h, 2))

tempHour=0
ans=0

for i in range(len(hlist)):
    tempHour=hlist[i][0]+hlist[i][1]
    if tempHour < ans or ans == 0:
        ans = tempHour
# 出力
print(ans)

Measured memory_bytes: 3060
/*input
10
oxooxoxoox
*/

#include <iostream>
#include <vector>

using namespace std;

bool check_target(const int N, const int target,
	const vector<int> &array, const vector<int> &animals){

	bool result;
	int left = target - 1;
	if(left < 0) left += N;
	int right = (target + 1) % N;

	if(animals[target] == 0){ // last is sheep
		if(array[target] == 0){
			if(animals[left] == animals[right]) result = true;
			else result = false;
		}else{
			if(animals[left] == animals[right]) result = false;
			else result = true;
		}
	}else{ // last is wolf
		if(array[target] == 0){
			if(animals[left] != animals[right]) result = true;
			else result = false;
		}else{
			if(animals[left] != animals[right]) result = false;
			else result = true;
		}
	}

	return result;
}

bool check(const int N, const int first, const int second,
	const vector<int> &array, vector<int> &animals){

	// first is sheep && second sheep
	animals[0] = first;
	animals[1] = second;

	for(int i=2;i<N;i++){
		if(array[i-1] == 0 && animals[i-1] == 0){
			animals[i] = animals[i-2];
		}else if(array[i-1] == 0 && animals[i-1] == 1){
			animals[i] = 1 - animals[i-2];
		}else if(array[i-1] == 1 && animals[i-1] == 0){
			animals[i] = 1 - animals[i-2];
		}else{
			animals[i] = animals[i-2];
		}
	}

	bool result1 = check_target(N, N-1, array, animals);
	bool result2 = check_target(N, 0, array, animals);

	return (result1 && result2);
}

void display(vector<int>&animals){
	for(int a:animals){
		if(a == 0){
			cout << "S";
		}else{
			cout << "W";
		}
	}
	cout << endl;
}

int main()
{

	int N;
	string s;

	cin >> N;
	cin >> s;

	vector<int> array(N);
	vector<int> animals(N);
	for(int i=0;i<N;i++){
		if(s[i] == 'o') array[i] = 0;
		else array[i] = 1;
		// cout << array[i] << " ";
	}
	// cout << endl;

	bool result;

	result = check(N, 0, 0, array, animals);
	if(result){
		display(animals);
		return 0;
	}

	result = check(N, 0, 1, array, animals);
	if(result){
		display(animals);
		return 0;
	}

	result = check(N, 1, 0, array, animals);
	if(result){
		display(animals);
		return 0;
	}

	result = check(N, 1, 1, array, animals);
	if(result){
		display(animals);
		return 0;
	}

	cout << (-1) << endl;

	return 0;
}


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

//#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;

#ifndef LOCAL
#define int long long
#endif

mt19937 rnd(time(0));
#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("dead", "r", stdin); freopen("tmp.out", "w", stdout);
#define s second
#define f first
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define res resize
#define PI acos(-1)

template<class T>
ll upmax(T &a, T b) { return (b > a) ? a = b, 1 : 0; }

template<class T>
ll upmin(T &a, T b) { return (b < a) ? a = b, 1 : 0; }

const ll INF = 1e9;//9223372036854775807L; //LONG_MAX;
constexpr ll mod = 1e9 + 7, dopmod = 6914882281337;


void solve() {
    int n;
    cin>>n;
    string x;
    cin>>x;
    int ans = 0;
    for(int i = 2;i<n;i++)if(x[i-2]=='A'&&x[i-1]=='B'&&x[i]=='C')ans++;
    cout<<ans<<'\n';
}

signed main() {
    int t = 1;                                                                                                                                                                        //ll
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#数直線上を N+1 回跳ねるボールがあり、
#1 回目は 座標 D1=0, i 回目は 座標 Di=Di−1+Li−1(2≤i≤N+1) で跳ねます。
#数直線の座標が X 以下の領域でボールが跳ねる回数は何回でしょうか。

N, X = map(int, input().split())
L = list(map(int, input().split()))
d = 0
ans = 1
for i in range(N):
    d += L[i]
    if d <= X:
        ans += 1
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, ans;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    ans += a;
  }
  ans -= n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 500005
int n,k,cnt;
int a[M],p[M],deg[M],ans[M],minn[M<<2];

vector <int> vec[M];
priority_queue <int> q;

void tpsort(){
	for(int i=1; i<=n; i++)
		if(!deg[i]) q.push(-i);
	while(!q.empty()){
		int x=-q.top(); q.pop();
		a[++cnt]=x;
		for(int i=0; i<vec[x].size(); i++)
			if(--deg[vec[x][i]]==0) q.push(-vec[x][i]);
	}
}

void build(int k,int l,int r){
	minn[k]=0x3f3f3f;
	if(l==r) return ;
	int mid=(l+r)>>1;
	build(k<<1,l,mid); 
	build(k<<1|1,mid+1,r);
} 

void modify(int k,int l,int r,int x,int v){
	if(l==r) { minn[k]=min(minn[k],v);return ;}
	int mid=(l+r)>>1;
	if(x<=mid) modify(k<<1,l,mid,x,v);
	if(x>mid) modify(k<<1|1,mid+1,r,x,v);
	minn[k]=min(minn[k<<1],minn[k<<1|1]);
}

int query(int k,int l,int r,int x,int y){
	if(l>=x&&r<=y) return minn[k];
	int mid=(l+r)>>1;
	int res=0x3f3f3f;
	if(x<=mid) res=min(res,query(k<<1,l,mid,x,y));
	if(y>mid) res=min(res,query(k<<1|1,mid+1,r,x,y));
	return res;
}
void d(){ puts("HH");}
int main()
{
	cin >> n >> k;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]), p[a[i]]=i;
	build(1,1,n);
	for(int i=n;i ;i--){ // 倒序 （并不知道为什么
		int t1=query(1,1,n,max(1,p[i]-k+1),p[i]);
		if(t1<=n) vec[p[i]].push_back(p[t1]), deg[p[t1]]++;
		int t2=query(1,1,n,p[i],min(n,p[i]+k-1));
		if(t2<=n) vec[p[i]].push_back(p[t2]), deg[p[t2]]++;
	//	cout<<i<<" "<<t1<<" "<<t2<<endl;
		modify(1,1,n,p[i],i); // 在p[i]位置加入i 
	}
	//for(int i=1; i<=n; i++) cout<<deg[i]<<" ";
	tpsort();  //拓扑排序 
	for(int i=1; i<=n; i++) ans[a[i]]=i;
	for(int i=1; i<=n; i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 44544
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 1000000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
ll extGCD(ll a,ll b,ll &x,ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}


// 逆元計算 (ここでは a と m が互いに素であることが必要)
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

int main(){
  ll n,q,ans=0,a,b;cin>>n>>q;
  if(mod((q*2-n),3)!=0){cout<<0<<endl;}
  else{
    a=(q*2-n)/3;b=q-2*a;
    COMinit();
    cout<<COM(a+b,a)<<endl;
  }
}



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

int n, k;

int main(){
    string s;
    cin >> n >> k;
    cin >> s;
    k--;
    if(s[k] == 'A') s[k] = 'a';
    else if(s[k] == 'B') s[k] = 'b';
    else s[k] = 'c';

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int i;
	int count = 0;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++)
	{
		if(c%i == 0)
		{
			count++;
		}
	}
	
	printf("%d\n",count);
	
	return 0;
}

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> R;
	for(int i=0; i<n; i++) {
		if(s[i] == 'W')
			R.push_back(i);
	}
	int w = 0;
	int px = 0;
	for(int i=n-1; i>=0; i--) {
		if(s[i] == 'R' && px < R.size() && R[px] < i) {
			w++;
			px++;
		}
	}
	cout<<w;
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,s,sum;
    cin >>n;
    s=n;
    while(s!=0){
        sum+=s%10;
        s/=10;
    }
    if(n%sum==0) cout << "Yes"<<endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	if(exponent<0) exponent+=MOD-1;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll fact[MAX],ifact[MAX];
ll choose(ll n,ll r)
{
	if(n==-1&&r==-1)
		return 1;
	if(n<0||r<0||r>n)
		return 0;
	ll ans=fact[n]*ifact[r];
	ans%=MOD;
	ans*=ifact[n-r];
	ans%=MOD;
	// cout<<n<<" "<<r<<" "<<ans<<endl;
	return ans;
}
int main()
{
	fact[0]=ifact[0]=1;
	for(int i=1;i<MAX;i++)
	{
		fact[i]=(fact[i-1]*1LL*i)%MOD;
		ifact[i]=powmod(fact[i],-1);
	}
	csl;
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	ll n,m;
	cin>>n>>m;
	ll ans=1;
	for(int i=2;i*i<=m;i++)
	{
		if(m%i==0)
		{
			int cnt=0;
			while(m%i==0)
			{
				m/=i;
				cnt++;
			}
			ans*=choose(cnt+n-1,n-1);
			ans%=MOD;
		}
	}
	if(m>1)
	{
		ans*=choose(1+n-1,n-1);
	}
	ans%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 15872
/*  4_3
    Y_Aizaki    */

#include <stdio.h>

/* プロトタイプ宣言 */
int snow(int index_tower, int east_over);

int main(void){
    int west, east;
    scanf("%d%d", &west, &east);
    // 西側の塔の露出している高さ、東側の塔の露出している高さ

    int snowfall = snow(east - west, east);
    // 積雪量
    printf("%d\n", snowfall);

    return 0;
}

int snow(int index_tower, int east_over){
    // 東側の塔のindexと、露出している高さを引数にとる

    int snowfall = (1 + index_tower) * index_tower / 2 - east_over;

    return snowfall;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;

int nokori;
int kaisu;

vector<int> dp(1001, -1);

int dfs(int step, int nv){
  // cout << nv << endl;
  if(nv > nokori) return 1;
  if(dp[nv] == 1) return dp[nv] = 1;
  if(nv == nokori) {
    // print(dp);
    cout << 1 << endl;
    exit(0);
  }
  if(step == kaisu) return dp[nv] = 1;
  dp[nv] = dfs(step+1, nv+5);
  dp[nv] = dfs(step+1, nv+4);
  dp[nv] = dfs(step+1, nv+3);
  dp[nv] = dfs(step+1, nv+2);
  dp[nv] = dfs(step+1, nv+1);
  return dp[nv] = 1;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  nokori = x % 100;
  kaisu = x / 100;
  dfs(0, 0);
  // print(dp);
  cout << 0 << endl;
}


Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		vector<pair<string,pii>> v;
		ll int n;
		cin>>n;
		v.resize(n);
		for(ll int i=0;i<n;i++)
		{
			cin>>v[i].F>>v[i].S.F;
			v[i].S.F*=-1;
			v[i].S.S=i+1;
		}
		sort(all(v));
		for(auto i:v) cout<<i.S.S<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int h,w;
  cin>>h>>w;
  char c[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin>>c[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout<<c[i][j];
    }
    cout<<endl;
    for(int j = 0; j < w; j++){
      cout<<c[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256