akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <list>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


template <class Monoid>
class SegmentTree
{
public:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid M1;
  int sz;
  vector<Monoid> seg;

  SegmentTree(int n,const Func fu, const Monoid &m1): F(fu) , M1(m1) {init(n);}
  void init(int n)
  {
      sz= 1;
      while (sz < n) sz *= 2;
      seg.assign(sz * 2, M1);
  }
  void update(int k,const Monoid &x)
  {
    k+=sz;
    seg[k]=x;
    while(k>>=1)
    {
      seg[k]=F(seg[k*2],seg[k*2+1]);
    }
  }
  Monoid query(int l,int r)
  {
    Monoid L=M1,R=M1;
    l+=sz;r+=sz;
    for(;l<r;l>>=1,r>>=1)
    {
      if(l&1)L=F(L,seg[l++]);
      if(r&1)R=F(seg[--r],R);
    }
    return F(L,R);
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<pair<ll,ll>>b(n);
  rep(i,n)b[i]={a[i],-i};
  map<ll,ll>ma;
  sort(all(b));

  ll id=1;
  rep(i,n){
    ma[(b[i].first<<32)-b[i].second]=id++;
  }
  auto check=[&](){
    SegmentTree<ll>st(id+1,[](ll a,ll b){return max(a,b);},0);
    rep(i,n){
      ll ta=ma[(a[i]<<32)+i];
      ll tmax=st.query(0,ta);
      ll ng=0,ok=ta;
      while(ok-ng>1){
        ll nn=(ok+ng)/2;
        if(tmax==st.query(0,nn))ok=nn;
        else ng=nn;
      }
      ll tm=ng;
      if(tmax==0){
        st.update(ta,ta);
      }
      else {
        st.update(tm,0);
        st.update(ta,ta);
      }
    }
    ll res=0;
    rep(i,id+1){
      if(st.query(i,i+1))res++;
    }
    return res;
  };
  cout<<check()<<endl;


  return 0;

}


Measured memory_bytes: 10880
N, K = map(int, input().split())
l = list(map(str, input().split()))
 
for i in range (N, 100000): 
	k = str(i)
	counter = 0
	for j in range (0, K):
		if k.find(l[j]) >= 0:
			counter+=1
	if counter == 0:
		print(i)
		exit()

Measured memory_bytes: 72900
def shuffle(l,h):
	l.extend(l[0:h])
	del l[0:h]
	
while True :
	card_list = list(raw_input())
	if card_list == ['-']:
		break
	else :
		m = input()
		h_count = [0]*m
		for i in range(m):
			h_count[i] = input()
			shuffle(card_list,h_count[i])
		print("".join(card_list))

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

int numofbits(int bits)
{
    int num;

    num = (bits >> 1) & 03333333333;
    num = bits - num - ((num >> 1) & 03333333333);
    num = ((num + (num >> 3)) & 0707070707) % 077;

    return num;
}

int main()
{
    int n, m;
    vector<int> s;
    vector<int> k, p;
    cin >> n >> m;
    s.resize(m);
    k.resize(m);
    p.resize(m);
    for (int i = 0; i < m; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)
        {
            int ss = 0;
            cin >> ss;
            ss = 1 << (ss - 1);
            s[i] |= ss;
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        bool flag = true;
        for (int j = 0; j < m; j++)
        {
            // cout << i << " " << j << " " << s[j] << " " << (i & s[j]) << endl;
            if (numofbits(i & s[j]) % 2 == p[j])
                continue;
            else
            {
                flag = false;
                break;
            }
        }
        if (flag)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0074
"""
import sys


def calc_remaining_second(hh, mm, ss):
    elapsed = (hh*3600) + (mm*60) + ss
    return (3600*2) - elapsed


def prettify_second(s, mode='normal'):
    if mode == 'long':
        s *= 3
    hh = s // 3600
    s %= 3600
    mm = s // 60
    s %= 60
    ss = s
    return '{:02d}:{:02d}:{:02d}'.format(hh, mm, ss)



def main(args):
    while True:
        hh, mm, ss = [int(x) for x in input().strip().split(' ')]
        if hh == -1 and mm == -1 and ss == -1:
            break
        remaining_sec = calc_remaining_second(hh, mm, ss)
        print(prettify_second(remaining_sec, 'normal'))
        print(prettify_second(remaining_sec, 'long'))


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7756
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K;
	cin >> K;
	cout << K / 2 * (K - K / 2) << endl;
	PAU;
	return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
int a[maxn];
multiset<int> s;

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

  cin>>n;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    s.insert(a[i]);
  }

  for (int i=0; i<n; i++) {
    int x = a[i];
    s.erase(s.find(x));
    cout<<*s.rbegin()<<"\n";
    s.insert(x);
  }
  

  return 0;
}


Measured memory_bytes: 11776
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 1e6+5;
const int mod = 1e9+7;
using namespace std;

int f[maxn],a[maxn],b[maxn];

void solve() {
	ll n,cnt=0; cin >> n;
	rep(i,0,n) {
		cin >> a[i];
		f[a[i]]++;
	}
	rep(i,0,n) {
		//ll tmp = a[i];
		int flag=1;
		if (f[a[i]]-1 > 0) continue; 
		int z=0;
		for (int j=1; j*j <= a[i]; j++) {
			if(a[i]%j==0) {
    			b[z++]=j;  
    			if(j!=a[i]/j)
    				b[z++]=a[i]/j;   
   			}    
		}
		rep(k,0,z) if (b[k] != a[i] && f[b[k]]) flag=0;
		if (flag) cnt++;
	}
	cout << cnt;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 8312
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


NA, NB, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))
B = list(map(int, sys.stdin.buffer.readline().split()))
XYC = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

ans = INF
for x, y, c in XYC:
    x -= 1
    y -= 1
    ans = min(A[x] + B[y] - c, ans)

ans = min(ans, min(A) + min(B))
print(ans)


Measured memory_bytes: 48740
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

bool check(string& s) {
    for(auto c:s) {
        if(!(c=='A' || c=='T' || c=='C' || c=='G')) {
            return false;
        }
    }
    return true;
}

signed main() {
    string s;cin>>s;
    const int len = s.size();
    if(len == 1) {
        if(check(s)) {
            cout<<1<<endl;
        } else {
            cout<<0<<endl;
        }
        return 0;
    }
    int ans=0;
    rep(i,0,len-1) {
        string t;t+= s[i];
        if(!check(t)) continue;
        rep(j,i+1,len){
            string b;b+=s[j];
            if(!check(b)) {
                break;
            }
            t+=s[j];
        }
        ans = max<int>(ans, t.size());
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 888
#include<stdio.h>

int main(void){
int W,H,x,y,r;
scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

if((x-r>=0 && x+r<=W) && (y-r>=0 && y+r<=H)){

printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using S = long long;
using F = long long;
const S INF = 1e18;
const F ID = -1e18;

S op(S a, S b) { return std::max(a, b); }
S e() { return -INF; }
S mapping(F f, S x) { return (f == ID ? x : max(x, f)); }
F composition(F f, F g) { return (f == ID ? g : max(g, f)); }
F id() { return ID; }

ll max_a = 350000;

int main() {
    ll n, k;
    cin >> n >> k;
    lazy_segtree<S, op, e, F, mapping, composition, id> lst(max_a);
    for (ll i = 0;i < n;++i) {
        ll a;
        cin >> a;
        ll now = lst.get(a);
        cerr << now << endl;
        lst.apply(max(0ll, a - k), min(max_a, a + k + 1), max(1ll, now + 1));
    }
    cout << lst.all_prod() << endl;
}


Measured memory_bytes: 18344
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, M = map(int, input().split())
if N == M:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 8008
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll s,w;cin>>s>>w;
    if(w>=s)cout<<"unsafe";
    else cout<<"safe";
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える



int banme(vi P){
    int res = 0;

    int n = P.size();

    vi p(n); rep(i, n) p[i] = i;
}

int main(){
    int n; cin >> n;
    vi P(n), Q(n); rep(i, n) cin >> P[i]; rep(i, n) cin >> Q[i];

    vi a(n); rep(i, n) a[i] = i+1;


    map<vi, int> mp;
    //この時点mpのサイズを指定しない
    //

    do{
        mp[a] = mp.size();
    }while(next_permutation(all(a)));

    cout << abs(mp[P]-mp[Q]) << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define N 50
int dup[N][N];

int main(){
	int n;
	cin>>n;
	vector<string> a(n);
	rep(i, n) cin>>a[i];

	rep(i, N) rep(j, N) dup[i][j]=0;
	vector<P> posi;
	vector<int> num(100, 0);

	rep(i, n){
		ll b=0;
		int k=0;
		for(; k<a[i].size() && a[i][k]!='.'; k++){
			b*=10;
			b+= a[i][k]-'0';
		}
		rep(_, 9) b*=10;
		k++;
		ll bb=0;
		int l=9;
		for(; k<a[i].size(); k++, l--){
			bb*=10;
			bb+=a[i][k]-'0';
		}
		rep(_, l) bb*=10;
		b+=bb;

		int n2=0, n5=0;
		for(ll c=b; c%2==0; c/=2) n2++;
		for(ll c=b; c%5==0; c/=5) n5++;
		dup[n2][n5]++;
	}

	ll cnt=0;
	rep(i, N) rep(j, N){
		for(int x=max(0, 18-i); x<N; x++) for(int y=max(0, 18-j); y<N; y++){
			//if(i+x>=18 && j+y>=18)
			ll cc;
			if(i==x && j==y) cc= (ll)dup[i][j]*(dup[x][y]-1)/2*2;
			else cc= (ll)dup[i][j]*dup[x][y];
			cnt+=cc;
		}
	}
	cnt/=2;

	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
const int N=5005;
int n,m;
int Fac[N],Inv[N];
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int dp[N][N];
int main(){
	n=read(),m=read();
	Fac[0]=1;
	For(i,1,m)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[m]=Pow(Fac[m],mod-2);
	Fod(i,m,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
//	outarr(Fac,0,m);
//	outarr(Inv,0,m);
	dp[0][1]=1;
	For(i,1,n){
		For(j,1,m){
			int v=dp[i-1][j];
			if (!v)
				continue;
//			printf("dp[%d][%d]=%d\n",i-1,j,v);
			int val=(LL)v*(j+1)%mod;
			Add(dp[i][j],val);
			Del(dp[i][j+1],val);
			val=(LL)v*j*2%mod;
			Add(dp[i][j+1],val);
			Del(dp[i][m+1],val);
		}
		For(j,1,m)
			Add(dp[i][j],dp[i][j-1]);
	}
//	outarr(dp[n],1,m);
	int ans=0;
	For(i,1,m)
		Add(ans,(LL)dp[n][i]*C(m-1,i-1)%mod);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 101424
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define setval(arr,v) memset(arr,v,sizeof(arr));
#define lli long long int
#define ll long long
#define mod 1000000009
#define v vector
#define pb push_back
#define pf pop_front;
#define fi first
#define se second
using namespace std;



void solve()
{
	int n,x,t;
	cin>>n>>x>>t;
	int a;
	if(n%x == 0)
		a = 0;
	else
		a = 1;
	cout<<((n/x)+a)*t;




    
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();

    }
    return 0;

}



Measured memory_bytes: 3608
A,B,C,D = map(int, input().split())
Takahashi=0
Aoki=0
while C-B>0:
    C-=B
    Takahashi+=1
while A-D>0:
    A-=D
    Aoki+=1
print("Yes") if Aoki>=Takahashi else print("No")

Measured memory_bytes: 8948
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int x,y;
    cin >> x >> y;
    int t = 4*x-y;
    int a,b;
    if(t >= 0 && (t%2==0)){
        a = t/2;
        b = x - a;
        if(b >= 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,k,p,q;
  cin>>n>>k;
  p=k-1; q=n-k+1;
  ll binom[2001][2001];
  binom[0][0]=1; binom[1][0]=1; binom[1][1]=1;
  for(int i=2;i<2001;i++){
    binom[i][0]=1; binom[i][i]=1;
    for(int j=1;j<i;j++){
      binom[i][j]=(binom[i-1][j-1]+binom[i-1][j])%modbig;
    }
  }
  for(int i=1;i<=k;i++){
    if(i>q){
      cout<<0<<"\n";
    }else{
      cout<<(binom[p][i-1]*binom[q][i])%modbig<<"\n";
    }
  }
}

Measured memory_bytes: 31360
import java.util.*;

class Main{
	int a;
	int b;
	public Main(){
		Scanner scan = new Scanner(System.in);
		for(;;){
			a=scan.nextInt();
			b=scan.nextInt();
			if(a==0 || b==0)break;
			for(int i=0; i<a; i++){
				if(i==0 || i==a-1){
					for(int k=0; k<b; k++){
						System.out.print("#");
					}
				}else{
					for(int j=0; j<b; j++){
						if(j==0 || j==b-1){
							System.out.print("#");
					    }else{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
	public static void main(String[]args){
		new Main();
	}
}

Measured memory_bytes: 33512
# F - . (Single Dot)

import bisect
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
INF = 10**9 + 1
s_X = set([-INF, 0, INF])
s_Y = set([-INF, 0, INF])

def compress(s):
    ls = list(s)
    ls.sort()
    return {e: i for i, e in enumerate(ls)}

ABC = []
for i in range(N):
    A, B, C = map(int, readline().split())
    ABC.append((A, B, C))
    s_Y.add(C)

DEF = []
for i in range(M):
    D, E, F= map(int, readline().split())
    DEF.append((D, E, F))
    s_X.add(D)

mapX = compress(s_X)
mapY = compress(s_Y)
l_X = list(mapX.keys())
l_Y = list(mapY.keys())
maxX = len(mapX)*2
maxY = len(mapY)*2

W = [[0] * maxY for _ in range(maxX)]

for A, B, C in ABC:
    A = mapX[l_X[bisect.bisect_left(l_X, A)]]
    B = mapX[l_X[bisect.bisect_right(l_X, B)-1]]
    C = mapY[C]
    A *= 2
    B *= 2
    C *= 2
    for j in range(A, B+1):
        W[j][C] = 1

for D, E, F in DEF:
    D = mapX[D]
    E = mapY[l_Y[bisect.bisect_left(l_Y, E)]]
    F = mapY[l_Y[bisect.bisect_right(l_Y, F)-1]]
    D *= 2
    E *= 2
    F *= 2
    for j in range(E, F+1):
        W[D][j] = 1

#print(W)
q = []
q.append((mapX[0]*2, mapY[0]*2))
W[mapX[0]*2][mapY[0]*2] = 1
ans = 0
b_ans = True
while q:
    x, y = q.pop()
    if x == maxX or x == 0 or y == maxY or y == 0:
        b_ans = False
        break
    for (vx, vy) in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        nx = x + vx
        ny = y + vy
        if W[nx][ny] == 0:
            if nx%2==1 and ny%2==1:
                ex = l_X[(nx+1)//2] - l_X[(nx-1)//2]
                ey = l_Y[(ny+1)//2] - l_Y[(ny-1)//2]
                ans += ex * ey
                #print(nx, ny, ans)
            q.append((nx, ny))
            W[nx][ny] = 1

if b_ans == True:
    print(ans)
else:
    print('INF')


Measured memory_bytes: 143028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    for(int i=-1; i<=1; i+=2){
        for(int j=-1; j<=1; j+=2){
            for(int k=-1; k<=1; k+=2){
                priority_queue<ll> items;
                for(int a=0; a<n; a++){
                    ll scr = i * x[a] + j * y[a] + k * z[a];
                    items.push(scr);
                }
                ll tmp_ans = 0;
                for(int b=0; b<m; b++){
                    tmp_ans += items.top();
                    items.pop();
                }
                ans = max(ans, tmp_ans);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, W = map(int, input().split())
w = [0] * N
v = [0] * N

for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N)]
dp[0][w[0]] = v[0]

for i in range(1, N):
    for j in range(W + 1):
        if j > w[i]:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
        else:
            dp[i][j] = dp[i - 1][j]

ans = 0

for j in range(W + 1):
    if dp[-1][j] > ans:
        ans = dp[-1][j]

print(ans)


Measured memory_bytes: 119404
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);

        var d = new int[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(Console.ReadLine());
        }

        Array.Sort(d);

        var min = int.MaxValue;
        for (int i = m - 1; i < n; i++)
        {
            min = Math.Min(min, d[i] - d[i - m + 1]);
        }

        Console.WriteLine(min);
    }
}


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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N;
int h[110000];
int dp[110000];

signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++)cin >> h[i];
    dp[0] = 1145141919;
    for (int i = 2; i <= N; i++)dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    cout << dp[N] << endl;
}


Measured memory_bytes: 1792
s = input()
ymflag = True
myflag = True
head = int(s[:2])
tail = int(s[2:])
if head > 12:
    myflag = False
elif head == 0:
    myflag = False

if tail > 12:
    ymflag = False
elif tail == 0:
    ymflag = False
if ymflag and myflag:
    print("AMBIGUOUS")
elif ymflag:
    print("YYMM")
elif myflag:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

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

    int ans = max({a+b, a-b, a*b});

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int a = ia[0];
		int b = ia[1];
		int c;
		if (b < 10) {
			c = a * 10 + b;
		} else if (b < 100) {
			c = a * 100 + b;
		} else {
			c = a * 1000 + b;
		}
		int d = sqrt(c);
		if (d * d == c) {
			pln("Yes");
		} else {
			pln("No");
		}
	}

	int sqrt(long n) {
		return (int) Math.sqrt(n);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


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

int main(){
  int D, N; cin >> D >> N;
 
	int S = 1; for (int i = 0; i < D; i++) S *= 100;
	if(N == 100){
      N ++;
    }
  cout << N * S << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];		

		for(int i = 0 ; i < n ; i++) {
			a[i] = Integer.parseInt(sc.next());
		}



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

			if(SearchValue + 1 ==  a[i]) {
				SearchValue++;
			}

		}

		if(SearchValue == 0) {
			System.out.println(-1);
		}else {
			
			System.out.println(n-SearchValue);
		}
		
		
	}

}

Measured memory_bytes: 50812
n, m = gets.chomp.split(" ").map(&:to_i)
graph = Array.new(n).map{Array.new}
m.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    graph[a-1] << b-1
    graph[b-1] << a-1
end

dist = Array.new(n, -1)
dist[0] = 0
queue = [0]

until queue.empty?
    v = queue.shift
    graph[v].each do |i|
        next if dist[i] != -1
        dist[i] = dist[v] + 1
        queue << i
    end
end

puts dist[n-1] == 2 ? "POSSIBLE" : "IMPOSSIBLE"

Measured memory_bytes: 24828
#include <bits/stdc++.h>
#define endl '\n'
#define max_value 2147483647
using namespace std;
int n,h;
int values[100005];
int dp[100005];

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

    cin >> n;
    for(int i = 0 ;i < n;i++)
    {
        cin >> h;
        values[i] = h;
    }

    for(int i = 0;i < n;i++)
        dp[i] = max_value;
    dp[0] = 0;

    for(int i = 0;i < n;i++)
    {
        if(i+1 < n)
            dp[i+1] = min(dp[i+1],dp[i] + abs(values[i]-values[i+1]));
        if(i+2 < n)
            dp[i+2] = min(dp[i+2],dp[i] + abs(values[i]-values[i+2]));
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
import kotlin.collections.ArrayDeque

@kotlin.ExperimentalStdlibApi
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    println(0)
    var lowerS = readLine()!!
    if (lowerS == Pos.VACANT) return

    println(n-1)
    var upperS = readLine()!!
    if (upperS == Pos.VACANT) return

    val bfs = ArrayDeque<Pos>()
    bfs.addLast(Pos(n/2, 0, n-1))

    while (bfs.isNotEmpty()) {
        val pos = bfs.removeFirst()

        println(pos.idx)
        val res = readLine()!!
        if (res == Pos.VACANT) return

        val lowerCnt = pos.idx - pos.lower - 1
        val upperCnt = pos.upper - pos.idx - 1
        if ((lowerCnt % 2 == 1 && lowerS != res) || (lowerCnt > 0 && lowerCnt % 2 == 0 && lowerS == res)) {
            // a vacant seat in lower bound
            val nextIdx = pos.lower + (lowerCnt+1)/2
            bfs.addLast(Pos(nextIdx, pos.lower, pos.idx))
        } else {
            // a vacant seat in upper bound
            lowerS = res
            val nextIdx = pos.idx + (upperCnt+1)/2
            bfs.addLast(Pos(nextIdx, pos.idx, pos.upper))
        }
    }
}

data class Pos(val idx: Int, val lower: Int, val upper: Int) {
    companion object {
        val VACANT = "Vacant"
        val MALE = "Male"
        val FEMALE = "Female"
    }
}

Measured memory_bytes: 38788
#include<cstdio>
#include<iostream>
#define chkmax(a,b) ((a)>(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
inline void read(int &x)
{
	char c=getchar();x=0;int p=1;
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)){x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
int n,ans=-0x7f7f7f7f,now,tot;
int f[110][6][6],a[110][20];
int main()
{
	read(n);
	f(i,1,n)
	 f(j,1,5)
	  f(k,1,2)
	  read(f[i][j][k]);
	f(i,1,n)
	 f(j,0,10)
	  read(a[i][j]);
	f(i,1,((1<<10)-1))
	{
		now=0;
		f(j,1,n)
		{
			tot=0;
			f(k,1,10)if((i&(1<<(k-1)))&&f[j][(k+1)/2][(k-1)%2+1])++tot;
			now+=a[j][tot];
		}ans=chkmax(ans,now);
	}printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long

signed main(){
    int Q;cin>>Q;
    for(int q=0;q<Q;q++){
        int n,k;
        int x[200000];
        int d[200000];
        cin>>n>>k;
        for(int i=0;i<n;i++)cin>>x[i];
        int ans=x[n-1]-x[0];
        for(int i=0;i<n-1;i++)d[i]=x[i+1]-x[i];
        sort(d,d+n-1);reverse(d,d+n-1);
        if(n>=k)for(int i=0;i<k-1;i++)ans-=d[i];
        else ans=0;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4564
#include<iostream>
using namespace std;
  
class Cube{
public:
 int f[6];
   
 Cube(){}
 void roll_z(){ roll(1, 2, 4, 3);} //
 void roll_y(){ roll(0, 2, 5, 3);} // to W
 void roll_x(){ roll(0, 1, 5, 4);} // to N
 void roll(int i, int j, int k, int l){
  int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
 }
};
  
int getRight(Cube c1, int f1, int f2){
 for(int i = 0; i < 6; i++){
  for(int j = 0; j < 4; j++){
   if(c1.f[0] == f1 && c1.f[1] == f2) 
    return c1.f[2];
   c1.roll_z();
  }
  if(i % 2 == 0) c1.roll_y();
  else c1.roll_x();
 }
 return -1;
}
  
int main(){
 Cube c;
 int f1,f2;
  
 for(int i = 0; i < 6; i++) cin >> c.f[i];
 int q;
 cin >> q;
  
 for(int i = 0; i < q; i++){
  cin >> f1 >> f2;
  cout << getRight(c, f1, f2) << endl;
 }
  
 return 0;
}

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

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    string s; cin >> s;
    int q; cin >> q;
    bool rev = false;
    rep(i, q){
        int t; cin >> t;
        if (t == 1){
            if (!rev) rev = true;
            else rev = false;
        }else{
            int f; cin >>f;
            string c; cin >> c;
            if (rev){
                if (f == 1){
                    s.append(c);
                }else{
                    s.insert(0, c);
                }
            }else{
                if (f == 1){
                    s.insert(0, c);
                }else{
                    s.append(c);
                }
            }
        }
    }
    if (rev) reverse(s.begin(), s.end());
    cout << s << endl;
}


Measured memory_bytes: 900
# https://atcoder.jp/contests/abc088/tasks/abc088_b
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

alice = 0
bob = 0
for i in range(n//2 + 1):
    if len(a) > 0:
        alice += a.pop(0)
    if len(a) > 0:
        bob += a.pop(0)

print(alice - bob)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

lint app() {
  int n;
  cin>>n;
  n++;

  vector<int> a(n);
  lint leafs=0;
  rep(i,n){
    cin>>a[i];
    leafs+=a[i];
  }
  lint w=1,l=1;
  lint ans=0;
  rep(i,n){
    ans+=w;
    w-=a[i];
    if(w<0) return -1;
    lint newl=min(l+w,leafs);
    w+=(newl-l);
    l=newl;
  }

  return ans;
}

int main(){cout<<app()<<endl;return 0;}


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


int main(){
	string sa,sb,sc;
	
	cin >> sa;
	cin >> sb;
	cin >> sc;
	int next = 0;
	int win = -1;
	int a,b,c;
	a = b = c = 0;

	while(win == -1){
		switch(next){
			case 0:

				if(sa.length() <= a){ win = 0;break;}
				switch(sa.at(a)){
					case 'a':
						next = 0;
						break;
					case 'b':
						next = 1;
						break;
					case 'c':
						next = 2;
						break;
				}
				a++;
				break;
			case 1:
				if(sb.length() <= b) { win = 1; break;}
				switch(sb.at(b)){
					case 'a':
						next = 0;
						break;
					case 'b':
						next = 1;
						break;
					case 'c':
						next = 2;
						break;
				}
				b++;
				break;
			case 2:
				if(sc.length() <= c) { win = 2; break;}
				switch(sc.at(c)){
					case 'a':
						next = 0;
						break;
					case 'b':
						next = 1;
						break;
					case 'c':
						next = 2;
						break;
				}
				c++;
				break;
		}
	//	cout << next << " " << a << " " << b  << " " << c << endl;
	}

	switch(win){
		case 0: cout << 'A' << endl;
			break;
		case 1: cout << 'B' << endl;
			break;
		case 2: cout << 'C' << endl;
			break;
	}
	return 0;
}

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

int main(){

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

    int ans = 100100100;
    //書き換える値で全探索
    for(int x = -100; x <= 100; x++){
        int cost = 0;
        for(int i = 0; i < n; i++){
            cost += (x - a[i]) * (x - a[i]);
        }

        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  vector<tuple<int, int, int>> T(N);
  for (int i = 0; i < N; i++){
    T[i] = make_tuple(A[i] + B[i], A[i], B[i]);
  }
  sort(T.begin(), T.end());
  deque<pair<int, int>> dq;
  for (int i = 0; i < N; i++){
    dq.push_back(make_pair(get<1>(T[i]), get<2>(T[i])));
  }
  long long ans = 0;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      ans += dq.back().first;
      dq.pop_back();
    }
    if (i % 2 == 1){
      ans -= dq.back().second;
      dq.pop_back();
    }
  }
  cout << ans << endl;
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EOddSumRectangles {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      int ma = max(n, m);
      int h = (1<<ma);
      int w = (1<<ma);
      int dp[h][w];
      dp[0][0] = dp[0][1] = dp[1][0] = 0;
      dp[1][1] = 1;

      for(int k=2; k<=ma; k++) {
        int r = 1<<(k-1);
        rep(i, 1<<k) {
          rep(j, 1<<k) {
            if (i < r && j < r) continue;
            if (i < r) {
              dp[i][j] = dp[i][j-r];
            } else if (j < r) {
              dp[i][j] = dp[i-r][j];
            } else {
              dp[i][j] = 1-dp[i-r][j-r];
            }
          }
        }
      }

      rep(i, 1<<ma) {
        rep(j, 1<<ma) {
          cerr << dp[i][j];
        }
        cerr << endl;
      }

      rep(i, (1<<n)-1) {
        rep(j, (1<<m)-1) {
          if (dp[i+1][j] ^ dp[i][j+1] ^ dp[i][j]) {
            cout << 1 - dp[i+1][j+1];
          } else {
            cout << dp[i+1][j+1];
          }
        }
        cout << '\n';
      }
    }
};

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

Measured memory_bytes: 5376
solve (a:op:b:_)
    | op == "+" = s1 + s2
    | op == "-" = s1 - s2
    | op == "*" = s1 * s2
    | op == "/" = s1 `div` s2
    where 
        s1 = read a
        s2 = read b

main = do
    s <- fmap (map words . lines) getContents
    mapM_ putStrLn . map show . map solve $ takeWhile (\(_:(op:_)) -> op /= "?") s



Measured memory_bytes: 4064
a, b, c, x, y = map(int, input().split())

ab = c * 2

if ab < a and ab < b:
    print(max(x, y) * ab)
else:
    answer = min(a+b, ab) * min(x, y)

    if x > y:
        answer += min(a, ab) * (x - y)
    else:
        answer += min(b, ab) * (y - x)
    print(answer)

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int i,n;cin>>n;
	for(i=1;i<=n;i++){
		int x=i;
		bool aa=(i%3==0);
		while(x){if(x%10==3){aa=true;}x/=10;}
		if(aa){cout<<" "<<i;}
	}
	cout<<endl;
	RE;
}



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

const long N = 1e5 + 5;
const long MOD = 1e9 + 7;

long n, k;
long a[N];
long fact[N], invfact[N];

long pow(long a, long b, int m)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return ans;
}

long modinv(long k)
{
    return pow(k, MOD-2, MOD);
}

void precompute()
{
    fact[0]=fact[1]=1;
    for(long i=2;i<N;i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
    }
    invfact[N-1]=modinv(fact[N-1]);
    for(long i=N-2;i>=0;i--)
    {
        invfact[i]=invfact[i+1]*(i+1);
        invfact[i]%=MOD;
    }
}

long nCr(long x, long y)
{
    if(y>x)
        return 0;
    long num=fact[x];
    num*=invfact[y];
    num%=MOD;
    num*=invfact[x-y];
    num%=MOD;
    return num;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cout.setf(ios::fixed); cout.precision(20);
    precompute();
    cin >> n >> k;
    vector<long> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    long max = 0;
    long min = 0;

    for (long i = k - 1; i < n; ++i) {
        max += v[i] * nCr(i, k - 1);
        max = (max + MOD) % MOD;
    }
    for (long i = 0; i < n - k + 1; ++i) {
        min += v[i] * nCr(n - i - 1, k - 1);
        min = (min + MOD) % MOD;
    }
    long ans = (max - min + MOD) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long n=s.nextLong();
		long x=s.nextLong();
		long t=s.nextLong();
		
		long times=n/x;
		long rem=0;
		
		if(n%x!=0)
		{
			times++;
		}
		
		System.out.println(times*t);
		
	}
	
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<int>> data(M, vector<int>(2));
 

  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int a=data.at(0).at(0);
  for (int i = 0; i < M; i++) {
    if(data.at(i).at(0)>a){
      a=data.at(i).at(0);
      
    }  
  }
  int b=data.at(0).at(1);
  for (int i = 0; i < M; i++) {
    if(data.at(i).at(1)<b){
      b=data.at(i).at(1);
      
    }  
  }
  if(b>=a){
    
    cout<<b-a+1<<endl;
  }
  else{
    cout<<0<<endl;
  }
  
  
}

Measured memory_bytes: 5760
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    pr2(3*n*n);
    return 0;
}

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

#define vint vector<int>
#define vvint vector<vint>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}

void Main(){
    int n,m;
    cin >> n >> m;
    vint h = CinLine(n);
    vector<bool> goods(n); // syoki:0 1nara dame

    rep(i,m){
        int a,b;
        cin >> a >> b;

        if(h.at(a-1) > h.at(b-1)){
            goods.at(b-1) = 1;
        }else if(h.at(a-1) < h.at(b-1)){
            goods.at(a-1) = 1;
        }else{
            goods.at( a-1) = 1;
            goods.at( b-1) = 1;
        }
    }

    int c = 0;
    rep(i,goods.size()){
        if(goods.at(i) == 0){
            c++;
        }
    }
    ct(c);

}

int main() {
    Main();
}


Measured memory_bytes: 3788
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 100002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, A[CMax], B[CMax], res;

int gcd(int a, int b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    cin >> n;

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

    for (int i = 0; i < n; i++) {
        cin >> B[i];
        if (A[i] - B[i] > 0) res += A[i] - B[i];
    }

    cout << res;

    cout << endl;

    return 0;
}


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

int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	int l1=s.length(), l2=t.length();
	if(l1+1!=l2){
		cout<<"No"<<endl;
		return 0;
	}
	int i=0, j=0;
	while(i<l1 && j<l2-1){
		if(s[i]!=t[j]){
			cout<<"No"<<endl;
			return 0;
		}
		i++; j++;
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> cnt(n + 1, 0);
  FOR(i, 1, n + 1) {
    for (ll j = i; j <= n; j += i) {
      cnt[j]++;
    }
  }

  ll ans = 0;
  FOR(i, 1, n + 1) { ans += i * cnt[i]; }
  cout << ans << endl;
}

Measured memory_bytes: 81396