akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
    int n,m;
    cin >> n >> m;
    int u;
    vector<int> a(0);
    vector<int> bb(8);
    vector<string> b(8),d(n+1);
    rep(i,8) bb.at(i)=0;
    rep(i,n+1) d.at(i)="0";
    rep (i,m){
        cin >> u;
        if (u==1) {a.push_back(2);bb.at(2)=max(1,bb.at(2));}
        if (u==2) {a.push_back(5);bb.at(5)=max(2,bb.at(5));}
        if (u==3) {a.push_back(5);bb.at(5)=max(3,bb.at(5));}
        if (u==4) {a.push_back(4);bb.at(4)=max(4,bb.at(4));}
        if (u==5) {a.push_back(5);bb.at(5)=max(5,bb.at(5));}
        if (u==6) {a.push_back(6);bb.at(6)=max(6,bb.at(6));}
        if (u==7) {a.push_back(3);bb.at(3)=max(7,bb.at(3));}
        if (u==8) {a.push_back(7);bb.at(7)=max(8,bb.at(7));}
        if (u==9) {a.push_back(6);bb.at(6)=max(9,bb.at(6));}
    }
    rep(i,8) b.at(i)=to_string(bb.at(i));
    sort(a.begin(),a.end());
    d.at(0)="";
    string s;
    for (int i=0;i<n;i++){
        if (d.at(i)=="0") continue;
        for (int j=0;j<a.size();j++){
            if (i+a.at(j)>n) continue;
            s=d.at(i)+b.at(a.at(j));
            if (s.size()>d.at(i+a.at(j)).size()) {d.at(i+a.at(j))=s;continue;}
            else if (s.size()<d.at(i+a.at(j)).size()) continue;
            sort(s.begin(),s.end());
            reverse(s.begin(),s.end());
            
            d.at(i+a.at(j))=max(d.at(i+a.at(j)),s);
        }
    }
    cout << d.at(n) << endl;
}

Measured memory_bytes: 38528
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int T=sc.nextInt();
		int[]t=new int[N];
		for(int i=0;i<N;i++)t[i]=sc.nextInt();
		long sumtime=0;
		for(int i=0;i<N-1;i++){
			if(t[i+1]<t[i]+T){
				sumtime+=t[i+1]-t[i];
			}else{
				sumtime+=T;
			}
		}
		sumtime+=T;
		System.out.println(sumtime);
	}

}

Measured memory_bytes: 87344
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ll N,f;
	scanf("%lld",&N);
	f=0;
	rep(i,10){
		if(i==0) f+=N%10;
		else f+=(N/(ll)(pow(10,i)))%10;
	}
	if(N%f==0)printf("Yes");
	else printf("No");

  return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S == "SUN") {
    cout << 7 << endl;
  }
  else if (S == "MON") {
    cout << 6 << endl;
  }
  else if (S == "TUE") {
    cout << 5 << endl;
  }
  else if (S == "WED") {
    cout << 4 << endl;
  }
  else if (S == "THU") {
    cout << 3 << endl;
  }
  else if (S == "FRI") {
    cout << 2 << endl;
  }
  else if (S == "SAT") {
    cout << 1 << endl;
  }
  
}




Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int dataset;
vector<string> plane(8);

void dfs(int y,int x){
	rep(i,4){
		REP(j,1,4){
			int ny = y + DY[i] * j,nx = x + DX[i] * j;
			if(0 <= ny && ny < 8 && 0 <= nx && nx < 8 && plane[ny][nx] == '1'){
				plane[ny][nx] = '0';
				dfs(ny,nx);
			}
		}
	}
}
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int cnt = 1,sy,sx,ch;
	cin >> dataset;
	ch = getchar();

	while(cnt <= dataset){
		rep(i,8)
			cin >> plane[i];
		cin >> sx >> sy;
		ch = getchar();
		plane[sy - 1][sx - 1] = '0';
		dfs(sy - 1,sx - 1);
		cout << "Data " << cnt++ << ":" << endl;
		rep(i,8)
			cout << plane[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}


void dfs(vector<ll> ls, vector<vector<ll>> way, int ){
  ll cur = ls.back();
  ls.pop_back();

  rep(i, 0, N){
    if(way[cur][i] != 0){

    }
  }

}

 
int main() {
  int A, B, C, K;

  cin >> A >> B >> C >> K;

  int now = 0;
  if(A >= K){
    cout << K << endl;
  }
  else if(A + B >= K){
    cout << A << endl;
  }else{
    int resi = K - A - B;
    cout << A - resi << endl;
  }

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
int main(){
    ll N;
    cin >> N;
    const auto &res = prime_factorize(N);
    ll count=0;
    for (auto p : res) {
        for(int i = 1;i<=p.second;i++){
            if(p.second-i<0){break;}
            count++;
            p.second-=i;
        }
    }
    cout <<count << endl;
    

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int N, Y;
    cin >> N >> Y;
    Y /= 1000;
    vector<vector<int>> dp(N + 1, vector<int>(Y + 1, -1));
    int ar[3] = {1, 5, 10};
    dp[0][0] = 0;
    REP (i, 0, N) {
        REP (j, 0, Y + 1) {
            if (dp[i][j] == -1) continue;
            REP (k, 0, 3) {
                if (j + ar[k] <= Y) {
                    dp[i + 1][j + ar[k]] = ar[k];
                }
            }
        }
    }
    if (dp[N][Y] == -1) {
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    int res[3] = {0, 0, 0};
    int cur = Y;
    int cnt = N;
    while (dp[cnt][cur] != 0) {
        REP (i, 0, 3) {
            if (dp[cnt][cur] == ar[i]) {
                res[i]++;
                cur -= ar[i];
                cnt--;
            }
        }
    }
    cout << res[2] << ' ' << res[1] << ' ' << res[0] << endl;
    return 0;
}

Measured memory_bytes: 156672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int K , A , B;
    cin >> K >> A >> B;
    bool ok = 0;
    for(int i = A;i < B+1; i++){
        if(i%K == 0)ok = 1;
    }
    cout << (ok ? "OK" : "NG") << "\n";
}

Measured memory_bytes: 3692
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
x  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

yokin = 100
for i in range(10**18):
    yokin += int(yokin*0.01)

    if yokin >= x:
        print(i+1)
        break


Measured memory_bytes: 9472
n, m = [int(i) for i in input().split()]
a= [int(i)%m for i in input().split()]

s = [0]*(n+1)
d = {0:1}
for i in range(len(a)):
    s[i+1]=(s[i]+a[i])%m
    if s[i+1] in d:
        d[s[i+1]] +=1
    else:
        d[s[i+1]] = 1

def calc(n):
    return int(n*(n-1)/2)

ans = 0
for i in d:
    ans += calc(d[i])

print(ans)

Measured memory_bytes: 14716
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;
    int n = SZ(s);

    vector<int> ans(13);
    ans[0] = 1;
    rep(i, n){
        vector<int> tmp(13);
        rep(j, 13){
            if(s[i] != '?'){
                int x = j * 10 + (s[i] - '0');
                x %= 13;
                tmp[x] += ans[j];
                tmp[x] %= MOD;
                continue;
            }
            rep(k, 10){
                int x = j * 10 + k;
                x %= 13;
                tmp[x] += ans[j];
                tmp[x] %= MOD;
            }
        }
        ans = tmp;
    }
    cout << ans[5] << endl;

    return 0;
}


Measured memory_bytes: 512
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

H,W,M = LI()
h,w = LIR(M,2)

c = [0]*W
r = [0]*H

d = defaultdict(int)
for i in range(M):
    r[h[i]-1] += 1
    c[w[i]-1] += 1
    d[(h[i]-1,w[i]-1)] = 1

max_c = -1
c_index = []
max_r = -1
r_index = []

for i in range(H):
    if r[i] > max_r:
        max_r = r[i]
        r_index = [i]
    elif r[i] == max_r:
        r_index.append(i)
    else:
        continue

for i in range(W):
    if c[i] > max_c:
        max_c = c[i]
        c_index = [i]
    elif c[i] == max_c:
        c_index.append(i)
    else:
        continue

ans = max_c+max_r
flag = False
for i in r_index:
    for j in c_index:
        if d[(i,j)] == 0:
            flag = True
            break
    if flag:
        break

if not flag:
    ans -= 1

print(ans)

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


int main() {
	int n; long long int a, b; std::cin >> n >> a >> b;
	std::vector<long long int> towns(n); for (auto& t : towns) std::cin >> t;
	long long int result = 0;
	for (auto i = 1; i < n; ++i) {
		result += std::min((towns[i] - towns[i - 1]) * a, b);
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 4048
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>

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

vector<int> x_move, y_move, dp_v;
int memo[10000][10000];

bool dp(int i, int n) {
	if (n < 0) return 0;
	if (memo[i][n] != -1) return memo[i][n];
	if (dp_v[i] * 2 == n) return memo[i][n] = 1;
	if (i == 0) return memo[i][n] = 0;
	return memo[i][n] = (dp(i - 1, n - dp_v[i] * 2) || dp(i - 1, n)) ? 1 : 0;
}

int main() {
	char s[10000];
	int x, y;

	scanf("%s%d%d", s, &x, &y);

	int first = 0;

	bool isfirst = true;
	bool isx = false;
	int count = 0;
	x_move.push_back(0);
	y_move.push_back(0);

	rep(i, strlen(s) + 1) {
		if (isfirst) {
			if (s[i] == 'F') first++;
			else isfirst = false;
		}
		else {
			if (s[i] == 'F') {
				count++;
			}
			else {
				if (isx) x_move.push_back(count);
				else y_move.push_back(count);
				isx = !isx;
				count = 0;
			}
		}
	}

	memset(memo, 0xff, sizeof(memo));
	dp_v = x_move;
	if (dp(x_move.size() - 1, accumulate(x_move.begin(), x_move.end(), 0) + first - x)) {
		memset(memo, 0xff, sizeof(memo));
		dp_v = y_move;
		if (dp(y_move.size() - 1, accumulate(y_move.begin(), y_move.end(), 0) - y)) {
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;
}


Measured memory_bytes: 391040
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		double temp;
		double c;
		double lcm = 0;
		double top = 0;
		double ans = 0;

		List<Integer> num = new ArrayList();

		for (int i = 0; i < N; i++){
			int A = scan.nextInt();
			num.add(A);
		}
		for (int j = 0; j < N - 1; j++){
			double a = num.get(j);
			double b = num.get(j + 1);
			c = a;
			c *= b;
			while((temp = a % b) != 0) {
				a = b;
				b = temp;
			}
			lcm = c/b;
		}

		for (int i = 0; i < N; i++){
			double a = num.get(i);
			top += lcm / a;
		}

		if (N == 1){
			System.out.println(num.get(0));
		}else {
			ans = ((lcm) / (top));
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 36428
A,B,C,D=map(int,input().split())
f=0
while True:
    C-=B
    if C<=0:
        f=1
    if f==1:
        break
    A-=D
    if A<=0:
        f=2
    if f==2:
        break
print("Yes" if f==1 else "No")

Measured memory_bytes: 9176
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  char a,b;
  std::cin >> a >>b;

  if(a>b)printf(">\n");
  else if(a==b) printf("=\n");
  else printf("<\n");
  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

int main(){
  int h,w;
  int n;
  cin >>h>>w>>n;
  int l=max(h,w);
  int ans=(n+(l-1))/l;
  
  cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

// Self settings
// clang-format off
#define MAX_N 100
#define MAX_V 1000
#define INF 1000000001
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

ll N, W;
// ll dp[MAX_N + 1][MAX_V + 1];
ll dp[MAX_N + 1][MAX_N * MAX_V + 1];
ll w[MAX_N], v[MAX_N];

void solve()
{
  fill(dp[0], dp[0] + MAX_N * MAX_V + 1, INF);
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= MAX_N * MAX_V; j++) {
      if (j < v[i]) {
        dp[i + 1][j] = dp[i][j];
      }
      else {
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i <= MAX_N * MAX_V; i++)
    if (dp[N][i] <= W) res = i;
  cout << res << endl;
}
// void solve()
// {
//   fill(dp[0], dp[0] + MAX_N * MAX_V + 1, INF);
//   dp[0][0] = 0;
//   for (int i = 0; i < N; i++) {
//     for (int j = 0; j <= MAX_N * MAX_V; j++) {
//       if (j < v[i]) {
//         dp[i + 1][j] = dp[i][j];
//       }
//       else {
//         dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
//       }
//     }
//   }
//   int res = 0;
//   for (int i = 0; i <= MAX_N * MAX_V; i++) cout << dp[0][i] << " ";
//   for (int i = 0; i <= MAX_N * MAX_V; i++)
//     if (dp[N][i] <= W) res = i;
//   cout << res << endl;
//
//   // REP(i, N + 1) REP(j, MAX_V + 1) dp[i][j] = INF;
//   // dp[0][0] = 0;
//   // for (int i = 0; i < N; i++) {
//   //   for (int j = 0; j <= MAX_V; j++) {
//   //     if (j < v[i] || dp[i][j - v[i]] == INF) {
//   //       dp[i + 1][j] = dp[i][j];
//   //     }
//   //     else {
//   //       dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
//   //     }
//   //   }
//   // }
//   // ll ans = 0;
//   // // REP(j, MAX_V + 1) cout << dp[N][j] << " ";
//   // REP(j, MAX_V + 1) if (dp[N][j] <= W) ans = j;
//   // cout << ans << endl;
// }

int main(void)
{
  cin >> N >> W;
  REP(i, N) cin >> w[i] >> v[i];
  solve();
  return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>

using namespace std;

int H, W;
char grid[110][110];

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

int memo[101][101];

inline bool IN(int x, int y) {
  return 0<=x && x<W && 0<=y && y<H;
}

int const INF = 1<<29;

int main() {
  
  while(cin >> W >> H && W) {
    
    int sx, sy;
    
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
        cin >> grid[i][j];
        if(grid[i][j] == '&') {
          sx = j, sy = i;
        }
      }
    }
    
    int ans = 1<<29;
    
    memset(memo, -1, sizeof(memo));
    typedef pair<int, int> Pii;
    typedef pair<int, Pii> Piii;
    
    priority_queue<Piii> Q;
    Q.push(Piii(0, Pii(sx, sy)));
    while(!Q.empty()) {
      Piii piii = Q.top(); Q.pop();
      int const x = piii.second.first;
      int const y = piii.second.second;
      int const cost = -piii.first;
      
      bool ok = 0;
      
      for(int k=0; k<4; k++) {
        int nx = x + dx[k], ny = y + dy[k];
        if(IN(nx, ny)) {
          int ncost = cost + ((grid[y][x] == '.' || grid[y][x] == '&') && grid[ny][nx] == '#');
          if(memo[ny][nx] == -1 || memo[ny][nx] > ncost) {
            memo[ny][nx] = ncost;
            Q.push(Piii(-ncost, Pii(nx, ny)));
          }
        }
        else {
          cout << cost << endl;
          ok = 1;
          break;
        }
      }
      if(ok) break;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1388
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, k; cin >> n >> k;
    int mx = (n-1) * (n-2) / 2;
    if(k > mx){
        cout << -1 << endl;
        return;
    }
    cout << (n-1) + mx - k << endl;
    rep3(i, 2, n){
        cout << 1 << " " << i << endl;
    }
    mx -= k;
    rep3(i, 2, n-1){
        rep3(j, i+1, n){
            if(mx == 0) return;
            cout << i << " " << j << endl;
            mx--;
        }
    }
    return;
}

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b[101],cnt=0;
	cin>>a;
	for (int i=0;i<a;i++)
		cin>>b[i];
	for (int i=0;i<a;i++)
	{
		for (int n=i+1;n<a;n++)
		{
			for (int m=n+1;m<a;m++)
			{
				long long ways[3]={b[i],b[n],b[m]};
				sort(ways,ways+3);
				if (b[i]!=b[n]&&b[n]!=b[m]&&b[i]!=b[m]&&ways[0]+ways[1]>ways[2])
					cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,a[100005], b[5];
int main(){
	scanf("%d", &n);
	for( int i = 1; i <= n; i++ ) scanf("%d", &a[i]);
	for( int i = 1; i <= n; i++ ){
		if( a[i] & 1 ){ b[1]++; continue; }
		if( a[i]%4 == 0 ) b[4]++;
		else if( a[i]%2 == 0 ) b[2]++;
	}
	if( !b[2] && b[1] > b[4]+1 ) { puts("No"); return 0;}
	if(  b[2] && b[1] > b[4] ) { puts("No"); return 0;}
	puts("Yes");
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int H, N; cin >> H >> N;
    vi A(N); REP(i, N) cin >> A[i];
    ll sum = 0;
    REP(i, N) sum += A[i];
    if(sum >= H) Yes;
    else No;
}
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
const int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
	int K;
	std::cin >> K;
	std::cout << a[K - 1] << '\n';
}

Measured memory_bytes: 256
N, K =map(int, input().split())
p = list(map(int, input().split()))

c=[(i+1)/2 for i in p]
d =sum(c[:K])
e =d
for i in range(N-K):
    e -= c[i]
    e += c[i+K]
    if e>d:
        d=e
print(d)


Measured memory_bytes: 25060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  tree_order_statistics_node_update>  ordered_set; 
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (long double)(0.00000000001)
#define side 1e9
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;

ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[100005];
void power()
{
    powe[0]=1;
    REP(i,1,100005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
struct node
{
	vll adj;
    ll waysblack;
    ll wayswhite;
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,x;
    cin>>n>>m>>x;
    ll cost[n];
    ll A[n][m];
    REP(i,0,n)
    {
        cin>>cost[i];
        REP(j,0,m)
        {
            cin>>A[i][j];
        }
    }
    ll minm=LLONG_MAX;
    REP(mask,0,1<<n)
    {
        ll cos=0;
        ll algo[m]={};
        REP(j,0,n)
        {
            if((mask>>j)&1)
            {
                cos+=cost[j];
                REP(k,0,m)
                {
                    algo[k]+=A[j][k];
                }
            }
        }
        REP(j,0,m)
        {
            if(algo[j]<x)
            {
                goto hell;
            }
        }
        minm = min(minm, cos);
        hell:
        continue;
    }
    cout<<((minm<1e10)?minm:-1)<<"\n";
    return 0;
}




Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>

const ull mod = 1000000007ULL;
const ull INF = (ull)(-1LL);

int main(void){
	ull n;
	cin >> n;
	vull a(n + 1);
	loop(i, 0, n + 1)cin >> a[i];
	vull b(n);
	loop(i, 0, n)cin >> b[i];

	ull count = 0ULL;
	loop(i, 0, n){
		ull d = (a[i] < b[i] ? a[i] : b[i]);
		b[i] -= d;
		count += d;
		d = (a[i + 1] < b[i] ? a[i + 1] : b[i]);
		a[i + 1] -= d;
		count += d;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1792
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b;cin>>n>>a>>b;
    if(a>b)
    {
        cout<<"0\n";
        return 0;
    }
    if(n==1)
    {
        if(a<b)
        {
            cout<<"0\n";
            return 0;
        }
        else
        {
            cout<<"1\n";
            return 0;
        }
    }
    n-=2;
    ll max1=n*b,min1=n*a;
    cout<<max1-min1+1<<'\n';
}

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

int main () {

    char vet[15],vetb[15],vetc[15];

    scanf("%s%s%s", vet, vetb,vetc);

    printf("%c%c%c\n", toupper(vet[0]),toupper(vetb[0]),toupper(vetc[0]));

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

/*ここから*/
int V;//頂点の個数
vector<int> e[200010];//iから出る辺
int t[200010];//親情報の記録媒体

//すでにある辺と頂点の情報から木の作成
void Tree(int s){//sは一番根元
    for(int i=1;i<=V;i++){
        t[i]=i;//初期情報
    }
    queue <int> q;
    q.push(s);
    while(!q.empty()){
        int from;
        from=q.front();
        q.pop();
        while(!e[from].empty()){
            int to;
            to=e[from].back();
            e[from].pop_back();
            if(to!=t[from]){
                t[to]=from;
                q.push(to);
            }
        }
    }
}

/*ここまで*/

int main()
{ 
    LL n,m;
    cin>>n>>m;
    V=n;
    int link[n+2];
    link[1]=1;
    for(int i=2;i<=n;i++){link[i]=0;}
    vector<int> f[n+1];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        f[a].push_back(b);
        f[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int p=q.front();
        //cout<<p<<endl;
        q.pop();
        for(int i=0;i<f[p].size();i++){
            int r=f[p][i];
            //cout<<p<<' '<<r<<endl;
            if(link[r]==0){
                link[r]=1;
                q.push(r);
                e[p].push_back(r);
                e[r].push_back(p);
            }
        }
    }
    Tree(1);
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout<<t[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 18684
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int a, b; cin >> a >> b;
  vector<int> res{};

  res.push_back(a + b);
  res.push_back(a - b);
  res.push_back(a * b);

  cout << *boost::max_element(res) << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

using namespace std;

typedef pair<int, int> P;

bool ok[1000];
int A[1000][1000];
int idx[1000];

map<P, int> mp;

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N-1; j++){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    int ans = 1;
    vector<int> v;
    vector<int> v1;
    for(int i = 0; i < N; i++){
        v.push_back(i);
    }
    while(true){
        for(int i = 0; i < v.size(); i++){
            ok[v[i]] = true;
        }
        int cnt_m  = 0;
        for(int j = 0; j < v.size(); j++){
            int i = v[j];
            int a = A[i][idx[i]];
            if(ok[i] == false || ok[a] == false) continue;
            if(idx[a] == N-1 || idx[i] == N-1) continue;
            if(A[a][idx[a]] == i){
                //cout << i << ' ' << a << ' ' << ans << endl;
                ok[i] = false;
                ok[a] = false;
                idx[i]++;
                idx[a]++;
                cnt_m++;
                v1.push_back(i);
                v1.push_back(a);
            }
        }
        v.clear();
        for(int i = 0; i < v1.size(); i++){
            v.push_back(v1[i]);
        }
        v1.clear();
        //cout << cnt_m << endl;
        if(cnt_m == 0) break;
        ans++;
    }
    for(int i = 0; i < N; i++){
        if(idx[i] != N-1){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans-1 << endl;
}

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

using namespace std;

int main(){
 #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);

#endif
  
   long long mod = 1000000007;


string s;
cin>>s;
int n= s.length();

int i=0,j=n-1;
int cnt=0;
while(i<=j){
  if(s[i]!=s[j]){
cnt++;
  }
  i++;
  j--;
}

cout<<cnt<<endl;


return 0;
}

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

int head, tail;
int Q[100000]; //queue
int n;
int d[110]; //distance
bool a[110][110] = {}; //adjacency matrix

//queue
void enqueue(int x){
  
  Q[tail] = x;

  if(tail + 1 == 100000) tail = 0;
  else tail++;
}

int dequeue(){
  
  int x = Q[head];

  if(head + 1 == 100000) head = 0;
  else head++;

  return x;
}

void bfs(int u){
  
  enqueue(u);
  d[u] = 0;
  
  while(head != tail){
    int p = Q[head];
    dequeue();
    
    for(int i = 2;i <= n;i++){
      //if i is adjoining p and have not been visited, calculate the distance
      if(a[p][i] && d[i] == 0){
        enqueue(i);
        d[i] = d[p] + 1;
      }
    }
  }
}

int main(){
  
  int u, k, v;

  //input
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> v;
      a[u][v] = true;
    }
  }
  
  bfs(1);

  //output
  for(int i = 1;i <= n;i++){
    if(d[i] || i == 1) cout << i << " " << d[i] << endl;
    else cout << i << " " << -1 << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
 
 int tc=1;
// cin>>tc;
 while(tc--)
 {
string s;
cin>>s;
ll n=s.length();
if(n%2==1)
{
	string s1,s2;
	string s3,s4,s5;
	for(i=0;i<(n-1)/2;i++)
	s1+=s[i];
	for(i=(n+1)/2;i<n;i++)
	s2+=s[i];
	s3=s1;
	s4=s2;
	s5=s;
	reverse(s1.begin(),s1.end());
	reverse(s2.begin(),s2.end());
	reverse(s.begin(),s.end());
	if(s1==s3 && s2==s4 && s5==s)
	cout<<"Yes";
	else
	cout<<"No";
}
else
cout<<"No";
	 cout<<"\n";
 }
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//fac[]はn! inv[]はMODにおける逆元 finv[]はinv[]とfinv[]の累積積
const long long MAX = 510000;
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;
    }
}

// 二項係数計算(nCkをO(1)で)
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;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    COMinit();

    long long H,W;cin >> H >> W;
    long long A,B;cin >> A >> B;
    long long ans = 0;
    for(long long i = 1;i<=H-A;i++){
        //行けないゾーンを突破するまでに、i回縦とB回横移動する
        //突破したらあとは自由 H-i-1回縦とW-B-1回横移動してゴールする
        long long comb = COM(i-1+B-1,B-1);
        comb *= COM(H-i+W-B-1,H-i);
        ans += comb;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15608
function Main (input) {
  var splittedInputByLine = input.split(/\n/);
  var summerElements = splittedInputByLine[0].split(" ");
  var summerHolidays = summerElements[0];
  var homework = summerElements[1];
  
  var studyDaysArray = splittedInputByLine[1].split(" ");
  var studyDays = studyDaysArray.map(Number);
      
  
    var totalStudyDays = 0;
    for ( var i = 0; i < homework; i ++){
      totalStudyDays += studyDays[i];
    }
  
  if(summerHolidays < totalStudyDays) {
    console.log('-1');
  } else {
    console.log(summerHolidays - totalStudyDays);
  }
	
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30388
#include <stdio.h>

int main(){
	char rome[128];
	while(scanf("%s",rome)!=EOF){
		int a=0,b=0;
		int i=0;
		int sum=0;
		while(rome[i]!='\0'){
			b=a;
			switch(rome[i]){
			case 'I':
			a = 1;
			break;
			case 'V':
			a = 5;
			break;
			case 'X':
			a = 10;
			break;
			case 'L':
			a = 50;
			break;
			case 'C':
			a = 100;
			break;
			case 'D':
			a = 500;
			break;
			case 'M':
			a = 1000;
			break;
			}
			if(b<a)	sum-=b*2;
			sum+=a;			
			i++;
		}
		printf("%d\n",sum);
	}	
	return 0;
}

Measured memory_bytes: 540
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double log;
		log = Math.log10(N) / Math.log10(K);
		int ans = (int)Math.floor(log) + 1;
		
		System.out.println(ans);


	}
}


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

vector<int> v[100010];
bool win = false;

int search(int curr, int prev) {
    if (win) return -1;
    int c = 0;
    for (auto &next: v[curr]) {
        if (next == prev) continue;
        c += search(next, curr);
    }
    if (c >= 2) win = true;
    return (c + 1) % 2;
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b; a--; b--;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    if (search(0, -1) == 1) win = true;
    if (win) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

int main(){
    int N;
    vector<int> a;

    cin >> N;
    for(int i=0;i<N;i++){
        int ai;
        cin >> ai;
        a.push_back(ai);
    }

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

    int alice=0,bob=0;
    for(int i=0;i<N;i++){
        if(i%2==0){
            alice+=a[N-1-i];
        }else{
            bob+=a[N-1-i];
        }
    }

    cout << (alice-bob) << endl;

    return 0;
}

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

using ll = long long;
typedef unsigned long long ull;
using namespace std;
typedef pair<ll, ll>P;

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true, fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
double pai = 3.141592653589793;
bool comp(const etree& e1, const etree& e2) {
	return e1.cost < e2.cost;
}
#define ALL(x) (x).begin(),(x).end()

int main() {
	int a, b, c, x, ans = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0;i <= a;i++) {
		for (int j = 0;j <= b;j++) {
			for (int k = 0;k <= c;k++) {
				if (500 * i + 100 * j + 50 * k == x)ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
  int n, s = 0;
  scanf("%d", &n);
  int digit = 1, div;
  while((div = n / digit) != 0) {
    s += (div % 10);
    digit *= 10;
  }
  //printf("%d\n", s);
  if(n % s == 0) { printf("Yes\n"); } else { printf("No\n"); }
}

Measured memory_bytes: 128
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> vs(n); cin >> vs;
    sort(vs.begin(), vs.end());
    double ans = vs[0];
    for(int i = 1; i < n; i++){
        ans = (ans + vs[i]) / 2;
    }
    cout << fixed << setprecision(20) << ans << '\n';
}


Measured memory_bytes: 888
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: a,b,c
    read*, a,b,c

    if (a <= c .and. c <= b) then
        print'(a)', 'Yes'
    else
        print'(a)', 'No'
    end if
    
end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 1, maxv = h[0];
    rep(i, n) {
        if(i == 0) continue;
        if(h[i] >= maxv) {
            ans++;
            maxv = h[i];
        } 
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
	ll N;
	cin >> N;
  
	ll rootN = sqrt(N);
	for(ll i = rootN;i>0;i--){
		ll amari = N % i;
		ll syou = N / i;
		bool ok = (amari == 0);
		if(ok){
			cout << i+syou -2 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    d, x = map(int, input().split())
    a = [int(input()) for _ in range(n)]
    x += sum([sum([j * i + 1 <= d for i in range(1, d + 1)]) + 1 for j in a])
    print(x)


if __name__ == "__main__":
    main()


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

using lint = long long;

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

#define EPS 1e-6;

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

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

    int N;
    cin >> N;

    // 各桁の和，N >= 10 && sum == 1 の時10
    int ans = 0;
    for (int n = N; n > 0; n /= 10) {
        ans += n % 10;
    }

    if (ans == 1 && N >= 10) ans = 10;

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x) cerr << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cerr << a << " "; cerr << endl;
#define debug3(x) rep(i, sizeof(x)) cerr << x[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

set<ll> make_primes(int s = 1000) {
    set<ll> primes;

    REP(i, 2, s) {
        bool is_prime = true;
        for (auto p : primes) {
            if (i % p == 0) {
                is_prime = false;
                break;
            }
        }
        if (is_prime) primes.insert(i);
    }
    return primes;
}

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

    set<ll> primes = make_primes();
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for (ll i = 1; i <= n; ++i) {
        for (auto p : primes) {
            ll i_ = i;
            while (i_ % p == 0) {
                i_ /= p;
                mp[p]++;
            }
            if (i_ == 1) break;
        }
    }
    ll ans = 1;
    for (auto p : primes) ans = ans * (mp[p] + 1) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256