akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
using Weight = int;
struct Edge {
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };
//???????§?????????????(???????????????) Single Source Shortest Path
//Dijkstra O((E+V)logV)
//dist: ?§????????????????????????§??????????????¢ distance
//?????????: ???????????¨????????????(??????-1)
vector<int> dijkstra(const Graph &g, int s, vector<Weight> &dist) {
	using State = tuple<Weight, int, int>; //?§?????????????????°?????????? ??? ???
	priority_queue<State, vector<State>, greater<State>> PQ;
	int n = g.size();
	vector<int> color(n, WHITE);
	vector<int> prev(n, -1);
	dist.assign(n, INF);
	dist[s] = 0; PQ.emplace(0, s, -1); color[s] = GRAY; //?§????
	while (PQ.size()) {
		Weight d; int v, u;
		tie(d, v, u) = PQ.top(); PQ.pop(); //dist???????°???¨??????State???????????????
		if (dist[v] < d)continue; //?????§???????????§???????????°??????
		color[v] = BLACK;
		prev[v] = u;
		for (auto &e : g[v]) { //??£??\????????????????????¨????????????		
			if (color[e.d] == BLACK)continue; //??¢?´¢????????????
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				PQ.emplace(dist[e.d], e.d, v);
				color[e.d] = GRAY;
			}
		}
	}
	return prev;
}
signed main() {
	int V, E, r; cin >> V >> E >> r;
	Graph g(V);
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		g[s].emplace_back(s, t, d);
	}
	Array dist;
	dijkstra(g, r, dist);
	for (auto d : dist) {
		if (d == INF)cout << "INF" << endl;
		else cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 16792
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
    ll x,y; cin >> x >> y;
    if(abs(x-y)<=1){
        cout << "Brown" << endl;
    }
    else{
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{

    char na[11];
    
    int ti;
}pro;

int main(void){

    int i, n, q;

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

    pro pr[n];

    for(i=0;i<n;i++) scanf("%*c%s %d", pr[i].na, &pr[i].ti);

    int top=0, tail=0, tim=0, sta=0;

    while(1){

        if(sta==1 && top==tail) break;

        if(pr[top].ti<=q){

            tim+=pr[top].ti;

            pr[top].ti=0;

            printf("%s %d\n", pr[top].na, tim);

        }

        else{

            tim+=q;

            pr[top].ti-=q;

            pr[tail]=pr[top];

            tail++;

        }

        top++;

        if(top!=tail) sta=1;

        if(top==n) top=0;
        if(tail==n) tail=0;

    }

    return 0;

}


Measured memory_bytes: 2480
//atcoder.jp abc 120 d
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	
	while(!isdigit(ch)){
	   if(ch=='-')
	      f=-1;
	   ch=getchar();
	}
	
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
    //freopen("","r",stdin);
    //freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);/*syn加速*/
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;   //c(n,2)
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n>3199) cout<<s<<endl;
  else cout<<"red"<<endl;
  
  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const long double eps=1e-3;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<long double> xs(n),ys(n);
        rep(i,0,n) cin >> xs[i] >> ys[i];

        auto count=[&](const long double x,const long double y){
            int res=0;
            rep(i,0,n) if((xs[i]-x)*(xs[i]-x)+(ys[i]-y)*(ys[i]-y)<=1+eps) ++res;
            return res;
        };

        int ans=0;
        rep(i,0,2401){
            const long double y=10.*i/2400;
            rep(j,0,n){
                const long double tmp=1-(ys[j]-y)*(ys[j]-y);
                if(tmp<0) continue;
                const long double x1=xs[j]-sqrtl(tmp),x2=xs[j]+sqrt(tmp);
                ans=max({ans,count(x1,y),count(x2,y)});
            }
        }
        cout << ans << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 3324
#include<iostream>

using namespace std;

bool zone(int left,int target,int right){

	if(target<left)	return false;
	if(target>right) return false;
	return true;

}

int main(){

	int w,h,x,y,r;
	bool judge = true;

	cin>>w;
	cin>>h;
	cin>>x;
	cin>>y;
	cin>>r;

	if(!zone(0,x+r,w)) judge = false;
	if(!zone(0,x-r,w)) judge = false;
	if(!zone(0,y+r,h)) judge = false;
	if(!zone(0,y-r,h)) judge = false;

	if( judge )	cout<<"Yes"<<endl;
	else 		cout<<"No"<<endl;

}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int K = sc.nextInt();
            int X = sc.nextInt();

            int min = X - K + 1;
            int max = X + K - 1;

            System.out.println(min);
            for (int i = min + 1; i <= max; i++) {
                System.out.println(" " + i);
            }
        }
    }

}


Measured memory_bytes: 21716
N, P = map(int, input().split())
S = input()
if P == 2:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['2', '4', '6', '8', '0']:
            counter += i + 1
    print(counter)
elif P == 5:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['5', '0']:
            counter += i + 1
    print(counter)
else:
    list_a = [0] * P
    list_a[0] += 1
    counter = 0
    temp = 0
    power = 1
    for i in range(N):
        temp += pow(10, i, P) * int(S[N-i-1])
        temp %= P
        counter += list_a[temp]
        list_a[temp] += 1
    print(counter)



Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> as(n+1), bs(n);
    for(int i=0; i<n+1; ++i){
        cin >> as[i];
    }
    for(int i=0; i<n; ++i){
        cin >> bs[i];
    }
    long long ans=0;
    for(int i=0; i<n; ++i){
        int x=min(as[i], bs[i]);
        ans+=x;
        bs[i]-=x;
        int y=min(as[i+1], bs[i]);
        ans+=y;
        as[i+1]-=y;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

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

    int n = c-a;
    int m = d-b;

    for(int i=0;i<n;i++)
        cout << 'R';
    
    for(int i=0;i<m;i++)
        cout << 'U';

    for(int i=0;i<n;i++)
        cout << 'L';

    for(int i=0;i<m;i++)
        cout << 'D';

    cout << 'D';
    
    for(int i=0;i<=n;i++)
        cout << 'R';
    
    for(int i=0;i<=m;i++)
        cout << 'U';

    cout << "LU";

    for(int i=0;i<=n;i++)
        cout << 'L';

    for(int i=0;i<=m;i++)
        cout << 'D';
    
    cout << 'R';
}

Measured memory_bytes: 256
#カントリーロード
t=int(input())
for i in range(t):
    N,K=map(int, input().split())
    X=list(map(int,input().strip().split()))
    a=[0]
    for j in range(N-1):
        a.append(X[j+1]-X[j])
    b=sorted(a, reverse=True)
    if K>1:
        del b[0:K-1]

    print(sum(b))   


Measured memory_bytes: 22108
#include<iostream>
#include<vector>
#define mod 1000000007
#define DIM 500005
using namespace std;
int n, i, ii, sol, sum, s, x;
int z[DIM], d[DIM];
vector<int> v[(1 << 20) + 2];
int main(){
    cin>> n;
    for(i = 1; i <= n; i++){
        cin>> x;
        s ^= x;
        v[s].push_back(i);
        if(s == 0){
            z[i] = 1;
        }
        z[i] += z[i - 1];
    }
    if(s != 0){
        ii = s;
        sum = 1;
        s = 0;
        d[0] = 1;
        for(i = 1; i <= v[ii].size() - 1; i++){
            s = (s + sum * 1LL * (z[ v[ii][i] ] - z[ v[ii][i - 1] ]) ) % mod;
            d[i] = (s + 1) % mod;
            sum = (sum + d[i]) % mod;
        }
        cout<< d[ v[ii].size() - 1];
        return 0;
    }
    sol = 1;
    for(i = 1; i < v[0].size(); i++){
        sol = sol * 2 % mod;
    }
    for(ii = 1; ii < (1 << 20); ii++){
        if(v[ii].size() == 0){
            continue;
        }
        sum = 1;
        s = 0;
        for(i = 1; i < v[ii].size(); i++){
            s = (s + sum * 1LL * (z[ v[ii][i] ] - z[ v[ii][i - 1] ]) ) % mod;
            d[i] = (s + 1) % mod;
            sum = (sum + d[i]) % mod;
        }
        sol = (sol + sum) % mod;
    }
    cout<< sol;
}


Measured memory_bytes: 38388
import itertools
A = list(input())
n = len(A)

if(n == 1):
  ans = A[0]

elif(n == 2):
  ans = int(A[0])+int(A[1])+int(A[0]+A[1])
  
else:
 Comb =  []
 for i in range(n-1):
  Comb.append(['','+'])
 Comb = list(itertools.product(*Comb))
 
 ans = 0
 for i in range(len(Comb)):
  tmp = list(Comb[i])
  tmp_list,tmp_str = [],A[0]
  for j in range(n):
   if(j != n-1):
    if(tmp[j] == ''): 
      tmp_str += A[j+1]
    elif(tmp[j] == '+'): 
      tmp_list.append(tmp_str)
      tmp_str = A[j+1]
   elif((j == n-1)and(j >= 2)):
      tmp_list.append(tmp_str) 
  tmp_list = list(map(int,tmp_list))
  ans += sum(tmp_list)
  
print(ans)

Measured memory_bytes: 3064
n = int(input())
w = list(map(int, input().split()))

ans = sum(w)
for i in range(n):
    s1 = sum(w[0:i])
    s2 = sum(w[i:n])
    if abs(s1 - s2) < ans:
        ans = abs(s1 - s2)

print(ans)

Measured memory_bytes: 3060
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (0 ++^ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv
let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv
let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let between n x m = n <= x && x < m


(* ===== MAIN ===== *)

let xs = scan_list ~sep:' ' int_of_string

let () =
  List.fold_lefti (fun state i x ->
      if (state >= 1) then state
      else if (x = 0) then (i+1)
      else (-1)) (-1) xs
  |> Printf.printf "%d\n"



Measured memory_bytes: 5324
#include<stdio.h>
int a[31];
int main(void){
int i,b;
for(i=0;i<28;i++){
scanf("%d",&b);
a[b]=1;
}
for(i=1;i<31;i++){
if(a[i]==0){
printf("%d\n",i);
}
}
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int n;
char s[4005];
vector<int> c[3];
long long ans=0;
void sol(int q,int w,int e){
	for(int i:c[q]) for(int j:c[w]){
		if(j>i){
			vector<int>::iterator it = upper_bound(c[e].begin(),c[e].end(),j);
			if(it!=c[e].end()){
				ans+=(int)(c[e].end()-it);
				int tgt=j+j-i;
				if(find(c[e].begin(),c[e].end(),tgt)!=c[e].end()) ans--;
			}else break;
		}
	}
}
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		switch(s[i]){
			case 'R':c[0].push_back(i);break;
			case 'G':c[1].push_back(i);break;
			case 'B':c[2].push_back(i);break;
		}
	}
	sol(0,1,2);
	sol(0,2,1);
	sol(1,2,0);
	sol(1,0,2);
	sol(2,1,0);
	sol(2,0,1);
	cout<<ans<<endl;
	//cout<<s+1<<endl;
	return 0;
}

Measured memory_bytes: 3664
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  int a,b,c;
  cin >> a >>b >>c;


  long ans = 0;





  cout << (a*b/2);

  // cout << (ans-mx/2) <<endl;


}




















Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ll N;
  cin >> N;
  vector<ll> d(N);
  REP(i,N){
    cin >> d[i];
  }
  sort(ALL(d));
  //  cout << d[0] << "," << d[1] << endl;                                                                                       
  int result = 0;
  if(d[N/2-1] == d[N/2]){
    cout << 0 << endl;
    return 0;
  }else{
    result = d[N/2] - d[N/2-1];
    cout << result << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
/*ABC 134 B*/

int main(void)
{
  int N;
  int D;
  int count = 0;

  scanf("%d%d", &N, &D);

  if (N <= D * 2 + 1) {
    printf("1\n");
    return 0;
  }
  do {
    N -= D * 2 + 1;
    count++;
  } while(N > D * 2 + 1);
  count++;

  printf("%d", count);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 1999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
stringstream input(R"(
ac
)");
#define cin input
#endif

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

	if (s.size()==2)
		cout << s << endl;
	else
	{
		reverse(s.begin(), s.end());
		cout << s << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <cstdio>
using namespace std;

inline void read(int& sum)
{
    char ch; sum=0;
    ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9')
        sum=(sum<<1)+(sum<<3)+ch-'0',ch=getchar();
}

int main(void)
{
	int a,b;
	read(a),read(b);
	printf("%d\n",(--a)*(--b));
	return 0;
}

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

vector<int> chouri(5);

int calc_chouri_time();

int main()
{
  for (int i = 0; i < 5; i ++)
    cin >> chouri.at(i);
  
  int min_chouri_time = 644;
  int tmp;
  do
  {
    tmp = calc_chouri_time();
    if (tmp < min_chouri_time) min_chouri_time = tmp;
  }while(next_permutation(chouri.begin(), chouri.end()));

  cout << min_chouri_time << endl;
  return 0;
}

int calc_chouri_time()
{
  int chouri_time = 0;
  int n;
  
  for (int i = 0; i < 4; i ++)
  {
    n = chouri.at(i) / 10;
    if (chouri.at(i) % 10 != 0) n ++;
    chouri_time += n * 10;
  }
  
  chouri_time += chouri.at(4);
  return chouri_time;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
  }

  ll sum_a = accumulate(a.begin(), a.end(), 0LL);
  ll sum_b = accumulate(b.begin(), b.end(), 0LL);
  if (sum_a < sum_b) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> d;
  vector<int> e;
  for (int i = 0; i < n; i++) {
    if (a.at(i) > b.at(i)) {
      d.push_back(a.at(i) - b.at(i));
    }
    if (a.at(i) < b.at(i)) {
      e.push_back(b.at(i) - a.at(i));
    }
  }

  if (e.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(e.rbegin(), e.rend());
  sort(d.rbegin(), d.rend());

  int ans = 1;
  int k = 0;
  int pool = d.at(k);
  for (int i = 0; i < e.size(); i++) {
    while (pool < e.at(i)) {
      k++;
      pool += d.at(k);
      ans++;
    }
    pool -= e.at(i);
    ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n)*((n)+1)>>1)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;

const int MAXN = 1e5+5, MOD=1e9+7;
int n;
ll dp[MAXN][3];
vvi tree;

ll f(int u, int c, int p=-1){
    if(~dp[u][c]) return dp[u][c];
    ll ans=1;
    for (int v : tree[u]){
        if(v==p) continue;
        ans *= (f(v, 0, u) + (!c ? f(v, 1, u) : 0))%MOD;
        ans %= MOD;
    }
    return dp[u][c] = ans;
}


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


    cin >> n;
    tree.assign(n+1, vi());
    for (int i=0, u, v; i<n-1; i++){
        cin >> u >> v;
        tree[u].pb(v);
        tree[v].pb(u);
    }

    memset(dp, -1, sizeof dp);

    cout << (f(1, 0) + f(1, 1))%MOD << "\n";





    return 0;
}

/*
1
9 3
111100000
 */

Measured memory_bytes: 16384
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int dp[105][100005];
int sum[105][100005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, K; cin >> N >> K;
    rep(i, K+1) sum[0][i] = 1;
    rep1(i, N) {
        int a; cin >> a;
        rep(j, K+1) {
            int way = sum[i-1][j];
            if(j > a) way = (MOD + way - sum[i-1][j-a-1]) % MOD;
            if(j) sum[i][j] = (way + sum[i][j-1]) % MOD;
            else sum[i][j] = way;
            if(i == N && j == K) cout << way << endl;
        }
    }
}



Measured memory_bytes: 41216
#include <iostream>
using namespace std;
int main()
{

	while(true){

		int n;
		int p,d1,d2;
		int max = 0,pmax = 0;
		
		cin >> n;
		if(n==0)
			break;

		for(int i=0 ;i<n ;i++){

			cin >> p >> d1 >> d2;

			if(i==0){
				max = d1 + d2;
				pmax = p;
			}
			else if(max < (d1 +d2)){
				max = d1 + d2;
				pmax = p;
			}
		}

		cout << pmax  << ' ' << max << endl;
	}
	return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

vector<int> dp[10010];

int main(){
	int n = in.nextInt();
	vi v(n);
	rep(i, n) v[i] = in.nextInt();
	v.pb(-1);
	
	bool f = false;
	rep(i, n) if(v[i] == 0) f = true;
	if(!f){
		cout<<0<<endl;
		return 0;
	}
	dp[0].pb(-1);
	rep(i, n) dp[0].pb(i);
	int k = 0, a, b;
	while(++k){
		a = k / 10;
		b = k % 10;
		f = false;
		rep(i, dp[a].size()){
			if(v[dp[a][i] + 1] == b) dp[k].pb(dp[a][i] + 1);
		}
		if(dp[k].empty()){
			cout<<k<<endl;
			break;
		}
	}
}

Measured memory_bytes: 3452
def resolve():
    N, M = list(map(int, input().split()))
    SC = [list(map(int, input().split())) for _ in range(M)]
    value = [None for _ in range(N)]
    for s, c in SC:
        if not (value[s-1] is None or value[s-1] == c):
            print(-1)
            return
        value[s-1] = c
    for i in range(N):
        if value[i] is None:
            if i == 0:
                if N > 1:
                    value[i] = 1
                else:
                    value[i] = 0
            else:
                value[i] = 0
    if N > 1 and value[0] == 0:
        print(-1)
    else:
        print("".join(map(str, value)))


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 62116
D, G = map(int, input().split())
p = []
c = []
ans = 10 ** 9
for i in range(D):
    p_i, c_i = map(int, input().split())
    p.append(p_i)
    c.append(c_i)

for i in range(2 ** D):
    score = 0
    count = 0
    for j in range(D):
        if (i >> j) & 1:
            score += c[j] + p[j] * 100 * (j + 1)
            count += p[j]
    for k in range(D - 1, -1, -1):
        if (i >> k) & 1:
            continue
        if score >= G:
            break
        for l in range(p[k] + 1):
            score += 100 * (k + 1)
            count += 1
            if score >= G:
                break
    ans = min(ans, count)

print(ans)


Measured memory_bytes: 3064
#include <iostream>

int64_t getPower(const int training_num) {
  int64_t current_power = 1L;
  static int64_t P = 10e+8 + 7L;
  for (int64_t i = 0; i < training_num; ++i) {
    current_power *= (i + 1);
    current_power %= P;
  }
  return current_power;
}

int main() {
  int n;
  std::cin >> n;
  std::cout << getPower(n) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define N_MAX 500
int T[N_MAX]={0};
int main(){
  int N,C,S,F;
  cin >> N;
  for(int i=0;i<N-1;i++){ 
    cin >> C >> S >> F;
    T[i]=S+C;
    for(int k=0;k<i;k++){
      int m=0;
      while(S+m*F<T[k])m++;
      T[k]=S+m*F+C;
    }
  }
  for(int i=0;i<N;i++){
    cout << T[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
int main() {
	int n, u, k[101], data[101][100]; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> u >> k[i];
		for (int j = 0; j<k[i]; ++j) cin >> data[u][j];
	}
	int queue[10000], head = 0, tail = 1, cost[101];
	for (int i = 2; i <= n; ++i) cost[i] = -1;
	queue[0] = 1; cost[1] = 0;
	while (head != tail) {
		int val = queue[head++];
		for (int i = 0; i < k[val]; ++i) {
			if (cost[data[val][i]] == -1) {
				queue[tail++] = data[val][i];
				cost[data[val][i]] = cost[val] + 1;
			}
		}
	}
	for (int i = 1; i <= n; ++i) cout << i << " " << cost[i] << endl;
	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long
const int inf = 1 << 30;
#define INF 1e+9
#define MAX_V 100008


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


int main(){
  int n;
  cin >> n;
  cout << n + n * n + n*n*n << endl;
}


Measured memory_bytes: 3632
#include<iostream>
int num[10];
int f(int a,int b ,int c) {
	int flag = 0;
	if (a == 9)
		flag = 1;
	if (a == 0)
		return f(1, num[a], 0);
	else if (num[a] > b) {
		if (flag == 1)
			return 1;
		if (num[a] > c)
			return f(a + 1, num[a], c) + f(a + 1, b, num[a]);
		else
			return f(a + 1, num[a], c);
	}
	else if (num[a] > c) {
		if (flag == 1)
			return 1;
		return  f(a + 1, b, num[a]);
	}
	else
		return 0;
}
int main() {
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i += 1) {
		int N[10];
		for (int i = 0; i < 10; i += 1) {
			std::cin >> N[i];
			num[i] = N[i];
		}
		if (f(0, 0, 0) > 0)
			std::cout << "YES" << std::endl;
		else
			std::cout << "NO" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, K;
    cin >> N >> K;
    vec X(N), Y(N);
    loop(i, N) cin >> X[i] >> Y[i];
    ll ans = 5e18;
    loop(U, N)
    {
        loop(D, N)
        {
            loop(L, N)
            {
                loop(R, N)
                {
                    if (Y[U] >= Y[D] || X[R] >= X[L])
                        continue;
                    ll count = 0;
                    loop(i, N) if (X[i] <= X[L] && X[i] >= X[R] && Y[i] <= Y[D] && Y[i] >= Y[U]) count++;
                    if (count >= K)
                        ans = min(ans, (X[L] - X[R]) * (Y[D] - Y[U]));
                }
            }
        }
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 3632
import math

while True:
    inputs = list(map(str, input().split()))
    if inputs[1] == '?':
        break
    elif inputs[1] == '+':
        print(int(inputs[0]) + int(inputs[2]))
    elif inputs[1] == '-':
        print(int(inputs[0]) - int(inputs[2]))
    elif inputs[1] == '*':
        print(int(inputs[0]) * int(inputs[2]))
    elif inputs[1] == '/':
        print(math.floor(int(inputs[0]) / int(inputs[2])))



Measured memory_bytes: 5660
/*
2020-04-20
atcoder ABC
D - Line++
*/

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

int abs (int x, int y) {
    if (x > y) {
        return x - y;
    } else {
        return y - x;
    }
}
int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<long long> len_memo(N-1, 0);
    //処理
    for (int i = 1; i < N; i++) {
        for (int j = i + 1; j < N + 1; j++) {
            int min_len = min(min(abs(j - i), abs(X - i) + 1 + abs(Y - j)), abs(X - j) + 1 + abs(Y - i));
            len_memo.at(min_len - 1)++;
        }
    }
    rep(i, N-1) {
        cout << len_memo.at(i) << endl;
    }
    //出力処理
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
long A,B,X;
long dp[50][2][2];
main()
{
	cin>>N>>A>>B;
	for(int i=2;i<N;i++)
	{
		long x;cin>>x;X^=x;
	}
	long S=A+B;
	for(int i=0;i<50;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)dp[i][j][k]=-1;
	dp[49][0][0]=0;
	for(int i=49;i--;)for(int j=0;j<2;j++)for(int k=0;k<2;k++)if(dp[i+1][j][k]!=-1)
	{
		int lim=j?1:A>>i&1;
		for(int a=0;a<=lim;a++)for(int l=0;l<2;l++)
		{
			if(a+(a^(X>>i&1))-2*k+l==(S>>i&1))
			{
				long now=dp[i+1][j][k]|(long)a<<i;
				if(dp[i][j||a<lim][l]<now)dp[i][j||a<lim][l]=now;
			}
		}
	}
	long ans=dp[0][0][0];
	if(ans<dp[0][1][0])ans=dp[0][1][0];
	cout<<(ans<=0?-1:A-ans)<<endl;
}


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

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

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

void solve() {
  int a[9][9], wa[9][9] = {};
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> a[i][j];
    }
  }
  for (int d = 1; d < 10; d++) {
    for (int i = 0; i < 9; i++) {
      int cnt = 0;
      for (int j = 0; j < 9; j++) {
        cnt += a[i][j] == d;
      }
      if (cnt == 1) continue;
      for (int j = 0; j < 9; j++) {
        if (a[i][j] == d) wa[i][j] = 1;
      }
    }
    for (int j = 0; j < 9; j++) {
      int cnt = 0;
      for (int i = 0; i < 9; i++) {
        cnt += a[i][j] == d;
      }
      if (cnt == 1) continue;
      for (int i = 0; i < 9; i++) {
        if (a[i][j] == d) wa[i][j] = 1;
      }
    }
    for (int i = 0; i < 9; i += 3) {
      for (int j = 0; j < 9; j += 3) {
        int cnt = 0;
        for (int k = 0; k < 9; k++) {
          int ny = i + dy[k], nx = j + dx[k];
          cnt += a[ny][nx] == d;
        }
        if (cnt == 1) continue;
        for (int k = 0; k < 9; k++) {
          int ny = i + dy[k], nx = j + dx[k];
          if (a[ny][nx] == d) wa[ny][nx] = 1;
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << " *"[wa[i][j]] << a[i][j];
    }
    cout << endl;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    if (i) cout << endl;
    solve();
  }

  return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);

int main()
{
	/*RATUL*/
	ll a,v,b,w,t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	ll dis=abs(a-b);
	ll dv=v-w;
	if(dv<=0)
	{
		printf("NO\n");
		return 0;
	}
	dis-=(dv*t);
	if(dis<=0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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






int main(void) {
	int R,G;
	cin >> R >> G;
	cout << 2.0*G - (double)R << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    boolean judge=true;
    int H = sc.nextInt();
    int W = sc.nextInt();
  char[][] board = new char[H+2][W+2];
  for(int i=0;i<H+2;i++){
  board[i][0]='.';
  board[i][W+1]='.';
  }
  for(int j=0;j<W+2;j++){
    board[0][j]='.';
    board[H+1][j]='.';
  }
  for(int i=1;i<H+1;i++){
    String line=sc.next();
    char[] carr = line.toCharArray();
    for(int j=1;j<W+1;j++){
      board[i][j]=carr[j-1];
    }
  }
outer:  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
    if(board[i][j]=='#'){
      if(board[i-1][j]=='.'&&board[i+1][j]=='.'&&board[i][j-1]=='.'&&board[i][j+1]=='.'){
        judge=false;
        break outer;
      }
    }
    }
  }
  if(judge)
    System.out.print("Yes");
    else
    System.out.print("No");

  }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;


/* BIEN CUC BO BEGIN*/
	int a, b, A[100000+2];
	
	int cost[] = {0,2,5,5,4,5,6,3,7,6};
	string B[100000+2];
/* BIEN CUC BO END*/

bool comp(string a, string b){
	if (a.size() != b.size()) return a.size() < b.size();
	for (int i=0; i<a.size(); ++i){
		if (a[i] != b[i]) return a[i] < b[i];
	}
	return false;
}

void solve(){	
	cin >> a >> b;
	for (int i=1; i<=b; ++i){
		cin >> A[i];
	}
	for (int i=0; i<=100000; ++i){
		B[i] = "-";
	}
	B[0] = "";
	for (int i=0; i<=a; ++i){
		for (int j=1; j<=b; ++j){
			if (B[i] == "-") continue;
			if (comp(B[i+cost[A[j]]],B[i]+(char)('0'+A[j]))){
				B[i+cost[A[j]]] = B[i] + (char)('0'+A[j]);
			}
		}
	}
	cout << B[a];
}	

int main(){ FIO;
	solve();
return 0;}

Measured memory_bytes: 48384
#045_C
s=[int(i) for i in input()]
n=len(s)
ans=0

for i in range(2**(n-1)):
    tmp=s[0]
    res=0
    for j in range(n-1):
        if (i>>j)&1:
            res+=tmp
            tmp=s[j+1]
        else:
            tmp=tmp*10+s[j+1]
    res+=tmp
    ans+=res
    
print(ans)

Measured memory_bytes: 3064
def solve():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    x, y, c = [0] * M, [0] * M, [0] * M
    for i in range(M):
        x[i], y[i], c[i] = map(int, input().split())
    
    ans = min(a) + min(b)
    for i in range(M):
        ans = min(ans, a[x[i] - 1] + b[y[i] - 1] - c[i])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 23396
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
	int K,c;
	while(~scanf("%d",&K)){
		if(K==0) break;
		int sum=0;
		for(int i=0;i<K*(K-1)/2;i++){
			int c;
			scanf("%d",&c);
			sum += c;
		}

		printf("%d\n",sum/(K-1));
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
int main()
{
    int n;
    scanf("%d",&n);
vector<int> dp(3);
for(int day=0;day<n;day++)
{vector<int> new_dp(3,0);
    vector<int> c(3);
    for(int i=0;i<3;i++)
    {
        scanf("%d",&c[i]);
    }
    for(int i=0;i<3;i++)
    {for(int j=0;j<3;j++)
    {if(i!=j)
    {new_dp[j]=max(new_dp[j],dp[i]+c[j]);

    }

    }


    }
    dp=new_dp;



}
printf("%d",max({dp[0],dp[1],dp[2]}) );





}

Measured memory_bytes: 3752
import sys



def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ng = 0
    ok = 10 ** 9 + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        ans =0
        for i in range(N):
            ans += A[i]//mid -1
            if A[i]%mid !=0:
                ans +=1
            if ans >K:
                break

        if ans <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()


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

class DisjointSet {
    public:
        DisjointSet(int n) : N(n), sz(N), pars(N, -1) {

        }

        int find(int x) {
            return pars[x] < 0 ? x : (pars[x] = find(pars[x]));
        }

        bool merge(int x, int y) {
            x = find(x), y = find(y);
            if (x == y) {
                return false;
            }
            --sz;
            if (pars[x] < pars[y]) {
                swap(x, y);
            }
            pars[y] += pars[x];
            pars[x] = y;
            return true;
            
        }

        int size() {
            return sz;
        }

        int count(int x)  {
            return - pars[find(x)];
        }
    private:
        int N;
        int sz;
        vector<int> pars;
};

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

    int n, h, w;
    cin >> n >> h >> w;


    int N = h + w;
    vector<int> sz(N, 0);

    DisjointSet ds(N);

    long long res = 0;
    vector<pair<int, pair<int,int>>> edges;

    for (int i = 0; i < n; ++i) {
        int r, c, w;
        cin >> r >> c >> w;
        --r, --c;
        c += h;
        edges.emplace_back(w, make_pair(r, c));
    }

    sort(edges.begin(), edges.end());
    reverse(edges.begin(), edges.end());


    for (auto& e : edges) {
        int w = e.first;
        int u = e.second.first;
        int v = e.second.second;
        u = ds.find(u);
        v = ds.find(v);
        if (u == v) {
            if (sz[u] < ds.count(u)) {
                ++sz[u];
                ds.merge(u, v);
                res += w;
            }
        } else {
            if (sz[u] + sz[v] + 1 <= ds.count(u) + ds.count(v)) {
                ds.merge(u, v);
                int p = ds.find(u);
                sz[p] = sz[u] + sz[v] + 1;
                res += w;
            }
        }
    }
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3448
import math

n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]

def max_multi(a,b,d,c):
        length = b-a
        n = math.ceil((d-a)/2)
        if n < 0:
            n = 0
        elif n > length:
            n = length
        x = (a+n)*(d-n)
        n = math.floor((d-a)/2)
        if n < 0:
            n = 0
        elif n > length:
            n = length
        y = (a+n)*(d-n)
        return max(x,y)

def check(a, b, n):
    multi = a*b
    if n<a:
        return True
    else:
        if a<= n < b:
            second_1 = (n,1)
            second_2 = (0,0)
        else:
            second_1 = (b-1,1)
            second_2 = (n+1, b+1)
        m = (second_2[0] - second_2[1])+1
        if second_2 == (0,0):
            a1,b1,c1,d1 = 1, a-1, second_1[0], second_1[0]-(a-2)
            a2,b2,c2,d2 = a+1, n+1, second_1[0]-(a-1), second_1[1]
            s = max(max_multi(a1,b1,c1,d1), max_multi(a2,b2,c2,d2))
        elif m == a-1:
            a1,b1,c1,d1 = 1, a-1, second_2[0], second_2[1]
            a2,b2,c2,d2 = a+1, n+1, second_1[0], second_1[1]
            s = max(max_multi(a1,b1,c1,d1), max_multi(a2,b2,c2,d2))
        elif m > a-1:
            a1,b1,c1,d1 = 1, a-1, second_2[0], second_2[0]-(a-2)
            a2,b2,c2,d2 = a+1, m+1, second_2[0]-(a-1), second_2[1]
            a3,b3,c3,d3 = m+2, n+1, second_1[0], second_1[1]
            s = max(max_multi(a1,b1,c1,d1), max_multi(a2,b2,c2,d2), max_multi(a3,b3,c3,d3))
        else:
            a1,b1,c1,d1 = 1,m,second_2[0], second_2[1]
            a2,b2,c2,d2 = m+1, a-1, second_1[0], second_1[0]-(a-m-2)
            a3,b3,c3,d3 = a+1, n+1, second_1[0]-(a-m-1), second_1[1]
            s = max(max_multi(a1,b1,c1,d1), max_multi(a2,b2,c2,d2), max_multi(a3,b3,c3,d3))
        return True if s < multi else False

def search(a,b):
    a,b = min(a,b), max(a,b)
    low = 0
    high = 10**30
    while high - low > 1:
        if check(a,b,(low+high)//2):
            low = (low+high)//2
        else:
            high = (low+high)//2
    return high if check(a,b,high) else low

for i in lst:
    print(search(i[0], i[1]))

Measured memory_bytes: 3320
#include <iostream>
#include <algorithm>
#define INF 999999

using namespace std;

int a[100];

int selection_sort(int n){

  int cnt = 0;
  bool f;
  for( int i = 0 ; i < n ; i++ ){
    int m = i; f = true;
    for( int j = i ; j < n ; j++ ){
      if( a[j] < a[m] ){
	m = j;
	f = false;
      }
    }
    if(f)continue;
    swap(a[i] , a[m]);
    cnt++;
  }
  return cnt;
}

int main(void){

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

  int ans =  selection_sort(n);

  for( int i = 0 ; i < n ; i++ ){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1164
n = int(input())
p = list(map(float, input().split()))

dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(n):
        dp[i+1][j+1] += dp[i][j]*p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])

ans = 0
for i in range(n//2+1, n+1):
    ans += dp[n][i]
print(ans)

Measured memory_bytes: 252168
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+5;
int n,A,B,C,D;
char s[N];
bool chk(int l,int r)
{
  for(int i=l;i<r;i++)
    if(s[i]=='#'&&s[i+1]=='#')return false;
  return true;
}
bool fnd(int l,int r)
{
  for(int i=l;i<=r;i++)
    if(s[i-1]==s[i]&&s[i]==s[i+1]&&s[i]=='.')
      return true;
  return false;
}
int main()
{
  scanf("%d%d%d%d%d",&n,&A,&B,&C,&D);
  scanf("%s",s+1);
  if((!chk(A,C))||(!chk(B,D))){puts("No");return 0;}
  if(C<D){puts("Yes");return 0;}
  s[D]='#';
  if(chk(A,C)){puts("Yes");return 0;}
  s[D]='.';
  if(fnd(B,D)){puts("Yes");return 0;}
  puts("No"); return 0;
}


Measured memory_bytes: 384
import sys
n=int(input())
a=list(map(int,input().split()))
s=[0]
for i in range(n):
  s.append(s[i]+a[i])
h=sum(a)/2
for i in range(n+1):
  if s[i]==h:
    print(0)
    sys.exit()
  if s[i]>h:
    x=i
    break
ans=min(int((s[x]-h)*2),int((h-s[x-1])*2))
print(ans)

Measured memory_bytes: 26224