akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
// Function to return trailing  
// 0s in factorial of n 
int findTrailingZeros(int n) 
{ 
    // Initialize result 
    int count = 0; 
  
    // Keep dividing n by powers of  
    // 5 and update count 
    for (int i = 5; n / i >= 1; i *= 5) 
        count += n / i; 
  
    return count; 
} 
int32_t main(){
	int n;cin>>n;
	if(n%2==1)cout<<0<<endl;
	else cout<<findTrailingZeros(n/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
import sys
input = sys.stdin.readline

def main():
    N, D, A = map(int, input().split())
    B = []

    for i in range(N):
        x, h = map(int, input().split())
        B.append((x,h))

    B.sort()
    X = [0] * N
    H = [0] * N
    for i in range(N):
        X[i], H[i] = B[i]
    ans = 0
    ok = [False] * N
    S = [0] * (N + 1)
    for i in range(N):
        if S[i] < H[i]:
            cnt = (H[i] - S[i]) // A if (H[i] - S[i]) % A == 0 else (H[i] - S[i]) // A + 1
            ans += cnt
            search_max = bisect_right(X, X[i] + 2 * D)
            S[i] += cnt * A
            S[search_max] -= cnt * A
        
        S[i+1] += S[i]

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 68188
N,K=gets.split(" ").map(&:to_i)
h=[]
N.times{
	h<<gets.to_i
}
h=h.sort
min=1000000000
for i in 0..N-K
	dif=h[i+K-1]-h[i]
	if dif<min
		min=dif
	end
end
puts min

Measured memory_bytes: 4528
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    string s;
    cin>>s;
    bool checked[26]={};
    int ans=INF;
    rep(i,s.size()){
        int num=s[i]-'a';
        if(checked[num]) continue;
        checked[num]=true;
        string t=s;
        int tmp=0;
        while(1){
            bool flag=true;
            for(int j=1;j<t.size();j++){
                if(t[j-1]!=t[j]){flag=false;break;}
            }
            if(flag){ans=min(ans,tmp);break;}
            string sub="";
            for(int k=0;k<t.size()-1;k++){
                if(t[k]==s[i]||t[k+1]==s[i]){
                    sub+=s[i];
                }
                else{
                    sub+=t[k];
                }
            }
            tmp++;
            t=sub;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m,n;
	cin>>n>>m;
	if(n==1) n=14;
	if(m==1) m=14;
	if(n==m) cout<<"Draw";
	else if(n<m) cout<<"Bob";
	else cout<<"Alice";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int n,a;
    cin>>n>>a;
    vector<int> x(n);
    rep(i,0,n) cin>>x[i];
    
    auto dp=make_vec<ll>(55,3000,55);
    dp[0][0][0]=1;
    
    rep(i,0,n){
        rep(j,0,2700){
            rep(k,0,n){
                dp[i+1][j+x[i]][k+1]+=dp[i][j][k];
                dp[i+1][j][k]+=dp[i][j][k];
            }
        }
    }
    
    ll ans=0;
    rep(i,1,n+1){
        ans+=dp[n][a*i][i];
    }
    cout<<ans<<endl;
}


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

class Node {
  public:
    vector<int> children;
    int score;
    int cost;
    Node() { score = 0; cost = 0; }
};

void dfs(vector<Node>& node, int id, int pre, int cost)
{
  cost += node.at(id).cost;
  node.at(id).score = cost;
  for (int next : node.at(id).children) {
    if (next == pre) {
      continue;
    }
    dfs(node, next, id, cost);
  }
}

int main()
{
  int nnode, nquery;
  cin >> nnode >> nquery;
  vector<Node> node(nnode+1);
  for (int i = 0; i < nnode-1; i++) {
    int from, to;
    cin >> from >> to;
    node.at(from).children.push_back(to);
    node.at(to).children.push_back(from);
  }
  for (int i = 0; i < nquery; i++) {
    int id, cost;
    cin >> id >> cost;
    node.at(id).cost += cost;
  }
  dfs(node, 1, 0, 0);
  cout << node.at(1).score;
  for (int i = 2; i <= nnode; i++) {
    cout << ' ' << node.at(i).score;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 27392
#include <stdio.h>

int main() {
  int n,m;
  scanf("%d %d",&n,&m);
  int min = 0;
  int max = n;
  for(int i = 0;i < m;i++){
    int L,R;
    scanf("%d %d", &L, &R);
    if(min < L)min = L;
    if(max > R)max = R;
  }
  if(max >= min)printf("%d\n",max - min + 1);
  else printf("0\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>
using namespace std;

int main() {
	char a[3][3];
	for (int i = 0; i < 3;i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cout << a[0][0] << a[1][1] << a[2][2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    string S;
    cin >> S;
    if (S == "ABC") puts("ARC");
    else puts("ABC");
    return 0;
    // ll, 0, -, 1i, for s&g
}

Measured memory_bytes: 3584
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp;
    switch (N[$-1]) {
        case '3': writeln("bon"); return;
        case '0':
        case '1':
        case '6':
        case '8': writeln("pon"); return;
        default: writeln("hon"); return;
    }
}

Measured memory_bytes: 2632
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
  char ch;
  cin>>ch;
  if(ch=='A')
    cout<<'T';
  else if(ch=='T')
    cout<<'A';
  else if(ch=='G')
    cout<<'C';
  else
    cout<<'G';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef struct mtpj{
  int No,time,ACcnt,WAcnt[11];
  bool AC[11];
  static bool comp(const mtpj& hm,const mtpj& hmhm){
    if(hm.ACcnt!=hmhm.ACcnt) return hm.ACcnt>hmhm.ACcnt;
    if(hm.time!=hmhm.time) return hm.time<hmhm.time;
    return hm.No>hmhm.No;
  }
}P;
P p[50];
int main(){
  int M,T,P,R;
  int m,t,q,J;
  int TEcnt;
  while(cin >> M >> T >> P >> R && M|T|P|R){
    TEcnt = 0;
    for(int i=1;i<=T;i++){
      p[i].time=p[i].ACcnt=0,p[i].No=i;
      for(int j=1;j<=10;j++) p[i].WAcnt[j]=0,p[i].AC[j]=false;
    }

    for(int i=0;i<R;i++){
      cin >> m >> t >> q >> J;
      if(p[t].AC[q])continue;
      if(J==0){ //AC
	p[t].AC[q] = true;
	p[t].ACcnt++;
	p[t].time += p[t].WAcnt[q]*20 + m;
      }else p[t].WAcnt[q]++; //WA
    }
    sort(p+1,p+T+1,mtpj::comp);
    for(int i=1;i<=T;i++){
      if(p[i-1].time==p[i].time && p[i-1].ACcnt==p[i].ACcnt&&i!=1){
	cout << "=";
      }else if(i!=1){
	cout << ",";
      }
      cout << p[i].No;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    string t;
    cin >> t;

    string s;
    for(int i = 0; i < t.length(); i++){
        if(t[i] == '?'){
            s += 'D';
        }
        else{
            s += t[i];
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3836
#キーエンスプログラミングコンテスト2022-B-Robot Arms
n = int(input())
arm = []
for i in range(n):
    r,l = map(int,input().split())
    arm.append([r+l, r-l])
    
arm.sort()

ans = 1

max_r = arm[0][0]

for i in range(n-1):
    
    if max_r <= arm[i+1][1]:
        ans += 1
        max_r = arm[i+1][0]
        

print(ans)
        
        

Measured memory_bytes: 20108
ops = list(input().split())
stk = []
for i in ops:
    if i == '+':
        y = stk.pop()
        x = stk.pop()
        stk.append(int(x) + int(y))
    elif i == '-':
        y = stk.pop()
        x = stk.pop()
        stk.append(int(x) - int(y))
    elif i == '*':
        y = stk.pop()
        x = stk.pop()
        stk.append(int(x) * int(y))
    else:
        stk.append(i)
print(stk[0])


Measured memory_bytes: 5600
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ( a == b ) cout << c << endl;
    else if ( b == c ) cout << a << endl;
    else               cout << b << endl;
    return 0;
}


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

ll solve() {
    string S;
    cin >> S;
    ll ans = 0;
    if ( S == "SUN" ) ans = 7;
    if ( S == "MON" ) ans = 6;
    if ( S == "TUE" ) ans = 5;
    if ( S == "WED" ) ans = 4;
    if ( S == "THU" ) ans = 3;
    if ( S == "FRI" ) ans = 2;
    if ( S == "SAT" ) ans = 1;
    if ( S == "SUN" ) ans = 7;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
N=int(input())
def gcd(a,b):
  if a==b:
    return a
  else:
    a,b=max(a,b),min(a,b)
    if a%b==0:
      return b
    return gcd(b,a%b)  
if N%2==0:
  print(N)
else:
  lcm=int(2*N/gcd(2,N))
  print(lcm)

Measured memory_bytes: 3060
N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
T = [0]*(N+1)
for i in range(N):
    T[i+1] = T[i]+t[i]
def f(i, t):
    
    if T[i]<=t<=T[i+1]:
        return v[i]
    if t<T[i]:
        return v[i]+(T[i]-t)
    else:
        return v[i]+(t-T[i+1])
limit = [0]*(T[-1]*2+1)
for t in range(1, T[-1]*2+1):
    limit[t] = min(min(f(i, t/2) for i in range(N)), t/2, T[-1]-t/2)
print(sum(limit)/2)    

Measured memory_bytes: 47836
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


if __name__ == '__main__':
    N = int(input())
    T = []
    for i in range(N):
        T.append(int(input()))
    tmp = T[0]
    for j in range(N - 1):
        tmp = lcm(tmp, T[j+1])
    print(tmp)


Measured memory_bytes: 3060
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	a := sc.getInt()
	ans := a + a*a + a*a*a
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 1780
fun main(args : Array<String>) {
    val k = readLine()!!.toInt()
    val lun = mutableSetOf<String>()

    if (k < 11) {
        println(k)
        return
    }

    lun.addAll(listOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"))

    var targetLun = lun
    var newLun = mutableSetOf<String>()

    while (lun.size < 100000) {
        newLun = mutableSetOf()
        targetLun.forEach {
            val fd = it.take(1).toInt()
            if (fd != 0) newLun.add("${fd-1}$it")
            if (fd != 9) newLun.add("${fd+1}$it")
            newLun.add("${fd}${it}")
        }
        lun.addAll(newLun)
        targetLun = newLun
    }

    println(lun.filter { it[0] != '0' }.map { it.toLong() }.sorted()[k-1])
}


Measured memory_bytes: 98668
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

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

signed main(void) {
	int a, b;
	cin >> a >> b;
	cout << max(0, a - b * 2) << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
  $input = explode(" ", trim(fgets(STDIN)));
  $a = $input[0];
  $b = $input[1];
  $c = $input[2];
  $k = $input[3];

  $ans = 0;
  $flg = true;

  if($k <= $a){
    $ans = $k;
    $flg = false;
  } else {
    $ans = $a;
    $k = $k - $a;
  }

  if($flg == true && $k <= $b){
    $flg = false;
  } else {
    $k = $k - $b;
  }

  if($flg == true){
    $ans = $ans - $k;
  }

  echo $ans;
?>

Measured memory_bytes: 16096
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner r = new Scanner(System.in);
		int a[] = new int[3];
		int l = 0;
		for(int i = 0;i < 3;i++){
			a[i] = r.nextInt();
		}
		
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < 3;j++){
				if(a[i] < a[j]){
					l = a[i];
					a[i] = a[j];
					a[j] = l;
				}
			}
			
		}
		System.out.println(a[0]+" "+a[1]+" "+a[2]);
	}

}

Measured memory_bytes: 17312
import org.w3c.dom.ls.LSOutput;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int a[]= new int[n];
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        long money=1000;
        for (int start=0;start+1<n;start++){
            int end=start+1;
            if (a[end]<=a[start])continue;
//            while (end<n&&a[end]>a[start]){
//                end++;
//            }
            long times=money/a[start];
            money%=a[start];
            money+=a[end]*times;
//            start=end-1;
        }
        System.out.println(money);

    }
}






Measured memory_bytes: 35920
#include <cstdio>
#include <iostream>
#include <iomanip>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[100];
int main(){
	int n;
	cin >> n;
	int iwa=0;
	rep(i, n) { cin >> a[i]; iwa += a[i]; }
	sort(a, a + n);
	cout << iwa - (a[n-1] / 2) << endl;
}


Measured memory_bytes: 256
import queue
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

inf=100000000
ma=[]
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            x=[[inf for i_sub in range(w)] for j_sub in range(h)]
            #いまみているグリッド
            q=queue.Queue()
            d=0
            #初めのグリッド
            q.put([i,j])
            x[i][j]=0
            #次々にグリッドを辿って全部のグリッド辿ったら終わり
            while q.qsize()!=0:
                #距離を加算
                d+=1
                l=q.qsize()
                #今いるグリッドの数は数えておく
                for t in range(l):
                    I,J=q.get()
                    #今いるグリッドから次のグリッドへ
                    #その判定は"そこにグリッドがあるか","そこが辿れるのか","すでに辿っているのか"の三つです。
                    if I-1>=0 and s[I-1][J]=="." and x[I-1][J]==inf:
                        q.put([I-1,J])
                        #この更新をif文内で行わないと余計にグリッドを調べてしまう
                        x[I-1][J]=d
                    if I+1<=h-1 and s[I+1][J]=="." and x[I+1][J]==inf:
                        q.put([I+1,J])
                        x[I+1][J]=d
                    if J-1>=0 and s[I][J-1]=="." and x[I][J-1]==inf:
                        q.put([I,J-1])
                        x[I][J-1]=d
                    if J+1<=w-1 and s[I][J+1]=="." and x[I][J+1]==inf:
                        q.put([I,J+1])
                        x[I][J+1]=d
            ma_sub=0
            for k in range(h):
                for l in range(w):
                    if x[k][l]!=inf:
                        ma_sub=max(ma_sub,x[k][l])
            ma.append(ma_sub)

print(max(ma))

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

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

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

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  bool takahashi = true;
  while (true) {
    if (takahashi) {
      c -= b;
    } else {
      a -= d;
    }
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    } else if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    takahashi = !takahashi;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#define N 20
#define M 2000

int A[N],m[M],n;
int solve(int,int);

int main(){
  int i,q;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&A[i]);}

  scanf("%d",&q);
  for(i=0;i<q;i++){scanf("%d",&m[i]);}

  for(i=0;i<q;i++){
    if(solve(0,m[i])==1){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}


int solve(int i,int m){
  int res;
  if(m == 0){return 1;}
  if(i >= n){return 0;}
  res = solve(i + 1 , m) || solve(i + 1, m - A[i]);
  return res;
}

  



Measured memory_bytes: 2108
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

vector<LL> dx, dy;
vector<LL> dxsum(1), dysum(1);
map<pair<LL,LL>,LL> memo;

LL solve(LL x, LL n)
{
  if(abs(x)>dxsum.back()-dxsum[n]) return 0;
  if(abs(x)==dxsum.back()-dxsum[n]) return 1;
  if(n==dx.size()) {
    if(x==0) return 1;
    else return 0;
  }
  auto key = make_pair(x,n);
  if(memo.count(key)) return memo[key];
  memo[key] = max(solve(x-dx[n], n+1), solve(x+dx[n], n+1));
  return memo[key];
}

int main(void)
{
  string s;
  LL x,y;
  cin >> s >> x >> y;
  s.push_back('T');
  LL ix=0;
  LL mode = 2, tmp = 0;
  for(auto c:s) {
    if(c=='F') {
      if(mode == 2) ++ix;
      else ++tmp;
    } else {
      if(tmp) {
        if(mode == 0) dx.push_back(tmp);
        else dy.push_back(tmp);
        tmp = 0;
      }
      mode = (mode+1)%2;
    }
  }
  for(auto z:dx) dxsum.push_back(dxsum.back()+z);
  for(auto z:dy) dysum.push_back(dysum.back()+z);
  LL flag = 0;
  flag += solve(x-ix,0);
  dx = dy;
  dxsum = dysum;
  memo.clear();
  flag += solve(y,0);
  cout << (flag==2?"Yes":"No") << endl;
  return 0;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MX 100016

int a[MX];
pii x[MX];

int main()
{
    canhazfast();

    int n, m, k = 0;
    ll ans = 0;

    cin >> n >> m;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a+n);
    //cerr << "a ="; for (int i = 0; i < n; ++i) cerr << ' ' << a[i]; cerr << '\n';
    for (int i = 0; i < m; ++i) cin >> x[i].sec >> x[i].fir;
    sort(x, x+m, greater<pii>());
    for (int i = 0; i < m; ++i) {
        int b = x[i].sec, c = x[i].fir;
        //cerr << "op: b = " << b << " c = " << c << '\n';
        for (int j = 0; j < b; ++j) {
            brif(k == n || a[k] >= c);
            a[k++] = c;
        }
    }
    //cerr << "a ="; for (int i = 0; i < n; ++i) cerr << ' ' << a[i]; cerr << '\n';
    for (int i = 0; i < n; ++i) ans += a[i];
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  ll n,a[3005],res=0;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    res+=(a[i]-1);
  }
  cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	vi p(n), r(n);
	for(int i = 0; i < n; i++) cin >> p[i], r[p[i] - 1] = i + 1; 
	
	for(int i = 0; i < n; i++) cout << 30000 * (i + 1) << " ";
	cout << endl;
	for(int i = 0; i < n; i++) cout << 30000 * (n - 1 - i) + r[i] << " ";
	cout << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3800
H, W = map(int, input().split())
A = [[] for i in range(H)]
for i in range(H):
  A[i] = [int(x) % 2 for x in input().split()]
output = []
for i in range(H - 1):
  for j in range(W):
    if A[i][j] == 1:
      output += [[i + 1, j + 1, i + 2, j + 1]]
      A[i + 1][j] = 1 - A[i + 1][j]
for j in range(W - 1):
  if A[H - 1][j] == 1:
    output += [[H, j + 1, H, j + 2]]
    A[H - 1][j + 1] = 1 - A[H - 1][j + 1]
print(len(output))
for o in output:
  print(o[0], o[1], o[2], o[3])

Measured memory_bytes: 30188
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<int> g[200002];
LL ans[200002];
int sz[200002], c[200002];
int cnt[200002];
void dfs(int u, int p){
    sz[u] = 1;
    int tmp = cnt[c[u]];
    int sum = cnt[c[u]];
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(v == p) continue;
        dfs(v, u);
        sz[u] += sz[v];
        int co = cnt[c[u]]-tmp;
        ans[c[u]] -= (sz[v]-co)*1ll*(sz[v]-co-1)/2;
        tmp = cnt[c[u]];
    }
    cnt[c[u]] = sum+sz[u];
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &c[i]);
    for(int i=1;i<=n-1;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    for(int i=1;i<=n;i++) ans[i] = n*1ll*(n-1)/2;
    dfs(1, 0);
    for(int i=1;i<=n;i++) ans[i] -= (n-cnt[i])*1ll*(n-cnt[i]-1)/2;
    for(int i=1;i<=n;i++) ans[c[i]]++;
    for(int i=1;i<=n;i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 37420
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree = 
//  tree<key, val, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;

int n, m, k;

void solve(int test)
{
  cin >> n;
  cout << (n - 1) * n / 2 - n / 2 << '\n';
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (j == n - 1 - i - (n & 1)) continue;
      cout << i + 1 << ' ' << j + 1 << '\n';
    }
  }
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << endl << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count();
  return 0;
}


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

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  ll t = A[0], sum = 0;
  for (ll i = 1; i < N; i++) {
    if (A[i] > t) {
      t = A[i];
    } else {
      sum += t - A[i];
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 4752
#include <stdio.h>
 
char arr[1000000];
 
int main() {
    scanf("%s", arr);
 
    long long c = 0, t = 0;
    for (char *p = arr; *p != '\0'; p++) {
        t += (*p == 'W') * c;
        c += *p == 'B';
    }
 
    printf("%lld\n", t);
}

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

long long n,c;
long long iwa[35][35]={0};
long long cmemo[3][35]={0};
long long sum[3][35]={0};

int main(){
  long long i,j,k,ans=100000000009;
  cin >> n >> c;
  for(i=1;i<=c;i++)for(j=1;j<=c;j++)cin >> iwa[i][j];
  for(i=1;i<=n;i++)for(j=1;j<=n;j++){
      cin >> k;
      cmemo[(i+j)%3][k]++;
    }
  for(i=0;i<3;i++){
    for(j=1;j<=c;j++){
      for(k=1;k<=c;k++){
	sum[i][k]+=cmemo[i][j]*iwa[j][k];
      }
    }
  }
  for(i=1;i<=c;i++){
    for(j=1;j<=c;j++){
      for(k=1;k<=c;k++){
	if(i==j||j==k||k==i)continue;
	if(ans>sum[0][i]+sum[1][j]+sum[2][k])ans=sum[0][i]+sum[1][j]+sum[2][k];
      }
    }
  }
  
  

  cout <<ans<< endl;

  return 0;
}


Measured memory_bytes: 256
//PDF解説の別解を参考に
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,m,num,var;
  cin>> n >> m;
  vector<vector<int>> v(n+m); //[値,個数]の配列
  for (int i=0; i<n; i++){
    cin>> var;
    v.at(i)={var,1};
  }
  for (int i=0; i<m; i++){
    cin>> num >> var;
    v.at(n+i)={var,num};
  }
  sort(v.begin(),v.end()); reverse(v.begin(),v.end());
  
  int64_t ans=0;
  int count=0;
  for (int i=0; i<n; i++){
    num=v.at(i).at(1); var=v.at(i).at(0);
    while (num>0 && count<n){
      ans+=var;
      num--;
      count++;
    }
    if (count==n) break;
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 11136
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c, d = rm()
print(max(a*b, c*d))









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

int main() {
	long long int x;
	cin >> x;
	long long int yokin = 100;
	int tol = 0;

	while (yokin < x) {
		yokin += yokin / 100;
		tol++;
	}

	cout << tol << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 100 + 5 ; 
char s[N] ;
int n ;  
signed main()
{
	scanf("%s", s + 1 ) ;
	n = strlen( s + 1 ) ;
	int mid = n / 2, ans = 0 ; 
	for( re int i = 1; i <= mid; ++ i ) {
		if( s[i] != s[n - i + 1] ) ++ ans ; 
	}
	printf("%d\n", ans ) ;
	return 0 ;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    REP(i, 2*N){
    	if(i%2==0) cout << S[i/2];
    	else cout << T[i/2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    string s;
    cin >> s;
    bool ans = true;
    for (int i = 0; i < s.size(); i++)
    {
        char a = s[i];
        for (int j = 0; j < i; j++)
        {
            if (a == s[j])
            {
                ans = false;
            }
        }
        for (int k = i + 1; k < s.size(); k++)
        {
            if (a == s[k])
            {
                ans = false;
            }
        }
    }
    if (ans)
    {
        cout << "yes" << endl;
    }
    else
    {
        cout << "no" << endl;
    }
}

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

#define INF 1000000000

typedef struct{
    int cost;           //ノードのコスト
    char done;          //確定ノード
}Node;

int N;
Node node[100000];

void dijkstra(int g){
    int i, j, k,min;
    for(i = 0; i < N; i++){     //初期化
        node[i].cost = INF;
        node[i].done = 0;
    }
    node[g].cost = 0;           //開始地点のコストは0

    while(1){
        min = INF;
        for(i = 0; i < N; i++){
            if(!node[i].done && min > node[i].cost)min = node[i].cost;
        }
        if(node[0].done==1||min==INF)break;
        for(i = 0; i < N; i++){
            if(node[i].cost == min&&!node[i].done){
                node[i].done=1;
                if(i!=N-1){
                    if(node[i+1].cost > node[i].cost + 1){
                        node[i+1].cost = node[i].cost + 1;
                    }
                }else{
                    if(node[0].cost > node[i].cost + 1){
                        node[0].cost = node[i].cost + 1;
                    }
                }
                if(i){
                    j=(i*10)%N;
                    while(node[j].cost!=node[i].cost){
                        node[j].cost = node[i].cost;
                        j=(j*10)%N;
                    }
                }
            }
        }
    }
}

int main()
{
    scanf("%d",&N);
    int i,j;
    dijkstra(1);

    printf("%d\n",node[0].cost+1);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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


using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> p(n), c(n);
    rep(i,n) { cin >> p[i]; p[i]--; }
    rep(i,n) cin >> c[i];
    ll res = -100100100100100;
    rep(i,n){
        ll ans = 0;
        vector<ll> all;
        int now = i;
        while(true){
            now = p[now];
            ans += c[now];
            all.pb(ans);
            if(now ==  i) break;
        }
        int id = (int)all.size();
        if(k < id) rep(j,k) chmax<ll>(res,all[j]);
        else{
            ll num = ((k/id)-1) * max(all[id-1],0ll);
            rep(j,id) chmax<ll>(res,num+all[j]);
            num += max(all[id-1],0ll);
            rep(j,k%id) chmax<ll>(res,num+all[j]);
        }
    }
    cout << res << endl;
    return 0;
}

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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string line = Console.ReadLine();
            int R = 0;
            for(int i=0; i<N; i++)
            {
                if(line[i] == 'R')
                {
                    R++;
                }
            }
            if(R > N - R)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
	int a,b;
	cin>>a>>b;
	string c=to_string(a),d=to_string(b);
	string e="",f="";
	rep(i,a)e+=d;
	rep(i,b)f+=c;
	cout<<min(e,f)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int n,temp=0,c=0;
	vector<int> d;
	cin >> n;
	d.resize(n);
	REP(i,n){
		cin >> d[i];
	}
	sort(d.begin(),d.end());
	REP(i,n){
		if(temp!=d[i]){
			c++;
		}
		temp=d[i];
	}
	cout << c;
	return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << " ";
    return out;
}

istream& operator>> (istream& in, pii& b) {
    in >> b.first >> b.second;
    return in;
}

ostream& operator<< (ostream& out, const pii& b) {
    out << "{" << b.first << ", " << b.second << "}";
    return out;
}

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
#else
    #define dbg(x) 57
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
#endif

const ld PI = acos(-1);

#define time clock() / (double) CLOCKS_PER_SEC

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int a = 1; a <= n; a++) {
        int b = n / a;
        if (n % a == 0) {
            b--;
        }
        if (b == 0) continue;
        ans += b;
    }
    cout << ans;
}
/*

*/

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  
  ll n; cin >> n;
  vector<ll> v(n);
  rep(i,0,n) 
    cin >> v[i];

  ll res = 0;
  for (int i = 1; i < n; i++) {
    if (v[i] < v[i-1]) {
      res += v[i - 1] - v[i];
      v[i] = v[i - 1];
    }
  }
  cout << res;
}

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

int main(void){
    ll n, t[5];
    cin >> n;
    rep(i, 5)
        cin >> t[i];

//    ll t_num[6] = {n, 0, 0, 0, 0, 0};
//
//    ll count = 0;
//    while(t_num[5] != n){
//        ll current_num = 0;
//        for(ll i = 5; i > 0; i--){
//            if(t_num[i-1] >= t[i-1]){
//                t_num[i] += t[i-1];
//                t_num[i-1] -= t[i-1];
//            }else{
//                t_num[i] += min(t[i-1], t_num[i-1]);
//                t_num[i-1] -= min(t[i-1], t_num[i-1]);
//            }
//            current_num += t_num[i];
//            if(current_num == n)
//                break;
//        }
//        rep(i, 6){
//            cout << t_num[i] << " ";
//        }
//        cout << endl;
//        count++;
//    }

    sort(t, t + 5);
    ll count = 5 + ceil(n / (double)t[0]) - 1;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,f=0,g=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
        {
            g++;
            if(a[i]%3==0) f++;
            else if(a[i]%5==0) f++;
        }
    }

    if(f==g) cout<<"APPROVED\n";
    else cout<<"DENIED\n";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
	int t, n, s, f, sum;
	while(1){
		cin >> t;
		if(t == 0){
			break;
		}
		cin >> n;
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> s >> f;
			sum += f - s;
		}
		if(sum >= t){
			cout << "OK" << endl;
		}
		else{
			cout << (t - sum) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int a,b,x;
	cin>>a>>b>>x;
	cout<<min(x/1000 * a + min( (x%1000 != 0) *a ,( (x%1000) / 500 ) * b + ( (x%1000) % 500 != 0  ) * b ) , x/500 * b + (x%500 != 0 ) * min(a,b)  ) <<endl;


	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  ll ans = 0;
  for(int i=1;i<n;i++){
    if(a[i] < a[i-1]){
      ans += a[i-1] - a[i];
      a[i] = a[i-1];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4780
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 int N,X,T;
 cin >> N >> X >> T;
 int ans = N/X;
 double mod = N%X;
 if(mod > 0){
 ans = ans + 1;
 }
  ans = ans * T;
 cout << ans << endl;
}

Measured memory_bytes: 3636
N = int(input())
mod = 10**9 +7
dp = [[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
dp[0][3][3][3] = 1
for i in range(1,N+1):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                for a in range(4):
                    if c2 == 0 and c1 == 1 and a == 2:
                        continue
                    if c2 == 0 and c1 == 2 and a == 1:
                        continue
                    if c2 == 1 and c1 == 0 and a == 2:
                        continue
                    if c3 == 0 and c1 == 1 and a == 2:
                        continue
                    if c3 == 0 and c2 == 1 and a == 2:
                        continue
                    dp[i][c2][c1][a] += dp[i-1][c3][c2][c1]
                    dp[i][c2][c1][a] %= mod
ans = 0
for c1 in range(4):
    for c2 in range(4):
        ans += sum(dp[i][c1][c2])
        ans %= mod
print(ans)

Measured memory_bytes: 3436
#include<iostream>
using namespace std;
int main(){
  int n,k,q,i,b;cin >> n >> k >> q;
  int a[n];
  for (i=0;i<n;i++) a[i] = 0;
  for (i=0;i<q;i++){
    cin >> b;
    a[b-1] += 1;
  }
  for (i=0;i<n;i++){
    cout << ((a[i] > q-k) ? "Yes":"No") << endl;
  }
}
  

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int x;
	cin >> x;
	int ans = 1;
	for (int i = 1; i <= x; i++) {
		int sum = i;
		for (int j = 1; j < 10; j++) {
			sum = sum * i;
			if (sum > x) {
				break;
			}
			if (ans <= sum) {
				ans = sum;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256