akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, m;
    cin>>n>>m;
    vector< pii > adj[n + 5];
    f(i, m){
        int u, v;
        cin>>u>>v;
        adj[u].pb({v, i});
    }
    vector< vector<int> > ans(m);
    f(i, m){
        ans[i].resize(12, 0);
    }
    rep(i, 1, n){
        s(adj[i]);
    }
    rep(i, 1, n){
        int ptr = 1;
        for(auto it : adj[i]){
            int yr = it.first, id = it.second;
            int idx = ptr++;
            vector<int> fill(12, 0);
            int put = i;
            for(int k = 5; k >= 0; k--){
                if(put == 0) break;
                fill[k] = put % 10;
                put /= 10;
            }
            for(int k = 11; k >= 6; k--){
                if(idx == 0) break;
                fill[k] = idx % 10;
                idx /= 10;
            }
            ans[id] = fill;
        }
    }
    for(auto &i : ans){
        for(int j : i){
            cout<<j;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
 
using ll = long long;
using vll = V<ll>;


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  int d,g;
    cin>>d>>g;
  vll A(d);
  vll B(d);
  for(int i=0;i<d;i++){
    ll a,b;
      cin>>a>>b;
    A[i]=100*a*(i+1)+b;//全完したら何点か
    B[i]=a;//何回か
  }
  
  int ans=100000;
  
  //bit全探索
  for(int bit=0;bit<(1<<d);bit++){
      int now=0;//今の時点での合計点
      int count=0;//今の時点での回数
      int half=0;//中途半端に解く問題の点数
      bool b=true;

    for(int i=d-1;i>=0;i--){

      if(bit&(1<<i)){
        now+=A[i];
        count+=B[i];
      }//全完するのを選ぶ

      else if(b){
        half=i;
        b=false;
      }//中途半端に解くのを選ぶ
    }
      int n=B[half];
    for(int j=0;j<=n;j++){
      if(now>=g){
         chmin(ans,count);
         break;
      }

      else{
        now+=(half+1)*100;
        count++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//    package com.company;

    import java.io.*;
    import java.util.*;

    public class Main {

        public static void main(String[] args) throws IOException{
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            Program solver = new Program();
            solver.solve(in, out);
            out.close();
        }

        static class Program{

            static void solve(InputReader in, PrintWriter out) throws IOException{
               int n = in.nextInt();
               int q = n % 10;
               int w = n / 10;
               if(q == 9 || w == 9)out.print("Yes");else out.print("No");
            }

        }

        static class InputReader {
            public BufferedReader reader;
            public StringTokenizer tokenizer;

            public InputReader(InputStream stream) {
                reader = new BufferedReader(new InputStreamReader(stream), 32768);
                tokenizer = null;
            }

            public String next() {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    try {
                        tokenizer = new StringTokenizer(reader.readLine());
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
                return tokenizer.nextToken();
            }

            public int nextInt() {
                return Integer.parseInt(next());
            }

            public String nextLine(){
                try {
                    return reader.readLine();
                }catch(IOException e){
                    return null;
                }
            }

        }
    }


Measured memory_bytes: 23252
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    p = min(A[i], B[i])
    ans += p
    B[i] -= p
    p = min(A[i+1], B[i])
    ans += p
    A[i+1] -= p

print(ans)

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

int main() {
  double input;

  while(cin >> input){
    double y = input * input / 19.6;
    
    long long int x = max( 1, (int) ( ( y + 5 ) / 5 - 2 ) );
    while ( true ) {
      if ( y <= ( x - 1 ) * 5 ) {
	cout << x << endl;
	break;
      }
      x++;
    }
  }

  return 0;

}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    ll a, bn;
    string b;
    cin >> a >> b;
    bn = (b[0] - '0') * 100;
    if (b.size() >= 3) { bn += (b[2] - '0') * 10; }
    if (b.size() >= 4) { bn += (b[3] - '0'); }
    cerr << "bn=" << bn << endl;
    cout << a * bn / 100;
    return 0;
}


Measured memory_bytes: 3632
N, K = map(int, input().split())

d_list = []
A_set = set()

for _ in range(K):
  d = int(input())
  d_list.append(d)
  
  A = map(int, input().split())
  A_set = A_set | set(A)
  
print(N - len(A_set))

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

int main(){
  int num[4] = {0,0,0,0};
  for(int i=0;i<6;i++){
    int k;
    cin >> k;
    num[k-1] += 1;
  }
  int one=0, two=0;
  for(int i=0;i<4;i++){
    if(num[i] == 1) one++;
    else if(num[i] == 2) two++;
  }
  if(one==2 && two==2) cout << "YES";
  else cout << "NO";

  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())
if 0 in a:
    print('0')
    exit()
ans = 1
for x in a:
    ans = ans * x
    if ans > 10 ** 18:
        print('-1')
        exit()
print(ans)

Measured memory_bytes: 20116
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N=2*1e5+5,inf=1e9+5;;
int n;
LL A,B=inf,_A,_B=inf,ans;
int in[N],ou[N],cnt;
struct card {LL val,bag;} b[N<<1];
bool cmp(card u,card v)
{
	return u.val<v.val;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld%lld",&b[i*2-1].val,&b[i*2].val);
		b[i*2-1].bag=b[2*i].bag=i;
		if(b[i*2-1].val>b[i*2].val) swap(b[i*2-1],b[i*2]);
		A=max(b[i*2].val,A),B=min(b[i*2].val,B);
		_A=max(b[i*2-1].val,_A),_B=min(b[i*2-1].val,_B);
	}
	ans=(A-B)*(_A-_B);
	//cout<<ans<<" "<<A-_B<<endl;
	sort(b+1,b+n*2+1,cmp);
	//for(int i=1;i<=n<<1;++i) cout<<b[i].val<<" "<<b[i].bag<<endl;
	int l=2,r=2;
	while(r<=n*2)
	{
		while(cnt<n && r<=n*2) cnt+=(in[b[r].bag]==0),++in[b[r++].bag];
		if(r>2*n) break;
		while(in[b[l].bag]==2) --in[b[l].bag],++ou[b[l++].bag];
		ans=min(ans,(b[r-1].val-b[l].val)*(A-_B));
		//cout<<l<<" "<<r<<" "<<b[l].val<<" "<<b[r].val<<endl;
		if(ou[b[l].bag]==1) break;
		++ou[b[l].bag],--in[b[l].bag],++l,--cnt;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define MAX_SIZE 99
char field[MAX_SIZE][MAX_SIZE];

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

    for(int i = 0; i < 50; i++){
        for(int j = 0; j < MAX_SIZE; j++){
            field[i][j] = '#';
        }
    }
    for(int i = 50; i < MAX_SIZE; i++){
        for(int j = 0; j < MAX_SIZE; j++){
            field[i][j] = '.';
        }
    }

    int cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < 90; i++){
        for(int j = 0; j < 90; j++){
            if(i%2==0 && j%2==0 && cnt1!=a-1){
                field[i][j] = '.';
                cnt1++;
            }
        }
    }

    for(int i = 51; i < MAX_SIZE; i++){
        for(int j = 0; j < 90; j++){
            if(i%2==0 && j%2==0 && cnt2!=b-1){
                field[i][j] = '#';
                cnt2++;
            }
        }
    }
    cout << MAX_SIZE << " " << MAX_SIZE << endl;
    for(int i = 0; i < MAX_SIZE; i++){
        for(int j = 0; j < MAX_SIZE; j++){
            cout << field[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#import<iostream>
using namespace std;int x[200][200],y[200],z[200],n,i,a,j,k,b,s,c;main(){while(1){cin>>n;b=0;if(!n){break;}for(i=1;i<=n;i++){cin>>z[i];for(j=0;j<z[i];j++){cin>>x[i][j];}}cin>>a;for(i=0;i<a;i++){cin>>y[i];}for(i=1;i<=n;i++){s=0;for(j=0;j<a;j++){for(k=0;k<z[i];k++){if(x[i][k]==y[j]){s++;}}}if(s==a){c=i;b++;}}if(b-1){c=-1;}cout<<c<<endl;}}

Measured memory_bytes: 1240
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int N;
int a[101];
int c[101];
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
    c[a[i]]++;
  }
  if(N==2){
    if(a[0]==1 && a[1]==1)cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
  }
  sort(a,a+N);
   int Ma=a[N-1],Mi=a[0];
  if(c[Ma]<2){
    cout << "Impossible" << endl;
    return 0;
  }
 
  if(Ma%2==0){
    if(c[Mi]!=1){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  else{
    if(c[Mi]!=2){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  for(int i=Ma-1;i>Mi;i--){
    if(c[i]<2){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
  return 0;
}


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

typedef struct {
	int n;
} num_t;

int main(int argc, char *argv[])
{
	int N, i;
	static num_t list[100001];
	long long v = 1;
	scanf("%d", &N);
	for ( i = 1; i <= N; i++ ){
		int a;
		scanf("%d", &a);
		if ( a == 0 ){
			if ( N%2 == 0 ){
				printf("0\n");
				return 0;
			}
			if ( list[N/2+1].n != 0 ){
				printf("0\n");
				return 0;
			}
			list[N/2+1].n = 1;
		} else {
			int idx = (N-a)%2 == 0?(N-a)/2:(N-a)/2+1;
			if ( list[idx].n > 2 ){
				printf("0\n");
				return 0;
			}
			list[idx].n++;
			idx = (N+a)%2 == 0?(N+a)/2:(N+a)/2+1;
			list[idx].n++;
		}
	}
	for ( i = 1; i <= N/2; i++ ){
		v *= list[i].n;
		v %= 1000000007LL;
	}
	printf("%lld\n", v);
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	string s, t; cin >> s >> t;
	int match = 0;
	for (int i = 0; i < s.length() - t.length() + 1; ++i)
	{
		int count = 0;
		for (int j = 0; j < t.length(); ++j)
		{
			if (s[i + j] == t[j]) ++count;
		}
		match = max(match, count);
	}
	cout << t.length() - match << endl;
}


Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

H,W = map(int,input().split())
S = [input() for _ in range(H)]

seen = [[False for _ in range(W)] for _ in range(H)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
numb = 0
numw = 0

def dfs(y,x):
  global numb
  global numw
  seen[y][x] = True
  if S[y][x] == '#':
    numb += 1
  if S[y][x] == '.':
    numw += 1
  for i in range(4):
    if not(0<=y+dy[i]<H) or not(0<=x+dx[i]<W):
      continue
    if seen[y+dy[i]][x+dx[i]]:
      continue
    if S[y][x] == S[y+dy[i]][x+dx[i]]:
      continue
    dfs(y+dy[i],x+dx[i])

ans = 0
for i in range(H):
  for j in range(W):
    numb = 0
    numw = 0
    if S[i][j] == '#' and not seen[i][j]:
      dfs(i,j)
      ans += numb * numw
print(ans)


Measured memory_bytes: 148180
#include <iostream>
using namespace std;
bool hate_num[10] = {false};

bool f(int n) {
    while (n > 0) {
        int p = n % 10;
        if (hate_num[p]) {
            return false;
        }
        n /= 10;
    }
    return true;
}

int main() {
    int n, k; cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int p;
        cin >> p;
        hate_num[p] = true;
    }
    while (!f(n)) {
        n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 888
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int a;
    int b;
    int c;
    int tmp;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }if (b > c) {
        tmp = c;
        c = b;
        b = tmp;
    }if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int d[50][50], g[1005][1005];
int cost[5][50];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, c;
	cin >> n >> c;
	rep(i, c) rep(j, c) cin >> d[i][j];
	repn(i, 1, n + 1) repn(j, 1, n + 1) cin >> g[i][j], g[i][j]--;
	rep(i, 5) rep(j, 50) cost[i][j] = 0;
	//so there are 3 components in the grid based on the modulo of the sum of coords.
	int ans = 1e9;
	repn(i, 1, n + 1) repn(j, 1, n + 1){
		int md = (i + j) % 3;
		rep(k, c) cost[md][k] += d[g[i][j]][k];
	}
	rep(i, c) rep(j, c) rep(k, c) if(i != j && i != k && j != k){
		ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int N;


typedef long long int ll;
ll A[100009];
ll POWER[31];

int main(){

    scanf("%d",&N);
    for(int i=0;i<=N;i++) scanf("%lld",A+i);
    POWER[0]=1;
    for(int i=1;i<=30;i++) POWER[i]=POWER[i-1]*2;

    vector<pair<ll,ll>> intervals;
    ll lowbound=A[N],upperbound=A[N];
    for(int i=N;i>=0;i--){
        intervals.push_back(pair<ll,ll>(lowbound,upperbound));
        // printf("%lld %lld\n",lowbound,upperbound);

        bool within=((i>=30)||(lowbound<=POWER[i]))&&(upperbound>0);

        if (!within){
            puts("-1");
            return 0;
        }

        if (i!=0){
            auto low=A[i-1]+(lowbound+1)/2,high=A[i-1]+upperbound;
            lowbound=low;
            upperbound=(i>=30?high:min(high,POWER[i-1]));
        }
    }

    ll ans=0;
    upperbound=intervals.back().second;
    for(int i=intervals.size()-1;i>=0;i--){
        intervals[i].second=min(upperbound,intervals[i].second);
        if (intervals[i].second<=0||intervals[i].second<intervals[i].first){
            puts("-1");
            return 0;
        }
        ans+=intervals[i].second;
        upperbound=2*(intervals[i].second-A[N-i]);
    }

    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 5628
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  if i!=0:
    P[i]=P[i-1]+(P[i]+1)/2
  else:
    P[i]=(P[i]+1)/2
    
ans=P[K-1]
for i in range(N-K+1):
  ans=max(ans,P[i+K-1]-P[i-1])
    
print(ans)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    ll h;
    cin>>n>>h;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    sort(all(a));
    sort(all(b));
    
    vector<ll> th;
    rep(i,n){
        if(b[i]>a[n-1]) th.push_back(b[i]);
    }

    sort(all(th));
    reverse(all(th));

    ll ans=0;
    rep(i,th.size()){
        h-=th[i];
        ans++;
        if(h<=0) break;
    }

    if(h>0){
        ans+=(h+a[n-1]-1)/a[n-1];
    }

    cout<<ans<<endl;

}



Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
    ll n;
    cin>>n;
    ll a;
    cin>>a;
    n=n%500;
    if(n<=a)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    int N;
    cin >> N;
    int ans = 0, a, b;
    REP(i, N){
        cin >> a >> b;
        ans += (b - a + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

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

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

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

    int y = lcm(360,x);

    cout << y/x << endl;

    return 0;
}

Measured memory_bytes: 3628
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 INF = 2e12;

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

  int n; cin >> n;
  int64 k; cin >> k;
  vector<int64> a(n), f(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> f[i];

  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  auto ok = [&](int64 score) -> bool {
    int64 sum = 0LL;
    for (int i = 0; i < n; ++i) {
      if (a[i] * f[i] <= score) continue;
      sum += a[i] - score / f[i];
    }
    return sum <= k;
  };

  int64 high = INF, low = -1LL;
  while (high - low > 1LL) {
    int64 mid = (high + low) / 2;
    if (ok(mid)) {
      high = mid;
    } else {
      low = mid;
    }
  }

  cout << high << endl;

  return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e2+10;
const int maxm=1e3+10;
const int mod=1e9+7;
int n;
ll dp[maxn][5][5];
char s1[maxn],s2[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        scanf("%s %s",s1,s2);
        cls(dp,0);
        if(s1[0]==s2[0])
            dp[0][1][1]=dp[0][2][2]=dp[0][3][3]=1;
        else
        {
            dp[0][1][2]=dp[0][1][3]=dp[0][2][3]=1;
            dp[0][2][1]=dp[0][3][1]=dp[0][3][2]=1;
        }
        for(int i=1;i<n;i++)
        {
            if(s1[i]==s1[i-1])
                memcpy(dp[i],dp[i-1],sizeof(dp[i-1]));
            else
            {
                if(s1[i]==s2[i])
                {
                    dp[i][1][1]=(dp[i-1][2][2]+dp[i-1][3][3]+dp[i-1][2][3]+dp[i-1][3][2])%mod;
                    dp[i][2][2]=(dp[i-1][3][3]+dp[i-1][1][1]+dp[i-1][1][3]+dp[i-1][3][1])%mod;
                    dp[i][3][3]=(dp[i-1][1][1]+dp[i-1][2][2]+dp[i-1][1][2]+dp[i-1][2][1])%mod;
                }
                else
                {
                    dp[i][1][2]=(dp[i-1][3][3]+dp[i-1][2][1]+dp[i-1][2][3]+dp[i-1][3][1])%mod;
                    dp[i][2][1]=(dp[i-1][3][3]+dp[i-1][1][2]+dp[i-1][3][2]+dp[i-1][1][3])%mod;

                    dp[i][1][3]=(dp[i-1][2][1]+dp[i-1][2][2]+dp[i-1][3][1]+dp[i-1][3][2])%mod;
                    dp[i][3][1]=(dp[i-1][1][2]+dp[i-1][2][2]+dp[i-1][1][3]+dp[i-1][2][3])%mod;

                    dp[i][2][3]=(dp[i-1][1][1]+dp[i-1][1][2]+dp[i-1][3][1]+dp[i-1][3][2])%mod;
                    dp[i][3][2]=(dp[i-1][1][1]+dp[i-1][2][1]+dp[i-1][1][3]+dp[i-1][2][3])%mod;
                }
            }
        }
        ll ans=0;
        for(int i=1;i<=3;i++)
            for(int j=1;j<=3;j++)
            ans=(ans+dp[n-1][i][j])%mod;
        printf("%lld\n",ans);
    }
    return 0;
}


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

using ll = long long;
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int m;
	cin >> m;
	ll sum = 0;
	ll games = 0;
	for(int i = 0; i < m; i++){
		ll a, b;
		cin >> a >> b;
		sum += a * b;
		games += b;
	}
	cout << (sum - 1) / 9 + (games - 1) << '\n';
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int N, K;
int A[MAX];
int hoge[100];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	cin>>N>>K;
	
	rep(i,N){
		cin>>A[i];
		int num = A[i];
		
		for(int i = 0; num; i++){
			if(num%2)hoge[i]++;
			num /= 2;
		}
	}
	
	// for(int i = 0; i <= 20; i++){
		// cout<<i<<" "<<hoge[i]<<endl;
	// }
	
	
	int t = 1ll<<60, ans = 0;
	
		
	for(int i = 60; i >= 0; i--, t/= 2){
		if(hoge[i]*2 < N && K >= t){
			K -= t;
			ans += (N-hoge[i])*t;
			// cout<<"<><> "<<endl;
		} else {
			ans += hoge[i]*t;
		}
		// cout<<i<<" "<<t<<endl;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    cout<<a/b<<" "<<a%b<<" "<<fixed<<(double)a/b<<endl;
    return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

char s[100000+10];
int dp[100000+10];
const int INF = 1000000;

int main(void) {
  int n, m;
  scanf("%d%d%s", &n, &m, s);
  queue<int> q;
  dp[n] = 0;
  q.push(n);
  for(int i = n-1; i >= 0; --i) {
    while(!q.empty() && q.front() > i+m) {
      q.pop();
    }
    if(s[i] == '1' || q.empty()) {
      dp[i] = INF;
      continue;
    }
    dp[i] = dp[q.front()] + 1;
    q.push(i);
  }
  if(dp[0] == INF) {
    puts("-1");
    return 0;
  }
  // REP(i, n+1) {
  //   cerr << dp[i] << endl;
  // }
  for(int cur = 0; cur != n; ) {
    int next = cur+1;
    while(dp[next] != dp[cur]-1) {
      ++next;
    }
    printf("%d%c", next-cur, next == n ? '\n' : ' ');
    cur = next;
  }

  return 0;
}


Measured memory_bytes: 896
from fractions import gcd
A,B,C,D = list(map(int, input().split()))
def lcm(x, y):
    return (x * y) // gcd(x, y)
lcm = lcm(C,D)
nbc = B//C
nbd = B//D
nbl = B//lcm 
nac = (A-1)//C
nad = (A-1)//D
nal = (A-1)//lcm 
ans = B - A + 1-((nbc+nbd-nbl)-(nac+nad-nal))
print(int(ans))

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

int main()
{
int N,ans,s,f,middle,j;scanf("%d",&N);
vector<int> A(N);for(int i=0;i<N;i++)scanf("%d",&A[i]);
vector<int> dp(N,-1);
for(int i=0;i<N;i++)
{
  f=-1,s=N;
  while(s-f>1)
  {
    middle=(f+s)/2;
    if(dp[middle]<A[i])s=middle;
    else f=middle;
  }
  dp[s]=A[i];
}
for(j=0;j<N;j++){if(dp[j]==-1)break;}
if(j==N-1&&dp[j]!=-1)j--;
printf("%d\n",j);
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
typedef long long int ll;
int main(void){
  ll A,B,V,W,T;
  cin >> A >> V >> B >> W >> T;
  if(A > B){
    A = -A;
    B = -B;
  }
  // always A <= B
  ll finA,finB;
  finA = A + T*V;
  finB = B + T*W;
  if(finA >= finB){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
long long int power(long long int x,long long int y,long long int mod)
{
    long long int res=1LL;
    while(y>0)
    {
        if(y&1) res=(res*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return res;
}

/*bool compare(pair<long long int,long int> a,pair<long long int,long int> b)
{
    return a.s<b.s;
}*/

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    while(t--)
    {
        string s;
        cin>>s;
        long int n=s.length()+1;
        long long int a[n]={0};
        for(long int i=0;i<n-1;i++)
        {
            if(s[i]=='<')
            a[i+1]=a[i]+1;
        }
        for(long int i=n-2;i>=0;i--)
        {
            if(s[i]=='>')
            a[i]=max(a[i],a[i+1]+1);
        }
        long long int ans=0;
        for(long int i=0;i<n;i++)
        ans+=a[i];
        cout<<ans<<endl;
    }
	// your code goes here
	return 0;
}


Measured memory_bytes: 7700
import java.io.IOException;
import java.math.BigInteger;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			int b = scanner.nextInt();
			if (a.equals("0") && b == 0)
				break;
			BigInteger big = new BigInteger(a).pow(b);
			Deque<String> ans = new LinkedList<String>();
			String an = big.mod(man).toString();
			if (!an.equals("0"))
				ans.push(an);
			big = big.divide(man);
			for (String s : list) {
				an = big.mod(man).toString();
				if (!an.equals("0"))
					ans.push(an + s);
				big = big.divide(man);
				if (big.equals(BigInteger.ZERO))
					break;
			}
			while (!ans.isEmpty()) {
				System.out.print(ans.poll());
			}
			System.out.println();

		}
	}

	BigInteger man = new BigInteger("10000");
	String[] list = { "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko",
			"Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts" };
}

Measured memory_bytes: 18604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=-1e18;
void Main(){
    int n, k;
    cin >> n >> k;
    k--;
    vector<ll> p(n+1), c(n+1);
    For(i,1,n+1) cin >> p[i];
    For(i,1,n+1) cin >> c[i];
    auto calc = [&](int x){
        int now = x;
        ll cnt = 0;
        vector<ll> score(1,0);
        while(1){
            now = p[now];
            cnt += c[now];
            score.push_back(cnt);
            //cout << now << " ";
            if(now == x){
                break;
            }
        }
        int len = score.size() - 1;
        ll ret = 0; // k / len * score[len] + score[k%len]; 
        if(score[len] > 0){
            ll k2 = k;
            if(k > 3 * n){
                ret += (k / len - 1) * score[len];
                k2 = k % len + len;
            }
            cnt = 0;
            now = x;
            ll nax = c[p[now]];
            For(i,0,k2){
                now = p[now];
                cnt += c[now];
                nax = max(nax, cnt);
            }
            ret += nax;
        }
        else{
            ret = *max_element(score.begin(), score.begin() + min(len,k));
        }

        // cout << endl << len << " " << ret << endl;
        return ret;
    };
    For(i,1,n+1){
        ll sc = c[p[i]] + calc(p[i]);
        // cout << sc << endl;
        ans = max(ans, sc);
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n;
string s;
int main(){
	scanf("%d",&n);
	cin>>s;
	if(n<3200){
		cout<<"red\n";
	}
	else cout<<s;
	return 0;
}




Measured memory_bytes: 384
using System;
class Program
    {
        static void Main(string[] args)
        {
            //数の導入
            string str = Console.ReadLine();
            int[] test = new int[2];

            //二つに分離する
            for (int i = 0; i < str.Length - 1; i += 2)
            {
                test[i / 2] = int.Parse(str.Substring(i, 2));
            }

            //判定を行う
            int judge1 = 0;
            int judge2 = 0;
            //条件1を満たすか
            if (1 <= test[0] && test[0] <= 12)
                judge1 = 1;

            //条件2を満たすか
            if (1 <= test[1] && test[1] <= 12)
                judge2 = 1;

            //条件分離
            if (judge1 == 1 && judge2 == 1)
                Console.WriteLine("AMBIGUOUS");
            else if (judge1 == 1 && judge2 == 0)
                Console.WriteLine("MMYY");
            else if (judge1 == 0 && judge2 == 1)
                Console.WriteLine("YYMM");
            else
                Console.WriteLine("NA");

        }
    }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s;
  cin >> s;
  int ans = s.size();
  REP(i,s.size()-1) if (s[i] != s[i+1]) CHMIN(ans,max(i+1,(int)s.size()-i-1));
  cout << ans << endl;

  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    ll res = 0;
    vector<string> S(N);
    vector<ll> A(N);
    REP(i, N) cin >> S[i] >> A[i];
    string T;
    cin >> T;
    bool ok = false;
    REP(i, N){
    	if(ok) res += A[i];
    	if(S[i]==T) ok = true;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        String word;
        int m;
        int h;
        int original_length;
        while (true) {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        }
        System.out.print(output);
    }
}

Measured memory_bytes: 18392
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using Graph = vector<vector<int>>;

int main() {
    string T;
    cin>>T;
    string ans="";
    rep(i,T.size()){
        if(i==0){
            if(T.at(i)=='?'){
                ans.push_back('D');
            }
            if(T.at(i)=='P'){
                ans.push_back('P');
            }
            if(T.at(i)=='D'){
                ans.push_back('D');
            }
            continue;
        }
        if(T.at(i)=='P'){
                ans.push_back('P');
        }
        if(T.at(i)=='D'){
                ans.push_back('D');
        }
        if(T.at(i)=='?'){
            if(T.at(i-1)=='P'){
                ans.push_back('D');
                continue;
            }
            else{
                ans.push_back('D');
                continue;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

int main() {
    int x, y;
    cin >> x >> y;
    rep(i, x + 1) {
        int tori = i;
        int kame = x - i;
        if (tori * 2 + kame * 4 == y) {
            cout << YES << endl;
            return 0;
        }
    }
    cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  ll n = s.size();

  for (ll i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i]) {
      No();
      return 0;
    }
  }

  for (ll i = 0; i < (n - 1) / 2; i++) {
    if (s[i] != s[(n - 1) / 2 - 1 - i]) {
      No();
      return 0;
    }
  }

  for (ll i = n / 2 + 1; i < n; i++) {
    if (s[i] != s[n - 1 - i]) {
      No();
      return 0;
    }
  }

  Yes();
}

Measured memory_bytes: 256
n=int(input())
s=input()
rr=[]
gg=[]
bb=[]
for i in range(n):
  if s[i]=='R':
    rr.append(i)
  elif s[i]=='G':
    gg.append(i)
  else:
    bb.append(i)
lr=len(rr)
lg=len(gg)
lb=len(bb)
ans=lr*lg*lb
if ans==0:
  print(0)
  exit()
#print(ans,lr,lg,lb)
for xx in rr:
  for yy in gg:
    x,y=min(xx,yy),max(xx,yy)
    d=y-x
    a=x-d
    b=y+d
    if 0<=a<n and s[a]=='B':
      ans-=1
    if 0<=b<n and s[b]=='B':
      ans-=1
    if (x+y)%2==0:
      c=(x+y)//2
      if 0<=c<n and s[c]=='B':
        ans-=1



#print(rr,gg,bb)
print(ans)

Measured memory_bytes: 9228
N = int(input())
h = list(map(int,input().split()))
ans = 0
while True:
  if max(h) == 0:
    break
  i = 0
  while i < N:
    if h[i] == 0:
      i+=1
      continue
    else:
      ans += 1
      while (i < N and h[i] > 0):
        h[i] -= 1
        i += 1
print(ans)
        

Measured memory_bytes: 39152
// inputに入力データ全体が入る
function Main(input) {
  var a,b,t;
  a = Number(input.split('\n')[0].split(' ')[0]);
  b = Number(input.split('\n')[0].split(' ')[1]);
//  t = Number(input.split('\n')[0].split(' ')[2]);
  
  console.log(Math.max(a,b) + Math.max(Math.max(a,b) - 1, Math.min(a,b)));
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <map>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

bool primes[200009]; int vec[200009];

int main() {
	for (int i = 2; i <= 2000; i++) {
		for (int j = i*i; j <= 200000; j += i) primes[j] = true;
	}
	primes[1] = true;
	for (int i = 1; i <= 200000; i += 2) {
		if (primes[i] == false && primes[(i + 1) / 2] == false)vec[i]++;
	}
	for (int i = 1; i <= 200000; i++) vec[i] += vec[i - 1];
	int Q, l, r; cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << vec[r] - vec[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];
    vll x = {-a[0]};
    ll res = 1;
    REP(i, n){
        if(i == 0) continue;
        ll pos = upper_bound(ALL(x), -a[i]) - x.begin();
        if(pos == x.size()){
            x.push_back(-a[i]);
            res++;
        }
        else{
            x[pos] = -a[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2168
import itertools
n = int(input());
X = []
Y = []

for i in range(n):
  x, y = map(int, input().split());
  X.append(x);
  Y.append(y);
    
list_ = list(itertools.permutations(range(n)))
ans = 0
ans_list = []

for i in list_:
  for j in range(n - 1):
    ans += ((X[i[j + 1]] - X[i[j]]) ** 2 + (Y[i[j + 1]] - Y[i[j]]) ** 2) ** (1 / 2)
  
  ans_list.append(ans)
  ans = 0 
  
print(sum(ans_list) / len(ans_list))

Measured memory_bytes: 9332
#coding: utf-8
import sys

ROW = 0
COL = 1

def matrixchaincost(M):
    n = len(M)
    cost = [[0 for i in range(n)] for j in range(n)]

    for length in range(2, n+1):
        for i in range(0, n-length+1):
            k = i+length-1
            def f(i,j,k):
                return cost[i][j-1]+cost[j][k]+M[i][ROW]*M[j-1][COL]*M[k][COL]
            cost[i][k] = min([f(i,j,k) for j in range(i+1,k+1)])
    return cost[0][n-1]

n = input()
M = []
for i in range(n):
    M.append(map(int, raw_input().split()))
    
print matrixchaincost(M)

Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

class UnionFind {
  private:
    vector<int> parent;
    vector<int> rank;

  public:
    UnionFind(int size) : parent(size), rank(size, 0) {
      for (int i = 0; i < size; i++) {
        parent[i] = i;
      }
    }

    int find(int x) {
      if (parent[x] == x) {
        return x;
      } else {
        return parent[x] = find(parent[x]);
      }
    }

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;

      if (rank[x] < rank[y]) {
        parent[x] = y;
      } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }
};

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

  ll n, m;
  cin >> n >> m;
  vector<pll> edge(m);
  rep(i, m) {
    cin >> edge[i].first >> edge[i].second;
  }

  vector<ll> ans(m);
  ll cnt = n * (n-1) / 2;
  ans[0] = cnt;

  UnionFind uf(n);
  vector<ll> size(n, 1);

  rep(i, m-1) {
    ll l = edge[m-i-1].first-1;
    ll r = edge[m-i-1].second-1;

    ll ls = size[uf.find(l)];
    ll rs = size[uf.find(r)];

    bool flag = uf.same(l, r);

    if (!flag) {
      uf.unite(l, r);
      size[uf.find(l)] = ls + rs; 
      ans[i+1] = max((ll)0, cnt - ls*rs);
      cnt = max((ll)0, cnt - ls*rs);
    } else {
      ans[i+1] = cnt;
    }
  }

  rep(i, m) {
    cout << ans[m-i-1] << endl;
  }
}


Measured memory_bytes: 5248
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include "bits/stdc++.h"

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(x) x.begin(),x.end()
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)

const double EPS = 1e-14;

bool all_st[30];
bool exist[26];
bool done[26];
void solve() {
	string S; cin >> S;
	if (S == "#")exit(0);
	int N = S.size();
	//set<char>all_st;
    REP(i,26)all_st[i]=false;
	REP(i, N) {
		//all_st.insert(S[i]);
        int num = S[i]-'a';
        all_st[num]=true;
	}

	vector<string>ans;
    int cnt = 0;
    vector<string>ans_s,ans_t;
	REP(bit, 1 << N) {
		string nxt = S;

		memset(exist,0,sizeof(exist));
		memset(done,0,sizeof(exist));
		REP(i, N) {
			if (bit&(1 << (N-1-i))) {
				if (nxt[i] == 'z')goto END;
				nxt[i]++;
			}
		}

		REP(i, N) {
			int num = nxt[i]-'a';
			if (bit&(1 << (N-1-i))) {
				if (exist[num])goto END;
				done[num]=true;
			}
			exist[num]=true;
		}
		REP(i, N) {
			int num = nxt[i]-'a';
			if (!(bit&(1 << (N-1-i)))) {
				if (nxt[i]!='a'&&!done[num])goto END;
			}
		}
        cnt++;
        ans.push_back(nxt);
	END:;
	}

	//sort(ALL(ans));
	cout << cnt << '\n';
	int M = cnt;
	sort(ALL(ans));
	if (M <= 10) {
		REP(i, M) {
			cout << ans[i] << '\n';
		}
	}
	else {
		REP(i, 5) {
			cout << ans[i] << '\n';
		}
		REPR(i, 5) {
			cout << ans[M-i-1] << '\n';
		}
	}
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
	while (true)solve();
}


Measured memory_bytes: 4240
# AOJ 0095 Surf Smelt Fishing Contest
# Python3 2018.6.21 bal4u

n = int(input())
tbl = [0]*(n+1)
vmax = 0
for i in range(n):
	a, v = list(map(int, input().split()))
	tbl[a] += v
	if tbl[a] > vmax: vmax = tbl[a]

for i in range(1, n+1):
	if tbl[i] == vmax:
		print(i, vmax)
		break



Measured memory_bytes: 5600
import Control.Applicative ((<$>))

solve xs c =
  let ys = filter (\x -> x == c) xs in
    if ys /= []
      then "YES"
      else "NO"

main = do
  [a, b, c] <- fmap read <$> words <$> getLine :: IO [Int]
  let xs = fmap (\x -> x * a `mod` b) [1..b] in
    putStrLn (solve xs c)


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <sstream>

void inv(char& c)
{
	if (64 <= c && c <= 90)
		c += 32;
	else if (97 <= c && c <= 122)
		c -= 32;
}

int main()
{
	std::string text;
	std::getline(std::cin, text, '\n');

	for (int n = 0; n < text.size(); ++n)
	{
		inv(text.at(n));
	}

	std::cout << text << std::endl;

	return 0;
}


Measured memory_bytes: 3184
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b = map(int,input().split())
for i in range(2000):
  if int(i*0.08) == a and int(i*0.1) == b:
    print(i)
    exit()
print(-1)

Measured memory_bytes: 39408