akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int n,m,X,Y,dp[8][8],a,b,ok;
int ch(int x,int y){
    for(int i=0;i<8;i++){
        if(dp[i][y]==1)return 0;
        if(dp[x][i]==1)return 0;
    }
    X=x,Y=y;
    while(0<=X&&X<8&&0<=Y&&Y<8){
        if(dp[X][Y]==1)return 0;
        X++;Y++;
    }
    X=x,Y=y;
    while(0<=X&&X<8&&0<=Y&&Y<8){
        if(dp[X][Y]==1)return 0;
        X--;Y++;
    }
    X=x,Y=y;
    while(0<=X&&X<8&&0<=Y&&Y<8){
        if(dp[X][Y]==1)return 0;
        X++;Y--;
    }
    X=x,Y=y;
    while(0<=X&&X<8&&0<=Y&&Y<8){
        if(dp[X][Y]==1)return 0;
         X--;Y--;
    }
    return 1;
}
void f(int n){
    //cout<<n<<"W"<<((1<<8)-1)<<endl;
    if(n==((1<<8)-1)){
        for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            if(dp[i][j]==1)cout<<'Q';
            else cout<<'.';
        }
        cout<<endl;
    }
    ok=1;
        return ;}
    for(int i=0;i<8;i++){
        if(((n>>i)&1)==0){
            for(int j=0;j<8;j++){
                if(ch(i,j)==1){
                    dp[i][j]=1;
                    f(n|(1<<i));
                    if(ok==1)return ;
                    dp[i][j]=0;
                }
            }
        }
    }
    return ;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        m|=(1<<a);
        dp[a][b]=1;
    }
    f(m);
}



Measured memory_bytes: 3116
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)
	b := a[0]
	for i := 0; i < n; i++ {
		b = gcd(a[i], b)
	}

	// ff := false
	t := map[int]bool{}
	for i := 0; i < n; i++ {
		fac := factorize(a[i])
		for p := range fac {
			if t[p] {
				if b == 1 {
					fmt.Fprintln(wr, "setwise coprime")
				} else {
					fmt.Fprintln(wr, "not coprime")
				}
				return
			}
			t[p] = true
		}
	}

	// if ff {
	// 	if b == 1 {
	// 		fmt.Fprintln(wr, "setwise coprime")
	// 	} else {
	// 		fmt.Fprintln(wr, "not coprime")
	// 	}
	// } else {
	// }

	fmt.Fprintln(wr, "pairwise coprime")
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func prime(n int) []int {
	res := make([]int, 0)
	f := make([]bool, n+1)
	var m int
	for m = 2; m*m <= n; m++ {
		if f[m] {
			continue
		}
		res = append(res, m)
		for i := m * m; i <= n; i += m {
			f[i] = true
		}
	}
	for i := m; i < n+1; i++ {
		if f[i] {
			continue
		}

		res = append(res, i)
	}
	return res
}

func factorize(n int) map[int]int {
	res := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			res[i]++
			n /= i
		}
	}
	if n != 1 {
		res[n] = 1
	}
	return res
}


Measured memory_bytes: 18028
import sys
import itertools
m,k=map(int,input().split())
if k>=2**m:
    print(-1)
    sys.exit()

if m==0:
    if k==0:
        print("0 0")
    else:
        print(-1)
    sys.exit()
if m==1:
    if k==0:
        print("1 1 0 0")
    else:
        print(-1)
    sys.exit()
    
lst=[]
for i in range(m):
    if (k>>i)&1==1:
        lst.append(2**i)
    
ans_1=[]
for i in range(2**m):
    if i in lst:
        continue
    else:
        ans_1.append(i)

ans_1+=lst
ans_2=[]
for i in range(2**m-1,-1,-1):
    if i in lst:
        continue
    else:
        ans_2.append(i)
ans_2+=lst[::-1]
ans=ans_1+ans_2
print(*ans)

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

int main(){
    int n,m;
    cin >> n;
    string sa[100],sb[100];

    for(int i = 0; i < n; ++i)
        cin >> sa[i];

    cin >> m;

    for(int i = 0; i < m; ++i)
        cin >> sb[i];

    int ans = 0,c;

    for(int i = 0; i < n;++i){
        c = 0;
        for(int j = 0; j < n; ++j){
            if(sa[i] == sa[j]) c++;
        }

        for(int j = 0; j < m; ++j){
            if(sa[i] == sb[j]) c--;
        }

        if(ans < c) ans = c;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion



int main() {
	int n, m; cin >> n >> m;
	vector<string> a(n), b(m);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int j = 0; j < m; j++) cin >> b[j];
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			for (int x = 0; x < m; x++) {
				for (int y = 0; y < m; y++) {
					if (b[x][y] != a[i + x][j + y]) goto Cyan;
				}
			}
			cout << "Yes" << endl;
			goto ans;
		Cyan:;
		}
	}
	cout << "No" << endl;

ans:;
	return 0;
}

Measured memory_bytes: 3612
N = int(input())
C = input()

def main():

    reds = []
    for i in range(N):
        if C[i] == "R":
            reds.append(i +1)

    l = len(reds)
    ans = 0
    for i in range(l):
        if reds[i] > l:
            ans += 1

    print(ans)

main()

Measured memory_bytes: 79508
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const int N=2e5+5;
struct Node
{
    int num;
    bool operator < (const Node&m)const
    {
        return num>m.num;
    }
} vis[N];
int main()
{
   // freopen("in.txt","r",stdin);
    int n,k,x;
    while(~scanf("%d%d",&n,&k))
    {
        mem(vis,0);
        for(int i=0; i<n; i++)
        {
            scanf("%d",&x);
            vis[x].num++;
        }
        sort(vis,vis+N);
        int cnt=0;
        for(int i=k; vis[i].num; i++) cnt+=vis[i].num;
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int N,A[200005];
long long Ans,F[200005];
int main()
{
	scanf("%d",&N);
	for (int i=1;i<=N;i++) scanf("%d",&A[i]);
	if (A[1]){
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<N;i++) if (A[i+1]-A[i]>1){printf("-1\n");return 0;}
	for (int i=2;i<=N;i++) if (A[i]-A[i-1]==1) F[i]=F[i-1]+1,F[i-1]=0;else F[i]=A[i];
	for (int i=1;i<=N;i++) Ans+=F[i];
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, K = MI()
    A = LI()

    for i in range(K-1, N-1):
        b = A[i-K+1]
        f = A[i+1]
        if f > b:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 31012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
    return 0;
  }

  cout << 1 + min((b - 1 + a - 1 - 1) / 2, (n - a + n - b - 1) / 2) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


int main() {
    int A, B;
    cin >> A >> B;

    int res = 0;

    if (A > B) {
        res += A;
        A--;
    } else {
        res += B;
        B--;
    }

    if (A > B) {
        res += A;
        A--;
    } else {
        res += B;
        B--;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
t=input()

tla=list(t)
tlb=list(t)
pd1=0
pd2=0

for i in range(len(tla)):
  if tla[i]=="?":
    if i==0:
      pass
    elif i==len(tla)-1:
      tla[i]="D"
    elif tla[i-1]=="P":
      tla[i]="D"
    elif tla[i+1]=="D":
      tla[i]="P"
    elif tla[i+1]=="?":
      tla[i]="P"
    else:
      tla[i]="D"
  if tla[i]=="D":
    if i==0:
      pass
    elif tla[i-1]=="P":
      pd1+=1
d1=tla.count('D')
s1=d1+pd1

for i in range(len(tlb)):
  if tlb[i]=="?":
    tlb[i]="D"
  if tlb[i]=="D":
    if i==0:
      pass
    elif tlb[i-1]=="P":
      pd2+=1
d2=tlb.count('D')
s2=d2+pd2

if s1>s2:
  print(''.join(tla))
else:
  print(''.join(tlb))

Measured memory_bytes: 12528
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

ll dp[3001][3001][4];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  for(int i=0; i<3001; i++){
    for(int j=0; j<3001; j++){
      for(int k=0; k<4; k++){
        dp[i][j][k] = 0;
      }
    }
  }
  int R,C,K;
  cin >> R >> C >> K;
  vector<vector<ll>> G(R,vector<ll> (C,0));
  for(int i=0; i<K; i++){
    int r,c,v;
    cin >> r >> c >> v;
    r--;c--;
    G[r][c] = v;
  }
  for(int i=0; i<R; i++){
    for(int j=0; j<C; j++){
      for(int k=0; k<=3; k++){
        // 行移動
        chmax(dp[i+1][j][0],dp[i][j][k]);
        if(k != 3){
          chmax(dp[i+1][j][0],dp[i][j][k] + G[i][j]);
        }
        // 列移動
        chmax(dp[i][j+1][k],dp[i][j][k]);
        if(k != 3){
          chmax(dp[i][j+1][k+1],dp[i][j][k] + G[i][j]);
        }
      }
    }
  }
  ll ans = 0;
  for(int i=0; i<=3; i++){
    chmax(ans,dp[R][C-1][i]);
    chmax(ans,dp[R-1][C][i]);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 355020
import math
n = int(input())
d = {}
for i in range(1,(int(math.sqrt(n)))+1):
  if (n/i).is_integer():
    d.setdefault(i,n//i)
ans = []
for k,v in d.items():
  ans.append((k-1)+(v-1))
print(min(ans))

Measured memory_bytes: 40428
'''
制約 1< n< 200
'''
def make_divisors(n):
    '''約数のリストを返す
    '''
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors



n = int(input())
ans = 0
for i in range(1, n+1, 2):
    if len(make_divisors(i)) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3064
# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class Node:

    def __init__(self, nid):
        self.node_id = nid
        self.color = -1
        self.next = []


def main():
    n, k = list(map(int, readline().split()))

    nodes = [Node(i) for i in range(n)]

    for i in range(n - 1):
        a, b = list(map(int, readline().split()))
        a, b = a - 1, b - 1
        nodes[a].next.append(b)
        nodes[b].next.append(a)

    que = deque()
    que.append((0, 0, 0))

    while que:
        current_id, cn_1, cn_2 = que.popleft()

        cl = k - cn_1 - cn_2

        if cl <= 0:
            print(0)
            sys.exit()

        nodes[current_id].color = cl

        for nid in nodes[current_id].next:
            if nodes[nid].color == -1:
                cn_1 += 1
                que.append((nid, 1, cn_1 - 1))

    ans = 1
    for i in range(n):
        ans *= nodes[i].color
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define INF 1e9
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

class TaskA {
public:
    void solve() {
        long long a, b, ans = 0;
        cin >> a >> b;
        while (a > 0) {
          a -= b;
          ans++;
        }
        cout << ans;
    }
};

int main() {
//    freopen("absum.in","r",stdin);
//    freopen("absum.out","w",stdout);
    TaskA solver;
    solver.solve();
}


Measured memory_bytes: 256
import itertools
from scipy.spatial import distance

n, d = list(map(int, input().split()))

xs = []

for i in range(n):
	xs.append(list(map(int, input().split())))

pairs = list(itertools.combinations(xs, 2))

print(sum([True if distance.euclidean(pair[0], pair[1]) % 1 == 0 else False for pair in pairs]))

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



int main(){
  int N;
  cin >> N;
  vector<long long> V(N);
  rep(i,N){
    cin >> V[i];
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  long long ans = V[0];
  int i = 1;
  int counter = 1;
  while(true){
    for(int j = 0;j<2;j++){
      counter++;
      if(counter==N)break;
      ans += V[i];      
    }
    i++;
    if(counter==N)break;
  }
    

  cout << ans << endl;
}

      
  
  



Measured memory_bytes: 4832
arr = input()

chars = dict()

for i in range(len(arr)):
    chars.setdefault(arr[i], [])
    chars[arr[i]].append(i)

for _, inds in chars.items():
    for i in range(len(inds) - 1):
        if inds[i + 1] - inds[i] < 3:
            print(inds[i]+1, inds[i + 1]+1)
            exit()
print(-1, -1)


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

typedef long long LL;

const int N = 3e3;

int n, p, s[N + 5][N + 5], c[N + 5][N + 5];

int power(int x, int k, int mod) {
	int ans = 1;
	for (; k >= 1; k >>= 1, x = (LL)x * x % mod) {
		if (k & 1) {
			ans = (LL)ans * x % mod;
		}
	}
	return ans;
}
void init(int n) {
	c[0][0] = s[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		c[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % p;
			s[i][j] = (s[i - 1][j - 1] + (LL)j * s[i - 1][j] % p) % p;
		}
	}
}
int main() {
	scanf("%d%d", &n, &p);
	init(n + 1);
	int ans = 0;
	for (int sgn = 1, i = 0; i <= n; i++, sgn = p - sgn) {
		int sum = 0, pw0 = power(2, n - i, p);
		for (int cur = 1, j = 0; j <= i; cur = (LL)cur * pw0 % p, j++) {
			sum = (sum + (LL)s[i + 1][j + 1] * cur % p) % p;
		}
		ans = (ans + (LL)sgn * c[n][i] % p * sum % p * power(2, power(2, n - i, p - 1), p) % p) % p;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 69504
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint K, X; cin >> K >> X;
    cout << (500 * K >= X ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
unittest
{
	assert( [ "10", "aabbbbaaca" ].parse.expand.solve == 5 );
	assert( [ "5", "aaaaa" ].parse.expand.solve == 1 );
	assert( [ "20", "xxzaffeeeeddfkkkkllq" ].parse.expand.solve == 10 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return s.group.walkLength;
}


Measured memory_bytes: 2940
A = list(input())
B = list(input())
C = list(input())
pv = "abc"
p = 0
while True:
    if p == 0:
        if len(A) == 0:
            print("A")
            break
        p = pv.index(A.pop(0))
    elif p == 1:
        if len(B) == 0:
            print("B")
            break
        p = pv.index(B.pop(0))
    else:
        if len(C) == 0:
            print("C")
            break
        p = pv.index(C.pop(0))

Measured memory_bytes: 3064
main = do
    n <- readLn
    putStrLn $ solve n

lp = [x*y|x<-[1..9],y<-[x..9]]

solve :: Int -> String
solve n = search n lp
    where search n [] = "No"
          search n (x:xs)
            | n == x = "Yes"
            | otherwise = search n xs

Measured memory_bytes: 508
import collections

N = int(input())
S_list = []
for i in range(N):
  S_list.append(input())
c = collections.Counter(S_list)
most_count = c.most_common()[0][1]

ans_list = []
for i in c.items():
  if i[1] == most_count:
    ans_list.append(i[0])

ans_list.sort()

for i in ans_list:
  print(i)

Measured memory_bytes: 45116
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long mod_inv(long long n)
{
    long long left=MOD-2;
    long long num=n;
    long long ans=1;
    while(left!=0)
    {
        if(left%2==1)ans=(ans*num)%MOD;
        left/=2;
        num=(num*num)%MOD;
    }
    return ans;
}

int main()
{
    long long ans=1;
    long long x,y;cin>>x>>y;
    if((x+y)%3!=0)ans=0;
    else if(x>2*y||y>2*x)ans=0;
    else
    {
        long long move=(x+y)/3;
        long long dis=abs(x-y);
        long long smal=(move-dis)/2;
        long long lar=smal+dis;
        int i;
        for(i=1;i<=smal;i++)
        {
            ans=ans*(move+1-i)%MOD;
            ans=ans*mod_inv(i)%MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
a, b, m = map(int, input().split())
re = list(map(int, input().split()))
de = list(map(int, input().split()))
mre = min(re)
mde = min(re)
list1 = []
for i in range(m):
  x, y, c = map(int, input().split())
  price = re[x-1] + de[y-1] -c
  list1.append(price)
mlist = min(list1)
m1 = mre + mde

if m1 < mlist:
  print(m1)
else:
  print(mlist)


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

int main(){
  int N,M;
  cin>>N>>M;
  
  vector<int> A(N);
  int t=0;
  for(int i=0;i<N;++i){
      cin>>A[i];
      t+=A[i];
  }
  
  int c=0;
  for(int i=0;i<N;++i){
      if(A[i]>=t/(4.0*M))++c;
  }
  
  if(c>=M)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int index[1<<19];
int xor_sum[1<<19];
int ans[1<<19];
bool vis[1<<19];
int main(){
	int m,k;
	scanf("%d %d",&m,&k);
	if(m==0){
		if(k==0)
			printf("0 0\n");		
		else
			printf("-1\n");
		return 0;
	}else if(m==1){
		if(k==0)
			printf("0 0 1 1\n");		
		else
			printf("-1\n");
		return 0;
	}else{
		if(k>((1<<m)-1))
			printf("-1\n");
		else{
			for(int i=0;i<=((1<<m)-1);i++)
				if(i!=k)
					printf("%d ",i);
			printf("%d ",k);
			for(int i=((1<<m)-1);i>=0;i--)
				if(i!=k)
					printf("%d ",i);
			printf("%d ",k);	
		}
	}
	return 0;	
}

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

int main(){
	int n, k, s, b;
	
	while( cin >> n >> k , n || k ){
		vector<int> S;
		for(int i=0 ; i<k ; i++ ){
			cin >> s;
			S.push_back(s);
		}
		for(int i=0 ; i<n ; i++ ){
			for(int j=0 ; j<k ; j++ ){
				cin >> b;
				S[j] -= b;
			}
		}
		bool flag = true;
		for(int i=0 ; i<k ; i++ ){
			if( S[i] < 0 ){
				flag = false;
			}
		}
		cout << ( (flag)? "Yes" : "No" ) << endl;
	}
}

Measured memory_bytes: 892
#-*-coding:utf-8-*-

def main():
    while True:
        height,width=map(int,input().split())
        if height==0 and width ==0:
            break
        for i in range(height):
            sharp=""
            if i%2==0:                
                for j in range(width):
                    if j%2==0:
                        sharp+="#"
                    else:
                        sharp+="."
            else:        
                for j in range(width):
                    if j%2==0:
                        sharp+="."
                    else:
                        sharp+="#"
            print(sharp)
        print("")

if __name__=="__main__":
    main()


Measured memory_bytes: 5620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputLine = input.Split();

            int num = Array.IndexOf(inputLine, "0");
            Console.WriteLine(num + 1);
        }
    }
}


Measured memory_bytes: 25888
module Split = struct
let rec str_split str spchar =
    match str with
    | "" -> []
    | str ->
            try
                let spchar_index = String.index str spchar in
                let substr = String.sub str 0 spchar_index in
                if (spchar_index + 1) == (String.length str)
                then [substr]
                else
                    let rest = String.sub str (spchar_index + 1) ((String.length str) - spchar_index - 1) in
                    substr::(str_split rest spchar)
            with
                 Not_found -> [str]
                | Invalid_argument e -> []
end

let _ =
    let instr = read_line () in
    let instrlist = Split.str_split instr ' ' in
    let x = int_of_string (List.hd instrlist) in
    let y = int_of_string (List.hd (List.tl instrlist)) in
    print_int (x + (y / 2));
    print_newline ();


Measured memory_bytes: 384
N, M, X, Y = map(int, input().split())

X_list = [X]
X_list.extend(list(map(int, input().split())))
Y_list = [Y]
Y_list.extend(list(map(int, input().split())))


if max(X_list) < min(Y_list):
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

#define e pow(10,18);

int main ()
{
    int N;
    long long i,A[100005],n,zero;
    scanf("%d",&N);
    zero=0;
    n=e;
        for (i=0;i<N;i++)
    {
        scanf ("%lld",&A[i]);
        if (A[i]==0)
            zero++;
    }
        if (zero>=1)
        {
            printf("0\n");
            return 0;
        }
       long long m=1;
     for (i=0;i<N;i++)
     {
         if (A[i]<=n/m)
         {
             m=m*A[i];
         }
         else
         {
             printf("-1\n");
             return 0;
         }
     }
    printf("%lld\n",m);
    return 0;
}


Measured memory_bytes: 2516
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string ac = "AC";
	string wa = "WA";
	string tl = "TLE";
	string re = "RE";
	int a[4];
	memset(a, 0, sizeof(a));
	int n;
	cin >> n;
	for (int i=0; i<n; i++) {
		string s;
		cin >> s;
		if (s == ac) a[0]++;
		else if (s == wa) a[1]++;
		else if (s == tl) a[2]++;
		else a[3]++;
	}
	string ss = " x ";
	cout << ac << ss << a[0] << '\n';
	cout << wa << ss << a[1] << '\n';
	cout << tl << ss << a[2] << '\n';
	cout << re << ss << a[3] << '\n';
}

Measured memory_bytes: 3656
open Batteries
open Printf
let () =
  let h,w = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let s_l = Array.to_list @@ Array.init h (fun _ -> Scanf.scanf "%s " (fun a -> a)) in

  let rec aux n res = 
    if n = 0 then res else
      aux (n-1) ("#" ^ res)
  in
  print_endline @@ aux w "##";

  List.iter (fun x -> print_string "#";
              print_string x;
              print_endline "#";
            ) s_l;

  print_endline @@ aux w "##"


Measured memory_bytes: 3072
/*********** Template Starts Here ***********/

/*************** Shadman Taqi ***************/
#include<bits/stdc++.h>
using namespace std;

#define MAX 500
#define ll long long
#define ull unsigned long long
#define ___   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = b; i >= a; i--)
#define debug(x) cout << #x << " " << x << endl;
#define in(x) cin>>x;
#define out(x) cout<<x;
#define gap cout<<" ";
#define nl cout<<endl;
#define cs(x) cout<<"Case "<<x<<": ";

/*********** Template Ends Here ***********/

/** ################################## Code starts here ################################### **/

int main()
{
    ___
    ll K,N,sum=0,c=0,term=0;
    in(K)   in(N)
    int A[N+3];
    f(i,1,N)
        cin>>A[i];
    f(i,1,N-1)
    {
        term= A[i+1]-A[i];
        sum+= term;
        c=max(c,term);
    }
    term=K-A[N]+A[1];
    sum+= term;
    c=max(c,term);
    sum-=c;
    cout<<sum<<endl;
    return 0;
}

/** ################################## Happy Coding ################################### **/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[1000010],finv[1000010],inv[1000010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,1000010){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=invmod(i,mod);
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
vector<bool> IsPrime(1000010,true);
void sieve(ll n){
    IsPrime[0]=0;
    IsPrime[1]=0;
    REP(i,2,n+1){
        if(IsPrime[i]){
            ll k=2;
            while(k*i<=n){
                IsPrime[k*i]=0;
                k++;
            }
        }
    }
}
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>p(1000001);
    sieve(1000001);
    combinit();
    rep(i,n){
        ll s=a[i];
        REP(j,2,sqrt(a[i])+1){
            if(!IsPrime[j])continue;
            ll cnt=0;
            while(s%j==0){
                s/=j;
                cnt++;
            }
            p[j]=max(p[j],cnt);
        }
        if(s!=1)p[s]=max(p[s],1LL);
    }
    ll ans=1;
    REP(i,2,1000001){
        if(p[i]){
            ll k=p[i];
            while(k){
                k--;
                ans=(ans%inf*i%inf);
                ans%=inf;
            }
        }
    }
    ll b=0;
    rep(i,n){
        b=(b+(ans*(inv[a[i]])%inf))%inf;
        b%=inf;
    }
    b%=inf;
    if(b<0)b+=inf;
    cout<<b<<endl;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

void WarshallFloyd(vector<vector<int>> &D) {
    REP(k, 0, D.size()) {
        REP(i, 0, D.size()) {
            REP(j, 0, D.size()) {
                D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
            }
        }
    }
}

int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> C(10, vector<int>(10));
    REP(i, 0, 10) REP(j, 0, 10) cin >> C[i][j];

    vector<vector<int>> A(H, vector<int>(W));
    REP(i, 0, H) REP(j, 0, W) cin >> A[i][j];

    WarshallFloyd(C);
    int ans = 0;
    REP(i, 0, H) REP(j, 0, W) {
        if (A[i][j] == 1 || A[i][j] == -1) continue;
        ans += C[A[i][j]][1];
    }

    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;

template <class T>
class BIT
{
private :
    vector<T> bit;
    int n;
public :
    T sum(int, T);
    void add (int, T, T);

    BIT (int i) {
        n = i;
        bit.resize(i + 1);
    }
};

template <typename T>
T BIT<T>::sum (int i, T K) {
    T s = (T)(0);
    while (i) {
        s += bit[i];
        s %= K;
        i -= i & -i;
    }

    return s;
}

template <typename T>
void BIT<T>::add (int i, T x, T K) {
    while (i <= n) {
        bit[i] += x;
        bit[i] %= K;
        i += i & -i;
    }
}

int main() {
    ll A, B, P;
    while (cin >> A >> B >> P, A || B || P) {
        vector<string> vs;
        for (int i = A; i <= B; i++) {
            stringstream ss;
            ss << i;
            string s;
            ss >> s;
            vs.push_back(s);
        }

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

        BIT<ll> b(B - A + 1);
        for (int i = 0; i < vs.size(); i++) {
            stringstream ss;
            ss << vs[i];
            ll v;
            ss >> v;
            ll sum = b.sum((int)(v-A), P);
            b.add((int)(v-A+1LL), sum + 1LL, P);
        }

        cout << b.sum(B - A + 1LL, P) << endl;
    }

    return 0;
}

Measured memory_bytes: 9260
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <bitset>
#include <memory>

int main() {
	int n, m; std::cin >> n >> m;
	int max = 1;
	for (int i = 1; i * i <= m; ++i) {
		if (m % i == 0) {
			if (m / i >= n) max = std::max(max, i);
			if (i >= n) max = std::max(max, m / i);
		}
	}
	std::cout << max << '\n';
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl10
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
 SS(int,a,b,t);
p((t/a)*b);

}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  int n = 0;
  int w = 0;
  int s = 0;
  int e = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'N') {
      ++n;
    }
    if (S[i] == 'W') {
      ++w;
    }
    if (S[i] == 'S') {
      ++s;
    }
    if (S[i] == 'E') {
      ++e;
    }
  }
  if ((n > 0 && s > 0 && w > 0 && e > 0) || (n > 0 && s > 0 && w == 0 & e == 0) ||
      (n == 0 && s == 0 && w > 0 && e > 0)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3008
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    sc.close();

    String[] S = s.split("");
    
    Deque<String> deque = new ArrayDeque<>();

    for (int i = 0; i < S.length; i++) {
      if (S[i].equals("0")) {
        deque.addLast("0");
      }
      if (S[i].equals("1")) {
        deque.addLast("1");
      }
      if (S[i].equals("B")) {
        if (0 < deque.size()) {
          deque.pollLast();
        }
      }
    }

    int l = deque.size();

    for (int i = 0; i < l; i++) {
      System.out.print(deque.poll());
    }

    System.out.println("");

  }

}

Measured memory_bytes: 23124
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    string s;
    string res;
    cin >> s;

    int ssizein = s.size()-2;
    string ans = s[0] + to_string(ssizein) + s[s.size()-1];

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC=[list(map(int,input().split())) for i in range(Q)]

suma=sum(A)
dicA=defaultdict(int)
for a in A:
    dicA[a]+=1

for b,c in BC:
    D=(c-b)*dicA[b]
    suma+=D
    e=dicA[b]
    dicA[b]=0
    dicA[c]+=e
    print(suma)


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

int main()
{
    int n,w;cin>>n>>w;
    vector<pair<int,int>> items(n);
    for(auto &a : items)
    {
        cin>>a.first>>a.second;
    }

    int weight = 0;
    long long int k[n+1][w+1];
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            if(i == 0 || j == 0)
                k[i][j] = 0;
            else if(items[i-1].first <= j)
            {
                k[i][j] = max(items[i-1].second+k[i-1][j-items[i-1].first], k[i-1][j]);
            }
            else
            {
                k[i][j] = k[i-1][j];
            }
            
        }
    }

    cout<<k[n][w]<<"\n";
}

Measured memory_bytes: 79104
#include<iostream>

using namespace std;

int main() {
	long long x, y, a;

	cin >> x >> y;

	a = y / x;

	int count = 0;
	while (a > 1) {
		a /= 2;
		count++;
	}

	cout << count + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   vi a(4),b(4);
   rep(i,4)cin>>a[i];
   rep(i,4)cin>>b[i];
   if(accumulate(all(a),0)>accumulate(all(b),0)) cout << accumulate(all(a),0) <<endl;
   else cout << accumulate(all(b),0) <<endl;
}

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

// 各桁の和を計算する関数
int sumOfDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int sum = sumOfDigits(N);
//  cout << sum << endl;

  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N; cin >> N;
    vll ans(N, 0);
    for(ll i = 1; i < N; i++) {
        ll a;
        cin >> a;
        a--;
        ans[a]++;
    }
    for(auto a : ans) cout << a << endl;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define int long long
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
int T, a, b, c, d;
map<int, int> mp;
main(void) {
  for(read(T); T --;) {
    read(a); read(b); read(c); read(d);
    mp.clear();
    if(b > d || a < b) puts("No");
    else {
      int p = __gcd(d, b);
      int ta = (a - c) % p + c;
      if(ta == c) ta += p;
      if(ta < b) puts("No");
      else puts("Yes");
    }
  }
}


Measured memory_bytes: 256
/*	Success may not come to me immediately,
 *	but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li	int64_t
#define ld	double_t
#define ulli	uint64_t
//=====================================================================
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define repi(i,v)	for(i=v.begin();i!=v.end();i++)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
#define nl		cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>	 vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb	push_back
#define pob	pop_back
#define pf	push_front
#define pof	pop_front
#define all(v)	v.begin(),v.end()
#define itr	iterator
#define sz	size()
#define lb	lower_bound
#define ub	upper_bound
#define bs	binary_search
#define mp	make_pair
#define F	first
#define S	second
//=====================================================================
#define mod	(li)(1e9+7)
#define inf	(li)(1e18)
#define MX1	(li)(1e5+5)
#define MX2	(li)(1e6+5)
#define pi	acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a);}
a=(a*a);b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return 1<<n;}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/
 
li n,a[2*MX1],res[2*MX1],mark[2*MX1];
 
void solve(){
	li i,j=1;cin>>n;
	rep(i,1,n+1) cin>>a[i];
	for(i=n;i>=1;i-=2){
		mark[i]=1;
		res[j++]=a[i];
	}
	for(i=1;i<=n;i++){
		if(!mark[i]){
			res[j++]=a[i];
		}
	}
	rep(i,1,n+1) cout<<res[i]<<" ";
}
 
int main(){
	opt
/*     #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	li t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;

int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=1;
  for(int i=0;i<n;i++){
    ans*=k;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define int long long int
#define boost ios_base::sync_with_stdio(false)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//#define test int t;cin>>t; while(t--)
#define vi vector<int> 
#define mi map<int,int> 
#define rrep(i,a,b) for(int i=a;i>=b;i--)
//typedef pair <int,int> pii
//typedef vector<pii> vpi
#define build(arr,n) { int arr[n+1]; repp(i,1,n)cin>>arr[i]; }
#define buildv(v,n) { vi v; repp(i,1,n){int x; cin>>x; v.pb(x);} } 
#define in_edges(m) repp(i,1,m){int a,b; cin>>a>>b; adj[a].pb(b); adj[b].pb(a);}
#define mod 1000000007
#define pi 3.1415926
#define mx(arr) {*max_element(arr+1,arr+n+1);} 
using namespace std;
//vector<int> adj[100003];
//int vis[100003]={0};
//int dp[n+1]={0};
//vector<int> leaf;
signed main()
{
    int t; cin>>t; 
    string ans;
    int n=t%10;
    if(n==2||n==4||n==5||n==7||n==9)cout<<"hon";
    else if(n==3)cout<<"bon"<<endl;
    else
    cout<<"pon"<<endl;
        
    
    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
//Compiler version g++ 6.3.0
int fact(LL n){
  if(n==1||n==0){
    return 1; 
  }  
  else{
    return fact(n-1)*n;}
}
int main()
{
  LL a, b,c,k;
  cin>>a>>b>>c>>k; 
  LL d=0;
  while(a>=b){
    d++;
    b*=2;  
  }
  while(b>=c){
    d++;
    c*=2;  
  }
  if(d<=k) {
    cout<<"Yes"<<endl; 
  }
  else{
    cout<<"No"<<endl;} 
  return 0; 
 }
       


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,c,k; cin>>a>>b>>c>>k;
	int ans=min(a,k); k=max(0,k-a); k=max(0,k-b); ans-=k;
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3636