akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);

    int possible = 0;
    if(n < 4){
        printf("No\n");
    }else{
        for(int i = 1; ; i++){
            if(4 * i > n) break;

            if((n - (4 * i)) % 7 == 0){
                possible = 1;
                printf("Yes\n");
                break;
            }
        }

        if(possible == 0){
            for(int i = 1; ; i++){
                if(7 * i > n) break;

                if((n - (7 * i)) % 4 == 0){
                    possible = 1;
                    printf("Yes\n");
                    break;
                }
            }
        }
        if(possible == 0) printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	int cnt_even = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a % 2 == 0) cnt_even++;
	}
	cout << (int)(pow(3, n) - pow(2, cnt_even));
	return 0;
}

Measured memory_bytes: 640
n=input()
a=list(map(int,input().split()))
ans=mans=0
if a[0]==0:
    ans+=1
    mans+=1
    sim=1
    msim=-1
elif a[0]>0:
    ans=0
    sim=a[0]
    mans+=a[0]+1
    msim=-1
else:
    ans=-a[0]+1
    sim=1
    mans=0
    msim=a[0]
for i in a[1:]:
    if sim<0:
        sim+=i
        if sim<=0:
            ans+=1-sim
            sim=1
    else:
        sim+=i
        if sim>=0:
            ans+=sim+1
            sim=-1
    if msim<0:
        msim+=i
        if msim<=0:
            mans+=1-msim
            msim=1
    else:
        msim+=i
        if msim>=0:
            mans+=msim+1
            msim=-1
print(min(ans,mans))




Measured memory_bytes: 14468
#include<iostream>
#include<vector>

using namespace std;
const int MAX = 51;

vector<int> V[MAX],MET[MAX];
int n;

bool find_V(int P,int n){
  for(int i = 0; i < V[P].size(); i++)
    if(V[P][i] == n) return true;

  return false;
}


bool find(int P,int n){
  for(int i = 0; i < MET[P].size(); i++)
    if(MET[P][i] == n) return true;

  return false;
}

bool solve(int day, int P1, int P2){

  if(!find_V(P1,day) || !find_V(P2,day)) return false;

  for(int i = 0; i < MET[P1].size(); i++)
    if(!find(P2,MET[P1][i])) MET[P2].push_back(MET[P1][i]);

  for(int i = 0; i < MET[P2].size(); i++)
    if(!find(P1,MET[P2][i])) MET[P1].push_back(MET[P2][i]);


  for(int i = 0; i < n; i++)
    if(MET[i].size() == n) return true;

  return false;
}


void init(){
  for(int i = 0; i < MAX; i++){
    V[i].clear();
    MET[i].clear();
  }
}

int main(){
  while(cin >> n && n){
    init();
    for(int i = 0; i < n; i++){
      MET[i].push_back(i);
      int rev;
      cin >> rev;
      while(rev--){
	int in;
	cin >> in;
	V[i].push_back(in);
      }
    }

    bool flg = false;

    for(int i = 1; i <= 30; i++){
      for(int j = 0; j < n; j++){
	for(int k = j+1; k < n; k++)
	  if(solve(i,j,k)){
	    cout << i << endl;
	    flg = true;
	    break;
	  }
	if(flg) break;
      }
      if(flg) break;
    }

    if(!flg) cout << "-1" << endl;
  }
  return 0;
}

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

const int mod = 1e9+7;

int main(){
    int H, W, K; cin >> H >> W >> K;
    --K; 
    vector<vector<ll> > dp(H+1, vector<ll>(W, 0));
    dp[0][0] = 1;
    for(int h = 0; h < H; h++){
        for(int bit = 0; bit < (1 << (W-1)); bit++){
            bool isOK = true;
            for(int k = 0; k < W - 2; k++){
                if((bit & (1 << k)) && (bit & (1 << (k+1)))) isOK = false;
            }
            if(!isOK) continue;
            for(int w = 0; w < W; w++){
                if(bit & (1 << w)){
                    (dp[h+1][w+1] += dp[h][w]) %= mod;
                }else if(w > 0 && (bit & (1 << (w-1)))){
                    (dp[h+1][w-1] += dp[h][w]) %= mod;
                }else{
                    (dp[h+1][w] += dp[h][w]) %= mod;
                }
            }
        }
    }
    cout << dp[H][K] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
        vector<string> vec(n);
        vector<int> depth(n,0);
        rep(i,n){
        cin >> vec[i];
          rep(j,vec[i].size()){
          if(vec[i][j] == '.' && vec[i][j+1] != '.'){
                vec[i][j] = '+';
                depth[i] = j+1;
                break;
          }
        }
          for(int j=i-1; j>=0; j--){
            if(depth[i] > depth[j]) break;
            if(depth[i] == depth[j]){
                for(int k=j+1; k<i; k++) vec[k][depth[j]-1] = '|';
                break;
            }
          }
        }
        rep(i,n){
          rep(j,vec[i].size()){
                if(vec[i][j] == '.') vec[i][j] = ' ';
          }
        }
        rep(i,n) cout << vec[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string a;
	cin>>a;
	int l,r;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='A')
		{
			l=i;
			break;
		} 		
	} 
	for(int i=a.size()-1;i>=0;i--)
	{
		if(a[i]=='Z')
		{
			r=i;
			break;
		}
	}
	cout<<r-l+1<<endl;	
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
def  inpl(): return list(map(int, input().split()))
N, M = inpl()
X = sorted(inpl())
D = sorted([X[i+1] - X[i] for i in range(M-1)])
if N == 1:
    print(sum(D))
else:
    print(sum(D[:-N+1]))

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

const int INF = 2e9;

int main(){
    string s;
    cin >> s;
    int num = s.size();
    cout << s;
    if(s[num-1] == 's') cout << "es" << endl;
    else cout << "s" << endl; 
}

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

int main() {

    int x = 0;
  cin >> x;
  
   if(400 <= x && x <= 599){

       cout << 8;

   }else if(600 <= x && x <= 799){

       cout << 7;

   }else if(800 <= x && x <= 999){

       cout << 6;

   }else if(1000 <= x && x <= 1199){

       cout << 5;

   }else if(1200 <= x && x <= 1399){

       cout << 4;

   }else if(1400 <= x && x <= 1599){

       cout << 3;

   }else if(1600 <= x && x <= 1799){

       cout << 2;

   }else if(1800 <= x && x <= 1999){

       cout << 1;

   }

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, mod = 1e9 + 7;
int ans[N], fc[N], ifc[N], n, rtr;
int power(int a, int b) {
	if (!b)
		return 1;
	int rtr = power(a, b / 2);
	if (b % 2) 
		return 1ll * rtr * rtr % mod * a % mod;
	return 1ll * rtr * rtr % mod;
}
void getFc() {
	fc[0] = ifc[0] = 1;
	for (int i = 1; i < N - 5; i++) {
		fc[i] = 1ll * fc[i - 1] * i % mod;
		ifc[i] = 1ll * ifc[i - 1] * power(i, mod - 2) % mod;
	}
}
int ch(int y, int x) {
	return 1ll * fc[x] * ifc[y] % mod * ifc[x - y] % mod;
}
int main() {
	getFc();
	cin >> n;
	for (int i = 0; i <= (n - 2) / 2; i++)
		ans[i] = 1ll * ch(i, n - 3 - i + 1) * fc[i] % mod * fc[n - 1 - i] % mod;
	for (int i = 0; i <= (n - 2) / 2; i++) 
		rtr = (rtr + 1ll * (ans[i] - ans[i + 1] + mod) % mod * (n - 1 - i)) % mod; 
	cout << rtr;
	return 0;
}


Measured memory_bytes: 10496
N = '0' + input()
INF = float('inf')
dp = [[INF] * 2 for _ in range(len(N) + 1)]
dp[0][0] = 0

for i in range(len(N)):
    n = int(N[len(N) - 1 - i])
    for j in range(2):
        for a in range(10):
            ni = i + 1
            nj = 0
            b = a - n - j
            if b < 0:
                b += 10
                nj = 1
            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b)
            a == b

print(dp[len(N)][0])


Measured memory_bytes: 203652
#include <bits/stdc++.h>
using namespace std;
int n, m, nm, cost[51][51];
char g[51][51];
bool vis[51][51];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
bool vld(int x, int y) {
        if (x<0 || y<0 || x>=n || y>=m || g[x][y]=='#') return 0;
        else return 1;
}
int main() {
        cin >> n>> m;
        for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++) {
                                cin >> g[i][j];
                                if (g[i][j] == '#') nm++;
                }
        queue<pair<int, pair<int, int>>> q;
        q.push({1, {0, 0}});
        cost[0][0] = 1;
        while (q.size()) {
                int x = q.front().second.first;
                int y = q.front().second.second;
                int c = q.front().first;
                q.pop();
                vis[x][y] = 1;
                for (int i = 0; i < 4; i++) {
                        int tox = x + dx[i];
                        int toy = dy[i] + y;
                        if (!vis[tox][toy] && vld(tox, toy)) {
                               vis[tox][toy] = 1;
                               q.push({c + 1, {tox, toy}});
                               cost[tox][toy] = c + 1;
                        }
                }
        }
        if (cost[n - 1][m - 1] == 0) {
                cout << -1;
        }else
                cout << (n * m) - (cost[n - 1][m - 1] + nm);
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int i = 0,j;
    int num[] = new int[10001];
    while(true){
      num[i] = stdIn.nextInt();
      if(num[i] == 0){
        break;
      }
      i++;
    }


    for(j = 0;j < i;j++){
      System.out.println("Case " + (j + 1) + ": " + num[j]);
    }
  }
}

Measured memory_bytes: 43208
# Union Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


import sys

input = sys.stdin.readline
n, m = map(int, input().split())
par = [-1] * n
a = set()
for _ in range(m):
    ab = sorted(map(int, input().split()))
    a.add((ab[0], ab[1]))

for x, y in a:
    unite(x - 1, y - 1)

print(-min(par))

Measured memory_bytes: 47132
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    long long minv = 1e9;
    long long maxv = -1e9;
    long long sum = 0;
    REP(i, n)
    {
        long long tmp;
        cin >> tmp;
        minv = min(minv, tmp);
        maxv = max(maxv, tmp);
        sum += tmp;
    }
    printf("%lld %lld %lld\n", minv, maxv, sum);
}


Measured memory_bytes: 3228
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    ll m = 1000000007;
    int N;
    cin >> N;

    // 全体　- 0がない - 9がない + 0と9がない
    ll a = 1, b = 1, c = 1;
    rep(i,0,N) {
        a *= 10;
        b *= 9;
        c *= 8;
        a %= m;
        b %= m;
        c %= m;
    }
    ll ans = (a - 2 * b + c) % m;
    if (ans < 0) ans += m;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=1e6+3;
typedef long long ll;
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define per(i,a,b) for(int i=(a);i<b;i++)
#define rep(i,a,b) for(int i=(a);i<=b;i++)
#define pi acos(-1.0)
#define mid ((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
void read(int &x)
{
	int f=1;x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
set<char>se;
int main()
{
	char s[20];
	scanf("%s",s);
    int i,len=strlen(s);
    per(i,0,len)se.insert(s[i]);
    if(se.size()==2)puts("Yes");
    else puts("No");
}
    

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

typedef unsigned long long int ulli;

ulli div_and_ceil(ulli x, ulli y)
{
  return (x / y) + (((x % y) == 0) ? 0 : 1);
  //return (x + y  - 1) / y;
}

int main(void)
{
  unsigned N;
  std::cin >> N;
  
  ulli P = 1, Q = 1;
  
  for(unsigned n=0; n<N; ++n)
  {
    unsigned T, A;
    std::cin >> T >> A;
    
    ulli m = std::max(
      div_and_ceil(P, T),
      div_and_ceil(Q, A)
    );
    P = m * T;
    Q = m * A;
  }
  
  std::cout << (P + Q) << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

const int Maxx=2E6;
const int Maxn=2E6+5;
const int Mod=1E9+7;

int X[7],Y[7];

int fac[Maxn];
int inv[Maxn];
int Ans;

int Pow_Mod(int X,int K){
	int tmp=X,val=1;
	while(K){
		if(K&1) val=(LL)val*tmp%Mod;
		tmp=(LL)tmp*tmp%Mod; K>>=1;
	}
	return val;
}

void PrePare(){
	fac[0]=1;
	for(int i=1;i<=Maxx;++i)
		fac[i]=(LL)fac[i-1]*i%Mod;
	inv[Maxx]=Pow_Mod(fac[Maxx],Mod-2);
	for(int i=Maxx;i>=1;--i)
		inv[i-1]=(LL)inv[i]*i%Mod;
}

int C(int n,int m){
	return ((LL)fac[n+m]*inv[m]%Mod)*inv[n]%Mod;
}

int Calc(int X1,int Y1,int X2,int Y2){
	return ((LL)C(X2+1,Y2+1)-C(X1,Y2+1)-C(X2+1,Y1)+C(X1,Y1)+4ll*Mod)%Mod;
}

int main(){
	PrePare();
	for(int i=1;i<7;++i) cin>>X[i];
	for(int i=1;i<7;++i) cin>>Y[i];
	for(int x=X[3];x<=X[4];++x)
		Ans=(Ans+((LL)((LL)Mod-x-Y[3])*Calc(x-X[2],Y[3]-1-Y[2],x-X[1],Y[3]-1-Y[1])%Mod)*Calc(X[5]-x,Y[5]-Y[3],X[6]-x,Y[6]-Y[3]))%Mod;
	for(int y=Y[3];y<=Y[4];++y)
		Ans=(Ans+((LL)((LL)Mod-X[3]-y)*Calc(X[3]-1-X[2],y-Y[2],X[3]-1-X[1],y-Y[1])%Mod)*Calc(X[5]-X[3],Y[5]-y,X[6]-X[3],Y[6]-y))%Mod;
	for(int x=X[3];x<=X[4];++x)
		Ans=(Ans+((LL)((LL)x+Y[4]+1)*Calc(x-X[2],Y[4]-Y[2],x-X[1],Y[4]-Y[1])%Mod)*Calc(X[5]-x,Y[5]-Y[4]-1,X[6]-x,Y[6]-Y[4]-1))%Mod;
	for(int y=Y[3];y<=Y[4];++y)
		Ans=(Ans+((LL)((LL)X[4]+y+1)*Calc(X[4]-X[2],y-Y[2],X[4]-X[1],y-Y[1])%Mod)*Calc(X[5]-X[4]-1,Y[5]-y,X[6]-X[4]-1,Y[6]-y))%Mod;
	cout<<Ans;
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
    ll n;
    const unsigned long long b=1000000000000000000;
    unsigned long long ans=1;
 
    cin>>n;
    vector<unsigned long long >a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i] == 0){
            cout<<"0";
            return 0;
        }
    }
    
    rep(i,n){
        if(a[i]>b){
            cout<<"-1";
            return 0;
        }
        else if((ULLONG_MAX/ans)>a[i]){
            ans*=a[i];
            if(ans>b){
            cout<<"-1";
            return 0;
        }
        }
        else{
            cout<<"-1";
            return 0;
        }
    }
    cout<<ans;
}

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

using ll_t = long long;

ll_t solve(const std::string &s, int k) {
  ll_t res = 0;
  int len = s.length();
  int pos = 1;
  while (pos < len && s[pos] == s[0]) ++pos;
  if (pos == len) return static_cast<ll_t>(len) * k / 2;
  
  bool pre_has_changed = false;
  bool last_char_changed = false;
  for (int i = (pos + 1) % len; i % len != pos; i = (i + 1) % len) {
    if (s[i] == s[(i - 1 + len) % len] && !pre_has_changed) {
      ++res;
      pre_has_changed = true;
      if (i == len - 1) last_char_changed = true;
    } else {
      pre_has_changed = false;
    }
  }
  res *= k;
  if (s[0] == s[len - 1] && !last_char_changed && pos % 2 == 1) --res;
  return res;
}

int main() {
  int k;
  std::string s;
  std::cin >> s >> k;
  std::cout << solve(s, k) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused)]
use std::io::{stdin, stdout, Write};
#[allow(unused)]
use std::iter::Iterator;
#[allow(unused)]
use std::cmp;
#[allow(unused)]
macro_rules! read {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty), *) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            read!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(non_snake_case)]
#[allow(unused_variables)]
fn main() {
    let n = read![i32];
    let mut c = String::new();
    stdin().read_line(&mut c).unwrap();
    let c: Vec<_> = c.bytes().collect();
    let mut rRCount = c.iter().filter(|&item| *item == b'R').count();
    let mut lWCount = 0;
    let mut min = rRCount;
    for i in 0..c.len() {
        if c[i] == b'R' {
            rRCount -= 1;
        } else {
            lWCount += 1;
        }
        min = std::cmp::min(min, std::cmp::max(rRCount, lWCount));
    }
    println!("{}", min);
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int d;
        cin >> d;
        v.push_back(d);
    }

    set<int> st;
    for(int i=1;i<=4;++i){
        for(int j=0;j<n-i+1;++j){
            int num = 0;
            for(int k=0;k<i;++k){
                num *= 10;
                num += v[j+k];
            }
            st.insert(num);
        }
    }
    int ans = 0;
    for(int i=0;i<=10000;++i){
        if(!st.count(i)){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main() {
  int64_t X;
  cin >> X;
  int64_t count = 100;
  int answer = 0;
  while (count < X) {
    count += count / 100;
    answer++;
    if (count >= X) {
      cout << answer << endl;
      break;
    }
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	ll N;
	cin >> N;
	ll s[N + 10];
	ll sum = 0;
	for (ll i = 0; i < N; i++) {
		cin >> s[i];
		sum += s[i];
	}
	sort(s, s + N);
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}

	for (ll i = 0; i < N; i++) {
		if (s[i] % 10 != 0) {
			sum -= s[i];
			break;
		}
	}
  	if(sum%10==0) sum=0;
	cout << sum << endl;
}



Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let nmax = 1000000 in
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let z = 1_000_000_007 in

    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = ((a mod z) * (b mod z)) mod z in

    let minprime =
        let r = Array.init (nmax + 1) (fun a -> a) in
        for i = 2 to int_of_float (sqrt (float nmax)) do
            let rec loop j =
                if j <= nmax then (
                    r.(j) <- min r.(j) i;
                    loop (j + i)
                )
            in
            loop (i * i)
        done;
        r
    in

    let invsum = Array.fold_left (fun acc v -> acc +@ inv v z) 0 a in
    let lcm = Array.make (nmax + 1) 0 in
    Array.iter (fun v ->
        let rec loop v =
            if v > 1 then (
                let q = minprime.(v) in
                let rec count r i =
                    if r mod q = 0 then count (r / q) (i + 1) else (
                        lcm.(q) <- max lcm.(q) i;
                        loop r
                    )
                in
                count v 0
            )
        in
        loop v
    ) a;

    let pow_mod a b =
        let rec loop r i acc =
            if i = 0 then acc else
                let acc = if i land 1 = 1 then acc *@ r else acc in
                loop (r *@ r) (i lsr 1) acc
        in
        loop a b 1
    in
    let reduce =
        let rec loop i acc =
            if i > nmax then acc else loop (i + 1) (acc *@ pow_mod i lcm.(i))
        in
        loop 2 1
    in
    reduce *@ invsum |> Printf.printf "%d\n"
)

Measured memory_bytes: 21116
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;

    for (int i = l; i <= r; i++) {
        if (i % d == 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL N,A,B;
    cin>>N>>A>>B;
    LL X[N];
    REP(i,N){
        cin>>X[i];
    }
    LL ans=0;
    REP(i,N-1){
        if((X[i+1]-X[i])*A>B){
            ans+=B;
        }else{
            ans+=(X[i+1]-X[i])*A;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ll n, cnt, ans, temp, line;
  cin >> n;
  temp = n;
  ans = 0;
  for (ll i = 2; i <= sqrtl(temp) + 1LL; i++) {
    line = 1;
    cnt = 0;
    while (n % i == 0) {
      cnt++;
      if (cnt >= line) {
        line++;
        cnt = 0;
        ans++;
      }
      n /= i;
    }
  }
  if (n > 1LL)
    ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>

int main(){
    int n;
    int h,m,s;

    scanf("%d",&n);

    s=n%60;
    m=((n-s)%3600)/60;
    h= (n-60*m-s)/3600;
    
    printf("%d:%d:%d\n",h,m,s);                            
    return 0;

}


Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n+1);
  cin >> a[0] >> a[0];
  for(int i = 1; i <= n; i++) cin >> a[i];

  static int dp[3001][2];
  fill(dp[0], dp[3000] + 2, -1);
  function< int(int,int) > rec =
  [&](int k, int t){
    if(dp[k][t] != -1) return dp[k][t];
    dp[k][t] = abs(a[k] - a[n]);
    for(int i = k+1; i < n; i++){
      if(t == 0){
        dp[k][t] = max(dp[k][0], rec(i, t^1));
      }else {
        dp[k][t] = min(dp[k][0], rec(i, t^1));
      }
    }
    return dp[k][t];
  };
  cout << rec(0, 0) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <bits/stdc++.h>

using namespace std;
int S,W;

int main() {


  cin >> S >> W;

  if (W>=S)
    printf("unsafe\n");
  else
    printf("safe\n");

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  ll A, B, K;
  IN(A);
  IN(B);
  IN(K);

  ll l = K - A;
  if (l > 0) cout << 0 << " " << max(B - l, (ll)0);
  else cout << A - K << " " << B;
  cout << endl;
}


Measured memory_bytes: 256
N=int(input())
if 	100<=N<=111:
  print(111)
elif 112<=N<=222:
  print(222)
elif 223<=N<=333:
  print(333)
elif 334<=N<=444:
  print(444)
elif 445<=N<=555:
  print(555)
elif 556<=N<=666:
  print(666)
elif 667<=N<=777:
  print(777)
elif 778<=N<=888:
  print(888)
elif 889<=N<=999:
  print(999)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	while (ans < n) ans += 1000;
	cout << ans - n << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    char c;
    cin>>c;
    if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o')cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
    
}

   


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int students [] [] = new int [n] [2];
		int points [] [] = new int [m] [2];
		for (int i = 0 ; i < n ; i++) {
			students [i] [0] = scanner.nextInt();
			students [i] [1] = scanner.nextInt();
		}
		for (int j = 0 ; j < m ; j++) {
			points [j] [0] = scanner.nextInt();
			points [j] [1] = scanner.nextInt();
		}
		
		int [] result = new int [n];
		for (int i = 0 ; i < n ; i++) {
			int minDist = Integer.MAX_VALUE;
			int minIndex = 0;
			for (int j = 0 ; j < m ; j++) {
				int dist = Math.abs(students [i] [0] - points [j] [0]) + Math.abs(students [i] [1] - points [j] [1]);
				if (dist < minDist) {
					minDist = dist;
					minIndex = j;
				}
			}
			result [i]= minIndex + 1;
		}
		for (int i = 0 ; i < n ; i++) {
			System.out.println(result [i]);
		}
	}
} 

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

ll divisor(ll x) {
  ll res=0;
  for (ll i=1; i*i<=x; i++) {
    if (x%i==0) res+=2;
    if (i*i==x) res--;
  }
  return res;
}

int main() {
  ll n; cin>>n;
  ll res=divisor(n-1);
  for (ll i=2; i*i<=n; i++) {
    if (n%i!=0) continue;
    ll nn=n;
    while (nn%i==0) nn/=i;
    if ((nn-1)%i==0) ++res;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,flag=0;
  cin>>c>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%c==0){
      flag=1;
      break;
  }
  }
    if(flag==0) cout<<"NG";
    else cout<<"OK";
  }

Measured memory_bytes: 3096
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
vector<ll>v[200005];
ll ans[200005],fact[200005],invf[200005],dp[200005],sz[200005];
ll modexp(ll a,ll b)
{
	a%=mod;
	if(a==0||a==1)
	return a;
	if(b==0)
	return 1;
	if(b%2==0)
	{
		ll res=modexp(a,b/2);
		return (res*res)%mod;
	}
	return (a*modexp(a,b-1))%mod;
}
void dfs(ll ind,ll par)
{
	sz[ind]=1;
	dp[ind]=1;
	for(ll i=0;i<v[ind].size();i++)
	{
		if(v[ind][i]!=par)
		{
			dfs(v[ind][i],ind);
			sz[ind]+=sz[v[ind][i]];
			dp[ind]=(dp[ind]*dp[v[ind][i]])%mod;
			dp[ind]=(dp[ind]*invf[sz[v[ind][i]]])%mod;
		}
	}
	dp[ind]=(dp[ind]*fact[sz[ind]-1])%mod;
}
void reroot(ll ind, ll par)
{
	ans[ind]=dp[ind];
	for(ll i=0;i<v[ind].size();i++)
	{
		if(v[ind][i]!=par)
		{
			ll chl_dp=dp[v[ind][i]], par_dp=dp[ind], chl_sz=sz[v[ind][i]], par_sz=sz[ind];
		
			ll pdp=(dp[ind]*invf[par_sz-1])%mod;
			pdp=(pdp*fact[chl_sz])%mod;
			pdp=(pdp*modexp(chl_dp,mod-2))%mod;
			pdp=(pdp*fact[par_sz-chl_sz-1])%mod;
			
			dp[ind]=pdp;
			sz[ind]=par_sz-chl_sz;
			sz[v[ind][i]]=par_sz;
			
			ll cdp=(dp[v[ind][i]]*invf[chl_sz-1])%mod;
			cdp=(cdp*fact[sz[v[ind][i]]-1])%mod;
			cdp=(cdp*invf[sz[ind]])%mod;
			cdp=(cdp*dp[ind])%mod;
			dp[v[ind][i]]=cdp;
			
	//		cout<<"par dp-"<<dp[v[ind][i]]<<"  sz-"<<sz[v[ind][i]]<<" chl dp-"<<dp[ind]<<" sz-"<<sz[ind]<<endl;
			
			reroot(v[ind][i],ind);
		
			dp[v[ind][i]]=chl_dp;
			dp[ind]=par_dp;
			sz[v[ind][i]]=chl_sz;
			sz[ind]=par_sz;
		}
	}
}
int main()
{
	sync;
	fact[0]=invf[0]=1;
	for(ll i=1;i<=200000;i++)
	{
		fact[i]=(fact[i-1]*i)%mod;
		invf[i]=(invf[i-1]*modexp(i,mod-2))%mod;
	}
	ll n;
	cin>>n;
	for(ll i=1;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,0);
	reroot(1,0);
	for(ll i=1;i<=n;i++)
		cout<<ans[i]<<"\n";
}
	
	

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

struct Node{
  int key;
  struct Node *prev;
  struct Node *next;
};

struct Node *nil;

struct Node* listSearch(int key){
  struct Node * cur = nil->next;
  
  while((cur != nil) && (cur->key != key)){
    cur = cur->next;
  }
  return cur;
}

void init(void){
  
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}

void printlist(){
  struct Node *cur = nil->next;
  int isf = 0;
  
  while(1){
    if(cur == nil){
      break;
    }
    if(isf++ > 0){
      printf(" ");
    }
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}



void deleteNode(struct Node *t){

  if(t == nil){
    return;
  }

  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void){
  int key,n,i;
  int size = 0,np = 0,nd = 0;
  char com[20];

  scanf("%d",&n);
  init();
  for(i = 0;i < n;i++){
    scanf("%s %d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }else if(com[0] == 'd'){
      if(strlen(com) >= 6){
	if(com[6] == 'F'){
	  deleteFirst();
	}else if(com[6] == 'L'){
	  deleteLast();
	}else{
	  deleteKey(key);
	  nd++;
	}
	size--;
      }
    }
  }
  printlist();

  return 0;
}
    



Measured memory_bytes: 33024
from queue import deque
n = int(input())
a = deque(map(int, input().split()))
b = deque()
for i in range(n):
    if i%2==0:
        b.appendleft(a.popleft())
    else:
        b.append(a.popleft())
b = list(b)
if n%2==0:
    b = b[::-1]
print(*b)

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
int main(){
int counter1,counter2;
counter1=0;
counter2=0;
int answer=0;
string S; cin>>S;
for(long long i=0; i<S.size();i++){
if(S.at(i)=='S'){
counter1++;}
else{
if(counter1>0){
counter1--;}
else{
answer++;}}}
cout<<answer+counter1<<endl;}

Measured memory_bytes: 640
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>
#include <cstdlib>

typedef long long ll;

using namespace std;

struct ToLower {    char operator()(char c) { return tolower(c); }};

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

	int ball[10];
	int a=0, b=0;
	int check = 0;

	for(int i=0; i<N; ++i){
		a=0, b=0, check=0;

		for(int j=0; j<10; j++){
			cin >> ball[j];
		}
		for(int j=0; j<10; ++j){
			if(ball[j] > a && ball[j] > b){
				(a > b ? a : b) = ball[j];
				continue;
			} else if(ball[j] < a && ball[j] < b){
				cout << "NO" << endl;
				check = 1;
				break;
			} else {	
				(a < b ? a : b) = ball[j];
			}
		}
		if(check == 0) cout << "YES" << endl;

	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define li long long int
#define pb push_back
#define rep(i,n) for(li i=0;i<n;i++)
void solve()
{
    li a,b,c;
    cin>>a>>b>>c;
    li k;
    cin>>k;
    while(k--)
    {
        if(c>b && b>a)
        {
            cout<<"Yes";
            return;
            
        }
        if(b<=a)
        b=b*2;
        else if(c<=b)
        c=c*2;
        
    }
    if(c>b && b>a)
    cout<<"Yes";
    else
    cout<<"No";
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    li t;
    t=1;
    while(t--)
    {
        solve();
        
    }
}

Measured memory_bytes: 3644
import numpy as np
N = int(input())

abc = np.array([list(map(int, input().split())) for i in range(N)])

dp = [[0]*3 for i in range(N+1)]

for i in range(1, N+1):
    dp[i][0] = max(dp[i - 1][1] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][2])
    dp[i][1] = max(dp[i - 1][0] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][2])
    dp[i][2] = max(dp[i - 1][1] + abc[i - 1][1], dp[i - 1][0] + abc[i - 1][0])

print(max(dp[-1]))


Measured memory_bytes: 41852
#include <bits/stdc++.h>
using namespace std;
bool gt(int h1,int w1,int h2,int w2) {
    return h1*h1+w1*w1>h2*h2+w2*w2||(h1*h1+w1*w1==h2*h2+w2*w2&&h1>h2);
}
int main() {
    int h,w;
    while(scanf("%d %d",&h,&w),h) {
        int ans_h=514,ans_w=514;
        for(int H=1;H<=150;H++) {
            for(int W=H+1;W<=150;W++) {
                if(gt(H,W,h,w)&&gt(ans_h,ans_w,H,W)) {
                    ans_h=H,ans_w=W;
                }
            }
        }
        printf("%d %d\n",ans_h,ans_w);
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e,sum=0;
  int chu[5];
  cin >> chu[0] >> chu[1] >> chu[2] >> chu[3] >> chu[4];
  int chu_1[5];
  int arr[13];
  for(int i=0;i<5;i++){
    if(chu[i]>=100){
      chu_1[i] = chu[i] % 10 % 10;
      //cout << endl;
    }else if(chu[i]>=10){
      chu_1[i] = chu[i] % 10;
    }else{
      chu_1[i] = chu[i];
    }
  }
  int lastNum,tmp=9,index=0;
  for(int i=0;i<5;i++){
    // cout << "chu_1:" << chu_1[i] << endl;
    if(chu_1[i]<tmp && chu_1[i]!=0){
      tmp = chu_1[i];
      index = i;
    }
  }
  //削除
  // cout << "tmp: " << tmp << endl;
  lastNum=chu[index];
  chu[index] = 0;

  for(int i=0;i<14;i++){
    arr[i] = i * 10;
  }
  //cout << arr[5] << endl; //OK
  int diff=0;
  for(int i=0;i<5;i++){
    for(int j=0;j<14;j++){
      if(chu[i]<=arr[j]){
        diff += arr[j]-chu[i];
        // cout << "arr_j: " << arr[j] << endl;
        // cout << "chu_i: " << chu[i] << endl;
        // cout << "diff: " << diff << endl;
        break;
      }
    }
    sum = sum + chu[i];
  }

  cout << sum+diff+lastNum << endl;
  return 0;
}


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

int main() {
  
  int K; cin >> K; int ans = 0;
  
  for (int i = 1; i <= K; i++) {
    
    for (int j = 1; j <= K; j++) {
      
      int tmp = __gcd(i, j);
      
      for (int k = 1; k <= K; k++) ans += __gcd(tmp, k);
      
    }
    
  }
  
  cout << ans << endl;
  
}

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

#define pb push_back
#define f first
#define s second
using namespace std;


int main()
{
    char s[3];
    int k=0;
    for(int i=0;i<3;i++)
       { cin>>s[i];if(s[i]=='A')k++;
       }
    if(k==0||k==3)cout<<"No";
    else cout<<"Yes";
return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	if (n % 2 == 1) {
		if (n == 1) {
			char s;
			cin >> s;
		}
		else {
			string s;
			cin >> s;
		}
		puts("No");
	}
	else {
		int flag = 0;
		string s;
		cin >> s;
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[n / 2 + i]) {
				flag = 1;
				break;
			}
		}
		if (flag == 0)
			puts("Yes");
		else
			puts("No");
	}
	}

				

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll mod = 1e9+7;

int fac[1000007];

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

int power(int a, int b) {
	int rs=1;
	while(b) {
		if(b%2) 
			rs = mul(rs, a);
		a = mul(a,a);
		b/=2;
	}
	return rs;
}

int dv(int a ,int b) {
	return mul(a, power(b,mod-2));
}



int comb(int a,int b) {
	return dv(fac[a], mul(fac[a-b],fac[b]));
}

int add(int a,int b) {
	a+=b;
	if(a>=mod)
		a-=mod;
	if(a<0)
		a+=mod;
	return a;
}

void pre() {
	fac[0]=1;
	for(ll i=1;i<1e6+5;i++) {
		fac[i] = mul(fac[i-1],i);
	}
}

int32_t main() {
	ll n,k;
	cin>>n>>k;
	ll a[n],i;
	for(i=0;i<n;i++)
		cin>>a[i];
	ll ml = 1;
	unordered_map<ll,ll> mp;
	for(i=0;i<k;i++) {
		mp[a[i]]++;
	}
	ll ind=0;
	for(i=k;i<n;i++) {
		ll rem = a[ind];
		if(a[ind] < a[i])
			cout<<"Yes\n";
		else
			cout<<"No\n";
		ind++;
	}
	return 0;
}

Measured memory_bytes: 12852
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef pair<int, int> pii;
/*
bool memo[1000000] = {};
vector<int> pri;

void calc()
{
	for (int i = 2; i < 1000000; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < 1000000; l += i)
			{
				memo[l] = true;
			}
		}
	}
}
*/
int main()
{
	long long a, b,n;
	while (cin >> a >> b >> n)
	{
		int ans = 0;
		a = a %b; a *= 10;
		for (int i = 0; i < n; i++)
		{
			ans += a / b;
			a = a%b; a *= 10;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cctype>
#include <cmath>
#include <climits>
#include <set>
#include <deque>
 
using namespace std;
using ll = long long;
int main(void){


  int n;
  cin>>n;
	vector<ll> a(n + 1), b(n);
  for(int i=0;i<n+1;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  ll ans=0;
  ll m=0;
  
  for(int i=0;i<n;i++){
    m=min(a[i],b[i]);
    ans+=m;
    a[i]-=m;
    b[i]-=m;
    m=min(a[i+1],b[i]);
    ans+=m;
    a[i+1]-=m;
    b[i]-=m;
  }
  cout<<ans<<endl;
}


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

typedef long long ll;

ll power(ll base, ll exponent){
	
	ll a = base;
	for(ll i = 1; i < exponent; i ++){
		a = a * base;
	}
	return a;
	
}

int main(){
	
	ll N, M;
	cin >> N >> M;
	cout << power(2, M) * ((N - M) * 100 + (M * 1900));
	
}

Measured memory_bytes: 256
///God help me.

#include<bits/stdc++.h>

using namespace std;

map<string,int>mp;
map<string,int>::iterator it;

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i<n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    int m;
    cin >> m;
    for(int i = 0; i<m; i++){
        string s;
        cin >> s;
        mp[s]--;
    }
    int ans = 0;
    for(it = mp.begin(); it!=mp.end(); it++){
        if(it->second > 0)ans = max(ans,it->second);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	std::vector<std::pair<long long, long long>> rest;
	int N;
	std::cin >> N;
	for (int i{};i < N;++i)
	{
		int a, b;
		std::cin >> a >> b;
		rest.emplace_back(a%b, b);
	}
	long long count{};
	for (int i = N - 1;i >= 0;--i)
	{
		rest[i].first = (rest[i].first + count) % rest[i].second;
		auto plus = (rest[i].second - rest[i].first) % rest[i].second;
		count += plus;
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define int long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int h,w;
	cin >> h >> w;
	string s[h];
	for(int i=0;i<h;i++){
		cin >> s[i];
	}
	int dp[h][w];
	bool ok=true;
	for(int i=0;i<w;i++){
		if(s[0][i]=='#'){
			ok=false;
		}
		if(ok)	dp[0][i]=1;
		else	dp[0][i]=0;
	}
	ok=true;
	for(int i=0;i<h;i++){
		if(s[i][0]=='#'){
			ok=false;
		}
		if(ok)	dp[i][0]=1;
		else	dp[i][0]=0;
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(s[i][j]=='#'){
				dp[i][j]=0;
			}
			else{
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=1000000007;
			}
		}
	}
	cout << dp[h-1][w-1];


	return 0;
}

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

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

    vector<bool> good(N, true);
    int A, B;
    for (int i = 0; i < M; i++) {
        cin >> A >> B;
        if (H[A - 1] < H[B - 1]) {
            good[A - 1] = false;
        } else if (H[A - 1] > H[B - 1]) {
            good[B - 1] = false;
        } else {
            good[A - 1] = false;
            good[B - 1] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (good[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000000000ll
#define maxn 100010
#define inf (1ll<<60)
#include<queue>
struct node{
	int x,v;
	bool operator < (node a) const{
		return a.v>v;
	}
};
priority_queue<node>q;
int main(){
	int n,m;
	in(n);in(m);
	ll ans=0;
	FOR(i,1,n){
		int x;
		in(x);
		q.push((node){x/2,x-x/2});
		ans+=x;
	}
	while(m--){
		node x=q.top();q.pop();
		ans-=x.v;
		q.push((node){x.x/2,x.x-x.x/2});
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
N,T = map(int,input().split())
list_aaa = [list(map(int,input().split())) for i in range(N)]

min_aaa =1001

for i in range(N):
    if T>= list_aaa[i][1]:
        min_aaa = min(min_aaa,list_aaa[i][0])

if min_aaa ==1001:
    print("TLE")
else:
    print(min_aaa)




Measured memory_bytes: 3060
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut n: usize,
        nums: [u32; n-1]
    }

    let mut cnt = vec![0;n];
    //let n = n as u32;
    //for i in 1..n+1 {
    //    cnt.push(nums.iter().filter(|&n| *n == i).count());
    //}

    for i in nums.iter() {
        let i = *i as usize;
        cnt[i-1] += 1;
    }

    for i in cnt.iter() {
        println!("{}",i);
    }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int lmax = 1;
    int rmin = n;
    rep(i, 0, m) {
        int l, r;
        cin >> l >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }

    int ans = rmin - lmax + 1;
    cout << max(ans, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const string YES = "Yes";
const string NO = "No";
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


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

    ll n,k,d,p;
    cin >> n >> k;
    d = log10(n)/log10(k);

    cout << d+1 << endl;

    return 0;
}


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

using namespace std;

#define NIL -1

struct Node {
    int id;
    int parent;
    int left_child;
    int right_child;

    Node() {
        id = NIL;
        parent = NIL;
        left_child = NIL;
        right_child = NIL;
    };
};

const int MAX_N = 25;
Node T[MAX_N];

int getSibling(int location) {
    if (T[location].parent == NIL)
        return NIL;
    else if (T[location].id == T[T[location].parent].left_child)
        return T[T[location].parent].right_child;
    else if (T[location].id == T[T[location].parent].right_child)
        return T[T[location].parent].left_child;
}

int getDegree(int location) {
    int degree = 0;
    if (T[location].left_child != NIL)
        degree++;
    if (T[location].right_child != NIL)
        degree++;
    return degree;
}

int getDepth(int location, int depth) {
    if (T[location].parent == NIL)
        return depth;
    return getDepth(T[location].parent, depth + 1);
}

int getHeight(int location) {
    int left_height = 0, right_height = 0;
    if (T[location].left_child != NIL) {
        left_height = getHeight(T[location].left_child) + 1;
    }

    if (T[location].right_child != NIL) {
        right_height = getHeight(T[location].right_child) + 1;
    }

    return max(left_height, right_height);
}

string getType(int location) {
    if (T[location].parent == NIL)
        return "root";
    if (T[location].right_child == NIL && T[location].left_child == NIL)
        return "leaf";
    return "internal node";
}


void print(int location) {
    cout << "node " << T[location].id << ": ";
    cout << "parent = " << T[location].parent << ", ";
    cout << "sibling = " << getSibling(location) << ", ";
    cout << "degree = " << getDegree(location) << ", ";
    cout << "depth = " << getDepth(location, 0) << ", ";
    cout << "height = " << getHeight(location) << ", ";
    cout << getType(location) << endl;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int id, left_child, right_child;
        cin >> id >> left_child >> right_child;
        T[id].id = id;
        T[id].left_child = left_child;
        T[T[id].left_child].parent = T[id].id;
        T[id].right_child = right_child;
        T[T[id].right_child].parent = T[id].id;
    }

    for (int i = 0; i < n; ++i) {
        print(i);
    }
}

Measured memory_bytes: 3124
is_prime = [True] * (10**5+1)
is_prime[0] = False
is_prime[1] = False
for i in range(2,int(10**2.5)+1):
    if is_prime[i]:
        for j in range(i * 2, 10**5 + 1, i):
            is_prime[j] = False

s=[0]*(10**5+1)
c=0

for i in range(3,10**5+1):
    if is_prime[i] and is_prime[(i+1)//2]:
        c+=1
    s[i]=c
for i in range(int(input())):
    l,r=map(int,input().split())
    print(s[r]-s[l-1])

Measured memory_bytes: 51416