akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    string s;
    cin >> s;
    deque<char> queue(s.begin(), s.end());
    ll Q;
    cin >> Q;
    ll revert_cnt = 0;
    rep(q,0,Q) {
        ll T;
        cin >> T;
        if (T == 1) {
            revert_cnt++;
        } else {
            ll F;
            cin >> F;
            char c;
            cin >> c;
            if (F == 1) {
                if (revert_cnt % 2 == 0) {
                    queue.push_front(c);
                } else {
                    queue.push_back(c);
                }
            } else {
                if (revert_cnt % 2 == 0) {
                    queue.push_back(c);
                } else {
                    queue.push_front(c);
                }
            }
        }
    }
    string ans(queue.begin(), queue.end());
    if (revert_cnt % 2 == 1) {
        reverse(ans.begin(), ans.end());
    }
    cout << ans.c_str() << endl;
}


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

int main()
{
    int N, C;
    cin >> N >> C;

    int s, t, c;
    vector<vector<int>> matrix(C + 1, vector<int>(100000 + 1, 0));
    for (int i = 0; i < N; i++)
    {
        cin >> s >> t >> c;
        for (int i = s; i <= t; i++)
        {
            matrix[c][i] |= 1;
        }
    }

    int ans[100000 + 1] = {};
    for (int i = 0; i <= 100000; i++)
    {
        for (int j = 1; j <= C; j++)
        {
            ans[i] += matrix[j][i];
        }
    }

    cout << *max_element(ans, ans + 100000 + 1) << endl;
}


Measured memory_bytes: 12800
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    repn = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        repn[a - 1].append(b - 1)
        repn[b - 1].append(a - 1)
    visited = [0] * N

    def dfs(u, n):
        if n >= 2:
            visited[u] = 1
            return
        visited[u] = 1
        for v in repn[u]:
            if visited[v] != 0: continue
            dfs(v, n + 1)

    dfs(0, 0)
    if visited[N - 1] == 1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == "__main__":
    main()


Measured memory_bytes: 107204
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll solve(vector<ll> s,vector<ll> t){
  ll dp[305][305]={0};
  ll dist[605][305]={0};
  ll n=s.size();
  for(int i=-(n-1);i<=n-1;i++){
    ll ks=0;
    for(int j=n-1;j>=0;j--){
      if(j-i>=0&&j-i<n){
        ks+=(s[j]==t[j-i]?1:0);
        dist[i+n-1][j]=ks;
      }
    }
  }
  ll inf=17441744174417;
  for(int i=0;i<305;i++){
    for(int j=0;j<305;j++) dp[i][j]=inf;
  }
  dp[0][0]=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(i<n){
        dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(j==n?0:dist[(i-j)+n-1][i]));
      }
      if(j<n){
        dp[i][j+1]=min(dp[i][j+1],dp[i][j]+(i==n?0:dist[(i-j)+n-1][i]));
      }
    }
  }
  return dp[n][n];
}
int main(){
  ll h,w;
  cin>>h>>w;
  vector<ll> vec[305];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char c;
      cin>>c;
      vec[j].push_back((int)(c-'a'));
    }
  }
  for(int i=0;i<w;i++) reverse(vec[i].begin(),vec[i].end());
  ll ans=0;
  solve(vec[0],vec[1]);
  for(int i=0;i<(w-1);i++) {
    ans+=solve(vec[i],vec[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

void swap(int *a,int *b){
  *a^=*b;
  *b^=*a;
  *a^=*b;
  return;
}

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(B<C) swap(&B,&C);
  if(A<B) swap(&A,&B);
  if(B<C) swap(&B,&C);
  printf("%d\n",A-C);
  return 0;
}

Measured memory_bytes: 1736
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= 8 && b <= 8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}


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

using namespace std;

struct rest{
    int point;
    char name[10];
    int num;
};

int main(){
    int  N;
    cin >> N;
    rest rests[N], tmp;
    for(int i = 0; i < N; i++){
        cin >> rests[i].name >> rests[i].point;
        rests[i].num = i + 1;
    }
    
    for(int i = 0; i < N; i ++){
        for(int j = i + 1; j < N; j++){
            if(strcmp(rests[i].name, rests[j].name) > 0){
                tmp = rests[i];
                rests[i] = rests[j];
                rests[j] = tmp;
            }
            else if(strcmp(rests[i].name, rests[j].name) == 0){
                if(rests[i].point < rests[j].point){
                    tmp = rests[i];
                    rests[i] = rests[j];
                    rests[j] = tmp;
                }
            }
        }
    }
    for(int i = 0; i < N; i++){
        cout << rests[i].num << endl;
    }
}

Measured memory_bytes: 3580
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   char[] c = sc.next().toCharArray();
   int N = c.length;
   boolean b = true;
   boolean dame = false;
   int ans =N-2;
   for(int i = 2;i<N;i+=2)
   {
     dame = false;
     for(int k = 0;k<(N-i)/2;k++)
     {
       if(c[k]!=c[k+(N-i)/2])
       {
         dame=true;
         break;
       }
     }
     if(!dame) 
     {
       ans = N-i;
       break;
     }
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 23380
import sys
input=sys.stdin.readline
n,m,l=map(int,input().split())
abc=[list(map(int,input().split())) for _ in range(m)]
q=int(input())
st=[list(map(int,input().split())) for _ in range(q)]


d = [[float("inf") for i in range(n)] for i in range(n)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    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])
    return d

for i in range(m):
    a,b,c=abc[i]
    d[a-1][b-1]=c
    d[b-1][a-1]=c

warshall_floyd(d)

dd=[[float("inf") for _ in range(n)] for _ in range(n)]

for i in range(n):
    for j in range(n):
        if i==j:
            dd[i][j]=0
        if d[i][j]<=l:
            dd[i][j]=1
            dd[j][i]=1

warshall_floyd(dd)

for i in range(q):
    s,t=st[i]
    s-=1
    t-=1
    if dd[s][t]==float("inf"):
        print(-1)
    else:
        print(dd[s][t]-1)


Measured memory_bytes: 132700
/*
[abc104] A - Rated for Me
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int R;

string solve() {
    if (R < 1200) {
        return "ABC";
    } else if (R < 2800) {
        return "ARC";
    } else {
        return "AGC";
    }
}

int main() {
    cin >> R;

    cout << solve() << endl;

    return 0;
}


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

int main() {
    lint h, w, a, b;
    cin >> h >> w >> a >> b;

    string oi = string(w-a, '0') + string(a, '1');
    string io = string(w-a, '1') + string(a, '0');

    for(lint i = 0; i < h; i++) {
        if(i < b)  cout << oi << endl;
        else       cout << io << endl;
    }
}

Measured memory_bytes: 1280
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
S = int("".join(S.split("/")))

if S <= 20190430:
	print("Heisei")
else:
	print("TBD")


Measured memory_bytes: 3892
N = int(input())
S = input()
e, w, ans = [0], [0], 10**6
for i in range(1, N + 1):
    if S[i-1] == 'E':
        e.append(e[i - 1] + 1)
        w.append(w[i - 1])
    else:
        e.append(e[i - 1])
        w.append(w[i - 1] + 1)
for i in range(1, N + 1):
    ans = min(ans, w[i - 1] + e[N] - e[i])
print(ans)


Measured memory_bytes: 17772
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

string num = "0123456789";

string mrj(string s) {
  return s[s.length()-1] + s.substr(0, s.length()-1);
}

string missc(string s) {
  return s.substr(1, s.length()-1) + s[0];
}

string mre(string s) {
  if (s.length() % 2 == 1) return s.substr(s.length()/2+1, s.length()/2) + s[s.length()/2] + s.substr(0, s.length()/2);
  else return s.substr(s.length()/2, s.length()/2) + s.substr(0, s.length()/2);
}

string mra(string s) {
  string res = "";
  for (int i = s.length()-1; i >= 0; i--) {
    res += s[i];
  }
  return res;
}

string drp(string s) {
  for (int i = 0; i < s.length(); i++) {
    int index = (int)num.find(s[i]);
    if (index >= 0) {
      s[i] = num[(index+9)%10];
    }
  }
  return s;
}

string mrm(string s) {
  for (int i = 0; i < s.length(); i++) {
    int index = (int)num.find(s[i]);
    if (index >= 0) {
      s[i] = num[(index+1)%10];
    }
  }
  return s;
}

int main() {
  int n;
  string order, message;
  cin >> n;
  while (n--) {
    cin >> order >> message;
    for (int i = order.length()-1; i >= 0; i--) {
      if (order[i] == 'J') message = mrj(message);
      if (order[i] == 'C') message = missc(message);
      if (order[i] == 'E') message = mre(message);
      if (order[i] == 'A') message = mra(message);
      if (order[i] == 'P') message = drp(message);
      if (order[i] == 'M') message = mrm(message);
    }
    cout << message << el;
  }
}

Measured memory_bytes: 1216
//
// Created by aim_cpo on 17/10/27.
//
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"

using namespace std;

int n;
string s;
ll ans=0;

inline ll dfs(int now,ll sum,ll nowsum){
    if(now==n-1) {
        //cout<<sum+nowsum<<endl;
        ans+=sum+nowsum;
        return sum + nowsum;
    }
    ll res=dfs(now+1,sum+nowsum,s[now+1]-'0')+dfs(now+1,sum,nowsum*10+s[now+1]-'0');
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    n=(int)s.length();
    dfs(0,0,s[0]-'0');
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N;
int a[2][101];

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

  cin >> N;
  
  REP(h, 2) {
    REP(i, N) {
      cin >> a[h][i];
    }
  }

  int ans = 0;
  
  REP(i, N) {
    int tmp = 0;
    REP(j, i + 1) {
      tmp += a[0][j];
    }
    FOR(j, i, N) {
      tmp += a[1][j];
    }
    ans = max(ans, tmp);
  }

  cout << ans << endl;
  
  return 0;
}



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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> vec(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> vec.at(i);
		sum = sum + vec.at(i);
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	sum = (sum-1)/(4*m) +1;
	if(vec.at(m-1)>=sum){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

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

  int n= s.size() -1;

  ll ans=0;

  rep(i,1<<n){
  ll tmp=0;

    rep(j,n+1){
        tmp*=10;
        tmp += s[j]-'0';
        if(i>>(n-1-j) & 1){
            ans += tmp;
            tmp=0;
        }
    }

    ans += tmp;



  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

char f[MAX][MAX];
int visited[MAX][MAX];

void get_ans(int y,int x){
	
	if(visited[y][x]==1){
		printf("LOOP\n");
		return;
	}
	
	visited[y][x]=1;
	switch(f[y][x]){
		case '>':get_ans(y,x+1);
				 break;
		case 'v':get_ans(y+1,x);
				 break;
		case '^':get_ans(y-1,x);
				 break;
		case '<':get_ans(y,x-1);
				 break;
		case '.':printf("%d %d\n",x,y);
				 return;
	}
	
	return;
	
}


int main(){
	int h,w;
	char str[MAX+1];
	
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0)break;
		
		for(int i=0;i<h;i++){
			scanf("%s",str);
			for(int j=0;j<w;j++){
				f[i][j]=str[j];
				visited[i][j]=0;
			}
		}
	
		get_ans(0,0);
	}
	return 0;
	
}
			


Measured memory_bytes: 2044
<?php

fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s %s", $s, $t);

$s_arr = str_split($s);
$t_arr = str_split($t);

for ($i = 0; $i < $n; ++$i) {
    echo $s_arr[$i];
    echo $t_arr[$i];
}



Measured memory_bytes: 4604
n=int(input())
ls=list(input())
r_ls = [i for i,v in enumerate(ls) if v=='R']
w_ls = [i for i,v in enumerate(ls) if v=='W']
end_flag = False
if len(r_ls) == 0 or len(w_ls) == 0:
    end_flag = True
else:
    r_mx, w_min = max(r_ls), min(w_ls)
    max_try = min(len(r_ls), len(w_ls))

r_i, w_i = -1, 0

if end_flag:
    print(0)
elif r_mx < w_min:
    print(0)
else:
    c = 0
    for i in range(max_try):
        c += 1
        r_ls[r_i], w_ls[w_i] =  w_ls[w_i], r_ls[r_i]
        if i == max_try -1:
            print(c)
            break
        else:
            try:
                r_mx = max(r_ls[r_i], r_ls[r_i - 1])
                w_min = min(w_ls[w_i], w_ls[w_i + 1])
            except:
                print(c)
                break
            if w_min > r_mx:
                print(c)
                break
            r_i -= 1
            w_i += 1


Measured memory_bytes: 89544
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(N)]

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(1, N):
  for j in range(1, min(K+1, i+1)):
    dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

print(dp[N-1])

Measured memory_bytes: 56672
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,1,-1,0,1,-1,0};
ll digitsum(ll n){
    ll sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
bool f[100010];
int main(){
    vector<ll> v;
    ll s=1;
    for(ll i=0;i<15;i++){
        for(ll j=2;j<=150;j++){
            v.push_back(s*j-1);
        }
        s*=10;
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    for(int i=0;i<v.size();i++){
        for(int j=i+1;j<v.size();j++){
            double a=(double)v[i]/(double)digitsum(v[i]);
            double b=(double)v[j]/(double)digitsum(v[j]);
            if(a>b){
                f[i]=true;
            }
        }
    }
    int k;cin>>k;
    int c=0;
    for(int i=0;i<v.size();i++){
        if(c==k)break;
        if(f[i])continue;
        cout<<v[i]<<endl;
        c++;
    }   
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

struct UnionFind {
  vector<int64_t> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int64_t> size; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int64_t N) : par(N), size(N, 0) { //最初は全てが根であるとして初期化
    for (int64_t i = 0; i < N; i++) par[i] = i;
  }

  int64_t root(int64_t x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int64_t x, int64_t y) { // xとyの木を併合
    int64_t rx = root(x); //xの根をrx
    int64_t ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    size[ry] = size[ry] + size[rx] + 1;
  }

  bool same(int64_t x, int64_t y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int64_t rx = root(x);
    int64_t ry = root(y);
    return rx == ry;
  }
};

class DFriendSuggestions {
public:
  void solve(std::istream &cin, std::ostream &cout) {
    int64_t n, m, k;
    cin >> n >> m >> k;
    UnionFind UF(n + 1);
    vector<vector<int64_t>> connect(n + 1, vector<int64_t>(0));
    for (int64_t i = 0; i < m; ++i) {
      int64_t a, b;
      cin >> a >> b;
      if (b > a) swap(a, b);
      UF.unite(a, b);
      connect[a].emplace_back(b);
      connect[b].emplace_back(a);
    }
    vector<vector<int64_t>> not_connect(n + 1, vector<int64_t>(0));
    for (int64_t i = 0; i < k; ++i) {
      int64_t c, d;
      cin >> c >> d;
      not_connect[c].emplace_back(d);
      not_connect[d].emplace_back(c);
    }
    vector<int64_t> count(n + 1, 0);
    for (int64_t i = 1; i < n + 1; ++i) {
      int ans = UF.size[UF.root(i)] - connect[i].size();
      for (auto &item : not_connect[i])if (UF.same(item, i)) ans--;
      cout << ans << " ";
//      cout << 1 << " ";
    }
    cout << endl;

  }
};


int main() {
  DFriendSuggestions solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int findOrder(int N, vector<int> S) {
    // 基本順列
    vector<int> normal(N);
    for (int i = 0; i < N; i++) {
        normal[i] = i+1;
    }
    int count = 0;
    do {
        count ++;
        if (normal == S) break;
    } while (next_permutation(normal.begin(), normal.end()));
    return count;
}

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }

    int a = findOrder(N, P);
    int b = findOrder(N, Q);
    cout << abs(a-b) << endl;
    
    return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";
#define eputs(s)                                                               \
    cout << s << "\n";                                                         \
    exit(0);

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using pq = priority_queue<T>;
template <typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

typedef long long ll;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 9e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

signed main() {
    LCIN(N);
    VL A(N + 1), B(N);
    VECCIN(A);
    VECCIN(B);
    ll ans = 0;
    REP(i, N) {
        ll temp = B[i];
        REP(j, 2) {
            ll dec1 = min(A[i + j], temp);
            ans += dec1, A[i + j] -= dec1, temp -= dec1;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double pi = Math.PI;
		double menseki =0;
		double enshu = 0;
		if(0<r && r<10000) {
			menseki = r*r*pi;
			enshu   = (r*2)*pi;
		}
		System.out.println(String.format("%.6f %.6f", menseki ,enshu));
	}
}

Measured memory_bytes: 28484
import sys
def input():
    return sys.stdin.readline()[:-1]
D,G=map(int, input().split())
G//=100
p=[list(map(int, input().split())) for i in range(D)]
m=[None]*D
for i in range(D):
    m[i]=p[i][0]*(i+1)+p[i][1]//100
l=[None]*2**D
for i in range(2**D):
    l[i]="{:0>{}b}".format(i,D)
a=1000
for i in l:
    c=0
    t=0
    for j in range(D):
        if i[j]=="1":
            t+=m[j]
            c+=p[j][0]
    if t>G:
        if a>c:
            a=c
        continue
    s=i.rfind("0")
    if t+(s+1)*p[s][0]>G:
        c+=(G-t-1)//(s+1)+1
        if a>c:
            a=c
print(a)


Measured memory_bytes: 40048
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;

int main() {
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	if (A[0] + A[1] + A[2] >= 22) {
		cout << "bust\n";
	}
	else {
		cout << "win\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){

    ll a,b;
    cin >> a >> b;
    rep(i,20000){
        //cout << i*1.08 << " " << i*1.10 << endl;
        if(int(i*0.08)==a&&int(i*0.10)==b) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
    

}

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	int A, B;
	cin >> A >> B;

	cout << max( { A + B, A - B, A * B } ) << endl;
	return ( 0 );
}


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

int main() {
	int a[3];
	for (int i = 0;i < 3;i++) {
		cin >> a[i];
	}
	if ((a[0] + a[1] + a[2]) >= 22) {
		cout << "bust";
	}
	else cout << "win";
	return 0;
}

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

bool isLeapYear(int y){
    return ( y%4 == 0 && ( y%100 != 0 || y%400 == 0 ) )? true : false ;
}

int main(){
	int a,b;
	bool flag, iniFlag = true;
	
	while( cin >> a >> b , a || b ){
		flag = true;
		if( iniFlag == false ){
			cout << endl;
			
		}else{
			iniFlag = false;
		}	

		for(int i=a ; i<=b ; i++){
			if( isLeapYear(i) ){
				flag = false;
				cout << i << endl;
			}
		}
		if( flag ) cout << "NA" << endl;		
	}
}

Measured memory_bytes: 0
li = []

a = 10

for i in range(5):
    x = input()
    if int(x[-1]) == 0:
        li.append(int(x))
    else:
        if int(x[-1]) < a:
            a = int(x[-1])
        x = x[:-1] + "0"
        x = int(x) + 10
        li.append(x)

if a == 10:
    a = 0

if a:
    print(sum(li) - 10 + a)
else:
    print(sum(li))


Measured memory_bytes: 3060
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = readInts()
cumsum = list(accumulate(A))
cnt = 0

# -
plus = None
ans = float('inf')
for k in range(2):
    if k%2:
        plus = True
    else:
        plus = False
    #print(plus,'-')
    one = cumsum.copy()
    #print(one)
    cnt = 0
    change = 0
    for i in range(n):
        one[i] += change
        if plus:
            if one[i] > 0:
                pass
            else:
                cnt += abs(1-one[i])
                change += abs(1-one[i])
            plus = not plus
        else:
            if one[i] < 0:
                pass
            else:
                cnt += abs(one[i]+1)
                change -= abs(one[i]+1)
                #print(change)
            plus = not plus
    ans = min(ans, cnt)
print(ans)


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

int main() {
 int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i=0; i<N; i++){
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  reverse(mochi.begin(),mochi.end());
  
  int takasa=0;
  for (int i=0; i<N-1; i++){
    if (mochi.at(i)>mochi.at(i+1)){
      takasa++;
    }
  }
  cout << takasa+1;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[303];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	ll xo=0;
	for(i=2;i<N;i++) xo^=A[i];
	
	vector<int> cand;
	FOR(i,1<<20) if(i<A[0]) {
		ll v=(A[0]-i)^(A[1]+i)^xo;
		if((v&((1<<20)-1))==0) cand.push_back(i);
	}
	
	ll mi=1LL<<50;
	FORR(c,cand) {
		for(ll a=c;a<min(mi,A[0]);a+=1<<20) {
			ll v=(A[0]-a)^(A[1]+a)^xo;
			if(v==0) mi=min(mi,a);
		}
	}
	
	if(mi==1LL<<50) mi=-1;
	cout<<mi<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
			inv[i]=ppow(fact[i],MOD-2);
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};
ll dp[4000][2];
P p[4000];

int main(){
	int h,w;scanf("%d%d",&h,&w);
	int n;scanf("%d",&n);
	Fact fact(h+w);
	rep(i,n){
		scanf("%d%d",&p[i].first,&p[i].second);
		p[i].first--;
		p[i].second--;
	}
	sort(p,p+n);
	rep(i,n)dp[i][1]=fact.nrC(p[i].first,p[i].second);
	rep(i,n)rep(j,2){
		for(int k=i+1;k<n;k++){
			if(p[k].second>=p[i].second)
			(dp[k][!j]+=dp[i][j]*fact.nrC(p[k].first-p[i].first,p[k].second-p[i].second))%=MOD;
		}
	}
	ll ans=0;
	rep(i,n){
		(ans+=dp[i][1]*fact.nrC(h-1-p[i].first,w-1-p[i].second)%MOD)%=MOD;
		ans+=MOD;
		(ans-=dp[i][0]*fact.nrC(h-1-p[i].first,w-1-p[i].second)%MOD)%=MOD;
	}
	cout<<(fact.nrC(h-1,w-1)+MOD-ans)%MOD<<endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define gc getchar
#define re register
#define rep(i,u,z) for(re int i=u;i<=z;++i)
#define reb(i,u,z) for(re int i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

inline int read(){
	int rt=0;
	char ch=gc();
	while(ch<'0'||ch>'9')ch=gc();
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt;
}
int main(){
	char c;
	scanf(" %c",&c);
	if(c=='A')puts("T");
	else if(c=='T')puts("A");
	else if(c=='G')puts("C");
	else puts("G");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int n;
    cin >> n;
    vector<double>p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    vector<vector<double> > dp(n, vector<double>(n+1, 0));
    dp[0][0] = 1-p[0];
    dp[0][1] = p[0];
    for(int i = 1; i < n; i++){
        for(int j = 0; j <= i+1; j++){
            dp[i][j] = dp[i-1][j] * (1 - p[i]);
            if( j > 0)
            dp[i][j] += dp[i-1][j-1] * p[i];
        }
    }
    double ans = 0;
    for(int j = n/2+1 ; j <= n; j++){
        ans += dp[n-1][j];
    }
    cout << fixed;
    cout << setprecision(10);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
using namespace std;
 
int main()
{
	string S;
 
	cin >> S;
 
	if (S <= "2019/04/30")
	{
		cout << "Heisei" << endl;
	}
	else
	{
		cout << "TBD"<< endl;
	}
 
	return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t h,n;
    cin >> h >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    int64_t sum = 0;
    rep(i,n) sum += a.at(i);
    if(sum >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
     string S;
     cin >> S;

     int f,b;
     f = stoi(S);
     b  =f%100;
     f /= 100;
    
    
    if (12<f && 12<b){
        cout << "NA" <<endl;
    }else if(12 < f){
        if(b != 0) cout << "YYMM" <<endl;
        else cout << "NA" << endl;
    }else if(12 < b){
        if(f != 0) cout << "MMYY" <<endl;
        else cout << "NA" <<endl;
    }else{
        if(f !=0 && b !=0) cout << "AMBIGUOUS" << endl;
        else if(f ==0 && b==0) cout << "NA" <<endl;
        else if(f ==0) cout << "YYMM" <<endl;
        else if(b ==0) cout << "MMYY"  <<endl;
        else cout << "NA" <<endl;
    }
}

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

int main()
{
    string x;
    cin >> x;
    int s = 0, count = 0;
    rep(i, x.length())
    {
        if (x[i] == 'S')
            s++;
        else
        {
            if (s > 0)
            {
                count++;
                s--;
            }
        }
    }
    cout << x.length() - count * 2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c[1000100];
int dp[1000010][2];
int main(){	
	scanf("%s",c+1);n=strlen(c+1);
	dp[n+1][0]=100000;
	for(register int i=n;i>=1;i--){
		dp[i][0]=min(dp[i+1][1]+1+10-(c[i]-'0'),dp[i+1][0]+10-(c[i]-'0'+1));
		dp[i][1]=min(dp[i+1][1]+c[i]-'0',dp[i+1][0]+c[i]-'0');
	}
	printf("%d\n",min(dp[1][0],dp[1][1]));
	return 0;
}

Measured memory_bytes: 9216
N = gets.to_i
S = gets.chomp

def repeat(s)
  length = s.length
  half_l = length/2
  ary = s.chars
  t1 = ary.first(half_l).join(" ")
  t2 = ary.last(half_l).join(" ")
  if t1 == t2
    puts "Yes"
  else
    puts "No"
  end
end

if N % 2 == 1
  puts "No"
else
  repeat(S)
end

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	X := sc.NextInt()

	fmt.Println(8 - (X-400)/200)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1772
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(int(f/100)+1):
    for j in range(int(f/100)+1):
        if 0 < a*i*100 + b*j*100 <= f:
            water.append(a*i*100 + b*j*100)
water.sort()
sugar = []
for i in range(int(f/c)+1):
    for j in range(int(f/d)+1):
        if c*i+(c*i)*e/100 + d*j+(d*j)*e/100 <= f:
            sugar.append(c*i + d*j)
sugar.sort(reverse=True)
check = -1.0
for w in list(set(water)):
    for s in list(set(sugar)):
        if w+s <= f and s <= w*e/100:
            if check < 100*s/(w+s):
                check = 100*s/(w+s)
                ans1, ans2 = w+s, s
print(ans1, ans2)


Measured memory_bytes: 5288
//url:
//problem name: 

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

const int MOD = 1000000007;

int main() {
    int N,M;
    cin >> N >> M;
    int ans = 0;
    vector<P> edge(M);
    REP(i,M) cin >> edge[i].first >> edge[i].second;
    REP(i,M) {
        vecveci G(N);
        REP(j,M) {
            if(i != j) {
                int a = edge[j].first;
                int b = edge[j].second;
                a--;
                b--;
                G[a].push_back(b);
                G[b].push_back(a);
            }
        }

            vector<int> dist(N,-1);
            queue<int> que;
            int count = 0;
            for(int v = 0; v < N; v++) {
                if(dist.at(v) != -1) continue;
                dist.at(v) = 0;
                que.push(v);
                while(!que.empty()) {
                    int v = que.front(); 
                    que.pop();
                    for(auto w:G.at(v)) {
                        if(dist.at(w) != -1) continue;
                        que.push(w);
                        dist.at(w) = dist.at(v) + 1;
                    }
                }
                count++;
            }
            if(count > 1) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	string a, b; cin >> a >> b;
	int num = stoi(a + b);
	for (int i = 4; i <= sqrt(num); ++i) {
		if (i * i == num) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
card_a = input()
card_b = input()
card_c = input()

num_a = 0
num_b = 0
num_c = 0


card_str = "a"
while 0 == 0:
  if card_str == "a":
    if num_a == len(card_a):
      print("A")
      exit()
    card_str = card_a[num_a]
    num_a += 1
  if card_str == "b":
    if num_b == len(card_b):
      print("B")
      exit()
    card_str = card_b[num_b]
    num_b += 1
  if card_str == "c":
    if num_c == len(card_c):
      print("C")
      exit()
    card_str = card_c[num_c]
    num_c += 1

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc  = new Scanner(System.in);
      	int n = sc.nextInt();
      	int y = sc.nextInt();
     
      	for(int i = 0; i <= n; i++){
        	for(int j = 0; i+j <= n; j++){
            	int k = n - i - j;
              	if((1000*i) + (5000*j) + (10000*k) == y){
					System.out.println(k + " " + j + " " + i);
                  	return;
                }
            }
        }
      	System.out.println("-1 -1 -1");
      	sc.close();
    }
}


Measured memory_bytes: 39600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    while(true){
        bool flag = false;
        for(int i = 0; i < h; i++){
            int white = 0;
            int deleted = 0;
            for(int j = 0; j < w; j++){
                if(a[i][j] == '.'){
                    white++;
                } else if(a[i][j] == '-'){
                    deleted++;
                }
            }
            if(white + deleted == w && deleted != w){
                for(int j = 0; j < w; j++){
                    a[i][j] = '-';
                }
                flag = true;
            }
        }

        for(int i = 0; i < w; i++){
            int white = 0;
            int deleted = 0;
            for(int j = 0; j < h; j++){
                if(a[j][i] == '.'){
                    white++;
                } else if(a[j][i] == '-'){
                    deleted++;
                }
            }
            if(white + deleted == h && deleted != h){
                for(int j = 0; j < h; j++){
                    a[j][i] = '-';
                }
                flag = true;
            }
        }
        if(!flag){
            break;
        }
    }

    for(int i = 0; i < h; i++){
        int count = 0;
        for(int j = 0; j < w; j++){
            if(a[i][j] != '-'){
                cout << a[i][j];
                count++;
            }
        }
        if(count != 0){
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256