akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    bool submit[n] = {};
    bool ac[n] = {};
    int wa[n] = {};
    REP(i,m){
        int p;
        string s;
        cin >> p >> s;
        p--;
        submit[p] = true;
        if(s == "WA" && !ac[p]){
            wa[p]++;
        }else{
            ac[p] = true;
        }
    }
    int ans1 = 0, ans2 = 0;
    REP(i,n){
        if(ac[i]){
            ans1++;
            ans2 += wa[i];
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

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

int main(void){
  	string s;
  	cin >> s;
  	int cnt = 0;
  	int sz = s.size();
  	rep(i, sz/2){
    	if(s[i] == s[sz-1-i]) continue;
      	cnt++;
    }
  	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push( int );
int pop();
int top;//ポインタ
int keep[1000];//データ格納用配列

int main( void ){
	
	int x, y;
	char cal[100];
	
	top = 0;
	while( scanf("%s", cal ) != EOF ){
		if( cal[0] == '+' ){
			x = pop();
			y = pop();
			push( x + y );
		}
		else if( cal[0] == '-' ){
			x = pop();
			y = pop();
			push( y - x );
		}
		else if( cal[0] == '*' ){
			x = pop();
			y = pop();
			push( x * y );
		}
		else{
			push(atoi(cal));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
}

void push( int x ){
	keep[++top] = x;
}

int pop(){
	top--;
	return keep[top+1];
}




Measured memory_bytes: 2100
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (d, mut n) = i.read2::<usize, usize>();
    let mut r = 1;
    for _ in 0..d {
        r *= 100;
    }
    if n == 100 {
        n = 101
    };

    writeln!(o, "{}", r * n).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = i.next().unwrap().parse().ok().unwrap();
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }
    }

}


Measured memory_bytes: 4352
n,k=map(int, input().split())
x=list(range(1,n+1))
for i in range(k):
    d=int(input())
    a=list(map(int, input().split()))
    for j in range(d):
        try:
            x.remove(a[j])
        except:
            x=x
print(len(x))

Measured memory_bytes: 68068
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> v1;
int n = 2;
vector<pair<int,int>> arr[25];
int len = 0;
int m;
void mult(){
    for(int i=1;i<=20;i++){
        for(auto &x:arr[i]){
            x.second*=2;
        }
    }
    arr[n].push_back(make_pair(n+1,0));
    arr[n].push_back(make_pair(n+1,1));
    m+=2;
    n++;
    len*=2;
}
void add(){
    arr[1].push_back(make_pair(n,len++));
    m++;
}
int main() {
	int l;
	cin>>l;
	while(l){
	    v1.push_back(l%2);
	    l/=2;
	}
	reverse(v1.begin(),v1.end());
	for(int i=0;i<v1.size();i++){
	    if(i==0){
	        if(v1[i]){
	            add();
	        }
	        continue;
	    }
	    if(len!=1){
	        mult();
	    }
	    if(len==1){
	        add();
	    }
	    if(v1[i]){
	       add();
	    }
	}
	cout<<n<<" "<<m<<endl;
	for(int i=1;i<=20;i++){
	    for(auto x:arr[i]){
	        cout<<i<<" "<<x.first<<" "<<x.second<<endl;
	    }
	}
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()
	okline := 0
	alist := make([]int, n)
	for i := 0; i < n; i++ {
		alist[i] = nextInt()
		okline += alist[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(alist)))
	//fmt.Println(alist, okline)

	if alist[m-1]*(4*m) >= okline {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

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


Measured memory_bytes: 1764
a,b,q,c,d,w,f=map(int,input().split())
k=[b,b]
k[0]+=(a-(a%2)+c-(c%2)+d-(d%2))
if a%2==1 and c%2==1 and d%2==1:
  k[0]+=3
if a and c and d:
  a-=1;c-=1;d-=1
  k[1]+=(3+a-(a%2)+c-(c%2)+d-(d%2))
print(max(k))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
string s;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	s[1]=('R'+'B'-s[1]);
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        int count = 0;
        for (int i = 0; i < s.length; i++) {
            if ("+".equals(s[i])) {
                count++;
                continue;
            }
            count--;
        }
        System.out.println(count);
    }

}


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


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int max = a;
  if(max < b){
    max = b;
  }
  if(max < c){
    max = c;
  }
  if(max == a){
    cout << a*10+b+c << endl;
  }else if(max == b){
    cout << a+b*10+c << endl;
  }else if(max == c){
    cout << a+b+c*10 << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int llint;
int x[25][25],dp[2200005],n;
llint mod=1e9+7;
llint sum(llint a,llint b) {
	return ((a%mod)+(b%mod))%mod;
}
llint rek(int ind,int mask) {
	if(ind==n) return 1;
	if(dp[mask]!=-1) return dp[mask];
	llint ret=0;
	for(int i=0;i<n;i++) {
		if(mask & (1 << i)) continue;
		if(x[ind][i]==0) continue;
		ret=sum(ret,rek(ind+1,mask+(1 << i)));
	}
	dp[mask]=ret;
	return ret;
}
int main()
{
	cin >> n;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			cin >> x[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout << rek(0,0);
	return 0;
}


Measured memory_bytes: 8832
import java.util.*;

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

        Map<String, Integer> m = new HashMap<>();
        per(m, "", n, new boolean[n]);

        System.out.println(Math.abs(m.get(join(a)) - m.get(join(b))));

    }

    static int[] populateList(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) arr[i] = sc.nextInt();
        return arr;
    }

    static String join(int[] arr) {
        StringBuilder sb = new StringBuilder();
        for (int i : arr) {
            sb.append(i);
        }
        return sb.toString();
    }

    static void per(Map<String, Integer> m, String ans, int n, boolean[] mask){
        if (ans.length() == n) {
            m.put(ans, m.size());
            return;
        }

        for (int i = 0; i < n; i++) {
            if (!mask[i]) {
                mask[i] = true;
                per(m, ans + (i+1), n, mask);
                mask[i] = false;
            }
        }
    }
}

Measured memory_bytes: 45236
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto s = readln().chomp();
    writeln(s[0..4], " ", s[4..$]);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<tuple<string, int , int>> res (N);
  for (int i=0;i<res.size();i++){
    string C;
    int P;
    cin >> C >> P;
    res.at(i)=make_tuple(C,-P,i+1);
  }
  sort (res.begin(), res.end());
  for (int j=0;j<N;j++){
    int k;
    tie (ignore , ignore ,k)=res.at(j);
    cout << k << endl;
  }
}

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

int main(){
    string s;
    cin >> s;
    int first , end, ans;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
            first = i;
            break;
        }    
    }
    for(int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            end = i;
            break;
        }
    }
    ans = end - first + 1;
    cout << ans << endl;
    return 0;
}

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

#define fi first
#define se second

const int N = 100100;
const int mod = 1e9 + 7;

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        int n;
        cin >> n;
        vector < int > a(n);
        int res = 0;
        for(int i = 0; i < n; i++){
                cin >> a[i];
        }
        for(int i = 0; i < n; i++){
                if(a[i] == i + 1){
                        res += 1;
                        i += 1;
                }
        }
        cout << res << "\n";
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int mo=998244353,N=1000005;

typedef long long LL;

int n,m,ans,Fac[N],Inv[N],FInv[N];

int C(int n,int m)
{
	return (LL)Fac[n]*FInv[m]%mo*FInv[n-m]%mo;
}

int main()
{
	scanf("%d%d",&n,&m);
	if (n>m) swap(n,m);
	Fac[0]=FInv[0]=Fac[1]=Inv[1]=FInv[1]=1;
	for (int i=2;i<=m+n;i++)
	{
		Fac[i]=(LL)Fac[i-1]*i%mo; Inv[i]=(LL)Inv[mo%i]*(mo-mo/i)%mo;
		FInv[i]=(LL)FInv[i-1]*Inv[i]%mo;
	}
	for (int i=1;i<=n;i++) ans=(ans+(LL)C(i+i,i)%mo*C(n+m-i-i,n-i))%mo;
	ans=(LL)ans*Inv[2]%mo*Fac[n]%mo*Fac[m]%mo*FInv[n+m]%mo;
	ans=(ans+m)%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    char mine='z',maxe='a';
    bool x=0,y=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]<mine) mine=s[i];
        for(int j=i+1;j<s.size();j++)
        {
            if(s[j]!=s[i]) x=1;
        }
    }
    for(int i=0;i<t.size();i++)
    {
        if(t[i]>maxe) maxe=t[i];
        for(int j=i+1;j<t.size();j++)
        {
            if(t[j]!=t[i]) y=1;
        }
    }
    if(x==0&&y==0){
        if(maxe>mine) cout<<"Yes";
        else if(maxe==mine)
        {
            if(t.size()>s.size()) cout<<"Yes";
            else cout<<"No";
        }
        else cout<<"No";
    }
    else
    {
        if(maxe>mine) cout<<"Yes";
        else cout<<"No";
    }
}


Measured memory_bytes: 256
from itertools import accumulate

def getNums(Ss):
    lenS = len(Ss)
    nums = [0] * lenS
    Ss += '#'
    num = -1
    for i, S in enumerate(Ss):
        if S == '.':
            num += 1
        else:
            if num > 0:
                nums[i-(num+1)] = num
                if i < lenS:
                    nums[i] = -num
            num = -1
    return accumulate(nums)


H, W = map(int, input().split())
Sss = [input() for _ in range(H)]

numHss = [list(getNums(Ss)) for Ss in Sss]
Sss_tr = list(map(''.join, zip(*Sss))) # 転置
numVss_tr = [getNums(Ss) for Ss in Sss_tr]
numVss = list(map(list, zip(*numVss_tr))) # 転置

ans = 0
for i in range(H):
    for j in range(W):
        num = numHss[i][j] + numVss[i][j] + 1
        if num > ans:
            ans = num

print(ans)


Measured memory_bytes: 170628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n, W;
  cin >> n >> W;
  ll w[n], v[n];
  rep(i, n) cin >> w[i] >> v[i];
  ll dp[W + 1];
  ll ans = 0;
  rep(i, W + 1) dp[i] = 0;
  rep(i, n) {
    repr(j, W + 1) {
      if (j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
      ans = max(ans, dp[j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int length = S.length();
  
  int atama = (length-1)/2;
  int usiro = (length+3)/2;
  int flag_a = 0;
  int flag_u = 0;
  int flag_all = 0;
  
  for(int i=0; i < length ; i++){
    //cout << length << " " << atama << " " << i << " " << atama-i-1 << endl;
    //cout << S[i] <<" " << S[atama-i-1] << endl;
    if(S.at(i) == S.at(length-i-1)){
      flag_all = 1;
    }else{
      flag_all = 0;
      break;
    }
  }

  for(int i=0; i < atama ; i++){
    if(i > (atama-i-1)){
      break;
    }
    //cout << length << " " << atama << " " << i << " " << atama-i-1 << endl;
    //cout << S[i] <<" " << S[atama-i-1] << endl;
    if(S.at(i) == S.at(atama-i-1)){
      flag_a = 1;
    }else{
      flag_a = 0;
      break;
    }
  }
  //cout << "aaa"  << flag_a << endl;
  for(int i=0; i < (length-usiro+1) ; i++){

    if((usiro+i-1) > (length-i-1)){
      break;
    }
    //cout << length << " " << usiro << " " << usiro+i-1 << " " << (length-i-1) << endl;
    //cout << S[usiro+i-1] <<" " << S[length-i-1] << endl;
    if(S.at(usiro+i-1) == S.at(length-i-1)){
      flag_u = 1;
    }else{
      flag_u = 0;
      break;
    }
  }
  if(flag_a && flag_u && flag_all){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

typedef std::vector<int> vec;

inline bool power_of_2(int n) {
    return (n & (n - 1)) == 0;
}

inline int max_divisor(int n) {
    return n & -n;
}

int g(const vec& sequence) {
    int sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        sum += sequence[i];
    }

    vec table(sum + 1);
    std::fill(table.begin() + 1, table.end(), -1);
    table[0] = 0;

    sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        for (int a = sum & -x; a >= 0; a -= x) {
            if (table[a] >= 0) {
                int b = a + x;
                table[b] = std::max(table[a] + 1, table[b]);
            }
        }
        sum += sequence[i];
    }

    int max = 0;
    for (int i = 1; i <= sum; i <<= 1) {
        max = std::max(max, table[i]);
    }
    return max;
}

vec extract(const vec& sequence, int k) {
    vec subsequence;
    int min = INT_MAX;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        if (x % k == 0 && power_of_2(x / k)) {
            subsequence.push_back(x);
            min = std::min(min, x);
        }
    }
    for (int i = 0; i < subsequence.size(); i++) {
        subsequence[i] /= min;
    }
    return subsequence;
}

void sort_and_uniq(vec& numbers) {
    std::sort(numbers.begin(), numbers.end());
    numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end());
}

int f(const vec& sequence) {
    vec numbers;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        numbers.push_back(x / max_divisor(x));
    }
    sort_and_uniq(numbers);

    int max = 0;
    for (int i = 0; i < numbers.size(); i++) {
        int k = numbers[i];
        const vec& subsequence = extract(sequence, k);
        max = std::max(max, g(subsequence));
    }
    return max;
}

int main() {
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        vec sequence(n);
        for (int i = 0; i < n; i++) {
            std::cin >> sequence[i];
        }
        std::cout << f(sequence) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, n;
  string s, k, t={};
  cin >> a >> b;
  long x;
  x=a*b;
  long y;
  if(a<b){
    y=a;
    a=b;
    b=y;
  }
  
  long r;
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  
  co(x/b);
  
  
  return 0;
}

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

#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define all(v) v.begin(), v.end()
#define ar array

#define F first
#define S second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using ld = long double;

const int mod = 1e9 + 7;
// const int mod = 998244353;
const ll inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-7;

const int N = 1e5 + 5;

int i (char x) {
	return x - '0';
}

void solve () {
	string SS;
	cin >> SS;
	int f = i(SS[0]) * 10 + i(SS[1]), s = i(SS[2]) * 10 + i(SS[3]);
	if (f <= 12 && s <= 12 && min (f, s) >= 1) {
		cout << "AMBIGUOUS";
	}
	else if (f <= 12 && f) {
		cout << "MMYY";
	}
	else if (s <= 12 && s) {
		cout << "YYMM";
	}
	else {
		cout << "NA";
	}
}

int main () {
	ios;
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
		cout << "\n";
	}
}




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

int main ()
{
    string s;cin>>s;
   // s = "#" + s;
   // s = s + "*";
   // string str = "01";
   int cnt = 0;
   int x = s.size();
    for(int i = 0; i<x-1; i++)
    {
        if(s[i] == s[i+1])
        {
            if(s[i] == '0')s[i+1] = '1';
            else s[i+1] = '0';
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int a,b,c;cin >>a>>b>>c;
    int ans;
    if(a==b)ans=c;
    if(c==b)ans=a;
    if(a==c)ans=b;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int sumdigits(int N){
    int sum = 0;

    while(N > 0){
        sum += N % 10;
        N /= 10;
    }
    return sum;
}

int main() {
    int n,a,b; cin >> n >> a >> b;
    int ans = 0;

    for (int i = 1; i <= n; ++i) {
        int sum = sumdigits(i);
        if(a <= sum && b >= sum)ans += i;
    }
    print(ans);
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int D,N;
  cin>>D>>N;
  if(N==100){
    if(D==0){
      cout<<101<<endl;
      return 0;
    }
    if(D==1){
      cout<<101*100<<endl;
      return 0;
    }
    if(D==2){
      cout<<101*10000<<endl;
      return 0;
    }
  }
  if(D==0){
    cout<<N<<endl;
    return 0;
  }
  else if(D==1){
    cout<<N*100<<endl;
    return 0;
  }
  else if(D==2){
    cout<<N*10000<<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();
      String po=sc.nextLine();po=sc.nextLine();
      int count=0;
      for(int i=1;i<po.length();i++){
        int nm=0;
      	String a=po.substring(0,i);
        String b=po.substring(i);
        Map<String,Integer>m=new HashMap<String,Integer>();
        for(int j=0;j<a.length();j++){
        	m.put(a.substring(j,j+1),1);
        }
        for(int j=0;j<b.length();j++){
        	if(m.get(b.substring(j,j+1))!=null){
            	nm++;
              m.put(b.substring(j,j+1),null);
            }
        }
        //System.out.println(a+" "+b+" "+nm);
        count=Math.max(count,nm);
      }
      System.out.println(count);
    }
}


Measured memory_bytes: 21844
/*
─────────▄▄▄▄▄▄▄▄▄▄▄▄─────────
─────▄▄▀▀░░░░░░░░░░░░▀▀▄▄─────
───▄▀░░░░░░░░░░░░░░░░░░░░▀▄───
──█░░░░░▄▄▄▄▄░░░░▄▄▄▄▄░░░░░█──
─█░░░░░██░█░██▄▄██░█░██░░░░░█─
█░░░░░░░▀▀▀▀▀░░░░▀▀▀▀▀░░░░░░░█
█░░░░▄▄▄░░░░░░░░░░░░░░▄▄▄░░░░█
█░░░░██▀█▄▄▄▄▄▄▄▄▄▄▄▄██▀█░░░░█
─█░░░▀██▄████████▄▄▄▄██▄▀░░░█─
──█░░░░▀██▀▀▀▀████████▀░░░░█──
───▀▄░░░░▀▄▄▄▄██████▀░░░░▄▀───
─────▀▀▄▄░░░░░░░░░░░░▄▄▀▀─────
─────────▀▀▀▀▀▀▀▀▀▀▀▀─────────
*/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= d; ++j) {
			if (j >= 20 and j % 10 >= 2 and (j / 10) * (j % 10) == i) {
				++ans;
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0) cout << 1;
  if (b == 0) cout << 2;
  if (c == 0) cout << 3;
  if (d == 0) cout << 4;
  if (e == 0) cout << 5;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
  ll D, G;

  cin >> D >> G;

  int P[D], C[D];
  for (int i = 0; i < D; i++)
  {
    cin >> P[i] >> C[i];
  }

  int ans = pow(10, 9);

  for (int i = 0; i < pow(2, D); i++)
  {
    int score = 0;
    int cnt = 0;
    int max_q_no = 0;
    // 何番目の問をコンプリートするか
    for (int j = 0; j < D; j++)
    {
      if (i & (1 << j))
      {
        score += 100 * (j + 1) * P[j] + C[j];
        cnt += P[j];
      }
      // コンプリートしない場合
      else
      {
        max_q_no = j;
      }
    }
    // まだ点数が足りない場合
    if (score < G)
    {
      // 残り
      int remain = G - score;
      // 最大の問題番号をコンプリートしない数だけ解いて達成できるか？
      int q_p = 100 * (max_q_no + 1);
      int need = ceil((remain + (q_p - 1)) / q_p);
      if (need < P[max_q_no])
      {
        cnt += need;
      }
      else
      {
        continue;
      }
    }

    ans = min(ans, cnt);
  }

  cout << ans;

  return 0;
}

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

int main()
{
    int all_num = 0;
    string str;
    cin >> all_num;
    cin >> str;

    int r_ct = 0;
    int b_ct = 0;
    for (int i = 0; i < all_num; i++)
    {
        if (str[i] == 'R')
        {
            r_ct++;
        }
        else
        {
            b_ct++;
        }
    }
    if (r_ct > b_ct)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline()

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i - 1]
            i &= i - 1
        return s

    def update(self, i, x):
        while i < self.n:
            self.data[i] += x
            i |= i + 1
        return


n, m = map(int, input().split())
c = list(map(int, input().split()))
b = BIT(n)
for i in range(n):
    b.update(i, c[i])

res = []
for i in range(m):
    t, x, y = map(int, input().split())
    if t == 1:
        res.append(b.sum(y) - b.sum(x))
    else:
        b.update(x, y)
print("\n".join(map(str, res)))


Measured memory_bytes: 175832
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  string S;
  cin >> S;

  int64_t cnt = 0;
  int64_t max = 0;
  if (S == "SSS") {
    cout << 0;
  } else if (S == "SSR" or S == "SRS" or S == "RSS" or S == "RSR") {
    cout << 1;
  } else if (S == "SRR" or S == "RRS") {
    cout << 2;
  } else {
    cout << 3;
  }

  return 0;
}


Measured memory_bytes: 3644
H = int(input())
W = int(input())
N = int(input())

myflag = [ [ 0 for w in range(W)] for h in range(H) ]
#print(myflag)

def check_black():
    mycnt = 0
    for h in range(H):
        for w in range(W):
            if myflag[h][w] == 1:
                mycnt += 1
    return mycnt

mycnt = check_black()
#print(mycnt)

myans = 0
myblack = 0
h_cnt = 0
w_cnt = 0
while mycnt < N:
    if H > W and w_cnt < W:
        for h in range(H):
            myflag[h][w_cnt] = 1
        w_cnt += 1
    else:
        for w in range(W):
            myflag[h_cnt][w] = 1
        h_cnt += 1
    myans += 1
    mycnt = check_black()

print(myans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
vvi E(100010);
int par[100010];
int dist[100010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  vi hoge(100010);
  for(int i=0;i<n+m-1;i++){
    int a,b;cin>>a>>b;
    E[a].pb(b);
    hoge[b]++;
  }
  vi cnt(100010);
  for(int i=1;i<=n;i++){
    if(hoge[i]!=0)continue;
    queue<int>que;
    que.push(i);
    while(!que.empty()){
      int now=que.front();
      que.pop();
      for(int j=0;j<E[now].size();j++){
	  cnt[E[now][j]]++;
	  par[E[now][j]]=now;
	  if(cnt[E[now][j]]==hoge[E[now][j]])
	    que.push(E[now][j]);
      }
    }
  }
  for(int i=1;i<=n;i++){
    printf("%d\n",par[i]);
  }
  return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
const int numP = 3;
using namespace std;
int main() {
    queue<int> p_cards[numP];
    for(int i = 0; i < numP; i++) {
        string s; cin >> s;
        for(char &ch : s) {
            p_cards[i].push(ch - 'a');
        }
    }

    int ans = 0;
    for(int prev = p_cards[ans].front(); !p_cards[ans].empty(); ans = prev, prev = p_cards[ans].front()) {
        p_cards[ans].pop();
    }
    cout << char (ans + 'A');
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s, t;
  int score[2]{};
  for (int i{}; i < n; ++i) {
    cin >> s >> t;
    if (s == t) {
      score[0]++, score[1]++;
    } else if (s > t) {
      score[0] += 3;
    } else {
      score[1] += 3;
    }
  }

  cout << score[0] << ' ' << score[1] << endl;
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
long long const mod = 1e9+7;
int main(void){
    int n, k;
    cin >> n >> k;
    vector<long long> pls, mns;
    int zr = 0;
    long long ans = 1;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a > 0) pls.push_back(a);
        else if(a < 0) mns.push_back(-a);
        else zr++;
        ans *= (mod+a)%mod;
        ans %= mod;
    }
    if(k == n){
        cout << ans << endl;
        return 0;
    }
    ans = 1;
    sort(pls.begin(), pls.end(), greater<long long>());
    sort(mns.begin(), mns.end(), greater<long long>());

    if(zr + k > n){
        ans = 0;
    }else if(mns.size()+zr == n){
        if(k%2 == 0){
            for(int i=0;i<k;i++){
                ans *= mns[i];
                ans %= mod;
            }
        }else if(zr>0){
            ans = 0;
        }else{
            for(int i=0;i<k;i++){
                ans *= mns[n-1-i];
                ans %= mod;
            }
            ans = mod-ans;
            ans %= mod;
        }
    }else if(pls.size()+mns.size()/2*2 < k){
        ans = 0;
    }else{
        int pi = 0, mi = 0;
        int ps = pls.size();
        int ms = mns.size();
        if(k%2==1){
            ans *= pls[pi++];
            k--;
        }
        for(;k>0;){
            long long pv = -1e18, mv = -1e18;

            if(pi+1 < ps) pv = pls[pi] * pls[pi+1];
            if(mi+1 < ms) mv = mns[mi] * mns[mi+1];
            if(pv > mv){
                ans *= pv%mod;
                ans %= mod;
                pi += 2;
                k -= 2;
            }else{
                ans *= mv%mod;
                ans %= mod;
                mi += 2;
                k -= 2;
            }
            // cout << ans << endl;
        }
    }
    cout << ans << endl;
}


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

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

  vector<int> v(N);
  for (int n = 0; n < N; n++) {
	cin >> v[n];
  }

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

  float cur = v[0];
  for (int i = 1; i < N; i++) {
	cur = (cur + v[i]) / 2;
  }

  cout << cur << endl;




  return 0;
}


Measured memory_bytes: 256
n = int(input())
lst = [ [ int(i) for i in input().split() ] for j in range(n) ]
r = 0
for i in range(n-2):
    if lst[i][0] == lst[i][1]:
        if lst[i+1][0] == lst[i+1][1]:
            if lst[i+2][0] == lst[i+2][1]:
                r = 1
if r == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9208
import java.util.*;
interface Main{
static void main(String[]$) {
Scanner s=new Scanner(System.in);
int m=1000000007,n=s.nextInt(),c=0,i=2*n;long a=1;
String t=s.next();
while(i-->0)if((t.charAt(i)+i&1)!=0)c++;else a=a*c--%m;
while(n>0)a=a*n--%m;
System.out.print(c>0?0:a);}}

Measured memory_bytes: 27732
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll ans = N;
  vector<ll> A(N);
  bool inc = false;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll money = 1000;
  for (int i = 0; i < N - 1; i++) {
    if (A[i] < A[i + 1]) {
      ll start = i;
      ll end = i + 1;
      while (end + 1 < N && A[end] < A[end + 1]) {
        end++;
      }
      ll buy = money / A[start] * A[start];
      ll sale = money / A[start] * A[end];
      money += sale - buy;
      i = end;
    }
  }
  cout << money << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){
        cout << "Yes" << endl;
    }else if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]){
        cout << "Yes" << endl;
    }else if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll int
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
int a[100001]={-1};
int ar[21][21]={0};
int main()
{	
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		a[t]++;
		a[t-1]++;
		a[t+1]++;
	}
	int mx=0;
	for(int i=0;i<=100000;i++)
	{
		mx=max(mx,a[i]);
	}
	cout<<mx;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, m;
	cin >> n >> m;
	int ans = 0;
	ans += m * 1900;
	ans += (n - m) * 100;
	rep(i, m) {
		ans *= 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
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()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N==0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        int[] d = new int[102];
        for(int i=0; i<=101; i++){
            d[i]=i;
        }
        
        for(int i = 0; i<n;i++) {
        	p[i] = sc.nextInt();
        	d[p[i]]=-1;
        }
        
        
        
        
        int min = 99999;
        int ans = 0;
        if(n==0) ans = x;
        for(int i=0; i<=101; i++){
            if(d[i] != -1) {
            	if(Math.abs(i-x) < min ) {
            		ans = i;
            		min = Math.abs(i-x);
            	}
            }
            
        }
        
        
        System.out.print(ans);
        
	}
}

Measured memory_bytes: 36124
#include<cstdio>
const int mod=1000000007;
int N,A,f[5010][5010][2],fac[10000010],ifac[10000010];
long long C(int n,int m){return m<0||m>n?0:1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
long long inv(int a,int p=mod){return a==1?1:(1+p*(a-inv(p%a,a)))/a%p;}
int main(){
	scanf("%d%d",&N,&A);
	for(int i=*fac=1;i<=N;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N]=inv(fac[N]);
	for(int i=N;i;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	for(int i=A;i>=0;i--){
		for(int j=i;j>=0;j--){
			f[i][j][0]=(C(N-A+i-j-1,i-1)*(i<A?fac[A-i-1]:1)+f[i+1][j+1][0]+f[i+1][j][1]*(A-i-1ll))%mod;
			f[i][j][1]=(f[i+1][j][0]+f[i+1][j][1]*(A-i-1ll))%mod;
		}
	}
	int s=***f*1ll*fac[N-A]%mod;
	printf("%d\n",s);
}

Measured memory_bytes: 197984
//
//  main.cpp

#include <iostream>
using namespace std;
using ll = long long;

ll max(ll x,ll y){
	if(x > y){
		return x;
	}else{
		return y;
	}
}

int main(){	
	int N,M;
	cin >> N >> M;
	ll weather[1001];
	ll dist[1001];//??????i-1??????i?????§????????¢
	
	for(int i=0;i<N;i++){
		cin >> dist[i];
	}
	for(int i=0;i<M;i++){
		cin >> weather[i];
	}
	
	ll dp[1002][1002];//i??\????????????j????????????????????´???dp[i][j]
	for(int i=0;i<1002;i++){
		for(int j=0;j<1002;j++){
			dp[i][j] = 10000000000;
		}
	}
	dp[0][0] = 0;
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++){
			if(dp[i][j] == 10000000000)continue;
//			if(dp[i+1][j] == 0)
			dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
			dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j] + dist[j]*weather[i]);
		}
	}
	
	ll answer = 10000000000;
	for(int i=0;i<=M;i++){
		answer = min(dp[i][N],answer);
	}
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 10940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int q;
    cin >> q;

    for (int _ = 0; _ < q; _++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;

        if (abs(c - a) > abs(d - b)) swap(a, b), swap(c, d);
        if (b > d) swap(a, c), swap(b, d);

        //右上か右下へ進む
        //柱無視して(a, b)から(a, d)まで右へ進んで当たった最大の柱はどれか
        //bからdになる途中で、aが1な位が1になるか

        ll s = 1;
        ll i, l = 0;
        for (int k = 0; k < 30; k++) {
            if (a / s == c / s && a / s % 3 == 1) {
                ll t = b % (s * 3);
                if (t >= s) t -= s * 3;
                if (t + (d - b) >= s * 2) {
                    i = a / s * s;
                    l = s;
                }
            }
            s *= 3;
        }
        
            //cout << i << ' ' << l << endl;
            //cout << a << ' ' << b << ' ' << c << ' ' << d << endl;
        ll r;
        if (l == 0) {
            r = abs(c - a) + abs(d - b);
        } else {
            r = min((a - i + 1) + (c - i + 1), (i + l - a) + (i + l - c)) + abs(d - b);
        }

        cout << r << '\n';
    }

    return 0;
}

Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Tetromino Tiling
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 7;

/* typedef */

enum { T_I, T_O, T_T, T_J, T_L, T_S, T_Z };

typedef long long ll;

/* global variables */

ll as[N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++) cin >> as[i];

  ll sum = (as[T_I] & ~1LL) + as[T_O] + (as[T_J] & ~1LL) + (as[T_L] & ~1LL);
  ll r  = (as[T_I] & 1) + (as[T_J] & 1) + (as[T_L] & 1);
  if (r == 3) sum += 3;
  else if (r == 2 && as[T_I] > 0 && as[T_J] > 0 && as[T_L] > 0)
    sum += 3 - 2;

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 256
import sys
import math

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7


# ===CODE===


class Combination:
    def __init__(self, mod):
        self.mod = mod
        self.fact = [1] * (2 * 10 ** 6 + 1)
        for i in range(1, 2 * 10 ** 6 + 1):
            self.fact[i] = i * self.fact[i - 1] % self.mod

    def nCr(self, n, k):
        a = self.fact[n] % self.mod
        b = (self.fact[k] * self.fact[n - k]) % self.mod
        c = pow(b, self.mod - 2, self.mod)
        return a * c % self.mod


x, y = map(int, input().split())

if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
    print(0)
    exit(0)

yoko = (2 * x - y) // 3
tate = (2 * y - x) // 3

if yoko < 0 or tate < 0:
    print(0)
    exit(0)

comb = Combination(MOD)
print(comb.nCr(yoko + tate, yoko))


Measured memory_bytes: 82164
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
#include <iostream>

const int MAX_N = 2 * 100000, MAX_A = 1000000;
int N, A[MAX_N], A_MAX = 0;
bool dp[MAX_A+1], found[MAX_A+1];

int solve() {
	std::sort(A, A+N);
  std::fill(dp, dp + A_MAX + 1, true);
  std::fill(found, found + A_MAX + 1, false);
	dp[0] = false;

	// for (int i=0; i<N; i++) {
	// 	printf("%d ", A[i]);
	// }

	for (int i=0; i<N; i++) {
		int X = A[i];
    if (dp[X]) {
			if (found[X]) {
				dp[X] = false;
			} else {
				found[X] = true;
				for (int j=2; X * j <= A_MAX; j++) {
        	dp[X * j] = false;
      	}
			}
    }
	}
  int cnt = 0;
  for (int i=0; i<N; i++) {
    if (dp[A[i]]) {
			// printf("%d ", A[i]);
			cnt++;
		}	
	}
	return cnt;
}

int main() {
	scanf("%d", &N);
	for (int i=0; i<N; i++) {
		scanf("%d", &A[i]);
    A_MAX = std::max(A_MAX, A[i]);
  }
	printf("\n%d", 	solve());
	return 0;
}

Measured memory_bytes: 5832
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}
 
using namespace std;

int dp[45][500][500];
void solve(){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  const int infty=1e5;
  rep(i,45){
    rep(j,500){
      rep(k,500)dp[i][j][k]=infty;
    }
  }
  dp[0][0][0]=0;
  vector<int>a(n),b(n),c(n);
  rep(i,n)cin>>a[i]>>b[i]>>c[i];
  rep(i,n){
    rep(j,401){
      rep(k,401){
        if(j-a[i]>=0&&k-b[i]>=0)chmin(dp[i+1][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
        chmin(dp[i+1][j][k],dp[i][j][k]);
      }
    }
  }
  int ans=infty;
  for(int i=1;;++i){
    if(ma*i>400||mb*i>400)break;
    chmin(ans,dp[n][ma*i][mb*i]);
  }
  if(ans==infty)cout<<-1;
  else cout<<ans;
}

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


Measured memory_bytes: 44288
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, m, i, j, k, p, last;
	string s;
	cin >> n >> m >> s;

	vector<int> dp(n + 1, -1);
	vector<bool> reached(n + 1, false);
	last = -1;
	p = n - 1;
	reached[n] = true;
	for (i = n; i >= 1; i--) {
		if (s[i] == '1') continue;

		while ((p >= i - m) && (p >= 0)) {
			if (s[p] == '0') last = p;
			p--;
		}

		dp[i] = last;
		if ((last != -1) && (reached[i])) reached[last] = true;
	}

	if (!reached[0]) cout << "-1\n";
	else {
		vector<int> ans;
		ans.push_back(n);
		p = n;
		while (dp[p] != -1) {
			p = dp[p];
			ans.push_back(p);
		}
		reverse(ans.begin(), ans.end());
		for (i = 1; i < ans.size(); i++) cout << ans[i] - ans[i - 1] << " ";
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 1468
N = int(input())

ans = []
for n in range(1, int(N ** 0.5) + 1):
    if (N - 1) % n == 0:
        ans.append(n)
        ans.append((N - 1) // n)

for k in range(2, int(N ** 0.5) + 1):
    if N % k != 0:
        continue

    x = N
    while x % k == 0:
        x //= k

    if x % k == 1:
        ans.append(k)

print(len(set(ans)))


Measured memory_bytes: 3060
let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let M = input[1]
let X = input[2]

struct Book {
    var price: Int
    var contents: [Int]
}

var books = [Book]()

for _ in 0 ..< N {
    let book = readLine()!.split(separator: " ").map { Int($0)! }
    books.append(Book(price: book[0], contents: Array(book[1 ... M])))
}

func getBestPrice(_ listToBuy: [Bool] = []) -> Int? {
    guard listToBuy.count < N else {
        if getSumOfComprehension(listToBuy).first(where: { $0 < X }) == nil {
            return getSumOfPrice(listToBuy)
        } else {
            return nil
        }
    }

    switch (getBestPrice(listToBuy + [true]), getBestPrice(listToBuy + [false])) {
    case (.some(let t), .some(let f)):
        return min(t, f)
    case (.some(let t), .none):
        return t
    case (.none, .some(let f)):
        return f
    case (.none, .none):
        return nil
    }
}

func getSumOfPrice(_ listToBuy: [Bool]) -> Int {
    var result = 0
    for i in 0 ..< N {
        guard listToBuy[i] else { continue }
        result += books[i].price
    }
    return result
}

func getSumOfComprehension(_ listToBuy: [Bool]) -> [Int] {
    var result = Array(repeating: 0, count: M)
    for i in 0 ..< N {
        guard listToBuy[i] else { continue }
        for j in 0 ..< M {
            result[j] += books[i].contents[j]
        }
    }
    return result
}

print(getBestPrice() ?? "-1")


Measured memory_bytes: 8276
s1="keyence"
s=input()
k=-1
for i in range(len(s)):
    if s[i]!=s1[i]:
        k=i
        break
if k==-1:
    print("YES")
else:
    if s[:k]+s[len(s)-7+k:]==s1:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,ans=0,a;
    cin >> n ;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> a;
        v[i]=a;
    }
    sort(v.begin(), v.end());
    a=1;
    for(int i=1;i<n;i++){
        if(v[i]==v[i-1]){
            a++;
        }
        else{
            if(a%2==1){
                ans++;
            }
            a=1;
        }
    }
    if(a%2==1){
                ans++;
            }
    if(n==1){
        cout << 1;
    }
    else{
        cout << ans;
    }
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m,i,j;
	cin>>n>>m;
	int a[55]={},p,q;
	FOR(i,0,m){
		cin>>p>>q;
		a[p]++;
		a[q]++;
	}
	FOR(i,1,n+1){
		cout<<a[i]<<endl;
	}
    return 0;
}


Measured memory_bytes: 256