akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main(){
	int i=0;
	string a[3];
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	string get;
	for(i=0;i<3;i++){
		get=a[i][0];
		if(get[0]=='a')get='A';
		if(get[0]=='b')get='B';
		if(get[0]=='c')get='C';
		if(get[0]=='d')get='D';
		if(get[0]=='e')get='E';
		if(get[0]=='f')get='F';
		if(get[0]=='g')get='G';
		if(get[0]=='h')get='H';
		if(get[0]=='i')get='I';
		if(get[0]=='j')get='J';
		if(get[0]=='k')get='K';
		if(get[0]=='l')get='L';
		if(get[0]=='m')get='M';
		if(get[0]=='n')get='N';
		if(get[0]=='o')get='O';
		if(get[0]=='p')get='P';
		if(get[0]=='q')get='Q';
		if(get[0]=='r')get='R';
		if(get[0]=='s')get='S';
		if(get[0]=='t')get='T';
		if(get[0]=='u')get='U';
		if(get[0]=='v')get='V';
		if(get[0]=='w')get='W';
		if(get[0]=='x')get='X';
		if(get[0]=='y')get='Y';
		if(get[0]=='z')get='Z';
		cout<<get;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll power(ll x, ll y, ll p)
{ll res = 1;x = x % p;while (y > 0){if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
ll modInverse(ll n, ll p)
{return power(n, p-2, p);}
ll nCr(ll n, ll r, ll p)
{if (r==0) return 1;ll fac[n+1];fac[0] = 1;for(ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p;return (fac[n]*modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p;}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll i, j, k, n, m, t, p, temp, flag, x, y, z, count, a, b, c, d;
	cin >> a >> b >> c;
	if(a<=b*c)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


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

int main(){
  int M,D,i=0;
  cin>>M>>D;
  for(int m=4;m<=M;m++)
    for(int d10=2;d10*10<=D;d10++)
      for(int d1=2;d10*10+d1<=D && d1<10;d1++)
        if(m==d1*d10)
          i++;
  cout<<i<<endl;
}

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


void solve(long long N, long long K, std::vector<long long> h){
    long long ans = 0;
    for(int i = 0; i < N; ++i){
        if(h[i] >= K) ans++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 4012
#define ATOZ 26

#include <stdio.h>
#include <string.h>

int main(void)
{
    
    char ss[100]={};
    int i,j,n,k,len,a[100]={},b[26]={};
    
    scanf("%d",&n);
    
    for(i=0;i<ATOZ;i++)b[i]=50;
    
    for(i=0;i<n;i++){
        scanf("%s",ss);
        len = strlen(ss);
        
        for(k=0;k<len;k++){
            a[ss[k]-'a']++;
        }
        for(j=0;j<ATOZ;j++){
            if(a[j]<b[j])b[j]=a[j];
        }
        for(j=0;j<ATOZ;j++)a[j]=0;
    }
    
    for(i=0;i<26;i++){
        for(j=0;j<b[i];j++){
            printf("%c",i+'a');
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
		cout << "Yes" << endl;
	else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			double a,b,c,d;
			a = scan.nextDouble();
			b = scan.nextDouble();
			c = scan.nextDouble();
			d = scan.nextDouble();
			System.out.println(Math.hypot(a-c,b-d));
		}finally{
			if(scan!=null)scan.close();
		}
	}
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      cin >> vec.at(i).at(j);
    }
  }
  vector<vector<char>> answer(H + 2,vector<char>(W + 2));
  
  for(int i = 0;i < H + 2;i++) {
    for(int j = 0;j < W + 2;j++) {
      if(i == 0 || j == 0 || i == H + 1 || j == W + 1) {
        answer.at(i).at(j) = '#';
      }
      else {
        answer.at(i).at(j) = vec.at(i - 1).at(j - 1);
      }
    }
  }
  for(int i = 0;i < H + 2;i++) {
    for(int j = 0;j < W + 2;j++) {
      cout << answer.at(i).at(j);
      if(j == W + 1) {
        cout << endl;
      }
    }
  }
}

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

using namespace std;
using ll = long long;

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

struct UnionFind {
  vector<int> p;
  UnionFind(int n) : p(n, -1) {}

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (-p[x] < -p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
    return true;
  }

  int find(int x) {
    if (p[x] < 0) return x;
    return p[x] = find(p[x]);
  }

  int same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -p[find(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  vector<int> to[n];
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    --x, --y;
    to[x].push_back(y);
    to[y].push_back(x);
    uf.unite(x, y);
  }

  vector<int> g(n, -1);
  int cur = 0;
  rep(i, n) {
    if (g[i] != -1) continue;
    queue<int> q;
    q.push(i);
    g[i] = cur;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (auto v : to[u]) {
        if (g[v] != -1) continue;
        g[v] = cur;
        q.push(v);
      }
    }
    ++cur;
  }

  set<int> s;
  rep(i, n) s.insert(g[i]);
  cout << s.size() << endl;
  return 0;
}


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

class Dice {
public:
    int face[6];

    Dice(int face1, int face2, int face3, int face4, int  face5, int face6) {
        face[0] = face1;
        face[1] = face2;
        face[2] = face3;
        face[3] = face4;
        face[4] = face5;
        face[5] = face6;
    }

    int front() {
        return face[0];
    }

    void move(char c) {
        if (c == 'N') {
            moveFace(1, 2, 6, 5);
        } else if (c == 'S') {
            moveFace(1, 5, 6, 2);
        } else if (c == 'W') {
            moveFace(1, 3, 6, 4);
        } else if (c == 'E') {
            moveFace(1, 4, 6, 3);
        }
    }

    void moveFace(int i1, int i2, int i3, int i4) {
        int tmp = face[i1 - 1];
        face[i1 - 1] = face[i2 - 1];
        face[i2 - 1] = face[i3 - 1];
        face[i3 - 1] = face[i4 - 1];
        face[i4 - 1] = tmp;
    }
};

int main() {
    int face1, face2, face3, face4, face5, face6;
    cin >> face1 >> face2 >> face3 >> face4 >> face5 >> face6;
    Dice d(face1, face2, face3, face4, face5, face6);
    string command;
    cin >> command;

    for (int i = 0; i < command.size(); i++) {
        d.move(command[i]);
    }

    cout << d.front() << endl;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int a[30];
int main()
{
	char c;
	int n,i;
	long long ans=1;
	scanf("%d",&n);
	getchar();
	for(i=1;i<=n;i++)
	{
		scanf("%c",&c);
		a[c-'a']++;
	}
	for(i=0;i<26;i++)
		ans=ans*(a[i]+1)%1000000007;
	printf("%lld",(ans+1000000006)%1000000007);
    return 0;
}

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

int main()
{
    int x,y,n,i,ans=INT_MAX;
    cin>>x>>n;
    vector<int>v(n,0);
    map<int,int>m;
    for(i=0;i<n;i++)
        {
            cin>>v[i];
            m[v[i]]++;
        }
    sort(v.begin(),v.end());
    auto k=find(v.begin(),v.end(),x);
    if(k==v.end())
    {
        cout<<x<<endl;
    }
    else
    {
        int j=x-1;
        i=x+1;
        while(1)
        {
            if(m.find(j)==m.end())
            {
                cout<<j<<endl;
                return 0;
            }
            else if(m.find(i)==m.end())
            {
                cout<<i<<endl;
                return 0;
            }
            j--;
            i++;
        }
    }
}


Measured memory_bytes: 3624
n = int(input())
s = list(input())
st = [["S","S"],["S","W"],["W","W"],["W","S"]]
key = "F"
for i in st:
    ans = i
    a0,a1 = i
    for j in range(1,n):
        #print(a0,a1,s[j])
        if s[j] == "o":
            if a1 == "S":
                if a0 == "S":
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
        else:
            if a1 == "W":
                if a0 == "S":
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
    if ans[0] == ans[n]:
        a0 = ans[n-1]
        a1 = ans[n]
        if s[0] == "o":
            if a1 == "S":
                if a0 == "S":
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
        else:
            if a1 == "W":
                if a0 == "S":
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
        if ans[1] == ans[n+1]:
            key = "T"
            break
if key == "T":
    for i in range(n):
        print(ans[i],end="")
else:
    print(-1)

Measured memory_bytes: 8656
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;


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

  unordered_map<int, int> memo;
  int a;
  for (int i = 0; i < N; i++) {
    a = A[i];
    for (int x = 2; x * x <= a; x++) {
      if (a % x != 0) continue;

      int ex = 0;
      while (a % x == 0) {
        ex++;
        a /= x;
      }

      if (!memo.count(x)) memo[x] = 0;
      if (ex > 0) memo[x]++;
    }
    if (a > 1) {
      if (!memo.count(a)) memo[a] = 0;
      memo[a]++;
    }
  }

  bool flagCanBePairwise = true;
  bool flagCanBeSetwise = true;
  for (auto p : memo) {
    // cout << p.first << " : " << p.second << endl;

    if (p.second >= 2) flagCanBePairwise = false;
    if (p.second == N) flagCanBeSetwise = false;
  }

  if (flagCanBePairwise) cout << "pairwise coprime" << endl;
  else if (flagCanBeSetwise) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;

  return 0;
}


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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int l[n];
	int sum = 0;
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	sort(l,l+n);
	for(int i=1;i<n-1;i++){
		for(int j=0;j<i;j++){
			int itr = lower_bound(l+i+1,l+n,l[i]+l[j]) - l;
          if(itr == i+1){
				continue;
			}
			if(itr == n){
				sum += n - i -1;
			}else{
				sum += itr - i -1;
			}
		}
	}
	// keisan
	cout << sum;
	// syutsuryoku
}

Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let c: u32 = read();
    let x: u32 = read();
    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if i * 500 + j * 100 + k * 50 == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define fir first
#define sec second
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll A, B, C;

int main() {
	cin >> A >> B >> C;
	cout << max((ll)0, C - (A - B)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define _IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll N=3e5+5,mod=1e9+7,inf=1e18;
ll seg[4*N];

void update(ll rt,ll l,ll r,ll id,ll v)
{
    if(l>id||r<id)return;
    if(l==r)
    {
        seg[rt]=max(seg[rt],v);
        return;
    }
    ll md=(l+r)/2;
    update(rt*2,l,md,id,v);
    update(rt*2+1,md+1,r,id,v);
    seg[rt]=max(seg[rt*2],seg[rt*2+1]);
}

ll query(ll rt,ll l,ll r,ll i,ll j)
{
    if(l>j||r<i)return -inf;
    if(l>=i&&r<=j)return seg[rt];
    ll md=(l+r)/2;
    return max(query(rt*2,l,md,i,j),query(rt*2+1,md+1,r,i,j));
}

int main()
{
    _IO;
    ll n,k;cin>>n>>k;
    ll mx=0;
    while(n--)
    {
        ll x;cin>>x;
        ll p=query(1,0,N, max(0LL,x-k), min(N,x+k) );
        update(1,0,N,x,p+1);
        mx=max(mx,p+1);
    }
    cout<<mx<<"\n";

}


Measured memory_bytes: 11848
#include<stdio.h>
#include<string.h>
char a[12];
int main()
{
    int i,j,k;
    scanf("%s",a);
    k=strlen(a);
    if(k<4)
    {
        printf("No\n");
        return 0;
    }
    if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
S = input()
n = len(S)
Max = 0
count = 0
for i in range(n):
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    count += 1
  else:
    Max = max(count,Max)
    count = 0
Max = max(count,Max)
print(Max)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define INF 10000000000000000
#define ll long long

using namespace std;

int main(){
  ll V, E, r;
  cin >> V >> E >> r;
  vector< vector< pair<ll,ll> > > edges(V);
  for(ll i = 0; i < E; i++){
    ll s,t,d;
    cin >> s >> t >> d;
    edges[s].push_back(make_pair(t,d));
  }
  vector<ll> dist(V, INF);
  dist[r] = 0;
  priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > > pq;
  pq.push(make_pair(0,r));

  while(!pq.empty()){
    ll source = pq.top().second;
    pq.pop();
    for(pair<ll,ll> edge: edges[source]){
      if(dist[edge.first] > dist[source] + edge.second){
	dist[edge.first] = dist[source] + edge.second;
	pq.push(make_pair(dist[edge.first], edge.first));
      }
    }
  }

  for(ll i = 0; i < V; i++){
    if(dist[i] == INF){
      cout << "INF" << endl;
    }else{
      cout << dist[i] << endl;
    }
  }


}

Measured memory_bytes: 19376
from heapq import heappop as pop
from heapq import heappush as push
INF = 1000000000000

def bfs(lst, used, que, w, h):
  v, y, x  = pop(que)
  if y > 0 and not used[y - 1][x]:
    push(que, (lst[y - 1][x], y - 1, x))
    used[y - 1][x] = True
  if h > y + 1 and not used[y + 1][x]:
    push(que, (lst[y + 1][x], y + 1, x))
    used[y + 1][x] = True
  if x > 0 and not used[y][x - 1]:
    push(que, (lst[y][x - 1], y, x - 1))
    used[y][x - 1] = True
  if w > x + 1 and not used[y][x + 1]:
    push(que, (lst[y][x + 1], y, x + 1))
    used[y][x + 1] = True
  return v

def make_dic(lst, w, h, x, y):
  que = [(1, y, x)]
  used = [[False] * w for _ in range(h)]
  used[y][x] = True
  dic = [[0, 0]]
  app = dic.append
  Max = 0
  acc = 0

  while que:
    v = bfs(lst, used, que, w, h)
    acc += 1
    if v > Max:
      app([v, acc])
      Max = v
    else:
      dic[-1][1] += 1
  return dic

def solve():
  while True:

    R = int(input())
    if not R:
      break

    w1, h1, x1, y1 = map(int, input().split())
    lst1 = [list(map(int, input().split())) for _ in range(h1)]
  
    w2, h2, x2, y2 = map(int, input().split())
    lst2 = [list(map(int, input().split())) for _ in range(h2)]
  
    dic1 = make_dic(lst1, w1, h1, x1 - 1, y1 - 1)
    dic2 = make_dic(lst2, w2, h2, x2 - 1, y2 - 1)
  
    end1 = len(dic1)
    end2 = len(dic2)
    ind1 = 0
    ind2 = end2 - 1
    ans = INF
  
    while ind1 < end1 and ind2 > 0:
      r1, sum1 = dic1[ind1]
      r2, sum2 = dic2[ind2]
  
      if sum1 + sum2 < R:
        ind1 += 1
        continue
  
      while ind2 > 0 and sum1 + sum2 >= R:
        ind2 -= 1
        r2, sum2 = dic2[ind2]
  
      if ind2 == 0 and sum1 + sum2 >= R:
        rs = r1 + r2
        if rs < ans:
          ans = rs
        break
  
      else:
        if ind2 < end2 - 1:
          ind2 += 1
        r2 = dic2[ind2][0]
        rs = r1 + r2
        if rs < ans:
          ans = rs
  
      ind1 += 1
    print(ans)
 
solve()


Measured memory_bytes: 57608
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 2e5 + 5;
int a[maxn], h[maxn];
ll tree[maxn * 4];

int main() {
    int n;
    scanf("%d", &n);
    REP(i, n) scanf("%d", h + i);
    REP(i, n) scanf("%d", a + i);
    // base: smallest power of 2 that is larger that n
    // [0, n] has n + 1 values
    int base = 1;
    while (base <= n) {
        base *= 2;
    }
    ll ans = 0;
    REP(i, n) {
        ll best = 0;
        int x = base + h[i];
        while (x > 1) {
            if (x & 1) best = max(best, tree[x - 1]);
            x /= 2;
        }
        ans = max(ans, best + a[i]);
        for (int j = base + h[i]; j >= 1; j /= 2) {
            tree[j] = max(tree[j], best + a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, T, A;
    cin >> N >> T >> A;
    int res = 0;
    int cc = 10000000; // 気温差の最大値
    
    for (int i = 1; i <= N; i++) {
        int foo;
        cin >> foo;
        int d = abs((T*1000 - foo*6) - A * 1000);
        if (d < cc) {
            cc = d;
            res = i;
        }
    }
    cout << res << endl;
    return 0;
}

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

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

    int ans = 100;
    while (k > 0) {
        if (a % ans == 0 && b % ans == 0)
            k--;
        ans--;
    }

    cout << ans + 1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int Cars[10];
	int i = 0;
	int Temp;
	
	while(scanf("%d", &Temp) == 1){
		if(Temp == 0){
			i--;
			printf("%d\n",Cars[i]);
		}else{
			Cars[i] = Temp;
			i++;
		}
	}
		
	return 0;
}

Measured memory_bytes: 600
/***********************************************

    Md. Shahid-ul Islam
    Department of CSE, DIU
    fb- facebook.com/shahid.cse46

    CF Handle- ShA_hiD
    CodeChef Handle- shahid885
    Vjudge Handle- shahid109514 & ShA_hiD
    UVa Handle- shahid85

    #Happy_Coding_<3

***********************************************/

#include <bits/stdc++.h>

using namespace std;

/****************** TypeDef *******************/

typedef long long int ll;
typedef long int l;
typedef long double ld;
typedef double dd;
typedef unsigned long long ull;
typedef unsigned int ui;

/**********************************************/

int main()
{
	int a;
	cin >> a;
	int L = a/100;
	int R = a%100;
	if(1 <= L && L <= 12)
	{
		if(1 <= R && R <= 12) cout << "AMBIGUOUS\n";
		else cout << "MMYY\n";
	}

	else
	{
		if(1 <= R && R <= 12) cout << "YYMM\n";
		else cout << "NA\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N ;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  //mってなんぞ？？？
  int m=100;
  //cout<<m%vec.at(0)<<endl;
  //cout<<m%vec.at(1)<<endl;
  //cout<<m%vec.at(2)<<endl;
  //少なくとも、でかい数字をやる必要はない
  //3 4 6 なら、余りは最大でも5までしかでないから(11のとき)
  //一番小さい数字から、一番でかい数字までやればいいと思われる
  //全然違う
  //最大公約数？
  //公倍数は、全部0になるからNG
  //7 46 11 20 11なら、
  //6 45 10 19 10で最大になる
  
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=vec.at(i)-1;
  }
  cout<<sum<<endl;
  /*
  //動的にしてなかった
  //小さいの
  int minVec=vec.at(0);
  for(int i=1;i<N;i++){
    minVec=min( minVec,vec.at(i) );
  }
  //cout<<minVec<<endl;
  
  int maxVec=vec.at(0);
  //でっかいの
  for(int i=1;i<N;i++){
    maxVec=max( minVec,vec.at(i) );
  }
  //cout<<maxVec<<endl;
  
  int maxVec2=maxVec+(maxVec-1);
  //cout<<maxVec2<<endl;
  int maxSum=0;
  int sum;
  for(int i=minVec;i<=maxVec2*5000;i++){
    sum=0;
    //cout<<i<<" ";
    for(int j=0;j<N;j++){
      sum+=i%vec.at(j);
      //cout<<sum;
    }
    //cout<<endl;
    if(maxSum<sum){
      maxSum=sum;
      cout<<i<<endl;
    }
  }
  cout<<maxSum<<endl;*/
}


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

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                               \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define debug_4(x1, x2, x3, x4)                                           \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                       \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                      \
  CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
  (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int n, k;
  cin >> n >> k;
  vector<int> s(1001);
  s[0] = 0;
  rep(i, 1000) s[i+1] = s[i] + i + 1;
  vector<double> pp(n+1);
  pp[0] = 0.;
  rep(i, n) {
    int p;
    cin >> p;
    pp[i+1] = (double)s[p]/p;
  }
  rep(i, n) pp[i+1] += pp[i];
  double ans = 0.;
  REP(i, k, n+1) ans = max(ans, pp[i] - pp[i-k]);
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


string s;

int bfs(int i,string n){
    if(i == 0)
        n = to_string((int)(s[0] - '0'));
    if(i == s.size() - 1){        
        int sum = 0;
        int j = 0;
        string tmp = "";
        for(int j = 0; j <= n.size(); j++){
            if(isdigit(n[j])){
                tmp += n[j];
            }else if(!(isdigit(n[j]))){                
                sum += strtol(tmp.c_str(),nullptr,10);
                tmp.clear();
            }else if(j == n.size() -1){
                tmp += n[j];
                sum += strtol(tmp.c_str(),nullptr,10);
            }
        }   
        return sum;        
    }
    return bfs(i+1,n + s[i+1]) +  bfs(i+1,n + "+" + s[i+1]);
}

signed main(){
cin >> s;
cout << bfs(0,string()) << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  vector<int>vec(n);
  vector<int>ans(n);
  vector<int>show;
  rep(i,n) cin >> vec[i];
  rep(i,n)ans[i]=0;
  for(int i=n-1;0<=i;i--){
    int sum=0;
    int j=i;
    while(j<n){
      sum+=ans[j];
      j+=i+1;
    }
    if(sum%2!=vec[i]){
      ans[i]++;
      show.push_back(i+1);
    }
    else continue;
  }
  cout << show.size() << endl;
  rep(i,show.size()){
    if(i!=0)cout<<" ";
    cout << show[i];
  }
  
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define ff first
#define ss second
#define inf 2000000007
#define pb push_back
#define MAXN 100100
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;

int dp[MAXN];

int32_t main(){
	fastio;
	int n,m;
	cin>>n>>m;
	dp[0]=1;
	int a[m];
	set<int> S;
	for(int i=0;i<m;i++){
		cin>>a[i];
		S.insert(a[i]);
	}
	for(int i=1;i<=n;i++){
		if(S.find(i)!=S.end()){
			dp[i]=-inf;
			continue;
		}
		dp[i]=0;
		if(i>1)dp[i]=max(0LL,dp[i-2]);
		
		dp[i]=(dp[i]+max(dp[i-1],0LL))%MOD;
	
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 6528
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

ans = 1
cnts = [0,0,0]
for i in range(N):
    ans = ans * cnts.count(A[i]) % mod
    for j in range(3):
        if cnts[j] == A[i]:
            cnts[j] += 1
            break
print(ans)


Measured memory_bytes: 16468
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;


int main()
{
  int r, D, x2000;
  cin >> r >> D >> x2000;

  int xi = x2000;
  for(int i=0; i<10; i++)
  {
    int xii;
    xii = r*xi - D;
    cout << xii << endl;
    xi = xii;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import Counter
S = input()
l = [0]
n = 0
for i, s in enumerate(S[::-1]):
    n = (int(s) * pow(10, i, 2019) + n) % 2019
    l.append(n)
ans = 0
c = Counter(l)
for v in c.values():
    ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 76652
import sys
sys.setrecursionlimit(100000)

N,K = map(int, input().split())
MOD = 10**9+7
A = N-K+1

nCr = {}
def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) in nCr:
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in range(K):
  if A >= i+1:
    print(cmb(K-1, i) * cmb(A, i+1) % MOD)
  else:
    print(0)


Measured memory_bytes: 166136
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}


int main(){
  int T;
  cin >> T;
  int n , d;
  rep(i,0,T) {
    cin >> n >> d;
    if(~n & 1) d ^= 127;
    cout << (n - 1) * 127 + d << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define remax(a,b)         a=max(a,b)
#define remin(a,b)         a=min(a,b)
#define bitcount(x)        __builtin_popcountll(x)
#define iceil(n,x)         (((n)-1)/(x)+1)
#define flush              fflush(stdout)
#define pf                 push_front()
#define pob                pop_back()
#define ins                insert
#define mii                map<int,int> 
#define show(x)            for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define show2(x)           for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";
#define test()             int x;cin >> x;while(x--){solve();}
#define test2()            int x;cin >> x;for(int i=1;i<=x;i++){cout << "Case #" << i << " : ";solve();}
#define watch(x)           cout << (#x) << " is " << (x) << endl
using namespace std;


/* Mathematical Functions */
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

const int inf = (int)1e17;
const int N = (int)3e5+5;

int32_t main(){

	
	FASTIO;
	string a,b;
	cin >> a >> b;
	int ans = 0;
	REP(i,0,a.size()){
		if(a[i]!=b[i])
			ans++;
	}
	cout << ans << "\n";
    return 0;

}
int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}
 
int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}
 
int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}
 
bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	ll A, B;
	std::cin >> A >> B;
	std::cout << A * B << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld ",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;
#define endl "\n"
const double pyi=3.14159265358979323846;




int main() 
{ 
    ll a,b,c,k;
    sfl(a); sfl(b); sfl(c); sfl(k);

    if(k<=a)
    {
    	d1(k);
    	return(0);
    }
    if(k<=(a+b))
    {
    	d1(a);
    	return(0);
    }
    d1(a-(k-(a+b)));
    return(0);
}

Measured memory_bytes: 3772
#include<algorithm>
#include<bitset>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<unordered_map>
#include<utility>
#include<vector>

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;

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

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


long long meguru_search(long long ok, long long ng, std::function<bool(long long)> check){
    while(1 < std::abs(ok - ng)){
        long long mid = (ok + ng) >> 1;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

long double bi_search(long double ok, long double ng, std::function<bool(long double)> check, int loop = 100){
    for(int i = 0 ; i < loop ; ++i){
        long double mid = (ok + ng) * 0.5;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

int main(){
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    std::map<int, int> cnt;
    for(int i = 0 ; i < n ; ++i){
        std::cin >> a[i];
        ++cnt[a[i]];
    }

    std::sort(a.rbegin(), a.rend());

    int ans = 0;
    for(int i = 0 ; i < n ; ++i){
        for(int d = 30 ; d >= 0 ; --d){
            int k = meguru_search(-1, n, [&](int j){ return a[j] >= (1 << d) - a[i]; });
            if(k >= 0 && a[i] + a[k] == (1 << d) && (a[i] == a[k] && cnt[a[i]] >= 2 || a[i] != a[k] && cnt[a[i]] >= 1 && cnt[a[k]] >= 1)){
                ++ans;
                --cnt[a[i]];
                --cnt[a[k]];
                break;
            }
        }
    }

    std::cout << ans << std::endl;
}

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

int main(){
    int r, g, b, n, i, j, c = 0;
    cin >> r >> g >> b >> n;
    for(i=0; i<=n/r; i++){
        for(j=0; j<=(n-r*i)/g; j++){
            if((n-r*i-g*j) >= 0 && (n-r*i-g*j)%b == 0){
                c++;
            }
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    ll a, b;
    cin >> a >> b;

    for (ll x = b * 10; x < b * 10 + 10; ++x) {
        if (x * 8 / 100 == a) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


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

int main()
{
    string S, T;

    cin >> S >> T;

    int count = 0;

    for (int i = 0, size = S.size(); i < size; i++)
    {
        if (S[i] != T[i])
        {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3920
#include<iostream>
#include<string>
#include<set>

using namespace std;
int main(){
    string s;
    cin>>s;
    int K;
    cin>>K;
    string ans;
    set<string> st;
    for(int i=0;i<26;i++){
        int bgn=0;
        while((int)s.find('a'+i,bgn)!=-1){
            size_t begin=s.find('a'+i,bgn);
            for(int j=1;j<=5;j++){
                st.insert(s.substr(begin,j));
            }
            bgn++;
        }
        
        if(K<=st.size()){
            break;
        }
    }
    set<string>::iterator itr;
    itr=st.begin();
    for(int i=1;i<K;i++){
        ++itr;
    }
    cout<<*itr<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        for (int i = a; i <= b; i++) {
            if (i - a < k || b - i < k) {
                System.out.println(i);
            }
        }
    }
}


Measured memory_bytes: 21844
N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
    quit()
MOD = 10 ** 9 + 7
fact = [1] * (max(N, M) + 1)
f = 1
for i in range(1, max(N, M) + 1):
    f = f * i % MOD
    fact[i] = f
print(((N == M) + 1) * fact[N] * fact[M] % MOD)


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

const ll mod = 1e9+7;


ll mod_pow(ll x, ll n){
  ll res = 1;
  while (n != 0){
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n = n >> 1;
  }
  return res;
}
 
ll mod_fact(ll x){
  ll res = 1;
  for (ll i = x; i > 0; i--)
    res *= i, res %= mod;
  return res;
}

ll nCr(ll n, ll r){
  ll nume = mod_fact(n);
  ll deno = mod_fact(r) * mod_fact(n - r) % mod;
  return nume * mod_pow(deno, mod - 2) % mod;
}

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll N, M;
    cin >> N >> M;
    
    // Mの素因数分解
    map<ll, ll> Mcoprime;

    ll tmp_M = M;
    for(ll i = 2; i <= M; i++){
        while(tmp_M % i == 0){
            Mcoprime[i]++;
            tmp_M /= i;
        }
        if(tmp_M == 1){
            break;
            }
    }

    // for(auto itr = Mcoprime.begin(); itr != Mcoprime.end(); ++itr) {
    //         std::cout << "key = " << itr->first           // キーを表示
    //                         << ", val = " << itr->second << endl;    // 値を表示
    //     }

    ll ans = 1;
    ll tmp = 0;
    for(auto itr = Mcoprime.begin(); itr != Mcoprime.end(); ++itr){
        tmp = itr->second;
        ans = (ans * nCr(tmp + N - 1, tmp)) % mod;
        // for(ll i = 1; i <= tmp; i++){
        //     ans = ans / i;
        //     // ans = ans % MOD;
        // }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

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


int main() {
  long long N,K;
  cin>>N>>K;
  long long X=K*pow(K-1,N-1);
  cout<<X<<endl;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    int flag=0;
    while(t!=0)
    {
        if(t%10==7)
            flag=1;
        t/=10;
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 3640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (H, W, h, w) = (v[0], v[1], v[2], v[3]);
    if h == 1 && w == 1 {
        println!("No");
        return;
    }
    let positive_const = 50000000;
    let negative_const = -50000001;
    let mut grid = vec![vec![0; W]; H];

    let mut positive_placed = 0;
    let mut current_h = 0;
    let mut current_w = 0;
    while current_h < H {
        current_w = 0;
        while current_w < W {
            grid[current_h][current_w] = positive_const;
            current_w += w;
            positive_placed += 1;
        }
        current_h += h;
    }

    let mut negative_placed = 0;
    let mut current_h = h - 1;
    let mut current_w = w - 1;
    while current_h < H {
        current_w = w - 1;
        while current_w < W {
            grid[current_h][current_w] = negative_const;
            current_w += w;
            negative_placed += 1;
        }
        current_h += h;
    }

    if positive_placed > negative_placed {
        println!("Yes");
        for i in 0..H {
            println!(
                "{}",
                grid[i]
                    .iter()
                    .map(|x| x.to_string())
                    .collect::<Vec<_>>()
                    .join(" ")
            );
        }
    } else {
        println!("No");
    }
}


Measured memory_bytes: 6652
S=int(input())
c=S//3
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

f=0
for i in range(1,c+1):
    #i個の箱にansを分ける
    ans=S-3*i#振り分けるべき残りの数
    #ball ans個
    #i-1 仕切りの数
    #print(ans,i)
    f+=combinations_count(ans+i-1,i-1)
print(f%(10**9+7))



Measured memory_bytes: 73724
K = list(map(int, list(input())))
D = int(input())
MOD = 10 ** 9 + 7

DP = [[[0] * 2 for _ in range(D)] for _ in range(len(K))]

for i in range(K[0]):
  DP[0][i % D][0] += 1
DP[0][K[0] % D][1] += 1

for i in range(1, len(K)):
  for j in range(10):
    for k in range(D):
      DP[i][(j + k) % D][0] = (DP[i][(j + k) % D][0] + DP[i - 1][k][0]) % MOD
  for j in range(K[i]):
    for k in range(D):
      DP[i][(j + k) % D][0] = (DP[i][(j + k) % D][0] + DP[i - 1][k][1]) % MOD
  for k in range(D):
    DP[i][(k + K[i]) % D][1] = (DP[i][(k + K[i]) % D][1] + DP[i - 1][k][1]) % MOD

ans = (DP[-1][0][0] + DP[-1][0][1] - 1) % MOD
while ans < 0:
  ans += MOD

print(ans)


Measured memory_bytes: 162632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n,k;
    cin>>n>>k;
    ll id=0;
    rep(i,n){
        int a;
        cin>>a;
        if(a==1) id=i;
    }

    int ans=(n-1+k-2)/(k-1);
    cout<<ans<<endl;
}




Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ran 111111
int n,rt;
vector<pair<int,int > > e[ran];
long long int d[ran];
void dfs(int x,int fat){
	for(vector<pair<int,int> >::iterator it = e[x].begin(); it!=e[x].end(); it++){
		int y = it->first;
		if(y == fat)continue;
		d[y] = d[x] + it->second;
		dfs(y, x);
	}
}
int main(){
	int x,y,z,q;
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		scanf("%d%d%d",&x,&y,&z);
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,z));
	}
	scanf("%d%d",&q,&rt);
	dfs(rt,rt);
	while(q--){
		scanf("%d%d",&x,&y);
		cout << d[x] + d[y] << endl;
	}
	return 0;
}


Measured memory_bytes: 13056
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

char S[SIZE],T[SIZE];
int int_S[SIZE],int_T[SIZE];
int table_S[26],table_T[26];


int main(){

	scanf("%s",S);
	scanf("%s",T);

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

		table_S[i] = -1;
		table_T[i] = -1;
	}

	int index_S = 0;
	int len;
	for(len = 0; S[len] != '\0'; len++);

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

		int ch = S[i]-'a';
		if(table_S[ch] == -1){

			table_S[ch] = index_S++;
		}
		int_S[i] = table_S[ch];
	}

	int index_T = 0;

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

		int ch = T[i]-'a';
		if(table_T[ch] == -1){

			table_T[ch] = index_T++;
		}
		int_T[i] = table_T[ch];
	}


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

		if(int_S[i] != int_T[i]){

			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 5488
check='abcdefghijklmnopqrstuvwxyz'
s=input()
l=len(s)
pos=[[0] for _ in range(26)]
for i in range(l):
  for j in range(26):
    if s[i]==check[j]:
      pos[j].append(i+1)
ans=10**9
for i in range(26):
  tmp=0
  for j in range(len(pos[i])-1):
    tmp=max(tmp,pos[i][j+1]-pos[i][j]-1)
  tmp=max(tmp,l-pos[i][-1])
  ans=min(ans,tmp)
print(ans)


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

int main(){
  int n,sum=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    a[i]*=n;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(abs(a[ans]-sum)>abs(a[i]-sum)) ans=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256