akhauriyash/Code-Regression huggingface dataset:
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T& y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T& y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long N, std::string S){
    for(auto& c2 : S){
        int c = c2;
        c -= 'A';
        c += N;
        c %= 26;
        c += 'A';
        c2 = c;
    }
    cout << S << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    int n; cin >> n;
    switch(n%10){
        case 0:
        case 1:
        case 6:
        case 8: cout<<"pon"<<endl; break;
        case 3: COUT("bon"); break;
        default : COUT("hon") break;
    }
}

Measured memory_bytes: 3592
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s = readln.chomp.to!(char[]);
  long k;
  rd(k);

  int j = -1;
  for (int i = 0; i < s.length; i++) {
    if (s[i] > '1') {
      j = i;
      break;
    }
  }
  if (j < 0) {
    writeln(1);
  } else {
    if (k <= j) {
      writeln(1);
    } else {
      writeln(s[j]);
    }
  }

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<algorithm>
using namespace std;

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

    cin >> S;
    cin >> w;

    int i = 0;

    while(true){
        ans += S[i];
        i += w;
        if(i >= S.size()) break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String x = sc.next();
		int c =0;
		int len =0;
		for(int i=0;i<x.length();i++) {
			if(x.charAt(i)=='T') {
				c--;
			}
			else {
				if(c<0) {
					len-=c;
					c=1;
				}
				else {
					c++;
				}
			}
		}
		len+=Math.abs(c);
		System.out.println(len);
	}
	
}


Measured memory_bytes: 40332
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int a, b,ans;
int main(void) {
    cin >> a >> b;
    ans = (b-1)/(a-1);
    if (((b-1)%(a-1))) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int n;
ll c, k;
ll t[100005];

int main(int argc, char const *argv[]) {
	cin >> n >> c >> k;
	FOR(i, n) cin >> t[i];
	sort(t, t+n);
	int ans = 0, cur = 0;
	ll last;
	FOR(i, n) {
		if (cur == 0) {
			ans++;
			cur++;
			last = t[i] + k;
		}
		else if (t[i] <= last && cur < c) {
			cur++;
		}
		else {
			ans++;
			cur = 1;
			last = t[i] + k;
		}
		if (cur == c) cur = 0;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int h,w;cin>>h>>w;
    vector<string> m(h);
    for(int i=0;i<h;++i){
        cin>>m[i];
    }
    vector<bool> hi(h,false);
    vector<bool> wi(w,false);
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(m[i][j]=='#'){
                hi[i]=true;
                wi[j]=true;
            }
        }
    }
    for(int i=0;i<h;++i){
        if(hi[i]){
            for(int j=0;j<w;++j){
                if(wi[j]){
                    cout<<m[i][j];
                }
            }
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.reverse.each_char.map(&:to_i)

count = 0

0.upto(n.size) do |i|
  num = n[i]
  break unless num

  if num == 10
    n[i + 1] = (n[i + 1] || 0) + 1
  elsif num == 5 && n[i + 1] && n[i + 1] >= 5
    count += num
    n[i + 1] += 1
  elsif 5 < num
    n[i + 1] = (n[i + 1] || 0) + 1
    count += 10 - num
  else
    count += num
  end
end

puts count


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

int main() {
  int N;
  cin >> N;
  
  int j = 0;
  for(int i=0; i<N; i++ ){
    char s;
    cin >> s;
    
    if(s == 'Y' ){
      j++;
    }
  }
  
  if(j == 0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
  
}


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

long long attack( long long h )
{
    if ( h == 1 )   return 1;
    else {
        return ( 2 * attack(h/2) + 1 );
    }
}

int main()
{
    long long H;
    scanf("%lld",&H);
    long long ans = attack( H );
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int cnt_e, cnt_p;
int main(){
    vector<int> a(3);
    rep(i, 3){
        cin >> a.at(i);
        a.at(i)%2?cnt_p++:cnt_e++;
    }
    sort(a.begin(), a.end());
    int ans;
    if(cnt_p == 3 || cnt_e == 3)
        ans = (a.at(2)-a.at(0))/2 + (a.at(2)-a.at(1))/2;
    else {
        ans = (a.at(2)+1-a.at(0))/2 + (a.at(2)+1-a.at(1))/2;
        if(cnt_p == 2 && !(a.at(2)%2))  ans--;
        if(cnt_p == 2 && a.at(2)%2)  ans++;
        if(cnt_e == 2 && !(a.at(2)%2))  ans++;
        if(cnt_e == 2 && a.at(2)%2)  ans--;
    }
    cout << ans << endl;
    return 0;
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int A, B, C, count = 0, money = 0;
	
	cin >> A >> B >> C;
	
	while(count < C){
		if(money + A <= B)
			money += A;
		else
			break;
		count++;
	}
	
	cout << count;
	
	return 0;
}

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

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

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

    int ans = 1;
    int flag = 0;
    for(int i=0; i+1<n; i++){
        if(a[i+1] == a[i]) continue;

             if(flag == 0 && a[i] < a[i+1]) flag = 1;
        else if(flag == 0 && a[i] > a[i+1]) flag = 2;
        else if(flag == 2 && a[i] < a[i+1]){ ans += 1; flag = 0; }
        else if(flag == 1 && a[i] > a[i+1]){ ans += 1; flag = 0; }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sousa = sum(b) - sum(a)
if sousa < 0:
    print('No')
    exit()
if sousa == 0:
    if a == b:
        print('Yes')
    else:
        print('No')
    exit()
p, q = 0, 0
for i, j in zip(a, b):
    if i > j:
        q += i - j
    if i < j:
        if (i - j) % 2 == 0:
            p += (j - i) // 2
        else:
            p += (j - i) // 2 + 1
            q += 1
# print(p, q, sousa)
if (sousa >= p) and (sousa >= q) and (sousa - p) * 2 == (sousa - q):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

struct node{
    vector<int> par;
    ll T, A, val;
};

static node c[100009];

void Aoki(int come, int cur, int depth){
    //cout<<cur<<" "<<depth<<endl;
    c[cur].A=depth;
    rep(i, c[cur].par.size()){
        if(c[cur].par[i]==come) continue;
        else Aoki(cur, c[cur].par[i], depth+1);
    }
}
void Taka(int come, int cur, int depth){
    c[cur].T=depth;
    if(c[cur].A<=depth) depth=100001;
    
    rep(i, c[cur].par.size()){
        if(c[cur].par[i]==come) continue;
        else{
           Taka(cur, c[cur].par[i], depth+1);
        }
    }
}


int main(void){
    int N, u, v, a, b;
    
    cin>>N>>u>>v;
    rep(i, N-1){
        cin>>a>>b;
        c[a-1].par.push_back(b-1);
        c[b-1].par.push_back(a-1);
    }
    Aoki(-1, v-1, 0);
    Taka(-1, u-1, 0);
    ll Maxim=0;
    rep(i, N){
        if(c[i].A>=c[i].T) Maxim=max(Maxim, c[i].A-1) /*cout<<i<<endl*/;
    }
    cout<<Maxim<<endl;
    return 0;
}


Measured memory_bytes: 13184
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
ll ans[2020];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,x,y;cin>>n>>x>>y;
    x--;y--;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll mind=mmin(j-i,mmin(abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)));
            ans[mind]++;
        }
    }
    for(ll k=1;k<=n-1;k++){
        cout<<ans[k]<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





























Measured memory_bytes: 256
console.log((args=>{
  const [[N,M,K],A,B] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const sB = [0];
  for ( let i = 0; i < M; i++ ) {
    sB.push( sB[i] + B[i] );
    if ( sB[i] > K ) break;
  }
  let max = 0, sA = 0;
  for ( let i = 0; i <= N; i++ ) {
    const Kb = K - sA;
    if ( Kb < 0 ) break;
    let l = -1, r = sB.length;
    while ( r - l > 1 ) {
      const m = l + (r-l&~1)/2;
      if ( sB[m] > Kb ) r = m;
      else l = m;
    }
    if ( Kb >= sB[l] && l + i > max ) max = l + i;
    sA += A[i];
  }
  return `${max}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 59892
grade=[]

while True:
    test_point=[]
    test_point=input().split()
    test_point[0]=int(test_point[0])
    test_point[1]=int(test_point[1])
    test_point[2]=int(test_point[2])
    if test_point[0]==-1 and test_point[1]==-1 and test_point[2]==-1:
        break
    elif test_point[0]==-1 or test_point[1]==-1:
        grade.append('F')
    elif test_point[0]+test_point[1]>=80:
        grade.append('A')
    elif test_point[0]+test_point[1]<80 and test_point[0]+test_point[1]>=65:
        grade.append('B')
    elif test_point[0]+test_point[1]<65 and test_point[0]+test_point[1]>=50:
        grade.append('C')
    elif test_point[0]+test_point[1]<50 and test_point[0]+test_point[1]>=30:
        if test_point[2]>=50:
            grade.append('C')
        else:
            grade.append('D')
    elif test_point[0]+test_point[1]<30:
        grade.append('F')

for i in range(0,len(grade)):
    print(grade[i])

Measured memory_bytes: 7780
#include <iostream>
#include <string>
using namespace std;
int N;
void dfs(string s, char mxc) {
  if(s.size() == N) {
    cout << s << endl;
  } else {
    for(char c = 'a'; c <= mxc; ++c) {
      dfs(s+c, (c==mxc?mxc+1:mxc));
    }
  }
}
int main() {
  cin >> N;
  dfs("", 'a');
}

Measured memory_bytes: 1536
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

A = [-1 for _ in range(N)]

for s, c in SC:
  if s == 1 and c == 0 and N != 1:
    print(-1)
    exit()
  if A[s-1] == -1:
    A[s-1] = c
  else:
    if A[s-1] == c:
      pass
    else:
      print(-1)
      exit()

for i in range(N):
  if A[i] == -1:
    A[i] = 0

if A[0] == 0:
  if N == 1:
    pass
  else:
    A[0] = 1

print(''.join(map(str, A)))

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	string s[100] = { { "" }, { "Man" }, { "Oku" }, { "Cho" }, { "Kei" }, { "Gai" }, { "Jo" }, { "Jou" }, { "Ko" }, { "Kan" }, { "Sei" }, { "Sai" }, { "Gok" }, { "Ggs" }, { "Asg" }, { "Nyt" }, { "Fks" }, { "Mts" } };
	int n, m;
	while (true){
		cin >> m >> n;
		if (m == 0 && n == 0)break;
		vector<int> p;
		p.resize(101);
		p[0] = 1;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 100; j++){
				p[j] *= m;
			}
			for (int j = 0; j < 100; j++){
				p[j + 1] += p[j] / 10000;
				p[j] %= 10000;
			}
		}
		for (int i = 100; i >= 0; i--){
			if (p[i]>0){
				cout << p[i];
				cout << s[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1212
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#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>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int maxV;

bool comp(const int &a, const int &b) {
    int x = min(a, maxV - a);
    int y = min(b, maxV - b);
    return x < y;
}

int main() {

    int N;
    cin >> N;

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

    maxV = *max_element(a.begin(), a.end());
    sort(a.begin(), a.end(), comp);

    cout << maxV << " " << a.back() << endl;

    return 0;
}








































Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <cmath>
#define INF 1000000007
using namespace std ;

int main(int argc, char const *argv[])
{

	string s ;
	cin>>s ;

	for(int i = 0 ; i < s.size(); i++) s[i] = 'x' ;
		cout<<s<<endl ;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        String[] ss = new String[n];
        int a = 0;
        long b = 0;

        for (int i = 0; i < n; i++) {
            ss[i] = s.substring(i, i + 1);
        }

        for (int j = 0; j < n; j++) {
            if ("W".equals(ss[j])) {
                a ++;
                b = b + (j + 1);
            }
        }


        long wa = 0;
        for (int k = 0; k <= a; k++) {
            wa = wa + k;
        }

        System.out.println(b - wa);
    }

}










Measured memory_bytes: 37608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int solve() {
    int n;
    cin >> n;
    return (n + 1) / 2;
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) cout << solve() << endl;
    return 0;
}

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

#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
	int N,K;
	
	cin >> N >> K;
	
	if(K==1)	cout << "0" << endl;
	else	cout << N-K << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std ; 
int main()
{
	long long int num ;  
	int a,b,c,flag = 0 ; 
	cin >> a >> b >> c ;
	for(num = a;num < 100000000;num += a)
	{
		if(num % b == c) 
		{
			flag = 1 ; 
			break;
		}
	}
	if(flag == 1)
	{
		cout <<"YES"<< endl; 
	}
	else if(flag == 0)
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
#define INF 2*1e9
#define LL_INF 1e18

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int n;
struct Edge {
  double cost;
  int to;
};
vv<Edge> g;
vector<double> d;
typedef pair<double, int> pdi;

void dijkstra(int s) {
  d.assign(n+2, (double)LL_INF);
  priority_queue<pdi, vector<pdi>, greater<pdi> > q;
  d[s] = 0.0;
  q.push(mp(0.0, s));

  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (auto e : g[v]) {
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        q.push(mp(d[e.to], e.to));
      }
    }
  }
}

int main() {
  ll xs, ys, xg, yg;
  scanf("%lld %lld %lld %lld", &xs, &ys, &xg, &yg);
  scanf("%d", &n);
  vll x(n+2), y(n+2), r(n+2);
  x[0] = xs;
  y[0] = ys;
  r[0] = 0;
  FOR (i, 1, n+1) {
    scanf("%lld %lld %lld", &x[i], &y[i], &r[i]);
  }
  x[n+1] = xg;
  y[n+1] = yg;
  r[n+1] = 0;
  g.resize(n+2);
  rep (i, n+2) {
    FOR (j, i+1, n+2) {
      ll dx = x[i] - x[j];
      ll dy = y[i] - y[j];
      double c = sqrt(dx*dx + dy*dy) - r[i] - r[j];
      c = max(c, 0.0);
      Edge e;
      e.cost = c;
      e.to = j;
      g[i].pb(e);
      e.to = i;
      g[j].pb(e);
    }
  }

  dijkstra(0);
  double ans = d[n+1];
  printf("%.12f\n", ans);

  return 0;
}


Measured memory_bytes: 20720
#include<bits/stdc++.h>
using namespace std;
typedef struct{
    int group;
    int flag;
    vector<int> Friend;
    vector<int> Block;
}USER;

vector<USER> user;

int dfs(int n, int g){
    //printf("DFS(%d,%d)\n",n+1,g);
    int add=1;
    for(int i=0; i<user.at(n).Friend.size(); i++){
        int f=user.at(n).Friend.at(i);
        if(user.at(f).flag==0){
            user.at(f).flag=1;
            user.at(f).group=g;
            add+=dfs(f,g);
        }
    }
    return add;
}
int main(){
    int N,M,K;
    cin >> N >> M >> K;
    user.resize(N);
    for(int i=0; i<N; i++){
        user.at(i).flag=0;
    }
    for(int i=0; i<M; i++){
        int f1,f2;
        cin >> f1 >> f2;
        user.at(f1-1).Friend.push_back(f2-1);
        user.at(f2-1).Friend.push_back(f1-1);
    }
    for(int i=0; i<K; i++){
        int b1,b2;
        cin >> b1 >> b2;
        user.at(b1-1).Block.push_back(b2-1);
        user.at(b2-1).Block.push_back(b1-1);
    }
    int now=0;
    int mindist;
    vector<int> numOfMemInGroup;
    int flag=0,num;
    for(int groupN=0;;groupN++){
        flag=0;
        user.at(now).flag=1;
        user.at(now).group=groupN;
        num=dfs(now,groupN);
        numOfMemInGroup.push_back(num);
        for(int i=now+1; i<N; i++){
            if(user.at(i).flag==0){
                now=i;
                flag=1;
                break;
            }
        }
        if(!flag) break;
    }
    int ans,f,b,ng,g;
    for(int i=0; i<N; i++){
        b=0;
        g=user.at(i).group;
        ng = numOfMemInGroup.at(user.at(i).group);
        f = user.at(i).Friend.size();
        for(int j=0; j<user.at(i).Block.size(); j++){
            if(user.at(user.at(i).Block.at(j)).group==user.at(i).group) b++;
        }
        ans=ng-f-b-1;
        cout << ans << endl;
        //printf("%2d %2d %2d %2d %2d\n",i+1,g,f,b,ans);
    }
    return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define tms(x) ___ = x; while(___--)
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int ___;
vector<pii> v;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, a, b, c, redPick, greenPick, nonePick, ans;
	redPick = greenPick = nonePick = ans = 0;
	cin>>x>>y>>a>>b>>c;
	rep(i, 0, a) v.pb(pii(next<int>(), 1));
	rep(i, 0, b) v.pb(pii(next<int>(), 2));
	rep(i, 0, c) v.pb(pii(next<int>(), 3));
	sort(v.begin(), v.end());
	for(int i = v.size()-1; i >= 0; i--)
	{
		if (redPick+greenPick+nonePick == x+y) break;
		if (v[i].second == 1 && redPick < x) redPick++, ans += v[i].first;
		else if (v[i].second == 2 && greenPick < y) greenPick++, ans += v[i].first;
		else if (v[i].second == 3) nonePick++, ans += v[i].first;
	}
	cout<<ans<<endl;
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

INF = 10**7
dist = [[INF for j in range(N)] for i in range(N)]
d = [[INF for j in range(N)] for i in range(N)]
prev = [[i for j in range(N)] for i in range(N)]
t = [[0 for j in range(N)] for i in range(N)]

for _ in range(M):
    a,b,c = map(int,input().split())
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
    d[a-1][b-1] = c
    d[b-1][a-1] = c



#　d[a][b]:aとbの距離
def warshall_floyd(n):
    for k in range(n):
        for i in range(n):#始点
            for j in range(n):#終点
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])

warshall_floyd(N)
ans = 0
for i in range(N):
    for j in range(N):
        if dist[i][j] != INF and d[i][j] != dist[i][j]:
            ans += 1
print(ans//2)


Measured memory_bytes: 41072
s = list(input())
k = int(input())
t = list(map(lambda x:ord(x)-ord("a"),s))

for i in range(len(t)):
  diff = 26-t[i]
  if diff != 26 and diff <= k: 
    t[i]+=diff
    k-=diff
t[-1]+=k

u = "".join(list(map(lambda x:chr((x%26+ord("a"))),t)))
print(u)

Measured memory_bytes: 11272
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional> 
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <bitset>
#include <string.h>
#include <stdio.h>
#include <limits.h>
//#include <unordered_map>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UNI;
typedef unsigned char UC;

#define STR(X) #X

#define ABS(a)      ((a>0)?a:-(a))
#define MIN(a,b)    ((a<b)?(a):(b))
#define MAX(a,b)    ((a<b)?(b):(a))
#define FOR(i,a,n)    for ( int i = (a); i < (n); ++i)
#define FOR_(i,a,n)		for ( int i = (a); i >= (n); --i)
#define FORI(n)        for(int i = 0; i < n; ++i)
#define MEMS(a,b)    memset(a,b,sizeof(a))

#define MP(p1, p2)      std::make_pair(p1, p2)
#define VI              std::vector<int>
#define SI              std::set<int>
#define PI				std::pair<int, int>
#define PL				std::pair<LL, LL>
#define PUI				std::pair<UNI, UNI>
#define RNG(container)  container.begin(), container.end()
#define endl			"\n"

const LL		MOD = 1000000007;
const double    EXP = 2.7182818284590452;
const double    Pi = 3.1415926535;
const long double    EPS = 1e-4;
const int		INF = 1000 * 1000 * 1001;
const long long	INFL = (LL)INF * (LL)INF;

//////////////////
//////////////////
#define MAXN 100005

int n;

string s1, s2;

bool is = false;

void accept()
{
	cin >> n >> s1 >> s2;

	FOR(i, 0, n)
	{
		is = true;
		FOR(j,0,n-i)
		{
			if (s1[i+j] != s2[j])
			{
				is = false;
			}
		}

		if (is)
		{
			cout << n + i;
			return;
		}
	}

	cout << n + n;
}

int main()
{

accept();

return 0;

}

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

int main (){
    long long k,ans=0,memo=0,ma=1,mb=1,ans1=0;
    char s[105];
    long long n,i;
    cin >> s >> k;
    n=strlen(s);
    if(s[0]!=s[n-1]){
    	memo=1;
    	for(i=1;i<n;i++){
    		if(s[i-1]==s[i]){
    			memo++;
    		} else {
    			ans+=((memo-memo%2)/2);
    			memo=1;
    		}
    	}
    	ans+=((memo-memo%2)/2);
    	ans=ans*k;
    } else {
    	memo=1;
    	for(i=1;i<n;i++){
    		if(s[i-1]==s[i]){
    			memo++;
    		} else {
    			ans+=((memo-memo%2)/2);
    			memo=1;
    		}
    	}
    	ans+=((memo-memo%2)/2);
    	ans=ans*k;
    	for(i=1;i<n;i++){
    		if(s[i]==s[0]) ma++;
    		else break;
    	}
    	for(i=n-2;i>=0;i--){
    		if(s[i]==s[n-1]) mb++;
    		else break;
    	}
    	if(ma==n){
    		ans=(n*k)/2;
    	} else if(ma==1&&mb==1) {
    		ans+=(k-1);
    	} else if(ma%2==1&&mb%2==1){
    		ans+=((k-1));
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

const int VMAX = 100;
const int EMAX = 1000;

// to: node id, cap: capacity of this edge, rev: reverse egde index
struct Egde {
    int to, cap, rev;
};

int V, E;
vector<Egde> G[VMAX];
bool used[VMAX];

/** Ford-Fulkerson **/
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;

    for(auto& e: G[v]) {
        if (e.cap == 0 || used[e.to]) continue;
        int flow = dfs(e.to, t, min(f, e.cap));
        if (flow > 0) {
            e.cap -= flow;
            G[e.to][e.rev].cap += flow;
            return flow;
        }
    }

    return 0;
}


// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
int grl_6_a() {
    cin >> V >> E;

    REP(i, E) {
        int u, v, c;
        cin >> u >> v >> c;
        G[u].pb({v, c, (int)G[v].size()});
        G[v].pb({u, 0, (int)G[u].size() - 1});
    }

    int flow = 0;

    while (true) {
        memset(used, false, sizeof(used));
        int f = dfs(0, V-1, inf);
        if (f == 0) break;
        flow += f;
    }

    print(flow);

    return 0;
}

int main() {
    return grl_6_a();
}


Measured memory_bytes: 3196
# encoding: utf-8
H, W, K = map(int, input().split())

raw_route = [0] * W # 0 in unused
possible_route = 0

for i in range(2 ** (W - 1)):
    # check
    i_tmp = i
    last = 0
    for j in range(W - 1):
        if i_tmp % 2 == last == 1: break
        last = i_tmp % 2
        i_tmp = i_tmp // 2
    else:
        # valid drawing
        i_tmp = i
        for j in range(W - 1):
            if i_tmp % 2 == 1: raw_route[j + 1] += 1
            i_tmp = i_tmp // 2
        possible_route += 1

# print("#", raw_route)

DP = [[None] * W for i in range(H)]

def draw(depth, clm):
    # done
    if depth == H + 1: return 1
    # running
    if DP[depth - 1][clm - 1] != None: return DP[depth - 1][clm - 1]
    ## param
    range_min = K - (H - depth)
    range_max = K + (H - depth)
    ## calc ans
    ans = 0
    # print("##", depth, clm, (range_min, range_max))
    ### go straight
    if range_min <= clm <= range_max:
        coeff = possible_route
        if clm > 1: coeff -= raw_route[clm - 1]
        if clm < W: coeff -= raw_route[clm]
        ans += coeff * draw(depth + 1, clm)
    ### go left
    if range_min <= clm - 1 and 1 <= clm - 1: ans += raw_route[clm - 1] * draw(depth + 1, clm - 1)
    ### go right
    if clm + 1 <= range_max and clm + 1 <= W: ans += raw_route[clm] * draw(depth + 1, clm + 1)
    ## end
    if DP[depth - 1][clm - 1] == None: DP[depth - 1][clm - 1] = ans % (10 ** 9 + 7)
    return ans % (10 ** 9 + 7)

print(draw(1, 1))


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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var redCount = 0;
            var blueCount = 0;

            foreach (var item in s)
            {
                if (item == 'R')
                {
                    redCount++;
                }
                else if (item == 'B')
                {
                    blueCount++;
                }
                else
                {
                    throw new Exception();
                }
            }

            if (redCount > blueCount)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

using namespace std;

#define LIMIT 100
typedef long long ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int x[100];

  int d = 0;

  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    d+= min(abs(x[i] -0), abs(x[i]-k));
  }
  std::cout << d*2 << std::endl;


  return 0;
}



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

int main()
{
	int n,a[105],b[105],sum=0;
	cin >> n;
	
	for(int i=1;i<=n-1;i++)
	{
		cin >> b[i];
		a[i] = 100005; 
		a[i+1] = 100005;
	}
	
	for(int i=1;i<=n-1;i++)
	{
		a[i] = min(a[i],b[i]);
		a[i+1] = min(a[i+1],b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int N = 1e18;
int main() {
    fast_cin();
    ll n;
    cin>>n;
    ll dp[3]={0};//stores the happiness point of prev one
    for(int days=0;days<n;days++) {
        ll curr[3];//stores the value we are currently calculating
        ll newdp[3]={0};
        for(int i=0;i<3;i++) {
            cin>>curr[i];
        }
        for(int i=0;i<3;i++) {
            for(int j=0;j<3;j++) {
                if(i!=j) {
                    newdp[j]=max(curr[j]+dp[i],newdp[j]);
                }
            }
        }
        for(int i=0;i<3;i++) {
            dp[i]=newdp[i];
        }
        
    }
    cout<<max(dp[0],max(dp[1],dp[2]));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int a[100005],t[100010];
int main (){
	int i,maxn=0,n;
	n=read();
	for (i=1;i<=n;i++)
	{a[i]=read();
	t[a[i]]++;t[a[i]+1]++;t[a[i]+2]++;
	}
	for (i=0;i<=100005;i++)
	{if (t[i]>maxn) {maxn=t[i];}
	}
	printf ("%d\n",maxn);
	return 0;
}
	

Measured memory_bytes: 1024
N=parse(Int,readline())
S=chomp(readline())
A=zeros(Int,10)
B=zeros(Int,100)
C=zeros(Int,1000)
for c=S
	x=Int(c)-48
	for i=0:99
		if B[i+1]==1
			C[i*10+x+1]=1
		end
	end
	for i=0:9
		if A[i+1]==1
			B[i*10+x+1]=1
		end
	end
	A[x+1]=1
end
println(sum(C))


Measured memory_bytes: 133584
#include<bits/stdc++.h>
using namespace std;
int stones[101];
int dp[100001][2];

bool solve(bool Tairo,bool Gairo,int size,int pile_size){
    if(pile_size<0){
        if(Tairo){
            return 0; //Gairo wins
        }
        if(Gairo){
            return 1; //Tairo wins
        }
    }
    if(pile_size==0){
        if(Tairo){
            return 1; //Tairo wins
        }
        if(Gairo){
            return 0; //Gairo wins
        }
    }
    if(Tairo){
        if(dp[pile_size][0]!=-1){
            return dp[pile_size][0];
        }
    }
    if(Gairo){
        if(dp[pile_size][1]!=-1){
            return dp[pile_size][1];
        }
    }
    
    bool final_win=0;
    bool final_win1=1;
    for(int i=0;i<size;i++){
        
        if(stones[i]<=pile_size){
            if(!Tairo){
                bool win=solve(1,0,size,pile_size-stones[i]);
                final_win=(final_win || win );
            }
            if(Tairo and !Gairo){
                bool win1=solve(0,1,size,pile_size-stones[i]);
                final_win1=(final_win1 and win1);
            }
        }
    }
    if(!Tairo){
        dp[pile_size][1]=final_win;
        return final_win;
    }
    if(Tairo and !Gairo){
        dp[pile_size][0]=final_win1;
        return final_win1;
    } 
    return 0;

}


int main(){
    int N,K;
    cin>>N>>K;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++){
        cin>>stones[i];
    }
    if(solve(0,0,N,K)){
        cout<<"First";
    }
    else{
        cout<<"Second";
    } 
}


Measured memory_bytes: 8832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        int n = s.Length;
        string ans = "No";
        for (int i = 0; i < n; i++)
        {
            string tmp = s.Substring((n - i), i) + s.Substring(0, (n - i));
            if(tmp == t)
            {
                ans = "Yes";
                break;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string s;
    cin >> s;
    string ans = "";
    int n = s.size();
    REP(i,n) {
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(ans != "") {
            int l = ans.size();
            ans.erase(ans.begin()+l-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())
prize = 0

# コード部門
if X == 1:
    prize += 300000
elif X == 2:
    prize += 200000
elif X == 3:
    prize += 100000
# 装置実装部門
if Y == 1:
    prize += 300000
elif Y == 2:
    prize += 200000
elif Y == 3:
    prize += 100000
# ガチ両刀
if X == 1 and Y == 1:
    prize += 400000

print(prize)

Measured memory_bytes: 3064
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll n,k;
    cin >> n >> k;
    if((n+1)/2 >= k) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define pb(s) push_back(s)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
#define combipari(a,b,c,d) ((a>=b) &&(b>=c)&&(c>=d))
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
ll Q;
  ll H;
   ll S;
  ll D;
  ll N;
  cin >>Q>>H>>S>>D>>N;
  ll a=Q*8;
  ll b=H*4;
  ll c=S*2;
  ll d=D*1;
  
  ll b1;
  ll b2;
  
if(combipari(a,b,c,d)) {
  b1=S;
  b2=D;
}
  if(combipari(a,b,d,c)) {
  b1=S;
  b2=S*2;
}
 if(combipari(a,c,b,d)) {
  b1=H*2;
  b2=D;
}
 if(combipari(a,c,d,b)) {
  b1=H*2;
  b2=H*4;
} 
  if(combipari(a,d,b,c)) {
  b1=S;
  b2=S*2;
}
  if(combipari(a,d,c,b)) {
  b1=H*2;
  b2=H*4;
}
  
  
  
  if(combipari(b,a,c,d)) {
  b1=S;
  b2=D;
}
  if(combipari(b,a,d,c)) {
  b1=S;
  b2=S*2;
}
  if(combipari(b,c,a,d)) {
  b1=Q*4;
  b2=D;
}
  if(combipari(b,c,d,a)) {
  b1=Q*4;
  b2=Q*8;
}
  if(combipari(b,d,a,c)) {
  b1=S;
  b2=S*2;
}
  if(combipari(b,d,c,a)) {
  b1=Q*4;
  b2=Q*8;
}
  
  
  
  if(combipari(c,a,b,d)) {
  b1=H*2;
  b2=D;
}
  if(combipari(c,a,d,b)) {
  b1=H*2;
  b2=H*4;
}
  if(combipari(c,b,a,d)) {
  b1=Q*4;
  b2=D;
}
  if(combipari(c,b,d,a)) {
  b1=Q*4;
  b2=Q*8;
}
  if(combipari(c,d,a,b)) {
  b1=H*2;
  b2=H*4;
}
  if(combipari(c,d,b,a)) {
  b1=Q*4;
  b2=Q*8;
}
  
  
  
  if(combipari(d,a,b,c)) {
  b1=S;
  b2=S*2;
}
  if(combipari(d,a,c,b)) {
  b1=H*2;
  b2=H*4;
}
  if(combipari(d,b,a,c)) {
  b1=S;
  b2=S*2;
}
  if(combipari(d,b,c,a)) {
  b1=Q*4;
  b2=Q*8;
}
  if(combipari(d,c,a,b)) {
  b1=H*2;
  b2=H*4;
}
  if(combipari(d,c,b,a)) {
  b1=Q*4;
  b2=Q*8;
}
  
  
 ll div=N/2;
  ll rem=N%2;
  ll ct=div*b2+rem*b1;
  ll cu=N*b1;
  cout<<min(ct,cu)<<endl;
}
  
  
  
  
  


Measured memory_bytes: 256
#include<stdio.h>
void trace(int A[], int N){
int i;
for(i = 0; i < N; i++){
if(i > 0) printf(" ");
printf("%d", A[i]);
}
printf("\n");
}
void insertionSort(int A[], int N){
int i, j, v;
for(i = 1; i < N; i++){
v = A[i];
j = i - 1;
while(j >= 0 && A[j] > v){
A[j + 1] = A[j];
j--;
}
A[j + 1] = v;
trace(A, N);
}
}
int main(){
int N, i, j;
int A[100];
scanf("%d", &N);
for(i = 0; i < N; i++) scanf("%d", &A[i]);
trace(A, N);
insertionSort(A, N);
return 0;
}


Measured memory_bytes: 2664
# ABC142E - Get Everything
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    p = 2 ** N
    dp = [float("inf")] * p
    dp[0] = 0
    for _ in range(M):
        a, _ = map(int, input().split())
        x = sum(2 ** (i - 1) for i in map(int, input().split()))
        for y in range(p):
            if dp[x | y] > dp[y] + a:
                dp[x | y] = dp[y] + a
    ans = dp[-1] if dp[-1] != float("inf") else -1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define intl long long int 

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,n;
	cin>>n;
	vector<intl> ar(n);
	map<intl,intl> mp;
	intl sum=0;
	for(i=0;i<n;i++){
		cin>>ar[i];
		mp[ar[i]]++;
		sum+=ar[i];
	}
	intl q;
	cin>>q;
	while(q--){
		cin>>i>>j;
		sum+=((j-i)*mp[i]);
		cout<<sum<<"\n";
		mp[j]+=mp[i];
		mp[i]=0;
	}
}


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

int a[100010];
long s[100010];
int main()
{
    cin.sync_with_stdio(0);
    int n; cin>>n;
    for(int i=0; i<n; ++i) cin>>a[i];
    sort(a, a+n);

    for(int i=0; i<n; ++i) s[i+1]=s[i]+a[i];

    long res=(1L<<35)-1;
    for(long x=1L<<34; x>0; x>>=1) {
        auto m=res-x;
        if (m>n-1) { res=m; continue; }
        bool ok=true;
        long t=s[m+1];
        for(int i=m+1; i<n; ++i) {
            if (2*t<a[i]) { ok=false; break; }
            t+=a[i];
        }
        if (ok) res=m;
    }
    cout<<n-res<<endl;
}



Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] hi = new int[n];
        for (int i = 0; i < n; i++) {
            hi[i] = sc.nextInt();
        }
        int ans = 1;
        int high = 0;
        for (int i = 1; i < n; i++) {
            if (hi[i] >= hi[i - 1] && hi[i] >= hi[0] && hi[i] >= high) {
                ans++;
                high = hi[i];
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
    string s;
    cin >> s;
    int count=0;
    string a="YAKIaaaaaa";
    for(int i=0;i<s.size();i++){
        if(s.at(i)==a.at(i)) count++;
    }
    if(count == 4) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b)
{
  return a > b ? b : a;
}

int main()
{
  int a,b,k,i,count=0,ans;

  scanf("%d%d%d", &a,&b,&k);

  for(i=min(a,b); i>0; i--)
  {
    if(a%i ==0 && b%i ==0)
      count++;

    if(count == k){
      ans = i;
      break;
    }
  }
  printf("%d", ans);

  return 0;
}


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

using namespace std;

struct num
{
    int n;
    int i;
    int si;
    bool operator < (num b) const
    {
        return n < b.n;
    }
};

num n[200005];
num sn[200005];
main()
{
    int nn;
    scanf("%d",&nn);
    int i;
    for(i=0;i<nn;i++)
    {
        scanf("%d",&n[i].n);
        n[i].i = i;
        sn[i] = n[i];
    }

    sort(sn,sn+nn);
    for(i=0;i<nn;i++)
    {
        n[ sn[i].i ].si = i;
    }

    for(i=0;i<nn;i++)
    {
        if(n[i].si < nn/2)
        {
            printf("%d\n",sn[nn/2]);
        }
        else
        {
            printf("%d\n",sn[nn/2-1]);
        }
    }
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
const ll mod = 1e9 + 7;


ll powmod(ll x,ll y){
   ll res=1;
   for(ll i=0;i<y;i++){
      res=res*x%mod;
   }
   return res;
}


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

   ll a;
   a=powmod(10,n)+powmod(8,n)-powmod(9,n)-powmod(9,n);
a %= mod;
a = (a+mod)%mod;

   cout << a  << endl;
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int y, yy,i,flg,cnt;
	char *str = "";
	while (1) {
		scanf("%d%d", &y, &yy);
		if (!(y + yy))break;
		printf("%s",str);
		cnt = 0;
		if (y % 4 != 0) y = y + (4 - y % 4);
		for (i =y; i <= yy; i += 4) {
			flg = i % 100 != 0;
			flg = flg || i % 400 == 0;
			if (flg) printf("%d\n", i),cnt++;	
		}
		if(!cnt)printf("NA\n");
		str = "\n";
	}
	return 0;
}

Measured memory_bytes: 612
R, G, B, N = map(int, input().split())

a = [R, G, B]
a.sort()

x = N // a[2]
ans = 0
for i in range(x+1):
    n = N - (i * a[2])
    y = n // a[1]
    for j in range(y+1):
        if (n - a[1] * j) % a[0] == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3064