akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int A[100100],B[100100];
int N;
vector<P> v;
bool used[100100];
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i];
		v.pb(P(A[i],i));
		v.pb(P(B[i],i));
	}
	ll ans = LLINF;
	chmin(ans,accumulate(A,A+N,0ll));
	chmin(ans,accumulate(B,B+N,0ll));
	sort(all(v));
	bool flag = false;
	for(int i=0;i<N;i++){
		if(used[v[i].sec]){
			flag = true;
			break;
		}
		used[v[i].sec]=true;
	}
	ll ret = 0ll;
	for(int i=0;i<N;i++)ret += v[i].fi;
	if(flag)chmin(ans,ret);
	else{
		for(int i=0;i<N;i++){
			chmin(ans,ret+max(A[i],B[i])-((v[N-1].sec==i)?v[N-2].fi:v[N-1].fi));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2932
a, b, c, d = input()
op_cnt = 3

for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = "+"
    if eval(a + op[0] + b + op[1] + c + op[2] + d) ==7:
        print(a + op[0] + b + op[1] + c + op[2] + d + "=7")
        break

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <string.h>
#include <vector>

using namespace std;

typedef vector<vector<int> > Graph;

vector<int> tsort(Graph G, int start, int end) {
  vector<int> ret;

  int degree[end];
  memset(degree, 0, sizeof(degree));

  for (int from = start; from < end; from++) {
    for (int i = 0; i < G[from].size(); i++) {
      int to = G[from][i];
      degree[to]++;
    }
  }

  stack<int> root;

  for (int i = start; i < end; i++) {
    if (degree[i] == 0) {
      root.push(i);
    }
  }

  while (!root.empty()) {
    int from = root.top();
    root.pop();

    ret.push_back(from);

    for (int i = 0; i < G[from].size(); i++) {
      int to = G[from][i];
      degree[to]--;

      if (degree[to] == 0) {
        root.push(to);
      }
    }
  }

  return ret;
}

int main() {
  int V, E;
  cin >> V >> E;

  Graph G(V);

  int s, t;

  for (int i = 0; i < E; ++i) {
    cin >> s >> t;

    G[s].push_back(t);
  }

  vector<int> res = tsort(G, 0, V);

  for (int i = 0; i < res.size(); ++i) {
    cout << res[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 3996
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> dp(100010, INF);
    dp[0] = 0;

    for (int n = 1; n <= 100000; n++)
    {
        int power = 1;
        while (power <= n)
        {
            dp[n] = min(dp[n], dp[n - power] + 1);
            power *= 6;
        }
        power = 1;
        while (power <= n)
        {
            dp[n] = min(dp[n], dp[n - power] + 1);
            power *= 9;
        }
    }

    cout << dp[N] << endl;
    return 0;
}

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

const long long mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  
  long long a, b, t, s;
  a = 1; b = 1; t = 1; s = 1;
  for (int i = 0; i < n; i++) {
    a = a*9%mod;
    b = b*9%mod;
    t = t*10%mod;
    s = s*8%mod;
  }
  long long ans;
  ans = (t + s - a - b + (mod * 4)) %mod;
  cout << ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    vl s(n);s[0]=a[0];
    for(ll i=1;i<n;i++)s[i]=s[i-1]+a[i];

    ll ans=abs(s[n-1]-2*s[0]);
    for(ll i=1;i<n-1;i++){
        if(abs(s[n-1]-2*s[i])<ans)ans=abs(s[n-1]-2*s[i]);
    }

cout<<ans<<endl;


}

Measured memory_bytes: 3328
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for p in range(1, 4):
    sum = 0
    for i in range(n):
        sum += abs(x[i] - y[i]) ** p
    print('{:.10f}'.format(math.pow(sum, 1/p)))
ans = 0
for i in range(n):
    ans = max(ans, abs(x[i] - y[i]))
print(ans)


Measured memory_bytes: 5700
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define syousuu(i) setprecision(i)

//template<typename A, size_t N, typename T>
//void Fill(A(&array)[N], const T &val) {
	//std::fill((T*)array, (T*)(array + N), val);
//}

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

ll N;
vector<bool> visited;
vector<pair<double, double>> vec;
vector<double> anss;

double distance(pair<double, double>& x, pair<double, double>& y) {
	return sqrt(pow(x.first - y.first, 2) + pow(x.second - y.second, 2));
}

void calc(int pre,double dist,int num) {

	if (num == N+1) {
		anss.emplace_back(dist);
	}

	rep(i, N) {

		if (visited[i] == false) {
			visited[i] = true;
			double tmp = 0;
			if (pre!=-1) tmp = distance(vec[i], vec[pre]);
			calc(i, dist + tmp,num+1);
			visited[i] = false;
		}

	}

}

//解法
void solve() {

	cin >> N;
	vec.resize(N);
	visited.resize(N,false);
	rep(i, N) {
		double a, b;
		cin >> a >> b;
		vec[i].first = a;
		vec[i].second = b;
	}

	calc(-1,0,1);

	double sum = 0;
	rep(i, anss.size()) {
		sum += anss[i];
	}
	cout << syousuu(12) << sum / anss.size();

}

int main() {

	//入力

	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 892
import sys


if __name__ == "__main__":
    n = int(sys.stdin.readline())
    ANS = [[0] * n for i in range(n)]
    for inp in sys.stdin.readlines():
        inp = list(map(int, inp.split()))
        for i in inp[2:]:
            ANS[inp[0]-1][i-1] = 1
    for row in ANS:
        print(" ".join(map(str, row)))

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

int main() {
  vector<char> a(4);
  int result = 0;
  for(int i = 0; i < 4; i++){
    cin >> a.at(i);
    if(a.at(i) == '-') result--;
    else result ++;
  }
  cout << result << endl;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long ans=0ll;
    for(int i=1;i<n;i++){
        ans+=max(0,a[i-1]-a[i]);
        // cout<<ans<<endl;
        a[i]=max(a[i],a[i-1]);
    }
    // for(int i=0;i<n;i++){
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4400
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 1000000000
#define mod 1000000007

typedef long long ll;

const int N = 5000;

int dp[N];

int main()
{
    fast;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < (1 << n); i++)
        dp[i] = inf;

    while (m--) {
        int a, b;
        cin >> a >> b;
        int x = 0;

        while (b--) {
            int z;
            cin >> z;
            z--;
            x |= (1 << z);
        }

        smin(dp[x], a);
    }

    for (int i = 0; i < (1 << n); i++)
        for (int j = i + 1; j < (1 << n); j++)
            smin(dp[i | j], dp[i] + dp[j]);

    if (dp[(1 << n) - 1] < inf)
        cout << dp[(1 << n) - 1];
    else
        cout << -1;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

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

const int inf=1e9+10;
const int maxn=1e5+10;
const ll mod=1e9+7;

ll dp[102][maxn];
int a[maxn];

int main(){
	int k,n;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<=a[0];i++) dp[0][i]=1;
	for(int i=1;i<n;i++){
		int sum=0;
		for(int j=0;j<=k;j++){
			if(j-a[i]-1>=0) sum=(sum+mod-dp[i-1][j-a[i]-1]);
			sum=(sum+dp[i-1][j])%mod;
			dp[i][j]=sum;
		//	cout<<sum<<" ";
		}
	//	cout<<endl;
	}
	cout<<dp[n-1][k]<<endl;
	return 0;
}


Measured memory_bytes: 79744
#include <iostream>

int main(int argc, char const *argv[]){
	int x,y;
	int q;
	std::cin >> x >> y;
	while( ( x > y? x%y : y%x) != 0 ){
		if(x>y) x = x % y;
		else if(y>x) y = y % x;
		else break;
	}
	std::cout << (x > y? y : x) << std::endl;
	return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

//関数名：mod_pow
//概要：modつき指数関数
//第一引数a：指数の底
//第二引数b：指数
//第三引数mod：法となる値
//戻り値：a^b(m mod)
ll mod_pow(ll a, ll b, ll mod){
    if(b == 0) return 1;
    if(b % 2 == 0){
        ll d = mod_pow(a,b/2,mod);
        return d%mod*d%mod;
    }else return a%mod*mod_pow(a,b-1,mod)%mod;
}

//関数名：mod_combination
//概要：modつき二項係数
//第一引数n：組み合わせの全体
//第二引数r：何個取り出すか
//第三引数mod：法となる値
//戻り値：nCr(m mod)
ll mod_combination(ll n,ll r,ll mod){
    if(r > n) return 0;
    if(n == r || r == 0) return 1;
    ll fact1 = 1,fact2 = 1;
    for(ll i = n; i >= n-r+1; i--) fact1 = fact1*i%mod;
    for(ll i = r; i >= 1; i--) fact2 = fact2*i%mod;
    return fact1*mod_pow(fact2,mod-2,mod)%mod;
}

void solve(ll i, ll n, ll k){
    cout << mod_combination(n-k+1,i,MOD)%MOD*mod_combination(k-1,i-1,MOD)%MOD << endl;
}

int main(){
    ll n,k; cin >> n >> k;
    for(ll i = 0; i < k; i++) solve(i+1,n,k);
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn main() {
    let N: i32 = read_line().parse().unwrap();
    let p = read_vec();
    let mut count = 0;
    for i in 0..(N as usize) {
        if p[i] != (i as i32)+1 {
            count += 1
        }
    }
    if count <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def bfs(graph, initial, MX):
    n = len(graph) - 1
    dist = [-1] * (n + 1)
    q = deque([initial])
    visited = [False] * (n + 1)
    visited[initial] = True
    dist = []

    while len(q) != 0:
        edge = q.popleft()
        nxt = graph[edge]
        dist.append(edge)

        if len(dist) == MX:
            return dist

        for i, e in enumerate(nxt):
            q.append(e)

    return dist


def main():
    N, K = MI()
    A = [i-1 for i in MI()]
    edges = [[] for i in range(N)]
    LIMIT = 3*10**5

    for i in range(N):
        edges[i].append(A[i])

    ret = bfs(edges, 0, LIMIT)
    m = defaultdict(int)
    loop_start = None
    loop_end = None
    for i in range(len(ret)):
        v = ret[i]
        if m[v] == 0:
            m[v] = i
        elif m[v] != 0:
            loop_start = m[v]
            loop_end = i - 1
            break
            # print(i)
    # print(ret[:5+1])

    if K <= LIMIT:
        print(ret[K]+1)
    else:
        # print(K % loop)
        # print(loop_start, loop_end)
        # org_K = K
        K -= loop_start
        loop_c = loop_end - loop_start + 1
        n_ret = ret[loop_start:]
        # print(n_ret[:15], 'loop_c',loop_c, 'K', K)
        print(n_ret[K % loop_c]+1)
        # print(ret[org_K]+1)
        # print(ret[:10])
        # print(ret[org_K])


if __name__ == '__main__':
    main()


Measured memory_bytes: 151488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,INF=1e18;



int main() {
    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N){
        cin>>A.at(i);
        if(A.at(i)==0){cout<<0<<endl;return 0;}
    }
    ll ans=1;
    rep(i,N){
        ll ord=2000000000000000000/ans;
        if(A.at(i)>ord){cout<<-1<<endl;return 0;}
        ans*=A.at(i);
        if(ans>1000000000000000000){cout<<-1<<endl;return 0;}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4052
n, m = map(int, input().split())
C = list(map(int, input().split()))

def coin():
    dp = [float('inf')]*(n+1)
    dp[0] = 0
    for i in range(m):
        for j in range(C[i], n+1):
            dp[j] = min(dp[j], dp[j-C[i]]+1)
    return dp[n]

print(coin())



Measured memory_bytes: 7520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define int long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int mod = 1e9+7;

int32_t main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

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

	sort(a,a+n);

	int ans = a[n-1];
	int i = n-3;
	int k = n-2;
	while(i >= 0){
		ans += a[k];
		i--;
		if(i < 0)
			break;
		ans += a[k];
		i--;
		k--;
	}	

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 5160
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
void func(int);
int suu[9],flg[10],cnt;
int main(void)
{
	int i;
	for(i=0;i<9;i++)	scanf("%d",&suu[i]);
	for(i=1;i<=9;i++)	flg[i]=0;
	for(i=0;i<9;i++)	flg[suu[i]]=1;
	cnt=0;
	func(0);
	printf("%d\n",cnt);
	return 0;
}
void func(int n)
{
	int i,sum,g,h,i2,ff;
//	printf("n=%d\n",n);
	if(n==6)	{
		sum=suu[0]+suu[2]+suu[5]+(suu[1]+suu[4])*10+suu[3]*100;
		g=sum/100;
		h=sum%100;	h=h/10;
		i2=sum%10;
		ff=1;
		if(sum>=1000)	ff=0;
		if(g==0 || h==0 || i2==0)	ff=0;
		if(g==h || g==i2 || h==i2)	ff=0;
		if(suu[6]!=-1 && suu[6]!=g)	ff=0;
		if(suu[6]==-1 && flg[g]!=0)	ff=0;
		if(suu[7]!=-1 && suu[7]!=h)	ff=0;
		if(suu[7]==-1 && flg[h]!=0)	ff=0;
		if(suu[8]!=-1 && suu[8]!=i2)	ff=0;
		if(suu[8]==-1 && flg[i2]!=0)	ff=0;
		if(ff==1)	cnt++;
	}
	else {
		if(suu[n]==-1)	{
			for(i=1;i<=9;i++)	{
				if(flg[i]==0)	{
//					printf("n=%d i=%d\n",n,i);
					suu[n]=i;
					flg[i]=1;
					func(n+1);
					flg[i]=0;
					suu[n]=-1;
				}
			}
		}
		else {
			func(n+1);
		}
	}
}


Measured memory_bytes: 2728
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;


using ll=long long int;


int main() {

	int x, a, b;
	cin >> x >> a >> b;

	if(abs(a-x)>abs(b-x)){
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}


	return 0;
}





Measured memory_bytes: 256
N = gets.chomp!.to_i
input = []
N.times do
	input << gets.chomp!
end

ans = ""
('a'..'z').each do |char|
	arr = input.map do |i| 
		i.count(char)
	end
		
	mi = arr.min
	ans += char * mi
	
end

puts ans



Measured memory_bytes: 1788
n, k = map(int, input().split())
s = input()

block = 0
count = 0
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        block += 1
    else:
        count += 1

for i in range(k):
    count += min(block, 2)
    block -= 2
    if block <= 0:
        break

print(count)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define debug(x) std::cerr<<"L: "<<__LINE__<<" f("<<__FUNCTION__<<") Var: "<<#x<<" Val: "<<x<<"\n";
typedef long long ll;
const int inf = 0x7f7f7f7f;
 
inline void gettime() {
	debug(clock());
}
inline ll read() {
	static char c;
	static ll x;
	while (c = getchar(), !isdigit(c));
	x = c - '0';
	while (c = getchar(), isdigit(c))
		x = (x << 1) + (x << 3) + c - '0';
	return x;
}
inline char achar() {
	static char c;
	while (c = getchar(), !isalpha(c));
	return c;
}
 
ll n, ns[200200], sum[200200];
 
int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif
 
	n = read();
	for (int i = 1; i <= n; ++i)
		ns[i] = read(), sum[i] = sum[i - 1] + ns[i];
 
//枚举中间切哪里
//k是第二部分最右边的元素位置,l&r同理
	ll ans = 1e18;
	for (int k = 2, l = 1, r = 3; k <= n - 2; ++k) {
		r = std::max(r, k + 1);
		for (; l + 1 < k; ++l)
			if (abs((sum[k] - sum[l + 1]) - sum[l + 1]) <
			        abs((sum[k] - sum[l]) - sum[l]));
			else break;
 
		for (; r + 1 < n; ++r)
			if (abs((sum[n] - sum[r + 1]) - (sum[r + 1] - sum[k])) <
			        abs((sum[n] - sum[r]) - (sum[r] - sum[k])));
			else break;
 
		// printf("%d %d %d\n", l, k, r);
 
		ll one = sum[l], two = sum[k] - sum[l], three = sum[r] - sum[k], four = sum[n] - sum[r];
		ans = std::min(ans,
		               std::max({one, two, three, four}) - std::min({one, two, three, four}));
	}
 
	printf("%lld\n", ans);
}

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> a(n);

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

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int a = Integer.parseInt(line);
		line = br.readLine();
		int b = Integer.parseInt(line);
		line = br.readLine();
		int h = Integer.parseInt(line);
		System.out.println((a+b)*h/2);
	}

}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int A;
int B;
int C;
cin >> A >> B >> C;
  if((A < C && C < B) || (A > C && C > B)){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  ll n;
  V c;
  ll res = 0;

  queue<ll> bfs_q;

  cin >> n;

  VV adj_list(n+1);
  V n_value(n+1);
  vector<bool> is_visited(n+1, false);
  ll c_idx = n-1;

  for(ll i=0; i<n-1; i++) {
    ll ta, tb;
    cin >> ta >> tb;

    adj_list[ta].push_back(tb);
    adj_list[tb].push_back(ta);
  }

  for(ll i=0; i<n; i++) {
    ll tc;
    cin >> tc;
    c.push_back(tc);
  }

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

  for(ll i=0; i<n-1; i++) {
    res += c[i];
  }

  bfs_q.push(1);
  while(!bfs_q.empty()) {
    ll node_idx = bfs_q.front(); bfs_q.pop();
    n_value[node_idx] = c[c_idx--];
    is_visited[node_idx] = true;

    for(auto itr=adj_list[node_idx].begin(); itr!=adj_list[node_idx].end(); itr++) {
      if(is_visited[*itr] != true) {
        bfs_q.push(*itr);
      }
    }
  }

  cout << res << endl;
  for(ll i=0; i<n; i++) {
    cout << n_value[i+1] << " "[i==n-1];
  }
  cout << endl;

  return 0;
}


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

const int maxn=2e5+5;
int a[maxn];
bool vis[maxn];

int main()
{
    int n;
    while(cin>>n){
        memset(vis, 0, sizeof(vis));
        multiset<int> LIS;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        LIS.emplace(a[0]);
        for(int i=1;i<n;i++){
            if(a[i]<=*LIS.begin()){
                LIS.emplace(a[i]);
            }
            else{
                auto it = LIS.lower_bound(a[i]);
                if(it!=LIS.begin()) it--;
                LIS.erase(it);
                LIS.emplace(a[i]);
            }
        }
        cout<<LIS.size()<<endl;
    }
    return 0;
}


Measured memory_bytes: 5504
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<bitset>
using namespace std;
const int maxn=200010;
int n,k,cnt[maxn],ans=0;
vector<int> v;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		cnt[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(!cnt[i])
		{
			continue;
		}
		v.push_back(cnt[i]);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<(int)v.size()-k;i++)
	{
		ans+=v[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, a[105];
void init(){
    n = read();
    for (int i = 1; i <= n; ++i)
        a[i] = read();
}
void solve(){
    int ans = INT_MAX;
    for (int i = 1; i <= 100; ++i){
        int cnt = 0;
        for (int j = 1; j <= n; ++j)
            cnt += (i - a[j]) * (i - a[j]);
        ans = min(ans, cnt);
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

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

using namespace std;

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> dist(n);
	int longest_dist = 0;
	int ignore;
	for (int i = 0; i < n - 1; i++) {
		dist[i] = a[i + 1] - a[i];
		if (longest_dist < dist[i]) {
			longest_dist = dist[i];
			ignore = i;
		}
	}
	dist[n - 1] = k - a[n - 1] + a[0];
	if (longest_dist < dist[n - 1]) {
		longest_dist = dist[n - 1];
		ignore = n - 1;
	}
	int sum_dist = 0;
	for (int i = 0; i < n; i++) {
		if (ignore == i) continue;
		sum_dist += dist[i];
	}
	cout << sum_dist << endl;
	return 0;
}

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

const int MOD=(int)1e9+7;
const int 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;
  }
}

//二項係数の計算
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(){
	int N;
	cin >> N;
	vector<int> x(N);
	for(int i=0;i<N;i++)	cin >> x.at(i);

	COMinit();
	long long X=1;//(N-1)!
	for(int i=1;i<N;i++)	X=(X*i)%MOD;
	vector<long long> C(N,0);
	C.at(0)=0;
	for(int i=1;i<N;i++){
		C.at(i)=C.at(i-1) + X*inv[i];
		C.at(i)%=MOD;
	}
	long long ans=0;
	for(int i=1;i<N;i++){
		ans+=C.at(i)*(x.at(i)-x.at(i-1));
		ans%=MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define dou long double
#define sp(n) cout << setprecision(n) << fixed

using namespace std;

const int MAXN = 3e3 + 10;

dou a[MAXN], dp[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0);

    sp(9);

    int n;
    cin >> n;

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

    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= n; ++j) {
					if (!j)
						dp[i][j] = (dou)(dp[i - 1][j] * (1 - a[i]));
					else
            dp[i][j] = ((dou)(dp[i - 1][j - 1] * a[i])) + ((dou)(dp[i - 1][j] * (1 - a[i])));
				}
 
    int k = (n >> 1) + 1;
    dou ans = 0;
    for (int j = k; j <= n; ++j)
        ans += dp[n][j];

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 141696
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x
//最大化問題最小化問題
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;
}

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;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

ll amp(ll N) {
    const auto &pf = prime_factorize(N);
    long long res = 1;
    for (auto p : pf) res *= p.second + 1;
    return res;
}

int main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;
    vll S(N+1);
    REP(i,N+1) S[i]=amp(i);
    ll ans = 0;


    FOR(i,1,N-1){
        ans += S[N-i];
    }
    
    //本文
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 11080
#include <iostream>
#include <math.h>
using namespace std;

int e,minimum;

int solve(){
    minimum = e;
    for(int z=0;z*z*z<=e;z++){
        for(int y=0;y*y <= e-z*z;y++){
            int x = e - z*z*z - y*y;
            if(x>=0)
                minimum = min(x+y+z,minimum);
        }
    }
    return minimum;
}

int main(){
    while(cin >> e && e!=0){
        cout << solve() << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  int a1, a10, a100;
  a1 = n % 10;
  a10 = n % 100 - a1;
  a100 = n % 1000 - a10 - a1;
  int ans = 0;
  if (a100 == 100)
    ans += 900;
  else
    ans += 100;
  if (a10 == 10)
    ans += 90;
  else
    ans += 10;
  if (a1 == 1)
    ans += 9;
  else
    ans += 1;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

const ll inf = 1e18;

int main(){
    int n;
    while(cin>>n){
        vi a(n+3);
        forn(i,n) cin>>a[i];
        vl dp(n+3, inf);

        dp[0] = 0;
        forn(i,n){
            min_self(dp[i+1], dp[i] + abs(a[i+1] - a[i]));
            min_self(dp[i+2], dp[i] + abs(a[i+2] - a[i]));
        }
        // print(dp);
        cout<<dp[n-1]<<endl;

    }
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  	string s;
  	cin>>s;
  	bool a0=0,b0=0;
  	for(int i=0;i<s.size();i++){
    	if(s[i]=='A'){
        	a0 = 1;
        }else{
        	b0 = 1;
        }
    }
  	if(a0 && b0){
    	cout<<"Yes";
    }else{
    	cout<<"No";
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;
int main(){
	int n =0;
  	cin >> n;
	auto a = vector<int>(n,0);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
  
	ll _min=INF;
	for(int i=-100;i<=100;i++){
		ll temp=0;
		for(int j=0;j<n;j++){
			if(a[j]==i) continue;
			temp+=(a[j]-i)*(a[j]-i);
		}
     	_min = min(_min,temp);
	}
	cout << _min;
	return 0;
}

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

typedef long long ll;

bool qry(ll z) {
	cout<<"? "<<z<<endl;
	fflush(stdout);
	string s;
	cin>>s;
	fflush(stdout);
	return (s == "Y");
}

void spc() {
	ll l = 1;
	while (true) {
		l*=10;
		if (qry(l-1)) {
			cout<<"! "<<(l/10)<<endl; return;
		}
	}
}


int main() {
	ll k = 1; ll d = 1;
	while (true) {
		if (!qry(k)) {
			d = d-1; break;
		}
		d++; k*=10;
		if (d > 14) { spc(); return 0; } // is a power of 10
	}

	ll l = 1;
	for (int i = 1; i <= d; i++) l *= 10;
	ll r = l*10 - 1;
	while (l/10 < r/10) {
		ll mid = (l+r-1)/2;
		if (qry(mid)) {
			r = mid;
		} else {
			l = mid+1;
		}
	}

	l/=10;
	cout<<"! "<<l<<endl;
	fflush(stdout);
}


Measured memory_bytes: 648
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n,k;
int d[15]={};
int main(void){
	scanf("%d%d",&n,&k);
	rep(i,k){
		int a;
		scanf("%d",&a);
		d[a]=1;
	}
	
	int i=n;
	for(;;){
		int t=i;
		bool ok=true;
		while(t>0){
			if(d[t%10]){
				ok=false;
				break;
			}
			t/=10;
		}
		if(ok){
			printf("%d\n",i);
			break;
		}
		i++;
	}
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string s;
int ap[30];
int i,j,mex,poz,pref,ch;
int main()
{
    cin>>s;
    if(s.size()<26)
    {
        for(i=0;i<s.size();i++)
            ap[s[i]-'a']=1;
        for(i=26;i>=0;i--)
            if(!ap[i])
              mex=i;
        s+=(mex+'a');
        cout<<s;
        return 0;
    }
    pref=-1;
    for(i=0;i<s.size();i++)
    {
       poz=s[i]-'a';
        for(j=25;j>poz;j--)
            if(!ap[j])
                pref=i,ch=j;
        ap[poz]=1;
    }
    if(pref==-1) cout<<pref;
    else
    {
        for(i=0;i<pref;i++)
            cout<<s[i];
        cout<<(char)('a'+ch);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n , a[N] , b[N] , c[N] , dp[N][4] , k;
int calc(int i , int op){
    if(i == n)
        return 0;
    int &ret = dp[i][op];
    if(ret != -1)
        return ret;
    ret = 0;
    if(op != 0){
        ret = max(ret , calc(i + 1 , 0) + a[i]);}
    if(op != 1)
        ret = max(ret , calc(i + 1 , 1) + b[i]);
    if(op != 2)
        ret = max(ret , calc(i + 1 , 2) + c[i]);
    return ret;
    }
int main(){
    scanf("%d", &n );
    for(int i = 0 ; i < n ; i++){
        scanf("%d%d%d", &a[i] , &b[i] , &c[i]);
    }
    memset(dp , -1 , sizeof dp);
    cout<<calc(0,3);
    return 0;
}

Measured memory_bytes: 7680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long res = Long.MAX_VALUE;
		for (long i = 1; i*i <= n; i++) {
			if (n % i == 0) {
				int tmpRes = 
						Math.max(
								String.valueOf(i).length(), 
								String.valueOf(n / i).length());
				res = Math.min(tmpRes, res);
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 35200
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string B = "ATCG";

    char ch;
    cin >> ch;

    for (int i = 0; i < B.length(); ++i) {
        if (ch == B[i]) {
            cout << B[i ^ 1] << "\n";
            break;
        }
    }

    return 0;
}

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

//0013
int main(){
	int x;
	stack<int> s;

	while(cin >> x){
		if(x){
			s.push(x);
		}else{
			cout << s.top() << endl;
			s.pop();
		}
		
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

const ll INF = 1e18;
const int MAX_V = 100010;

struct edge{int to; ll cost;};

//V := number of nodes
//G := adj
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];
void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		rep((int)G[v].size(), i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}


void solve(void){
	int K;
	cin >> K;
	V = K;
	rep(K, i) {
		G[i].pb((edge{(i+1)%K, 1LL}));
		G[i].pb((edge{(i*10)%K, 0LL}));
	}
	dijkstra(1);
	cout << d[0] + 1LL << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 8700
#include <iostream>
#include <algorithm>
#include <vector>

bool Check(const std::vector<int>& A, int m, int i, int v)
{
    if(v == m) return true;
    if(v >  m) return false;
    if(A.size() == i) return false;
    return
        Check(A, m, i+1, v + A[i]) ||
        Check(A, m, i+1, v);
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for(int i = 0; i < n; ++i){
        std::cin >> A[i];
    }
    
    int q;
    std::cin >> q;
    for(int i = 0; i < q; ++i){
        int m;
        std::cin >> m;
        std::cout << (Check(A, m, 0, 0) ? "yes" : "no") << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3092
n, m = map(int, input().split())
count = 0
s = [[]*2]*m
for i in range(0, m):
  s[i] = list(map(int, input().split()))
s.sort()
r = s[0][1] - 1
count += 1
for i in range(1, m):
  if s[i][1] < r + 1:
    r = s[i][1] - 1
  if s[i][0] > r:
    r = s[i][1] - 1
    count += 1
print(count)

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

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    int a[100000][3];
    for(int i=0;i<100000;++i)
        a[i][0] = a[i][1] = a[i][2] = 0;

    int zero_cnt = 0;
    int one_cnt = 0;
    int max_one_cnt = 0;
    bool prev_zero = false;

    for(int i=0;i<n;++i)
    {
        if(s[i] == '1')
        {
            one_cnt++;
            prev_zero = false;
            if(one_cnt > max_one_cnt)
                max_one_cnt = one_cnt;
        }            
        else
        {
            if(prev_zero)
            {
                a[zero_cnt - 1][1] += 1;
            }
            else
            {
                ++zero_cnt;
                if(zero_cnt > 1)
                    a[zero_cnt - 2][2] = one_cnt;                
                a[zero_cnt - 1][0] = one_cnt;
                a[zero_cnt - 1][1] = 1;                
                prev_zero = true;
                one_cnt = 0;
            }
        }        
    }

    if(!prev_zero && zero_cnt > 0)
        a[zero_cnt - 1][2] = one_cnt;

    int max_cnt = max_one_cnt;
    int tmp_cnt = 0;

    for(int i=0;i<min(k, zero_cnt);++i)
    {
        tmp_cnt += a[i][0] + a[i][1];
        if(i == min(k, zero_cnt)-1)
            tmp_cnt += a[i][2];
    }

    if(tmp_cnt > max_cnt)
        max_cnt = tmp_cnt;
        
    for(int i=1;i<zero_cnt-k+1;++i)
    {
        tmp_cnt -= a[i-1][0] + a[i-1][1];        
        tmp_cnt += a[i+k-1][1] + a[i+k-1][2];

        if(tmp_cnt > max_cnt)
            max_cnt = tmp_cnt;
    }

    cout << max_cnt << endl;
    return 0;
}

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

#define MAX 2000001
#define VMAX 10000

int n,i,j;

void CountingSort(short A[],short B[],int k)
{
  int C[VMAX+1];
  for(i=0;i<=k;i++) C[i]=0;

  for(j=0;j<n;j++) C[A[j]]++;

  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];

  for(j=n-1;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}

int main(){
  unsigned short *A, *B;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++) scanf("%d",&A[i]);
  CountingSort(A,B,VMAX);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i==n){
      printf("\n");
    }else printf(" ");
  }
  return 0;
}



Measured memory_bytes: 9552
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

const int MX = 1e6;
int isPrime[MX + 5];
vi primes;
void sieve(){
	fill(isPrime + 2, isPrime + MX + 1, 1);
	for (int i = 2; i <= MX; i++){
		if (isPrime[i])
			primes.pb(i);
		for (int j = 0; j < primes.size() && i * primes[j] <= MX; j++)
			isPrime[i * primes[j]] = 0;
	}
}
LL a, b;
int main(){
	sieve();
	a = re<LL>(); b = re<LL>();
	int tot = 1;
	for (int i : primes){
		if (a % i == 0 && b % i == 0){
			tot++;
		}
		while (a % i == 0) a /= i;
		while (b % i == 0) b /= i;
	}
	if (a == b && a > 1) tot++;
	printf("%d\n", tot);
	return 0;
}


Measured memory_bytes: 4732
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

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


Measured memory_bytes: 256
N,K = map(int,input().split())
l = list(map(int,input().split()))
slide = N - K + 1
Max = sum(l[:K])
Sum = 0
count = 0
m = sorted(l)

for i in range(0,slide):
        Sum = sum(m[i:K+i])
        if Max < Sum:
                 Max = Sum
print(Max)

Measured memory_bytes: 3064
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=105;
int n,m; bool g[N][N];
int main()
{
	RI i,j; for (scanf("%d",&n),i=1;i<=n;++i)
	for (j=i+1;j<=n;++j) g[i][j]=1;
	for (i=1;i<n-i+!(n&1);++i) g[i][n-i+!(n&1)]=0;
	for (i=1;i<=n;++i) for (j=i+1;j<=n;++j) if (g[i][j]) ++m;
	for (printf("%d\n",m),i=1;i<=n;++i) for (j=i+1;j<=n;++j)
	if (g[i][j]) printf("%d %d\n",i,j); return 0;
}

Measured memory_bytes: 1704
import math


def main():
    A, B = map(int, input().split())
    la = []
    lb = []
    for i in range(2000):
        if math.floor(i * 0.08) == A:
            la.append(i)
        if math.floor(i * 0.1) == B:
            lb.append(i)
    for sla in la:
        if sla in lb:
            return sla
    return -1


print(main())


Measured memory_bytes: 38512
S = input()
dp = [False for _ in range(len(S)+1)]
char_list = ['dream', 'dreamer', 'erase', 'eraser']
dp[0] = True

for i in range(len(S)):
  if dp[i] == False:
    continue
  for char in char_list:
    if S[i:i+len(char)] == char:
      dp[i+len(char)] = True

if dp[len(S)]:
  print('YES')
else:
  print('NO')
  

Measured memory_bytes: 3956