akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
typedef struct node_t {
    int val;
    struct node_t *prev, *next;
} node;
 
node* new_node(int val) {
    static int it = 0;
    static node pool[500100];
    pool[it] = (node){ val, NULL, NULL };
    return &pool[it++];
}
 
int main(void)
{
    int q, com, x, cnt = 0;
    node *st = new_node(0), *it = st, *tmp;
    scanf("%d", &q);
    while (q--) {
        scanf("%d", &com);
        if (com == 0) {
            scanf("%d", &x);
            tmp = new_node(x);
            if (it == st) st = tmp;
            tmp->next = it;
            tmp->prev = it->prev;
            if (it->prev) it->prev->next = tmp;
            it->prev = tmp;
            it = tmp;
            ++cnt;
        }
        else if (com == 1) {
            scanf("%d", &x);
            if (x >= 0) {
                while (x--) it = it->next;
            }
            else {
                x = -x;
                while (x--) it = it->prev;
            }
        }
        else {
            tmp = it;
            it = it->next;
            if (tmp == st) st = it;
            if (tmp->prev) tmp->prev->next = it;
            it->prev = tmp->prev;
            --cnt;
        }
    }
    while (st->next) {
        printf("%d\n", st->val);
        st = st->next;
    }
    return 0;
}



Measured memory_bytes: 13520
use proconio::{input,fastout};
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        m: usize,
        hs: [usize; n],
        ms: [(usize, usize); m],
    }

    let mut goods = 0;
    let mut pairs = vec![HashMap::new(); n];

    for i in 0..m {
        let left = ms[i].0;
        let right = ms[i].1;

        pairs[left-1].insert(right, ());
        pairs[right-1].insert(left, ());
    }

    'outer: for i in 0..n {
        for neighbor in pairs[i].keys() {
            if hs[i] <= hs[*neighbor-1] {
                continue 'outer;
            }
        }

        goods += 1;
    }

    println!("{}", goods);
}


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

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

	int	n;
	int	maxh;

	cin >> n;
	vector<int> H(n);
	rep(i, n)
		cin >> H.at(i);
	maxh = 0;
	for (int i = 0; i < n - 1;)
	{
		int	h;

		while (i < n - 1 && H.at(i) < H.at(i + 1))	
			i++;
		h = 0;
		while (i < n - 1 && H.at(i) >= H.at(i + 1))
		{
			i++;
			h++;
		}
		maxh = max(h, maxh);
	}
	cout << maxh << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, a, b; cin >> n >> a >> b;
  if ((b-a)%2) {
    ll ans = n;
    // go top
    ans = min(ans, a-1 + 1 + (b-a-1)/2);
    // go bot
    ans = min(ans, n-b + 1 + (b-a-1)/2);
    cout << ans << nl;
  } else {
    cout << (b-a)/2 << nl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[5];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  if(a[0]==a[1]){
    cout<<a[2]<<"\n";
  }
  else{
    cout<<a[0]<<"\n";
  }
  return 0;
}

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

int main()
{
	long long x;
	cin >> x;

	if (x == 2) {
		cout << 2 << endl;
		return 0;
	}
	else if (x % 2 == 0) {
		x++;
	}
	bool flag;
	while (1) {
		flag = true;
		for (int i = 2; i <= (int)sqrt(x); i++) {
			if (x % i == 0) {
				flag = false;
				break;
			}
		}

		if (flag) {
			cout << x << endl;
			return 0;
		}

		x++;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    char s[3][10] = {"Sunny", "Cloudy", "Rainy"};
    char c = getchar();
    int p;
    switch(c)
    {
        case 'S': p = 0; break;
        case 'C': p = 1; break;
        case 'R': p = 2; break;
    }
    printf(s[(p + 1) % 3]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;


int main()
{
  int N, T[50];
  static int dp[2][2501][2501];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> T[i];
  }

  fill_n(**dp, 2 * 2501 * 2501, INF);
  dp[1][0][0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 2500; j >= 0; j--) {
      for(int k = 2500; k >= 0; k--) {
        if(j >= T[i]) dp[i & 1][j][k] = min(dp[i & 1][j][k], dp[(i + 1) & 1][j - T[i]][k]);
        if(k >= T[i]) dp[i & 1][j][k] = min(dp[i & 1][j][k], dp[(i + 1) & 1][j][k - T[i]]);
        dp[i & 1][j][k] = min(dp[i & 1][j][k], dp[(i + 1) & 1][j][k] + T[i]);
      }
    }
    fill_n(*dp[(i + 1) & 1], 2501 * 2501, INF);
  }
  int ret = INF;
  for(int i = 0; i <= 2500; i++) {
    for(int j = 0; j <= 2500; j++) {
      ret = min(ret, max(i, max(j, dp[(N + 1) & 1][i][j])));
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 50032
#include <iostream>
using namespace std;
int main() {
    int d;
    cin >> d;
    int c[26], s[d][26], t[d], last[26], satisfaction = 0;
    for (int i=0; i<26; i++) {
        cin >> c[i];
        last[i] = -1;
    }
    for (int i=0; i<d; i++) {
        for (int j=0; j<26; j++) {
            cin >> s[i][j];
        }
    }
    for (int i=0; i<d; i++) {
        cin >> t[i];
    }
    for (int i=0; i<d; i++) {
        satisfaction += s[i][t[i]-1] + c[t[i]-1] * (i-last[t[i]-1]);
        for (int j=0; j<26; j++) {
            satisfaction -= c[j] * (i-last[j]);
        }
        last[t[i]-1] = i;
        cout << satisfaction << endl;
    }
}

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

using namespace std;

const int maxn = 2e5 + 7;
struct Node{
	int ed,t;
	bool operator < (const Node& a)const{
		return (ed == a.ed) ? (t < a.t) : (ed < a.ed);
	}
}a[maxn];
int n;
int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i)scanf("%d%d",&a[i].t,&a[i].ed);
	int cur = 0;
	sort(a + 1,a + n + 1);
	for(int i = 1; i <= n; ++i){
		cur += a[i].t;
		if(cur > a[i].ed){
			puts("No");
			exit(0);
		}
	}
	puts("Yes");
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)

//変数
ll N,K;

//解法
void solve() {

	ll ans = 0;

	for (int b = K+1; b <= N;b++) {

		//cout << "b=" << b << endl;

		ll cnt = 1;
		while (1) {

			if ((b*cnt - 1) <= N) {
				ans += b - K;
				//cout << "org:" << K + b*(cnt - 1) << "～" << b*cnt - 1 << endl;;
			}
			else {

				if ((K + b*(cnt - 1)) <= N) {
					ans += N - (K + b*(cnt - 1)) + 1;
					//cout << "def:" << K + b*(cnt - 1) << "～" << N << endl;;
				}
				break;
			}

			cnt++;
		}
		//cout << "ans:" << ans << endl;
	}

	if (K == 0) ans -= N - K;

	cout << ans;

	return;
}

int main() {
	//入力
	cin >> N >> K;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  char x , y;
  cin >> x >> y;
  if((int)x > (int)y)
    P(">");
  else if((int)x == (int)y )
    P("=");
  else
    P("<");
  ret 0;
}

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

using namespace std;

int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    if(s1[0] == s2[2]&&s1[1] == s2[1]&&s1[2] == s2[0])
    {
        cout << "YES\n" ;

    }else{
        cout << "NO\n";
    }
    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 2e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];

struct f{
    int cnt;
    int num;
}s[N];
int len;

bool cmp(f x, f y) {
    return x.cnt > y.cnt;
}
int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    int n,k;cin>>n>>k;
    for(int i = 0;i < n;i++) {
        int x;cin>>x;
        a[x]++;
    }
    for(int i = 0;i < N;i++) {
        if(a[i]) {
            s[len].cnt = a[i];
            s[len++].num = i;
        }
    }
    sort(s,s+len,cmp);
    if(k >= len) {
        cout<<0<<endl;
    } else {
        int sum = 0;
        for(int i = k;i < len;i++) {
            sum += s[i].cnt;
        }
        cout<<sum<<endl;

    }

    return 0;
}


Measured memory_bytes: 2560
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, 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 show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
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)


# show_flg = False
show_flg = True


def main():
    N, M = MI()
    ans = 0
    cur = -1.0
    cnt = 1
    correct = 0.5 ** M
    wrong = 1 - correct

    while cnt <= 10**4:
        cur = 0
        if cnt == 1:
            cur = (1900 * M + 100 * (N - M)) * correct
            # print(cur, cnt, (cnt * 1900 * M + cnt * 100 * (N - M)))
        # elif cnt == 2:
        #     cur = (cnt * 1900 * M + cnt * 100 * (N - M)) * \
        #         correct * (wrong ** (cnt - 1))
        #     print(cur, cnt, (cnt * 1900 * M + cnt * 100 * (N - M)))
        else:
            cur = (cnt * 1900 * M + cnt * 100 * (N - M)) * \
                correct * (wrong ** (cnt - 1))
            # cur = (cnt * 1900 * M + cnt * 100 * (N - M)) * \
            #     correct * (wrong ** (cnt - 1) ** M)
        ans += cur
        cnt += 1

    print(int(ans + 0.0001))


if __name__ == '__main__':
    main()


Measured memory_bytes: 66412
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];

            var rPts = new Tuple<long, long>[N];
            var bPts = new Tuple<long, long>[N];
            for (var i = 0; i < N; ++i)
            {
                var ab = Sarray();
                rPts[i] = Tuple.Create(ab[0], ab[1]);
            }
            for (var i = 0; i < N; ++i)
            {
                var cd = Sarray();
                bPts[i] = Tuple.Create(cd[0], cd[1]);
            }
            var rPairs = new List<HashSet<Tuple<long, long>>>();
            var bCount = new Dictionary<Tuple<long, long>, long>();
            for (var i = 0; i < N; ++i)
            {
                rPairs.Add(bPts.Where(b => rPts[i].Item1 < b.Item1 && rPts[i].Item2 < b.Item2).ToHashSet());
                bCount[bPts[i]] = rPts.Where(r => r.Item1 < bPts[i].Item1 && r.Item2 < bPts[i].Item2).Count();
            }
            rPairs.Sort((l, r) => r.Count.CompareTo(l.Count));
            var ans = 0L;
            while (rPairs.Any())
            {
                var lst = rPairs.Count - 1;
                if (0 == rPairs[lst].Count)
                {
                    rPairs.RemoveAt(lst);
                    continue;
                }
                var min = N + 1;
                var sel = new Tuple<long, long>(0, 0);
                foreach (var rpt in rPairs[lst])
                {
                    if (bCount[rpt] < min)
                    {
                        min = bCount[rpt];
                        sel = rpt;
                    }
                }
                ++ans;
                rPairs.RemoveAt(lst);
                foreach (var rpt in rPairs)
                    rpt.Remove(sel);
                rPairs.Sort((l, r) => r.Count.CompareTo(l.Count));
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 29076
#include <stdio.h>

int main()
{
  int n,y,a,b,count=0;

  scanf("%d%d", &n, &y);

  for (a=0; a <= n; a++) {
    for (b=0; b <= n-a; b++) {
      if (y == 10000*a + 5000*b + 1000*(n-a-b)) {
        printf("%d %d %d\n", a, b, n-a-b);
        count++;
        break;
      }
    }
    if (count > 0) {
      break;
    }
  }
  if (count <= 0) {
    printf("-1 -1 -1\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
/*
int stoi(string sstoi){//string->int
  ll int stois=0;
  rep(stoii,0,sstoi.length()){
    stois+=ctoi(sstoi[stoii])*jo(10,sstoi.length()-stoii-1);
  }
  return stois;
}*/
  
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  vector<int> a(3);
  int k;
  rep(i,0,3) cin>>a[i];
  cin>>k;
  asort(a);
  cout<<a[0]+a[1]+a[2]*jo(2,k);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示


Measured memory_bytes: 256
time = int(input())
nums = list(map(int,input().split(" ")))
count = 0

for i in range(time):
    top = nums[i]
    mi = min(nums[i:])
    if top > mi:
        count += 1
        a = top
        #0が複数あるからここでひっかかってしまう
        #同じ値がある場合にどうやって最小値の位置を特定するのかが問題
        tmpIndex = nums[i:].index(mi) + i
        nums[i] = mi
        nums[tmpIndex] = a

print(' '.join(map(str,nums)))
print(count)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int a[100005],b[100005];
ll res,ans;
int mpp[100005][2];
int x1,x2,x3,x4;//(0,0)(0,1)(1,0)(1,1)
vector<pair<int,pair<int,int> > > app;
int main(){
	cin>>m;
	n=m*2;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		app.push_back(make_pair(a[i],make_pair(i,0)));
		app.push_back(make_pair(b[i],make_pair(i,1)));
	}
	sort(app.begin(),app.end());
	for(int i=0;i<m;i++){
		pair<int,pair<int,int> > o=app[i];
		mpp[o.second.first][o.second.second]=1;
		res+=o.first;
	}
	x1=x2=x3=x4=0;
	for(int i=0;i<m;i++){
		if(mpp[i][0]==0){
			if(mpp[i][1]==0){
				x1++;
			}
			else x2++;
		}
		else{
			if(mpp[i][1]==0) x3++;
			else x4++;
		}
	}
	ans=res;
	if(x1>0){
		cout<<res<<endl;
		return 0;
	}
	else{
		if(x2==0 || x3==0){
			cout<<res<<endl;
			return 0;
		}
		else{
			pair<int,pair<int,int> > o,p;
			o=app[m-1];
			mpp[o.second.first][o.second.second]=0;
			res-=o.first;
			if(app[m].second.first==o.second.first){
				res+=app[m+1].first;
				ans-=app[m-2].first;
				ans+=app[m].first;
				res=min(res,ans);
			}
			else res+=app[m].first;
		}
	}
	cout<<res<<endl;
	return 0;
}

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

const int INF = 100000000;
const int C_MAX = 10;
const int N_MAX = 100;

//街の情報 <残りの割引券, 街の番号>
typedef pair<int, int> T;
//地点情報 <最小コスト, <残りの割引券, 街の番号>>
typedef pair<int, T> P;

//c: チケットの枚数(1 <= c <= 10)
//n: バスをつなぐ町の数(2 <= n <= 100)
//m: バスの路線数(1 <= m <= 500)
//s: 出発地点
//d: 目的地
int c, n, m, s, d;
//cost[町の番号][残りの割引券] = 費用
int cost[N_MAX][C_MAX + 1];

//すでにコストの最適値が決定済みかどうか
bool flag[N_MAX][C_MAX + 1];

//町間の料金
int line[N_MAX][N_MAX];

typedef priority_queue<P, vector<P>, greater<P> > Q;
Q dp_q;

int dijkstra(){
	while(!dp_q.empty()){
		P p = dp_q.top(); dp_q.pop();
		T &t = p.second;

		//p.first: 最小コスト
		//t.first: 残りの割引券
		//t.second: 町番号

		//既に最適値なのかどうかを調べる
		if(flag[t.second][t.first])	continue;
		flag[t.second][t.first] = true;

		if(t.second == d){
			return p.first;
		}

		//すべての頂点に対して割引券を使ったか使ってないかを決める
		for(int i = 0; i < n; ++i){
			//割引券を使わなかった場合のiのコスト
			//(t.secondでの最小コスト + t.second -> iの料金)が割引券がt.firstの時の町iのコストより小さい
			//時にc[i][t.first]を更新
			if(cost[i][t.first] > p.first + line[t.second][i]){
				cost[i][t.first] = p.first + line[t.second][i];
				dp_q.push(P(p.first + line[t.second][i], T(t.first, i)));
			}

			//割引券を使った場合のiのコスト
			//(t.secondでの最小コスト + t.second -> iの料金の半分)が
			//割引券がt.first - 1の時の町iのコストより小さい時に
			//c[i][t.first - 1]を更新
			if(t.first > 0 && cost[i][t.first - 1] > p.first + line[t.second][i] / 2){
				cost[i][t.first-1] = p.first + line[t.second][i] / 2;
				dp_q.push(P(p.first + line[t.second][i] / 2, T(t.first - 1, i)));
			}
		}
	}

	return INF;
}

void solve(){
	for(int i = 0; i < N_MAX; ++i){
		for(int j = 0; j < C_MAX; ++j){
			cost[i][j] = INF;
			flag[i][j] = false;
		}
	}

	dp_q = Q();
	dp_q.push(P(0, T(c, s)));

	cout << dijkstra() << endl;
}

int main(void){
	int a, b, f;

	while(true){
		cin >> c >> n >> m >> s >> d;
		if(!c && !n && !m && !s && !d)	break;
		s--; d--;
		
		for(int i = 0; i < N_MAX; ++i){
			for(int j = 0; j < N_MAX; ++j){
				line[i][j] = INF;
			}
		}

		for(int i = 0; i < m; ++i){
			cin >> a >> b >> f;
			a--;	b--;
			line[a][b] = f;
			line[b][a] = f;
		}

		solve();
	}
  return 0;
}

Measured memory_bytes: 1284
#include<stdio.h>

int main(){
	int a,b;
	char str[20];
	bool valids = true;
	
	scanf("%d %d", &a,&b);
	scanf("%s",str);
	
	if(str[a]!='-'){
	 valids = false;	
	}
	
	for (int i=0;str[i] !='\0';i++){
		if(i != a){
			if(str[i]<'0'){
				valids = false;
				break;
			}
		}
	}
	(valids) ? puts("Yes") : puts ("No");
	
	
	return 0;
}

Measured memory_bytes: 1660
foods = [ int(input()) for _ in range(5) ]

time = 0
result = 0

for food in foods:
  if food % 10 == 0:
    result += food
  else:
    result += (food // 10 + 1) * 10
    if (10 - (food % 10)) > time:
      time = 10 - food % 10

print(result - time)

Measured memory_bytes: 3060
n = int(input())
words = {}
for i in range(n):
    s = input()
    if s in words.keys():
        words[s] = words[s]+1
    else:
        words[s]=1
        
sorted_words = sorted(words.items(),reverse=True,key=lambda x:x[1])
ma = sorted_words[0][1]
ans = []
for i in range(len(sorted_words)):
    if sorted_words[i][1]==ma:
        ans.append(sorted_words[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)



Measured memory_bytes: 45784
N, M = map(int, input().split())

dic = {i:[(0,0)] for i in range(1,N+1)}
lst = ['']*M

for i in range(M):
  p,y = map(int, input().split())
  dic[p].append((y,i))
  
for k in dic:
  dic[k].sort(key=lambda x:x[0])
  for i in range(1,len(dic[k])):
    lst[dic[k][i][1]] = str(k).zfill(6)+str(i).zfill(6)
    
for l in lst:
  print(l)

Measured memory_bytes: 103288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S, ans = "";
	int w, len;

	cin >> S >> w;
	len = S.length();

	rep(i, len) {
		if (i % w == 0) ans.push_back(S[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def cmb(a, b):
    if a == b or b == 0: return 1
    c = a - b
    if b > c:
        return cmb(a, c)

    ans = 1
    for i in range(a, a - b, -1):
        ans *= i
    from math import factorial
    return ans // factorial(b)

def resolve():
    N, K = iim()
    mod = 10**9 + 7

    if N > K:
        print(0)
        return

    print(cmb(K, N) % mod)

if __name__ == "__main__":
    resolve()



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

int main() {
  string n;
  cin >> n;
  if(n[0]=='7'||n[1]=='7'||n[2]=='7'){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }
}

Measured memory_bytes: 3628
#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;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    string S;
    cin >> S;
    bool ok = (S[0] == 'A');
    int cnt = 0;
    bool smll = ('a' <= *rbegin(S) && *rbegin(S) <= 'z');
    smll &= ('a' <= S[1] && S[1] <= 'z');
    REP(i, 2, S.size() - 1) {
        if (S[i] == 'C') {
            cnt++;
        } else {
            smll &= ('a' <= S[i] && S[i] <= 'z');
        }
    }
    cout << (ok && cnt == 1 && smll ? "AC" : "WA") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto& x: a)
    cin >> x;
  int ans = 1;
  bool zouka;
  int init = 0;
  while(init < n-1){
    if(a[init] < a[init+1]){
      zouka = true;
      break;
    }else if(a[init] > a[init+1]){
      zouka = false;
      break;
    }else{
      init++;
      continue;
    }
  }

  for(int i = init; i < n-1; i++){
    if(zouka){
      if(a[i] <= a[i+1]){
        continue;
      }else{
        // 次は増加列かそうでないかを確認する
      }
    }else{
      if(a[i] >= a[i+1]){
        continue;
      }else{
        // 次は増加列かそうでないかを確認する
      }
    }
    ans++;
    while(i < n-1){
      i++;
      if(a[i] < a[i+1]){
        zouka = true;
        break;
      }else if(a[i] > a[i+1]){
        zouka = false;
        break;
      }else{
        continue;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
#define MP m ake_pair
#define LB lower_bound
#define UB upper_bound

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef long double DB;

const int N = 100100 , INF = 1000*1000*1000LL;

vector <int> adj[N];
queue <int> q;
bool mark[N];
int dp[N] , ds[N] , c[N] , deg[N] , ans(0) , n;

void buildtree(){
	
	for(int i = 0 ; i < n ; i++){
	   deg[i] = adj[i].size();
	   if(deg[i] == 1 && c[i] == 1)
		  q.push(i);
	}
	   
	while(!q.empty()){
	   int v = q.front();
	   q.pop();
	   mark[v] = 1;
	   for(int u : adj[v])
		  if(!mark[u]){
			 deg[u]--;
			 if(deg[u] == 1 && c[u] == 1)
				q.push(u);
		  }
	}

	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < adj[i].size() ; j++){
		   	int u = adj[i][j];
			if(mark[u]){
			   swap(adj[i][j] , adj[i].back());
			   adj[i].pop_back();
			   j--;
			}
		}
	}
	
	return;
}

void DFS1(int v , int par){

	dp[v] = ds[v] = c[v];
	
	for(int u : adj[v])
	   	  if(u != par){
			   DFS1(u , v);
			   dp[v] = min(dp[v] , dp[u] + c[v] - 1);
		  }
	
	return;
}

void DFS2(int v , int par){
   	
	if(v != par)
		ds[v] = min(ds[par] + c[v] - 1 , ds[v]);
	
	for(int z = 0 ; z < 2 ; z++){
		int mn = INF;
		for(int u : adj[v]){
			if(u != par){
				ds[u] = min(ds[u] , mn + c[u] + c[v] - 2);
				mn = min(dp[u] , mn);
				if(z)
				   DFS2(u , v);
			}
		}
	}
	
	return;
}

void DFS3(int v , int par){

	int t(0);
	for(int u : adj[v])
	   if(u != par)
		  DFS3(u , v) , t++;
	
	if(!t && v != par)
	   ans = min(ans , ds[par] - 1);
	
	return;
}

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

	int u , v;
	char ch;
	cin >> n;

	for(int i = 1 ; i < n ; i++){
	   cin >> u >> v;
	   adj[--u].PB(--v);
	   adj[v].PB(u);
	}

	for(int i = 0 ; i < n ; i++){
	   cin >> ch;
	   c[i] = (ch == 'W' ? 0 : 1);
	}
	
	buildtree();
	
	int r(-1) , num(0) , cnt(0) , lst(0);
	for(int i = 0 ; i < n ; i++)
	   if(!mark[i]){
		  cnt++;
		  if(adj[i].size() > 1)
			  r = i;
			  
		  if(!c[i])
			 num++;			 
		  c[i] = (c[i] + adj[i].size()) % 2;
		  if(!c[i])
			 c[i]-- , lst++;
	   }
	
	if(num < 2){
	   cout << num << endl;
	   return 0;
	}
	
	if(r == -1){
	   cout << 2 << endl;
	   return 0;
	}
	   


	DFS1(r , r);
	DFS2(r , r);
	DFS3(r , r);
	
	cout <<  cnt*2 - 2 + lst + ans << endl;

	return 0;	
}

Measured memory_bytes: 14720
# D
N,A,B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

max_mean = sum(v[:A])/A
print(max_mean)

from collections import Counter
from math import factorial

def comb(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))

v_count = Counter(v)
ans = 0
if v[0]==v[A-1]:
    n = v_count[v[A-1]]
    for r in range(A, B+1):
        if r>n: break
        ans += comb(n, r)
else:
    #print(n, r)
    n = v_count[v[A-1]]
    select_count = Counter(v[:A])
    r = select_count[v[A-1]]
    ans = comb(n,r)
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int T = Integer.parseInt(sc.next());
        int num = (T / A) * B;
        System.out.print(num);
    }
}

Measured memory_bytes: 23124
#include<stdio.h>

int main(void){
  int N,i;
  scanf("%d",&N);
  i=1;
  while(i*27/25<N){
    i++;
  }
  if(i*27/25==N){
    printf("%d",i);
  }else{
    printf(":(");
  }
  
  return 0;
}
  

Measured memory_bytes: 128
n = int(input())
no1 = -1
no1_i = -1
no2 = -2
no2_i = -1
S = []
for _ in range(n):
    S.append(int(input()))
 
for i in range(n):
  if S[i] > no1:
    no1_i =i
    no1 = S[i]
  elif S[i] > no2:
    no2_i = i
    no2 = S[i]
      
for i in range(n):
  if no1_i == i:
    print(no2)
  else:
    print(no1)

Measured memory_bytes: 12532
//输入N,S
//代表S的长度为N
//刚开始你在海拔0米的地方
//如果 S[i]=I的话往上爬1米
//如果 S[i]=D的话往下爬1米
//输出你最高站在海拔多少米(包括最开始的海拔0米)
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,maxn=0;
	cin>>n;
	char s[n+10];
	cin>>s;
	long long k=0;
	for(int i=0;i<=n-1;i++){
		if(s[i]=='I'){
			k+=1;
		}
		else if(s[i]=='D'){
			k-=1;
		}
		maxn=max(maxn,k);
		continue;
	}
	cout<<maxn<<endl;
	//cout<<s[0]<<" "<<s[n-1];
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll d; cin >> d; ll happy = 0;
  vl whatday(26);
  
  vector<bool> israted(26,false);
  
  vl human(26);
  rep(i,26) cin >> human[i];
  
  vvl userhappy(d,vl(26));  
  rep(i,d){
    rep(j,26){
      cin >> userhappy[i][j];
    }
  }
  
 
  rep(i,d){
    ll now = 0; ll nowhappy = 0;
    rep(j,26){
      if(israted[j]){
        if(userhappy[i][j] + 
           pow((human[j]*(i-whatday[j])),1.4) > nowhappy){
          now = j;
          nowhappy = userhappy[i][now] + 
            pow((i-whatday[j])*human[j],1.4);
        }
      }
      else if(userhappy[i][j] > nowhappy){
        now = j;
        nowhappy = userhappy[i][now];
      }
    }
    
    cout << now+1 << endl;
    israted[now] = true;
    whatday[now] = i;
  }
  
  
}

Measured memory_bytes: 4216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> c(H);
  rep(i, H) { cin >> c[i]; }

  int result = 0;
  rep(xflags, 1 << H) rep(yflags, 1 << W) {
    int black = 0;
    rep(i, H) rep(j, W) {
      if (!bitset<6>(xflags)[i] && !bitset<6>(yflags)[j] && c[i][j] == '#') {
        black++;
      }
    }
    if (black == K) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  int a;
  double b,c,BMI;
  
  while(scanf("%d,%lf,%lf",&a,&b,&c)!=EOF){
    BMI=b/(c*c);
    if(BMI>=25){
      printf("%d\n",a);
    }
  }
  return 0;
}

Measured memory_bytes: 628
using System;
using static System.Math;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = ReadLine();
			if (s[s.Length-1]=='s')
			{
				s += "es";
			}
			else {
				s += "s";
			}
			Console.WriteLine(s);
		}
		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n-1, m-1) / m;
		}
		public static double nC2(double n)
		{
			return (n*(n-1))*0.5;
		}
		public static string ReadLine()
		{
			return Console.ReadLine();
		}
		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}
		public static string[] ReadLineStringSplit(char s=' ')
		{
			return ReadLine().Split(s).ToArray();
		}
		public static int[] ReadLineIntSplit(char s=' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}
		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
		static long longPow(long x, long y, long mod)
		{
			long result = 1;
			for (int i = 0; i < y; i++)
				result = (result * x)%mod;
			return result;
		}
	}
}

Measured memory_bytes: 17340
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    mod = 1000000007

    H, W = map(int, input().split())
    a = [list(input().rstrip()) for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if a[i][j]=='#':
                a[i][j] = 0
    a[0][0] = 1
    for i in range(H):
        for j in range(W):
            if a[i][j]=='.':
                if i==0:
                    a[i][j] = a[i][j-1]
                elif j==0:
                    a[i][j] = a[i-1][j]
                else:
                    a[i][j] = a[i-1][j] + a[i][j-1]
    print(a[H-1][W-1]%mod)



if __name__ == '__main__':
    main()

Measured memory_bytes: 157672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	ll N;
	cin >> N;
	ll gg = (N-1) / 11;
	gg = 2 * gg;
	ll ans = (N-1)% 11;
	ans++;
	if(ans > 6) gg++;
	cout <<gg + 1  << "\n";
	
	
}



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

using namespace std;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int main(){
  ll n,ans;
  cin>>n;
  
  ll m = log10(n);
  
  if(m==1){
	ans=9;
  }else if(m==3){
    ans=909;
  }else if(m==5){
    ans=90909;
  }else if(m==2){
    ans=9+n-99;
  }else if(m==0){
    ans=n;
  }else{
	ans=9+900+n-9999;
  }
  
  
  cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;


struct node {
    int p, l, r;
    int d, h;
};
node nodes[100000];


void reg_depth(int id, int d)
{
    nodes[id].d = d;
    if (nodes[id].l >= 0)
        reg_depth(nodes[id].l, d + 1);
    if (nodes[id].r >= 0)
        reg_depth(nodes[id].r, d + 1);
}


int reg_height(int id)
{
    if (nodes[id].l == -1 && nodes[id].r == -1)
        return 0;

    int h, lh, rh;
    if (nodes[id].l >= 0)
        lh = reg_height(nodes[id].l) + 1;
    else
        lh = 0;
    if (nodes[id].r >= 0)
        rh = reg_height(nodes[id].r) + 1;
    else
        rh = 0;

    h = max(lh, rh);
    nodes[id].h = h;
    return h;
}


int main()
{
    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
        nodes[i].p = -1;

    for (int i = 0; i < n; i++) {
        int id, l, r;
        cin >> id;
        cin >> l >> r;
        nodes[id].l = l;
        nodes[id].r = r;

        if (l >= 0)
            nodes[l].p = id;
        if (r >= 0)
            nodes[r].p = id;
    }

    int root;
    for (int i = 0; i < n; i++) {
        if (nodes[i].p == -1) {
            root = i;
            break;
        }
    }

    reg_depth(root, 0);
    reg_height(root);

    for (int i = 0; i < n; i++) {
        int s = -1;
        if (nodes[i].p != -1) {
            int l, r;
            l = nodes[nodes[i].p].l;
            r = nodes[nodes[i].p].r;
            s = l != i ? l : r;
        }
        int deg = 0;
        if (nodes[i].l != -1)
            deg++;
        if (nodes[i].r != -1)
            deg++;

        string type;
        if (nodes[i].p == -1)
            type = "root";
        else if (nodes[i].l == -1 && nodes[i].r == -1)
            type = "leaf";
        else
            type = "internal node";

        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
                i, nodes[i].p, s, deg, nodes[i].d, nodes[i].h);
        cout << type << endl;
    }

    return 0;
}


Measured memory_bytes: 3356
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
T=int(input())
def cost(n):
 if n in memo:
  return memo[n]
 else:
  ans=n*d
  if n//2 in memo:
   ans=min(memo[n//2]+a*min(1,memo[n//2])+(n%2)*d,ans)
  else:
   ans=min(cost(n//2)+a*min(1,cost(n//2))+(n%2)*d,ans)
  if n//3 in memo:
   ans=min(memo[n//3]+b*min(1,memo[n//3])+(n%3)*d,ans)
  else:
   ans=min(cost(n//3)+b*min(1,cost(n//3))+(n%3)*d,ans)
  if n//5 in memo:
   ans=min(memo[n//5]+c*min(1,memo[n//5])+(n%5)*d,ans)
  else:
   ans=min(cost(n//5)+c*min(1,cost(n//5))+(n%5)*d,ans)
  if n//2+1 in memo:
   ans=min(memo[n//2+1]+a+(2-(n%2))*d,ans)
  else:
   ans=min(cost(n//2+1)+a+(2-(n%2))*d,ans)
  if n//3+1 in memo:
   ans=min(memo[n//3+1]+b+(3-(n%3))*d,ans)
  else:
   ans=min(cost(n//3+1)+b+(3-(n%3))*d,ans)
  if n//5+1 in memo:
   ans=min(memo[n//5+1]+c+(5-(n%5))*d,ans)
  else:
   ans=min(cost(n//5+1)+c+(5-(n%5))*d,ans)
  memo[n]=ans
  return ans
for j in range(T):
 N,a,b,c,d = map(int,input().split())
 memo = {0:0,1:d,2:min(2*d,a+d)}
 print(cost(N))
 memo={}


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

int gcd(int m,int n){
    int temp;
    if(m<n){swap(m,n);}
    if(n==0){
        return m;
    }
    while(n!=0){
        temp=m%n;
        m=n;
        n=temp;
    }
    return m;
}

int main(){
    int n,ans=0,tmp=0;
    cin>>n;
    int a[n+1],l[n+2],r[n+2];
    for(int i=1;i<n+1;i++){cin>>a[i];}
    l[0]=0;
    l[1]=a[1];
    r[n+1]=0;
    r[n]=a[n];
    for(int i=2;i<n+1;i++){l[i]=gcd(l[i-1],a[i]);}
    for(int i=n;i>0;i--){r[i]=gcd(r[i+1],a[i]);}
    for(int i=1;i<n+1;i++){
        tmp=gcd(l[i-1],r[i+1]);
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
s = list(input())
K = int(input())

for i in range(len(s)):
    if s[i] == "a":
        pass
    elif 123 - ord(s[i]) <= K:
        K -= (123 - ord(s[i]))
        s[i] = 'a'

K = K % 26
while K > 0:
    K -= 1
    if s[-1] == "z":
        s[-1] = "a"
    else:
        s[-1] = chr(ord(s[-1]) + 1)
print("".join(s))

Measured memory_bytes: 4284
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{ 
   int r;
   cin >> r;
   string ans = "AGC";
   if(r<1200)
      ans = "ABC";
   else if(r<2800)
      ans = "ARC";
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void shokika(int d[]){
	for(int i=0;i<51;i++){
		d[i]=0;
	}
}

int main(){
	int n,p,stoneNum;
	int haveStone[51];
	while(cin>>n>>p, n&&p){
		
		shokika(haveStone);
		stoneNum=p;
		
		for(int j=0;j<=n;j++){
			
			if(j==n){
				j=0;
			}
			
			//お椀が空の時
			if(p==0){
				//全ての石を自分で持っていないなら
				if(haveStone[j]!=stoneNum){
					p=haveStone[j];
					haveStone[j]=0;
				}
			}else{
				haveStone[j]++;
				p--;
			}
			//全て自分で持っているなら
			if(haveStone[j]==stoneNum){
				cout<<j<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1160
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
d = {}
L, R = -1, -1
for i in range(n + 1):
    if a[i] in d:
        L = d[a[i]] + 1
        R = i + 1
        break
    else:
        d[a[i]] = i

MOD = 10 ** 9 + 7
M = 100005
fact = [0] * M
fact[0] = 1
for i in range(1, M):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * M
rfact[M - 1] = pow(fact[M - 1], MOD - 2, MOD)
for i in range(M - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD

def comb(x, y):
    if x < 0 or y < 0 or x < y:
        return 0
    return fact[x] * rfact[y] * rfact[x - y] % MOD


for i in range(1, n + 2):
    print((comb(n + 1, i) - comb(n + 1 - R + L - 1, i - 1)) % MOD)

Measured memory_bytes: 25792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) {
        return 1;
    }
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
int main() {
    IN(int, n);
    IN(int, m);
    vector<vector<bool>> a(n,vector<bool>(n,false));
    REP(i, m){
        IN(int, k);
        IN(int, l);
        a[k-1][l-1] = true;
        a[l-1][k-1] = true;
    }
    vector<int> li;
    REP(i, n){
        li.push_back(i);
    }
    int ans = 0;
    do {
        if (li[0]!=0) {
            break;
        }
        cout << endl;
        bool flag = true;
        REPS(i, n-1){
            if (!a[li[i-1]][li[i]]) {
                flag = false;
            }
        }
        if (flag) {
            ans ++;
        }
    } while (next_permutation(ALL(li)));
    COUT(ans);
}




Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int A1 = scan.nextInt();
        int A2 = scan.nextInt();
        int A3 = scan.nextInt();
        if(A1 + A2 + A3 >= 22 )
            os.println("bust");
        else
            os.println("win");
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	vi in(3);
	rep(i,s.size())in[s[i]-'a']++;
	sort(all(in));
	if(in[2]-in[0]>1)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}











Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int a, b;

int main() {
    int res = 0, num = 0, kind = 0;
    while (scanf("%d,%d", &a, &b) != EOF) {
        res += a * b;
        num += b;
        ++kind;
    }
    
    int ave = num / kind;
    int amari = num % kind;
    
    if (amari * 2 >= kind) ++ave;
    
    cout << res << endl;
    cout << ave << endl;
    
    return 0;
}


Measured memory_bytes: 1204