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

int n, idx;
vector<string> s;

int calc(int dep) {
  if (isdigit(s[idx][dep])) {
    return s[idx++][dep] - '0';
  } else {
    char op = s[idx++][dep];
    int res = (op == '*');
    while (s[idx].length() > dep + 1) {
      res = (op == '*') ? res * calc(dep + 1) : res + calc(dep + 1);
    }
    return res;
  }
}

int main() {
  while (cin >> n, n) {
    idx = 0;
    s = vector<string>(n + 1);
    for (int i = 0; i < n; ++i) cin >> s[i];
    s[n] = "";
    cout << calc(0) << endl;
  }
  return 0;
}



Measured memory_bytes: 3164
import java.util.*;import static java.lang.System.*;class Main{public static void main(String[] a){Scanner s=new Scanner(System.in);int w=0;int x=0;int y=0;int z=0;for(int i=s.nextInt();i>0;i--){String b=s.next();if(b.equals("AC"))w++;if(b.equals("WA"))x++;if(b.equals("TLE"))y++;if(b.equals("RE"))z++;}out.println("AC x "+w);out.println("WA x "+x);out.println("TLE x "+y);out.println("RE x "+z);}}

Measured memory_bytes: 58516
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll a[4444];
ll cnt[2222];
ll memo[2222];
signed main() {
	ll n, k, ans = 0;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j])memo[a[i]]++;
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (a[i] > a[j])cnt[a[i]]++;
		}
	}
	rep(i, 2001) {
		ans += (((memo[i] % inf) * (k % inf)) % inf + ((cnt[i] % inf) * (((k - 1)* k / 2) % inf)) %inf);
	}
	cout << ans % inf << endl;
	ggr
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int K;
    int int_arr[32] = {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};
  	scanf("%d", &K);
	printf("%d", int_arr[K-1]);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
using namespace std;
int main()
{
	int k,x;
	scanf("%d%d",&k,&x);
	for(int i=-1000000;i<=1000000;i++)
		if(x-k<i&&i<x+k)
			printf("%d ",i);
	printf("\n");
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rr register
const int N=200010,INF=0x3f3f3f3f;
int a[N];
int n,K;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	K=read(),n=read();
	for(rr int i=1;i<=n;++i){
		a[i]=read();
	}
	if(n==1){
		printf("0");
		return 0;
	}
	int ans=1e9;
	for(rr int i=1;i<=n;++i){
		int reta=0,retb=0;

		if(i<n){
			reta=a[i];			
			reta+=K-a[i+1];	
		}else{
			reta=a[i]-a[1];
		}

		if(i>1){
			retb=K-a[i];			
			retb+=a[i-1];
		}else{
			retb=a[n]-a[i];
		}
		ans=std::min(ans,reta);
		ans=std::min(ans,retb);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1024
LIM = 50

graph =[[False  for _  in range(LIM)] for _ in range(LIM)]
visited = [False  for _  in range(LIM)]
bridges = []


def search(num):
    visited[num] = True
    for i, temp in enumerate(graph[num]):
        if not temp:  # つながってなかったら
            continue
        if visited[i]:  # 訪問済みならx
            continue
        search(i)


def do():
    ans = 0
    N ,M = list(map(int,input().split(" ")))
    for _ in range(M):
        a,b = list(map(int,input().split(" ")))
        a -= 1
        b -= 1

        bridges.append([a,b])
        graph[a][b] =  graph[b][a] = True
    for bridge in bridges: #M番目を落とす
        graph[bridge[0]][bridge[1]] = graph[bridge[1]][bridge[0]] = False
        for j in range(LIM):
            visited[j] = False
        search(0) #0から始めて良い∵連結グラフなので
        flag = False

        for i in range(N):
            if visited[i] == False:
                flag = True
        if flag:
            ans +=1
        graph[bridge[0]][bridge[1]] = graph[bridge[1]][bridge[0]] = True
    print(ans)





if __name__ == "__main__":
    do()

Measured memory_bytes: 41324
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int N;
vector<vector< pair<int, int> > > A;
int ans = 0;

int dfs(string S){
    //cout << S << endl;
    if(S.size() == N){
        vector<int> T, F;
        for(int i = 0; i < S.size(); i++){
            if(S[i] == '0') F.push_back(i+1);
            else T.push_back(i+1);
        }
        int ANS[N]; for(int i = 0; i < N; i++) ANS[i] = -1;

        for(int i = 0; i < N; i++){

            //cout << "   " << S[i] << " " << A[i].size() << endl;

            for(int j = 0; j < A[i].size(); j++){
                //cout << "y" << endl;
                if(S[i] == '1'){
                    int x = A[i][j].first-1;
                    int y = A[i][j].second;
                    if(ANS[x] == -1) ANS[x] = y;
                    else if(ANS[x] != y) return 0;
                }
                //else cout << "n" << endl;

            }
        }
        for(int i = 0; i < N; i++){
            if(ANS[i] == -1) continue;
            else if(ANS[i] != S[i]-48) return 0;
        }

        //cout << "ANS ";
        //for(int i = 0; i < N; i++) cout << ANS[i];
        //cout << "   ";
        if(ans < T.size()) ans = T.size();
        //ans = max(ans, T.size());
        //cout << ans << endl;
        return 0;
        

    }
    else{
        dfs(S+'0');
        dfs(S+'1');
    }
    return 0;
}



int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int AN; cin >> AN;
        vector<pair<int, int>> X;
        for(int j = 0; j < AN; j++){
            int x, y; cin >> x >> y;
            X.push_back(make_pair(x, y));
        }
        A.push_back(X);
    }
    dfs("");
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String[] strs = str.split("");
		int num = 0;
		for(int i = 0; i < strs.length; i++) {
			if(strs[i].equals("+")){
				num += 1;
			} else {
				num -= 1;
			}
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char c;
	int w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	int ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
int n,m;
int o[100005];
int oo(int x)
{
	return o[x]==x?x:o[x]=oo(o[x]);
}
int fa[100005];
int s[100005];//0相等，1不同
int find(int x)
{
	if(fa[x]==x)return x;
	int a=fa[x];
	fa[x]=find(fa[x]);
	s[x]=s[x]^s[a];
	return fa[x];
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)o[i]=i,fa[i]=i,s[i]=0;
	m=read();
	for(int i=1;i<=m;i++)
	{
		int c;
//		while((c=getchar())!='S'&&(c!='D'))c=getchar();
		int a,b;
		a=read();
		b=read();
		c=read();
		o[oo(a)]=oo(b);
		if(!(c&1))
		{
			if(find(a)==find(b))
			{
				if(s[a]!=s[b])
				{
					puts("0");
					return 0;
				}
			}
			else 
			{
				s[fa[b]]=s[b];
				fa[fa[b]]=a;
			}
		}
		else 
		{
			find(a);
			find(b);
//			cout<<a<<" "<<b<<' '<<fa[a]<<" "<<fa[b]<<" "<<s[a]<<" "<<s[b]<<endl;
			if(find(a)==find(b))
			{
				if(s[a]==s[b])
				{
					puts("0");
					return 0;
				}
			}
			else 
			{
				s[fa[b]]=s[b]^1;
				fa[fa[b]]=a;
			}
			find(a);
			find(b);
//			cout<<a<<" "<<b<<' '<<fa[a]<<" "<<fa[b]<<" "<<s[a]<<" "<<s[b]<<endl;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(oo(i)==i)
		{
			ans++;
		}
	}
//	long long res=1;
//	while(ans--)res*=2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5552
import itertools
n = int(input())
towns = [0] * n
for i in range(n):
    x,y = map(int,input().split())
    towns[i] = [x,y]

perm_towns = list(itertools.permutations(towns))
sum_length = 0
for i in range(len(perm_towns)):
    for j in range(n-1):
        length = ((perm_towns[i][j][0]-perm_towns[i][j+1][0]) **2 + (perm_towns[i][j][1] - perm_towns[i][j+1][1]) **2) **0.5
        sum_length += length 

ans = sum_length / (len(perm_towns))
print(ans)

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

using namespace std;

char s[100010];
int N,cnt = 0;
char ot[100010];
int v[100010];

int main()
{
	scanf("%s",s+1);
	N = strlen(s+1);
	int now = 0;
	for (int i=1;i<=N;i++)
	{
		if (s[i] != 'x')
		{
			ot[++cnt] = s[i];
			v[cnt] = now;
			now = 0;
		}
		else
		{
			now++;
		}
	}
	for (int i=1;i<=cnt;i++)
	if (ot[i] != ot[cnt+1-i])
		return 0*puts("-1");
	v[++cnt] = now;
	int ans = 0;
	for (int i=1;i<=cnt/2;i++)
	if (v[i] != v[cnt+1-i])
		ans += abs(v[i] - v[cnt+1-i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 768
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String n = sc.next();
			long k = sc.nextLong();
			int onecount = 0;
			char c = 0;
			for(int i = 0; i < n.length(); i++){
				if(n.charAt(i) == '1'){
					onecount++;
				}
				else{
					c = n.charAt(i);
					break;
				}
			}
			if(onecount >= k){
				System.out.println(1);
			}
			else{
				System.out.println(c);
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	for(int i = 1; i <= 9; i++){
		if(n % i == 0 && n / i >= 1 && n / i <= 9){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    const int mxn = 1e6;
    bitset<mxn> isComp;
    vector<ll> primes;
    for(int i = 2; i < mxn; i++) {
        if( isComp[i] ) continue;
        primes.push_back(i);
        for(int j = i + i; j < mxn; isComp[j] = 1, j += i);
    }
    int n, id = 0;
    cin >> n;
    vector<int> a(n);
    map<ll, ll> LCM, F[n];
    for(auto& ai : a) {
        cin >> ai;
        int x = ai;
        for(auto p : primes) {
            if( p * p > x ) break;
            if( x % p ) continue;
            ll cnt = 0;
            for(; x > 0 and x % p == 0; cnt++, x /= p);
            LCM[p] = max(LCM[p], cnt);
            F[id][p] = cnt;
        }
        if( x > 1 ) {
            LCM[x] = max(LCM[x], 1LL);
            F[id][x] = 1;
        }
        id++;
    }
    const ll mod = 1e9 + 7;
    ll lcm = 1;
    for(auto p : LCM) {
        for(int i = 0; i < p.second; i++) {
            lcm = (lcm * p.first) % mod;
        }
    }
    //cout << lcm << "\n";
    ll res = 0;
    auto bigMod = [](ll b, ll p, ll m) {
        ll x = 1LL;
        for(; p > 0; p /= 2) {
            if( p & 1 ) x = (x * b) % m;
            b = (b * b) % m;
        }
        return x;
    };
    for(int i = 0; i < n; i++) {
        ll tmp = lcm;
        for(auto p : F[i]) {
            tmp = (tmp * bigMod( bigMod(p.first, p.second, mod), mod - 2, mod )) % mod;
        }
        res = (res + tmp) % mod;
    }
    cout << res << "\n";
}

Measured memory_bytes: 4596
#include<stdio.h>

int main()
{
	for(int i = 1; i < 10; i++ )
	{
		for(int j = 1; j < 10; j++)
		{
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
} 
 


Measured memory_bytes: 2708
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for(int i=0;i<n;i++)par[i]=i;
    }

    int root(int x){
        if(par[x]==x)return x;
        return par[x] = root(par[x]);
    }

    void unite(int x,int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return ;
        par[rx]=ry;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx==ry;
    }
};
signed main () {
    SCANF(N);SCANF(M);
    UnionFind tree(N);
    REP(i,M){
        int a,b,c;scanf("%d %d %d",&a,&b,&c);
        if(a){
            if(tree.same(b,c)){
                printf("1\n");
            } else {
                printf("0\n");
            }
        } else {
            tree.unite(b,c);
        }
    }
}


Measured memory_bytes: 3248
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A[] = new long[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
        sc.close();
        if (posneg(A) % 2 == 0){
            for(int l=0;l<N;l++){
                A[l] = Math.abs(A[l]);
            }
            System.out.println(Arrays.stream(A).sum());
        }
        else{
            long pin = 1000000000;
            for(int j=0;j<N;j++){
                if (Math.abs(A[j]) <= pin){
                    pin = (long)Math.abs(A[j]);
                }
            }
            for(int k=0;k<N;k++){
                A[k] = Math.abs(A[k]);
            }
            System.out.println((long)Arrays.stream(A).sum()-2*pin);
        }
    }
    public static int posneg(long P[]){
        int negcnt = 0;
        for(int i=0;i<P.length;i++){
            if (P[i] < 0){
                negcnt += 1;
            }
        }
        return negcnt;
    }
}

Measured memory_bytes: 52388
#include<stdio.h>
int main()
{
	int r;
	scanf("%d",&r);
	if(1200>r){
		printf("ABC\n");
	}
	else if(2800>r){
		printf("ARC\n");
	}
	else{
		printf("AGC\n");
	}
	return 0;
}

Measured memory_bytes: 1632
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::*;
 
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        mut k: usize,
    }
    
    let mut ans : isize = 0;
  
  	if k > a {
      	ans += a as isize;
      	k -= a;
  	} else {
      	ans += k as isize;
      	k = 0;
  	}
  
  	if k > b {
      	k -= b;
  	} else {
      	k = 0;
  	}
  
  	if k > c {
      	ans -= c as isize;
      	k -= c;
  	} else {
      	ans -= k as isize;
      	k = 0;
  	}
  	
    println!("{}", ans);
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b,d,e,f;
    cin>>t;
    for(int i=1;i>0;i++)
    {
        a=i*1000;
        if(a>=t)
            break;
    }
    cout<<a-t<<endl;
}


Measured memory_bytes: 3620
<?php
$g = [];
fscanf(STDIN, "%d %d", $H, $W);
for($i = 0; $i < $H; $i++){
      $in = fgets(STDIN);
      for($j = 0; $j < $W; $j++){
            $g[$i][$j] = $in[$j];
      }
}
$dx = [-1, 1, 0, 0];
$dy = [0, 0, -1, 1];
$ans = true;
for($i = 0; $i < $H; $i++){
for($j = 0; $j < $W; $j++){
      if($g[$i][$j] == '#'){
            $found = false;
            for($k = 0; $k < 4; $k++){
                  $j2 = $j + $dx[$k];
                  $i2 = $i + $dy[$k];
                  if($i2 >= 0 && $j2 >= 0 && $i2 < $H && $j2 < $W && $g[$i2][$j2] == '#'){
                        $found = true;
                  }
            }
            if(!$found) $ans = false;
      }
}
}
echo $ans ? "Yes" : "No";

Measured memory_bytes: 4728
#include<stdio.h>
#define SIZE 1000


typedef unsigned long long int lui;

lui Euclid(lui A, lui B){
    if(B == 0){
        return A;
    }else{
        return Euclid(B, A%B);
    }
}

int main(void){
    lui A = 0, B = 0;
    lui p;
    lui d = 1;
    lui cnt = 1;
    lui i = 1, j = 0;
    int flg = 1;

    scanf("%llu %llu", &A, &B);

    p = Euclid(A, B);

    for(i = 2; i*i < p; i++){
        if(p%i == 0){
            cnt++;
            while(p%i == 0){
                p/=i;
            }
        }
    }

    if(p != 1){
        cnt++;
    }

    printf("%llu", cnt);

    return 0;
}

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

int n;
char s[] = {'p', 'p', 'h', 'b', 'h', 'h', 'p', 'h', 'p', 'h'};

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	int t = n % 10;
	cout << s[t] << "on" << endl;
	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

static const int N=100;

int main()
{
  int M[N][N];
  int i,j,u,n,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j]=0;
	}
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&u,&k);
      u--;
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  v--;
	  M[u][v]=1;
	}
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(j) printf(" ");
	  printf("%d",M[i][j]);
	}
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>

int main(void)
{
	int m[10000],f[10000],r[10000],i,n;
	
	i=1;
	
	scanf("%d %d %d",&m[i],&f[i],&r[i]);
	
	
	while(m[i]!=-1 || f[i]!=-1 || r[i]!=-1){
		i++;
		scanf("%d %d %d",&m[i],&f[i],&r[i]);
	}
	
	n=i-1;
	
	for(i=1;i<=n;i++){
		if(m[i]==-1 || f[i]==-1){
			printf("F\n");
		}
		else{
			if(m[i]+f[i]>=80){
				printf("A\n");
			}
			if(m[i]+f[i]>=65 && m[i]+f[i]<80){
				printf("B\n");
			}
			if(m[i]+f[i]>=50 && m[i]+f[i]<65){
				printf("C\n");
			}
			if(m[i]+f[i]>=30 && m[i]+f[i]<50){
				if(r[i]>=50){
					printf("C\n");
				}
				if(r[i]<50){
					printf("D\n");
				}
			}
			if(m[i]+f[i]<30){
				printf("F\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if (x>=r && x+r<=W && y>=r && y+r<=H){
        printf("Yes\n");
    } else {
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    int ans = 1;
    int j = 2;
    fact();
    int prevM = M;
    while(M > 1) {
        int cnt = 0;
        while(M % j == 0) {
            cnt++;
            M /= j;
        }
        j++;
        if(M < j * j) j = M;
        ans = Mul(ans, H(N, cnt));
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  
  int N, A, B, C, sum;
  cin >> N;
  C = 100000000;
  sum = 0;
  
  for (int i = 0; i < 9; i++) {
      
      if (i == 0) {
          A = N / C;
          B = N % C;
          sum += A;
      }
      else if (i >= 1) {
          A = B / C;
          B = B % C;
          sum += A;
      }
      
      
      if (C == 1) {
          break;
      }
      else {
          C /= 10;
      }
      
  }
  
  if (N % sum == 0) {
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
h = 0
(0...(n-1)).each{|i|
   if(a[i] > a[i+1])
    h += a[i] - a[i+1]
    a[i+1]=a[i]
  end
}
puts h


Measured memory_bytes: 30228
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  string a,b,c; ll n; cin >> n >> a >> b >> c; ll cnt = 0;
  
  rep(i,n){
    if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) cnt += 2;
    else if(a[i] == b[i] && b[i] == c[i]) cnt += 0;
    else cnt++;
  }
  
  cout << cnt << endl;
  
}

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

using namespace std;

const int MAX_N = 1e5 + 200;

int n;
struct node
{
    int val, id;
    bool operator<(const node &nd) const { return val < nd.val; }
} nodes[MAX_N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        nodes[i].id = i, scanf("%d", &nodes[i].val);
    sort(nodes + 1, nodes + 1 + n);
    for (int i = 1; i <= n; i++)
        printf("%d ", nodes[i].id);
    return 0;
}

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>
#include <bitset>
#include <set>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
typedef long long int lint;
typedef vector<vector<int> > matrix;

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

void print(matrix& mat) {
	REP(y, 10) {
		REP(x, 10) {
			if (x) cout << " ";
			cout << mat[y][x];
		}
		cout << endl;
	}
}

matrix mk_matrix(int n) {
	matrix mat(n);
	REP(i, n) {
		mat[i] = vector<int>(10, 0);
	}
	return mat;
}

void push(matrix& mat, int y, int x) {
	REP(i, 5) {
		int nx = x + dx[i];
		if (nx < 0 || nx >= 10) continue;
		int ny = y + dy[i];
		if (ny < 0 || ny >= 10) continue;
		mat[ny][nx] ^= 1;
	}
}

void solve(matrix& mat) {
	//?????????????????¨????????????????????????
	REP(i, 1024) {
		matrix mat_tmp = mat;
		matrix pushed = mk_matrix(10);
		int tmp = i;
		REP(j, 10) {
			if (!tmp) break;
			if (tmp & 1) {
				push(mat_tmp, 0, j);
				pushed[0][j] = 1;
				//print(mat_tmp);
			}
			tmp >>= 1;
		}

		FOR(y, 1, 10) {
			REP(x, 10) {
				if (mat_tmp[y - 1][x]) {
					push(mat_tmp, y, x);
					pushed[y][x] = 1;
					//print(mat_tmp);
				}
			}
		}
		//cout << i << endl;
		//print(mat_tmp);
		if (find(mat_tmp[9].begin(), mat_tmp[9].end(), 1) == mat_tmp[9].end()) {
			print(pushed);
			//cout << "solved." << endl;
			return;
		}
	}
}

bool AOJ0131()
{
	matrix mat = mk_matrix(10);
	REP(i, 10) {
		REP(j, 10) {
			cin >> mat[i][j];
		}
	}

	solve(mat);

	return true;
}

int main()
{
	int n;
	cin >> n;
	REP(i, n) AOJ0131();

	return 0;
}

Measured memory_bytes: 3128
class BinaryTree {
  constructor(n) {
    this.nodes = [];
    for (let i = 0; i < n; i++) this.nodes[i] = {id: i + 1, parentId: -1, leftId: -1, rightId: -1}
  }

  get root() { return this.nodes.find(n => n.parentId === -1); }

  find(id) { return this.nodes[id - 1] || {}; }

  getByPostorder() {
    let res = [];
    const postorder = (id) => {
      if (id === -1) return;
      let n = this.find(id);
      postorder(n.leftId);
      postorder(n.rightId);
      res.push(id);
    };
    postorder(this.root.id);
    return res;
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const preOrder = lines.shift().split(' ').map(Number);
  const inOrder = lines.shift().split(' ').map(Number);

  let tree = makeTree(preOrder, inOrder);
  console.log(tree.getByPostorder().join(' '));
})();

function makeTree(preOrder, inOrder) {
  let tree = new BinaryTree(preOrder.length);
  const innerMakeTree = (p, i) => {
    let midId = p[0];
    let midIdx = i.indexOf(midId);
    if (midIdx === -1) return;
    if (midIdx > 0) {
      tree.find(midId).leftId = p[1];
      tree.find(p[1]).parentId = midId;
      innerMakeTree(p.slice(1, midIdx + 1), i.slice(0, midIdx))
    }
    if (midIdx < i.length - 1) {
      tree.find(midId).rightId = p[midIdx + 1];
      tree.find(p[midIdx + 1]).parentId = midId;
      innerMakeTree(p.slice(midIdx + 1), i.slice(midIdx + 1))
    }
  }
  innerMakeTree(preOrder, inOrder);
  return tree;
}



Measured memory_bytes: 15400
/* 168b.c */
#include <stdio.h>

int main(void){
    int k=0;
    char s[1000];
    scanf("%d %s",&k,&s);
    for(int i=k;i<=1000;i++){
        if(s[i]=='\0'&&i==k){
            s[i]='\0';
            printf("%s",s);
            return 0;
        }
        if(i<k+3){
            s[i]='.';
        }else{
            s[i]='\0';    
        }
    }
    printf("%s",s);
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	auto V=vecin(3);
	
	out(*min_element(ALL(V)),*max_element(ALL(V)));
	return 0;
}


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

int n, k, a[100000];
int index, ans;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 1)index = i;
	}

	ans = index / (k - 1) + (n - 1 - index) / (k - 1);
	//cout << ans << endl;
	if ((index % (k - 1)) + (n - 1 - index) % (k - 1) <= (k - 1) && (index % (k - 1)) + (n - 1 - index) % (k - 1) > 0) {
		ans++;
	}
	else if((index % (k - 1)) + (n - 1 - index) % (k - 1) > 0){
		ans += 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    constexpr ll inf = 1e15;
    int n, m, l; cin >> n >> m >> l;
    auto g = make_v(n, n, inf);

    REP(i, m) {
        int a, b, c; cin >> a >> b >> c;
        --a; --b;
        g[a][b] = g[b][a] = c;
    }

    REP(k, n)REP(i, n)REP(j, n) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    }

    auto g2 = make_v(n, n, inf);

    REP(i, n)REP(j, n) {
        if (g[i][j] <= l) {
            g2[i][j] = g2[j][i] = 1;
        }
    }

    REP(k, n)REP(i, n)REP(j, n) {
        g2[i][j] = min(g2[i][j], g2[i][k] + g2[k][j]);
    }

    int q; cin >> q;
    REP(i, q) {
        int s, t; cin >> s >> t;
        --s; --t;

        if (g2[s][t] >= inf) {
            cout << -1 << endl;
        } else {
            cout << g2[s][t] - 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 1000005;
const int MM = 998244353;

int A[MX];
int N;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", A+i);
	ll mn = 2, mx = 2;
	for(int i = N; i >= 1; i--){
		mn = (mn + A[i]-1) / A[i] * A[i];
		if( mn > mx ) return !printf("-1\n");
		mx = mx / A[i] * A[i] + A[i]-1;
	}
	printf("%lld %lld\n", mn, mx);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 

typedef unsigned long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

main()
{
	IOS
	
	int n, s;
	cin >> n >> s;
	
	s /= 1000;
	
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n && i + j <= n; j++)
			if(s - 10 * i - 5 * j >= 0 && s - 10 * i - 5 * j + i + j == n)
			{
				cout << i << ' ' << j << ' ' << s - 10 * i - 5 * j;
				return 0;
			}
	cout << "-1 -1 -1";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k;
    cin>>n>>k;
    int ans=1;
    rep(i,n){
        if(ans*2<=ans+k) ans*=2;
        else ans+=k;
    }
    cout<<ans;
}

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

using namespace std;

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

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

    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i].first >> p[i].second;
    }

    auto max_it = max_element(p.begin(), p.end(), [](const auto& p1, const auto& p2) { return p1.first < p2.first; });

    int ans = max_it->first + max_it->second;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1272
#include <stdio.h>
#include <ctype.h>

int main(int argv, char *argc[]){
    char array[1001];
    int x=0, total=0;
    
    
    for(x=getchar(); !(EOF == x | '0' == x); x=getchar()){
        for(; !('\n'== x); x=getchar()){
            total += x-'0';
        }
        printf("%d\n", total);
        total = 0;
    }
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define P(s)     cout<<(s)<<endl
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	string s;
	cin>>s;
	
	int n=s.size();
	
	vi a(n,0);//ans.
	bool jud=false;//RLの区切りを発見.
	int p;//RLの区切りのポイント.
	vi cnt(2,0);
	REP(i,n){
		if(i==n-1){
			if(!jud) p=i;
			cnt[i%2]++;
			a[p-1]=cnt[(p-1)%2];
			a[p]=cnt[p%2];
			break;
		}
		
		if(jud){
			if(s[i]=='R'){
				a[p-1]=cnt[(p-1)%2];
				a[p]=cnt[p%2];
				jud=false;
				fill(ALL(cnt),0);
				cnt[i%2]++;
			}else{
				cnt[i%2]++;
			}
		}else{
			if(s[i]=='R'){
				cnt[i%2]++;
			}else{
				jud=true;
				p=i;
				cnt[i%2]++;
			}
		}
	}
	
	REP(i,n) P(a[i]);
}//解説参考.

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
using namespace std;

int main(){
	char str[32];
	int n, count = 0;

	cin >> str;
	n = strlen(str);

	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			if(str[i] == str[j]){
				++count;
			}
		}
	}

	if(count > 0){
		cout << "no\n";
	}
	else{
		cout << "yes\n";
	}

	return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
V g[inf];//隣接リストの作成
V dist(inf,-1);//スタート地点から何ステップで到達できるかを格納する
            //bool visitedの役割も果たす
bool flag=false;
void bfs(int);
int n;
int main(){
    int m;cin>>n>>m;
    rep(i,m){
        int a,b;cin>>a>>b;
        a--;b--;//0-index;
        //無向グラフ
        g[a].PB(b);
        g[b].PB(a);
    }
    //rep(i,n)dist[i]=-1;//全頂点を未訪問に
    //dist[0]=0;//初期条件
    bfs(0);
    cout<<(flag?"POSSIBLE":"IMPOSSIBLE")<<endl;
}
void bfs(int s){//頂点sに到達(頂点0を想定)
    Q que;
    que.push(s);
    dist[s]=0;//start地点のdistanceはゼロ
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(int nv=0;nv<(int)g[v].size();nv++){
            if(dist[g[v][nv]]!=-1)continue;//探索済みはスルー
            dist[g[v][nv]]=dist[v]+1;
            que.push(g[v][nv]);
        }
    }
    /*rep(i,n){
        printf("dist[%d]=%d\n",i,dist[i]);
    }*/
    if(dist[n-1]==2)flag=true;
}

Measured memory_bytes: 35056
#include <iostream>
using namespace std;
int main(void){
    unsigned int t;
    int h,m,s;
    cin>>t;
    
    h=t/3600;
    t=t%3600;
    
    m=t/60;
    t=t%60;
    
    s=t;
    
    cout<<h<<":"<<m<<":"<<s;
    cout << endl;
}



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

int main()
{
  int h, n;
  cin >> h >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) h -= a[i];
  if(h <= 0) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 640
s = input()
n = len(s)-1
ans = 0
for i in range(1<<n):
	sum = 0
	t = 0
	for j in range(n):
		if(i>>j & 1):
			sum += int(s[t:j+1])
			t = j+1
	sum += int(s[t:n+1])
	ans += sum
print(ans)

Measured memory_bytes: 3060
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int A[3];
    REP(i, 3) cin >> A[i];
    sort(A, A + 3);
    cout << A[0] + A[1] << endl;


    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	int ans=0,ma=h[0];
	for (int i = 0; i < n; ++i)
	{
		if (ma<=h[i])
		{
			++ans;
			ma=h[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 1e5 + 5;

int a[N];
int n;

int main() {
    read(n);
    for(register int i = 1; i <= n; i++) read(a[i]);
    --a[1];
    for(register int i = 2; i <= n; i++) {
        if(a[i] < a[i - 1]) {
            printf("No\n");
            return 0;
        }
        if(a[i] - 1 >= a[i - 1]) --a[i];
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long sum = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    sum += s[i] - '0';
  }
  if (sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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


def main():
    N = int(input())
    S = input()
    x = 0
    xm = 0
    for i in range(N):
        if S[i] == 'I':
            x+=1
        else :
            x-=1
        if xm < x:
            xm = x
    print(xm)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int dp[1010][10010];

int main(){
  int H,N;
  cin >> H >> N;
  vector<int> a(N);
  vector<int> b(N);
  rep(i,N) cin >> a[i] >> b[i];
  rep(i,N+1) rep(j,H+1) dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,N){
    for(int j=0;j<=H;j++){
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i][min(j+a[i],H)],dp[i][j]+b[i]);
    }
  }
  cout << dp[N][H] << endl;
}

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

int main(){
	int n, m;
	int A[100][100];
	int b[100], c[100] = {0};
	
	cin >> n >> m;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			c[i] += A[i][j] * b[j];
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << c[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    string S, T;
    cin >> S >> T;
    int Ns = S.size();
    int Nt = T.size();
    bool treasure = true;
    if (Ns < Nt) { treasure = false; }
    vector<string> candidate;
    REP(i, Ns - Nt + 1) {
        string tS = S;
        bool ok = true;
        REP(j, Nt) {
            if (tS[i + j] != T[j] && tS[i + j] != '?') {
                ok = false;
                break;
            } else {
                tS[i + j] = T[j];
            }
        }
        if (ok) {
            REP(j, Ns) {
                if (tS[j] == '?') { tS[j] = 'a'; }
            }
            candidate.push_back(tS);
        }
    }
    if (candidate.size() == 0) { treasure = false; }
    else {
        sort(candidate.begin(), candidate.end());
        string ans = candidate[0];
    }
    if (treasure) { cout << candidate[0] << endl; }
    else {
        cout << "UNRESTORABLE" << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Set(a,b) memset(a,b,sizeof(a))
using namespace std;
inline int read()
{
	int x=0;char ch=getchar();int t=1;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	return x*t;
}
const int N=1e5+10;
const int M=2e5+10;
struct edge{int to,next;}a[M];
int head[N];int cnt,n,m,S,T;
inline void add(int u,int v){a[++cnt]=(edge){v,head[u]};head[u]=cnt;return;}
typedef pair<int,int> PA;
int dis[3][N];queue<PA> Q;
void Dij(){const int inf=1e9;
	for(register int i=1;i<=n;++i) dis[0][i]=dis[1][i]=dis[2][i]=inf;dis[0][S]=0;
	Q.push(PA(0,S));
	while(!Q.empty()){
		PA P=Q.front();Q.pop();
		int u=P.second;
		int id=P.first;
		for(int v,i=head[u];i;i=a[i].next) {
			v=a[i].to;
			if(dis[(id+1)%3][v]==inf) dis[(id+1)%3][v]=dis[id][u]+1,Q.push(PA((id+1)%3,v));
		}
	}
	if(dis[0][T]==inf) puts("-1");
	else cout<<dis[0][T]/3<<endl;
}
int main()
{
	register int u,v,w;n=read();m=read();
	for(register int i=1;i<=m;++i){u=read();v=read();add(u,v);}
	S=read();T=read();
	Dij();
}


Measured memory_bytes: 2684
main :: IO ()
main = do
    (_:t:a:hs) <- getParams
    print $ solve t a hs

getParams :: IO [Double]
getParams = map read . words <$> getContents

solve :: Double -> Double -> [Double] -> Int
solve t a hs = snd $ minimum dis
  where
    dis = zip ds [1..]
    ds  = map (abs . subtract a) ts
    ts  = map (temperature t) hs
 
temperature :: Double -> Double -> Double
temperature t h = t - h * 0.006


Measured memory_bytes: 1148
from collections import Counter
H, W = map(int, input().split())

S = ""
for _ in range(H):
    S += input()

# print(S)
character_counter = Counter(S)
# print(character_counter)
g1 = (H % 2) * (W % 2)  # 行と列のどちらかが偶数であれば0
g2 = (W // 2) * (H % 2) + (H // 2) * (W % 2)  # 奇数のときに2つのブロックのペアをもてる
g4 = (H // 2) * (W // 2)
# 
# print(g1*1+g2*2+g4*4)  # この値を使い切る必要がある
# print(g1)
# print(g2)
# print(g4)
# print(character_counter)

character_counter_list = sorted(list(character_counter.values()), reverse=True)
# print(character_counter_list)

# g1を使う
for i in range(len(character_counter_list)):
    if character_counter_list[i] % 2 == 1 and g1 > 0:
        character_counter_list[i] -= 1
        g1 -= 1

# g2を使う
for i in range(len(character_counter_list)):
    if character_counter_list[i] % 4 == 2 and g2 > 0:
        character_counter_list[i] -= 2  # これによってmod4で0になっている
        g2 -= 1

if g2 % 2 == 1:  # g2が奇数個余っていたら終わり
    print("No")
    exit()

# 余ったg2は2つで1個分のg4として使える
g4 += (g2//2)
g2 = 0
# g4を使う
for i in range(len(character_counter_list)):
    if character_counter_list[i] % 4 == 0 and g4 > 0:
        tmp = (character_counter_list[i] // 4)
        character_counter_list[i] -= (4*tmp)  # もし文字の数が8個とかなら、g4を2つ使える
        g4 -= tmp
# print(character_counter_list)
# print(g1)
# print(g2)
# print(g4)

if g1 == 0 and g2 == 0 and g4 == 0 and sum(character_counter_list) == 0:  # 無事に使い切れたらYes
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
def myAnswer(N:int,P:int,A:list) -> int:
   for a in A:
      if(a % 2 == 1):
         return 2**(N - 1)
   return 2**N if( P == 0) else 0

def modelAnswer():
   return
def main():
   N,P = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,P,A[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3060