akhauriyash/Code-Regression huggingface dataset:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
res = {'AC':0,'WA':0,'TLE':0,'RE':0}
for _ in range(n):
    s = ns()
    res[s] += 1
for i,j in res.items():
    print(f'{i} x {j}')

Measured memory_bytes: 9212
#include<stdio.h>

int main() {
  
  int n;
  int ret;
  
  scanf("%d", &n);
  
  if (n < 10) {    
    ret = n;
  } else if (n < 100) {
    ret = 9;
  } else if (n < 1000) {
    ret = 9 + n - 100 + 1;
  } else if (n < 10000) {
    ret = 9 + 900;
  } else if (n < 100000) {
    ret = 9 + 900 + n - 10000 + 1;
  } else {
    ret = 90909;
  }
  printf("%d", ret);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	string s; cin >> s;
	int n = s.size();
	ll even = 0, odd = 0,memo = -1,cnt = 0;
	vl ans(n);
	rep(i,0,n){
		if(s[i] == 'R'){
			if(memo != -1){
				ans[memo] += even;
				ans[memo+1] += odd;
			}
			even = 0;
			odd = 0;
			memo = i;
			cnt = 0;
		}
		else{
			if(cnt % 2 == 0)even++;
			else odd++;
		}
		cnt++;
	}
	ans[memo] += even;
	ans[memo+1] += odd;
	even = 0;
	odd = 0;
	memo = -1;
	cnt = 0;
	for(int i = n-1; i>=0;--i){
		if(s[i] == 'L'){
			if(memo != -1){
				ans[memo] += even;
				ans[memo-1] += odd;
			}
			even = 0;
			odd = 0;
			memo = i;
			cnt = 0;
		}
		else{
			if(cnt % 2 == 0)even++;
			else odd++;
		}
		cnt++;
	}
	ans[memo] += even;
	ans[memo-1] += odd;
	rep(i,0,n)cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;
typedef pair<P,int>pi;

const int MAX_N = 500005;
const int MAX_Q = 101;

vector<pi> S,T;
vector<int> ans;
int n,Q;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
    	int x,y;
        scanf("%d%d",&x,&y);
        S.push_back(pi(P(x,y),i));
        T.push_back(pi(P(y,x),i));
    }
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    scanf("%d",&Q);
    rep(i,Q){
        int sx,tx,sy,ty;
        scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
        int lx = lower_bound(S.begin(),S.end(),pi(P(sx,sy),0)) - S.begin();
        int hx = upper_bound(S.begin(),S.end(),pi(P(tx,ty),n)) - S.begin();
        int ly = lower_bound(T.begin(),T.end(),pi(P(sy,sx),0)) - T.begin();
        int hy = upper_bound(T.begin(),T.end(),pi(P(ty,tx),n)) - T.begin();
        int wx = hx - lx;
        int wy = hy - ly;
        if(wx < wy){
            for(int i=lx;i<hx;i++){
                int y = S[i].first.second;
                if(sy <= y && y <= ty){ 
                	ans.push_back(S[i].second);
                }
            }
        }else{
            for(int i=ly;i<hy;i++){
                int x = T[i].first.second;
                if(sx <= x && x <= tx){
                	ans.push_back(T[i].second);
                }
            }
        }
        sort(ans.begin(),ans.end());
        rep(i,ans.size()){
        	printf("%d\n", ans[i]);
        }
        printf("\n");
        ans.clear();
    }
    return 0;
}

Measured memory_bytes: 14640
#include <stdio.h>

int main(void)
{
	int N,R;

	scanf("%d%d",&N,&R);
	if(N>=10){
		printf("%d\n",R);
	}
	else if(N<10){
		printf("%d\n",(100*(10-N))+R);
	}
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#define C_MAX 10000
#define R_MAX 10

int h,w,ans;
int J[R_MAX][C_MAX];
bool flag[R_MAX] ;

int count(){
	int tmp,res=0;

	for(int j=0;j<w;++j){
		tmp=0;
		for(int i=0;i<h;++i){
			if(flag[i]&&!J[i][j] || !flag[i]&&J[i][j])
				++tmp;
		}
		if(tmp<h-tmp)
			res+=h-tmp;
		else res+=tmp;
	}
	return res;
}

int solve(int idx){
	int res;
	if(idx==h){
		res=count();
		if(ans<res)
			ans=res;
		return ans;
	}

	flag[idx]=false;
	solve(idx+1);

	flag[idx]=true;
	solve(idx+1);
}

int main(){
	while(1){
	  std::cin>>h>>w;
	  if(h==0&&w==0)
		  break;
	  for(int i=0;i<h;++i){
		  for(int j=0;j<w;++j){
			  std::cin>>J[i][j];
		  }
	  }
	  std::cout<<solve(0)<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1548
N = int(input())
a_list = list(map(int,input().split()))

bit_a = [list(bin(a)[2:].zfill(20)) for a in a_list]

digits = [[int(a[i])for a in bit_a] for i in range(20)]

for digit in digits:
    one_idx = (-1,-1)
    for i,d in enumerate(digit):
        if d == 1:
            digit[i] = one_idx[1]
            one_idx = (one_idx[1],i)
        else:
            digit[i] = one_idx[0]
        

max_idx = [max([digit[i] for digit in digits]) for i in range(N)]

cnt = 0
for i,idx in enumerate(max_idx):
    cnt += i-idx

print(cnt)

Measured memory_bytes: 283848
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double EPS=1e-7;
const int N=1e6+10;
const ll mod=998244353;
const ll MOD=998244353;
inline ll read()  
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
   return x*f;
}
int n,x,t;
void solve()
{  cin>>n>>x>>t;
   printf("%d\n",(int)ceil(1.0*n/x)*t);
}
int main()
{  int t=1;
   while(t--)  
   {  
      solve();
   }
}

Measured memory_bytes: 3760
#include<iostream>
#define MAX_NUM 100001

int a[MAX_NUM] = {};

void swap(int i,int j){
    a[0] = a[i];
    a[i] = a[j];
    a[j] = a[0];
}

int partition(int p,int r){
    int x = a[r];
    int i = p-1;
    for(int j=p;j<r;j++){
        if(a[j] <= x){
            i++;
            swap(i,j);
        }
    }
    swap(i+1,r);
        
    return i+1;
}

int main(){
    int n;
    std::cin >> n;
    for(int i=1;i<=n;i++){
        std::cin >> a[i];
    }
    int k=partition(1,n);
    if(k!=1){
        std::cout << a[1] ;
    }
    for(int i=2;i<k;i++){
        std::cout << ' ' << a[i];
    }
    std::cout << " [" << a[k] << ']';
    for(int i=k+1;i<=n;i++){
        std::cout << ' ' << a[i];
    }
    std::cout << '\n';
    return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N; cin >> N;
  string S; cin >> S;

  for (int i = 0; i < S.length(); i++){
    char now = S[i] + N;
    if (now > 'Z'){
      now = now - 'Z' + 'A' - 1;
    }
    cout << now;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

int n, m;
string s[128];

string ans = "";

int main(){

  cin >> n >> m;
  REP( i , n ) cin >> s[i];
  sort( s , s+n );
  REP( i , n ) ans += s[i];
  cout << ans << endl;
  
  return 0;
}


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

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001
#define mod 1000000007

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n;
    long long int ans=0;
    long long int a=1, b=1, c=1;
    
    scanf("%d", &n);
    
    for (int i=1; i<=n; i++) {
        a=a*10%mod;
        b=b*9%mod;
        c=c*8%mod;
    }
    
    ans=(a-b-b+c)%mod;
    ans=(ans+mod)%mod;
    printf("%lld", ans);
    
    return 0;
}


Measured memory_bytes: 1716
#include<stdio.h>

int main(void)

{

   int a,b,d,r;

   double f;

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

   d=a/b;

   r=a%b;

   f=(double)a/b;

   printf("%d %d %lf",d,r,f);

   return 0;

}  

Measured memory_bytes: 632
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  M stick;
  REP(i,n){
    IN(x);
    stick[x]++;
  }
  Vi ans;
  for(auto p: stick){
    if(p.second >= 4) {ans.pb(p.first);ans.pb(p.first);}
    else if(p.second >= 2) ans.pb(p.first);
  }
  if(ans.size() >= 2) {
    RSORT(ans);
    OUT(ans[0] * ans[1]);
  } else {
    OUT(0);
  }
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	REP(i, a + b + 1) {
		if (i != a) {
			if (isdigit(static_cast<unsigned char>(s[i]))) {
				continue;
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (s[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
 
void solve()
{
	ll n,sum=0;
	cin>>n;
	vll a(n+1),cnt(100001,0);
	for(ll i=1;i<=n;i++)
		cin>>a[i],sum+=a[i],cnt[a[i]]++;
	ll q;
	cin>>q;
	for(ll i=0;i<q;i++)
	{
		ll x,y;
		cin>>x>>y;
		sum-=(cnt[x]*x);
		sum+=cnt[x]*y;
		cnt[y]+=cnt[x];
		cnt[x]=0;
		cout<<sum<<endl;
		
	}
	
}
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4676
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

namespace {
struct Pos {
  int x, y;
  Pos() = default;
  constexpr Pos(int x_, int y_) : x(x_), y(y_) {}
  constexpr Pos& operator+=(const Pos& rhs) {
    x += rhs.x, y += rhs.y;
    return *this;
  }
  constexpr Pos& operator*=(int rhs) {
    x *= rhs, y *= rhs;
    return *this;
  }
};
bool operator==(const Pos& lhs, const Pos& rhs) {
  return lhs.x == rhs.x && lhs.y == rhs.y;
}
Pos operator+(Pos lhs, const Pos& rhs) { return lhs += rhs; }
Pos operator*(Pos lhs, int rhs) { return lhs *= rhs; }
}  // namespace

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  Pos s, g;
  cin >> s.y >> s.x >> g.y >> g.x;
  s += Pos(-1, -1);
  g += Pos(-1, -1);
  vector<string> field(H);
  for (auto& e : field) cin >> e;
  constexpr array<Pos, 4> Dir = {{
      Pos(0, 1),
      Pos(0, -1),
      Pos(1, 0),
      Pos(-1, 0),
  }};
  constexpr int kInf = INT_MAX;
  vector rec(H, vector(W, kInf));
  queue<Pos> q;
  rec[s.y][s.x] = 0;
  q.push(s);
  while (!q.empty()) {
    Pos cur = q.front();
    q.pop();
    for (const auto& dir : Dir) {
      for (int i = 1; i <= K; ++i) {
        Pos nxt = cur + dir * i;
        if (nxt.x < 0 || W <= nxt.x || nxt.y < 0 || H <= nxt.y) continue;
        if (field[nxt.y][nxt.x] == '@') break;
        if (rec[nxt.y][nxt.x] <= rec[cur.y][cur.x]) break;
        if (rec[nxt.y][nxt.x] <= rec[cur.y][cur.x] + 1) continue;
        rec[nxt.y][nxt.x] = rec[cur.y][cur.x] + 1;
        q.push(nxt);
      }
    }
  }
  for (auto& row : rec)
    for (auto& e : row)
      if (e == kInf) e = -1;
  for (const auto& row : rec) {
    for (const auto& e : row) cerr << setw(2) << e << ',';
    cerr << '\n';
  }
  cout << rec[g.y][g.x] << '\n';
}


Measured memory_bytes: 12148
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll H,W;
    cin >> H >> W;
    if(H==1 || W==1){
        pr(1);
        return 0;
    }
    if(H&1){
        pr((H/2)*W+((W+1)/2));
    }else{
        pr((H/2)*W);
    }
}

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

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a <= 5) {
    cout << 0;
  }else if(a <= 12) {
    cout << b/2;
  }else {
    cout << b;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
const int mod = 1e9 + 7;
int add(int u, int v) {
  return (u + v) % mod;
}
int sub(int u, int v) {
  return add(u, mod - v);
}
int mul(int u, int v) {
  return u * 1ll * v % mod;
}
int pwr(int a, int n) {
  int r = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) r = mul(r, a);
    a = mul(a, a);
  }
  return r;
}
int inv(int a) {
  return pwr(a, mod - 2);
}
int choose(int n, int r) {
  int c = 1;
  for (int i = 1; i <= r; i++) {
    c = mul(c, inv(i));
    c = mul(c, n + 1 - i);
  }
  return c;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif
  
  int n, a, b; cin >> n >> a >> b;
  int ans = sub(pwr(2, n), 1);
  ans = sub(ans, choose(n, a));
  ans = sub(ans, choose(n, b));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  while (cin >> n, n) {
    vs v(n);
    cin >> v;
    vvi dp(n, vi(n));
    rep(i, n) rep(j, n) {
      if (v[i][j] == '*') continue;
      if (i == 0 || j == 0) {
        dp[i][j] = 1;
        continue;
      }
      dp[i][j] = min({dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]}) + 1;
    }
    int maxi = -INF;
    rep(i, n) rep(j, n) cmax(maxi, dp[i][j]);
    cout << maxi << endl;
  }
}

Measured memory_bytes: 11716
#include<iostream>

using namespace std;


int main(){
  long long N,M;
  long long sum1 = 1,sum2 = 1;
  long long sum = 0;
  cin >> N;
  cin >> M;

  if(N == M){
     for(int i = N;i > 0;i--){
       sum1 = sum1 % 1000000007 * i;
    }
    sum = sum1 % 1000000007 * sum1 *2 % 1000000007;
  }
  if(N-1 == M || M-1 == N){
    for(int i = N;i > 0;i--){
      sum1 = sum1 % 1000000007 * i;
    }
    for(int i = M;i > 0;i--){
      sum2 = sum2 % 1000000007 * i;
    }
    sum = sum1 % 1000000007 * sum2;
  }


  cout << sum % 1000000007 << endl;

}

Measured memory_bytes: 764
#include<stdio.h>

int main(void){
   int p;
   scanf("%d",&p);
   if(p%10==2||p%10==4||p%10==5||p%10==7||p%10==9){
      printf("hon");
   }else if(p%10==0||p%10==1||p%10==6||p%10==8){
      printf("pon");
   }else if(p%10==3){
      printf("bon");
   }

   return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

//make_tuple emplace_back next_permutation
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
string s999;stringstream ds999;
#define DBG(...) s999=#__VA_ARGS__;replace(ALL(s999),',',' ');ds999<<s999; debug(ds999,__VA_ARGS__);
inline void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<' '<<f<<' '; debug(ds,r...);}
#define ALL(v) (v).begin(),(v).end()
#define SI(v) (int)(v).size()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL i,o,t,j,l,s,z;
    cin >> i>>o>>t>>j>>l>>s>>z;
    LL ans=o;
    if(j%2+l%2+i%2>1 and j>0 and l>0 and i>0){
        ans+=3;
        --j;
        --l;
        --i;
    }
    ans+=(j/2)*2+(l/2)*2+(i/2)*2;
    cout << ans <<endl;



    return 0;
}


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

using namespace std;

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

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

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

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

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

  int N; cin >> N;
  double dist[2] = {-1, -1};
  int time[2] = {-1,-1};
  int f_, a_, t_, x_, y_;
  cin >> f_ >> a_ >> t_ >> x_ >> y_;
  REP(i,N-1){
	int f, a, t, x, y;
	cin >> f >> a >> t >> x >> y;
	if(t_ == t && a_ != a){
	  double dist_ = sqrt((x - x_)*(x-x_)+(y-y_)*(y-y_));
	  int time_ = f - f_;
	  if(dist_ > dist[t] || dist[t] == dist_ && time_ < time[t]){
		dist[t] = dist_, time[t] = time_;
	  }
	}
	f_ = f, a_ = a, t_ = t, x_ = x, y_ = y;
  }

  REP(i,2)
	if(time[i] < 0)
	  cout << -1 << " " << -1 << endl;
	else
	  cout << fixed << setprecision(9) << dist[i] << " " << (time[i]*1./60) << endl;
  
  return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll dp[100010];
int main()
{
	int N,K;
	cin >> N >> K;
	ll h[N];
	for(int i = 0; i < 100010; i++) dp[i] = INF;
	for(int i = 0; i < N; i++) cin >> h[i];
	dp[0] = 0;
	for(int i = 0; i < N + 1; i++)
	{
		for(int k = 1; k <= K; k++)
		{
			if(i+k <= N)
			{
				chmin(dp[i+k],dp[i] + abs(h[i] - h[i+k]));
			}
		}
	}
	cout << dp[N - 1] << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#define EPS 1e-10

using namespace std;


int main(){
  int n,A,B,C;
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> A >> B >> C;
      if(A == 100 || B == 100 || C == 100)cout << "A" << endl;
      else if((A+B) >= 180)cout << "A" << endl;
      else if((A+B+C) >= 240)cout << "A" << endl;
      else if(A+B+C >= 210)cout << "B" << endl;
      else if((A+B+C)>=150 && (A>=80 || B>=80))cout << "B" << endl;
      else cout << "C" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum[ohara],pos,k,sei[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k;
    rep(i,n){
        cin>>sum[i];
        if(sum[i]>0)sei[i]=sum[i];
    }
    rrep(i,1,n){
        sum[i]+=sum[i-1];
        sei[i]+=sei[i-1];
    }
    rep(i,n-k+1){
        if(i==0)tmp=max(sum[i+k-1],0LL);
        else tmp=max(sum[i+k-1]-sum[i-1],0LL);
        if(i==0)tmpp=sei[i+k-1];
        else tmpp=sei[i+k-1]-sei[i-1];
        ans=max(ans,tmp+sei[n-1]-tmpp);
    }
    Cout(ans);
    return 0;
}


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

int main(){
    long long x, y;cin>>x>>y;
    if (abs(x) < abs(y)){
        if (0 <= x && x <= y){
            cout << y - x << endl;
        } else if (0 <= x && y <= 0){
            cout << abs(y) - x + 1 << endl;
        } else if (x <= 0 && 0 <= y){
            cout << y - abs(x) + 1 << endl;
        } else {
            cout << abs(y) - abs(x) + 2 << endl;
        }
    } else {
        if (0 <= x && 0 < y){
            cout << (-y) - (-x) + 2 << endl;
        } else if (0 <= x && y <= 0) {
            cout << y - (-x) + 1 << endl;
        } else if (x <= 0 && 0 < y){
            cout << (-y) - x + 1 << endl;
        } else {
            cout << y - x << endl;
        }
    }
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, D, X; cin >> N >> D >> X;
    vi A(N); REP(i, N) cin >> A[i];

    int choco = 0;
    REP(i, N)
    {
        choco += (D-1)/A[i]+1;
    }
    cout << choco + X << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

void Main() {
	int64_t N, Y;
	cin >> N >> Y;

	int x = -1, y = -1, z = -1;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			for (int k = 0; k <= N - (i + j); k++) {
				int64_t sum = 10000 * k + 5000 * j + 1000 * i;
				if (i + j + k != N) continue;
				if (sum > Y) break;
				if (sum == Y) {
					x = k;
					y = j;
					z = i;
					goto OUTPUT;
				}
			}
		}
	}
OUTPUT:
	cout << x << " " << y << " " << z << endl;
}

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


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $m);
$D = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);
    $D[$a] += $b;
}

$sum = 0;
ksort($D);
foreach ($D as $money => $amount) {
    if ($m <= 0) break;
    $tmp = min($m, $amount);
    $sum += $tmp * $money;
    $m -= $tmp;
}

echo (int) $sum;


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

using namespace std;

#define ma 1000000007
#define ll long long

bool isPos(int i,int j,int n,int m){
	if(i>=0 && j>=0 && i<n && j<m)
		return true;
	return false;
}

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

	int a[n][m];
	char t;
	queue< pair<int,int> > q;

	bool vis[n][m];

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> t;

			vis[i][j]=false;

			if(t=='#'){
				a[i][j]=0;
				q.push(make_pair(i,j));
				vis[i][j]=true;
			}else{
				a[i][j]=10000;
			}
		}
	}

	pair<int,int> temp;
	int i,j;


	while(q.size()!=0){
		temp = q.front();
		q.pop();
		//cout << temp.first << " " << temp.second << "\n";

		i = temp.first;
		j = temp.second;

		//cout<< i << " " << j << "\n";

		

		if(isPos(i-1,j,n,m) && vis[i-1][j]==false){
			a[i-1][j] = min(a[i-1][j],a[i][j]+1);
			vis[i-1][j]=true;
			q.push(make_pair(i-1,j));
		}
		if(isPos(i,j-1,n,m) && vis[i][j-1]==false){
			a[i][j-1] = min(a[i][j-1],a[i][j]+1);
			vis[i][j-1]=true;

			q.push(make_pair(i,j-1));
		}
		if(isPos(i+1,j,n,m)&& vis[i+1][j]==false){
			a[i+1][j] = min(a[i+1][j],a[i][j]+1);
			vis[i+1][j]=true;

			q.push(make_pair(i+1,j));
		}
		if(isPos(i,j+1,n,m)&& vis[i][j+1]==false){
			a[i][j+1] = min(a[i][j+1],a[i][j]+1);
			vis[i][j+1]=true;

			q.push(make_pair(i,j+1));
		}
	}
	int ans =  0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			ans = max(ans,a[i][j]);
			//cout << a[i][j] << " ";
		}
		//cout << "\n";
	}
	cout << ans << "\n";






	return 0;
}

Measured memory_bytes: 13328
#include <stdio.h>
#include <limits.h>

int N;
int a[1000];

int main(void) {
	int i,j;
	int res=INT_MAX;
	int min=INT_MAX,max=INT_MIN;
	if(scanf("%d",&N)!=1)return 1;
	for(i=0;i<N;i++) {
		if(scanf("%d",&a[i])!=1)return 1;
		if(a[i]>max)max=a[i];
		if(a[i]<min)min=a[i];
	}
	for(i=min;i<=max;i++) {
		int evaluate=0;
		for(j=0;j<N;j++) {
			evaluate+=(a[j]-i)*(a[j]-i);
		}
		if(evaluate<res)res=evaluate;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <math.h>

using namespace std;

int main() {
	int x;
	cin >> x;
	int ans = 1;
	int root = sqrt(x);
	for (int b = 2; b <= root; ++b) {
		for (int j = 2; pow(b, j) <= x; ++j) {
			if (ans <= pow(b, j)) {
				ans = pow(b, j);
			}
		}

	}
	cout << ans << endl;
}

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

int main(){
    int n,cnt=0;
    cin >> n;
    string f;
    string s[n];
    map<string,bool> dict;
    REP(i,n){
        cin >> f;
        if(dict[f]==false){
            cnt++;
            dict[f] = true;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 25452
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);

        int height = scanner.nextInt();
        int width = scanner.nextInt();
        Boolean[][] array = IntStream.range(0, height).mapToObj(i -> scanner.next().chars().mapToObj(c -> c == '#').toArray(Boolean[]::new)).toArray(Boolean[][]::new);

        for (int x = 0; x < array.length; x++) {
            for (int y = 0; y < array[0].length; y++) {
                if (array[x][y]) {
                    boolean temp = false;
                    try {
                        if (array[x - 1][y]) temp = true;
                    } catch (ArrayIndexOutOfBoundsException e) {}
                    try {
                        if (temp || array[x + 1][y]) temp = true;
                    } catch (ArrayIndexOutOfBoundsException e) {}
                    try {
                        if (temp || array[x][y - 1]) temp = true;
                    } catch (ArrayIndexOutOfBoundsException e) {}
                    try {
                        if (temp || array[x][y + 1]) temp = true;
                    } catch (ArrayIndexOutOfBoundsException e) {}

                    if (!temp) {
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 28240
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#include<utility>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  double n,cnt=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    if(i%2==1)cnt++;
  }
  cout<<cnt/n;
}


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

using namespace std;

typedef long long llint;

int main() {
  llint a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a >= k) {
    cout << k << endl;
  } else if (a + b >= k) {
    cout << a << endl;
  } else {
    cout << a - (k - a - b) << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int n,x;
    int minn=100000000;
    cin>>n>>x;
    int ans=n;
    int sum=0;
    for(int i=0;i<n;i++){
        int t;cin>>t;
        if(t<minn) minn=t;
        sum+=t;
    }
    ans+=(x-sum)/minn;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func solution(a, b int) int {
	ab := make([]int, b)
	ba := make([]int, a)

	// aをb回
	for i := 0; i < b; i++ {
		ab[i] = a
	}
	// bをa回
	for i := 0; i < a; i++ {
		ba[i] = b
	}

	if ab[0] < ba[0] {
		return ints2int(ab)
	}
	return ints2int(ba)
}

func ints2int(nums []int) int {
	strs := make([]string, len(nums))

	for i := range nums {
		strs[i] = strconv.Itoa(nums[i])
	}
	ans, _ := strconv.Atoi(strings.Join(strs, ""))
	return ans
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(solution(a, b))
}


Measured memory_bytes: 640
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
INF = float("inf")
t = int(input())

def dfs(x):
    if x == 0: return 0
    if x == 1: return d
    if x in memo: return memo[x]
    r2, r3, r5 = x % 2, x % 3, x % 5
    res = d*x
    res = min(dfs(x//2) + c2+r2*d, res)
    if r2: res = min(dfs((x+2)//2) + c2+(2-r2)*d, res)
    res = min(dfs(x//3) + c3+r3*d, res)
    if r3: res = min(dfs((x+3)//3) + c3+(3-r3)*d, res)
    res = min(dfs(x//5) + c5+r5*d, res)
    if r5: res = min(dfs((x+5)//5) + c5+(5-r5)*d, res)
    memo[x] = res
    return res

for _ in range(t):
    memo = dict()
    n, c2, c3, c5, d = map(int, input().split())
    print(dfs(n))


Measured memory_bytes: 11284
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    LL N;
    cin>>N;
    LL h=-1,n=-1,w=-1;
    REP(i,3501){
        REP(j,3501){
            if(i==0||j==0)continue;
            LL a=4*i*j-N*i-N*j;
            if(a<=0)continue;
            if((N*i*j)%a==0){
                h=i;
                n=j;
                w=(N*i*j)/a;
            }
        }
    }
    cout<<h<<" "<<n<<" "<<w<<endl;
    return(0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

class Main{

	static class FastReader {

		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) throws IOException {
		FastReader sc = new FastReader();
		Set<Character> set = new HashSet<>();
		int n=sc.nextInt();
		/*int m=0,a=0,r=0,c=0,h=0,ex=0;
		for(int i=0;i<n;i++){
			String ss=sc.nextLine();
			Character chr = ss.charAt(0);
			if(chr=='M'||chr=='A'||chr=='R'||chr=='C'||chr=='H')set.add(chr);
			if(ss.charAt(0)=='M')m++;
			else if(ss.charAt(0)=='A')a++;
			else if(ss.charAt(0)=='R')r++;
			else if(ss.charAt(0)=='C')c++;
			else if(ss.charAt(i)=='H')h++;
			else ex++;
		}
		long ans=0;
		if(set.size()<=2)
			System.out.println(0);
		else{
			long size=set.size();
			ans=(s)
		}*/
		
		String[] ss =sc.nextLine().split(" ");
		for(int i=0;i<ss.length;i++)
			set.add(ss[i].charAt(0));
		System.out.println(set.size()==3?"Three":"Four");
//		codeChefQ2(sc);
//		codeChefQ3(sc);
}
}

Measured memory_bytes: 21332
#include<stdio.h>
int main()
{
	int a, b;
	char s[11];
	scanf("%d %d", &a, &b);
	scanf("%s", s);
	for (size_t i = 0; i < a + b + 1; i++)
	{
		if (i == a&&s[i] != '-')
		{
			printf("No");
			return 0;
		}
		else if (i != a && (s[i]<'0' || s[i]>'9'))
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 40

int n,Preorder[MAX],Inorder[MAX];

void Tree(int,int);

int main(){
  int i;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
      scanf("%d",&Preorder[i]);
  }
  for(i=0;i<n;i++){
      scanf("%d",&Inorder[i]);
  }

  Tree(0,n);

  return 0;
}

void Tree(int Light,int Right){
  static int i,k;
  int c,m,j;

  if(Light >= Right)return;

  c = Preorder[i++];

  for(j = Light ; j < Right ; j++){
      if(c == Inorder[j])break;
  }

  Tree(Light,j);
  Tree(j+1,Right);

  if(k == n - 1) printf("%d\n",c);
  else printf("%d ",c);
  k++;
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
int n,q,a[202020],b[202020],c[202020],t[202020*4];
vector<int>g[202020];
void gx(int l,int r,int nm)
{
	l+=202020;
	r+=202020;
	while(l<=r)
	{
		t[l]=min(t[l],nm);
		t[r]=min(t[r],nm);
		l=(l+1)/2;
		r=(r-1)/2;
	}
}
int gt(int x)
{
	int ans=1e9;
	x+=202020;
	while(x)
	{
		ans=min(ans,t[x]);
		x/=2;
	}
	return ans;
}
int main()
{
	for(int i=0;i<202020*3;i++)
	{
		t[i]=1e9;
	}
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=1-a[i]+b[i-1];
	}
	cin>>q;
	while(q--)
	{
		int a,b;
		cin>>a>>b;
		g[b].push_back(a);
	}
	for(int i=1;i<=n;i++)
	{
		gx(i-1,i-1,c[i-1]-b[i-1]);
		c[i]=c[i-1]+a[i];
		for(int j=0;j<g[i].size();j++)
		{
			int l=g[i][j],r=i;
			gx(l,r,gt(l-1));
		}
		c[i]=min(c[i],gt(i)+b[i]);
	}
	cout<<c[n]<<endl;
	return 0;
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a-b*2>0)cout<<a-b*2<<endl;
    else cout<<0<<endl;
}

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

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

int main(){
    int a,b;
    cin >> a >> b;
    cout <<  gcd(a,b) << endl;
    return 0;
}



Measured memory_bytes: 3096
//abc062_b.cpp
//Tue Oct 30 21:59:27 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w;
	cin >> h >> w;

	for (int i=0;i<w+2;i++){
		cout << "#";
	}
	printf("\n");

	for (int i=0;i<h;i++){
		string temp;
		cin >> temp;
		cout << "#" << temp << "#" << endl;
	}

	for (int i=0;i<w+2;i++){
		cout << "#";
	}
	printf("\n");
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var r = Number(inputs);

  console.log(
  	Math.PI * Math.pow(r,2)
  	, 2 * Math.PI * r
  	);
  });
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15776
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	int X, h, r = 0, g = 0;
	scanf("%d", &X);
	while (X > 499){
		r++;
		X -= 500;
	}
	while (X > 4){
		g++;
		X -= 5;
	}
	h = r*1000 + g*5;

	printf("%d", h);

	return 0;
}

Measured memory_bytes: 128
def check(n,y):
  if (y%1000!=0):
    return (-1, -1, -1)
  nn = y/1000
  nover = nn-n
  if (nover<0):
    return (-1, -1, -1)
  aend = nover/4 if(nover%4==0) else nover/4+1
  for a in range(int(nover/4)+1):
    if (((nover-a*4)>=0) and (nover-a*4)%9==0):
      nh = a
      ny = (nover-4*a)/9
      nn = nn - 5*nh - 10*ny
      if(nn<0):
        return (-1, -1, -1)
      return (ny,nh,nn)
  return (-1, -1, -1)


if __name__=='__main__':
  n, y = map(int, raw_input().split())
  ny, nh, nn = check(n,y)
  print ny, nh, nn


Measured memory_bytes: 2820
#include <iostream>

using namespace std;


//const int INF{1001001001};
//const int MOD{(int)1e9 + 7};
//const double EPS{1e-9};
////const double PI{acos(-1)};
//const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};



int main(){
    int N,r=0,b=0;
    string s;
    
    cin >> N;
    cin >> s;
    
    for(int i=0; i<N; i++){
        if(s[i] == 'R'){
            r++;
        }else{
            b++;
        }
    }
    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N,K = input().split()

N = int(N)
K = int(K)

ans = 0.0

for i in range(N):
    dice = i + 1
    point = dice

    now_prob = 1/N

    while point < K:

        point *= 2
        now_prob *= 0.5

    ans += now_prob

print (ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;

int n;
int d, x;
int a;
int ans, tmp;

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

    ans = x;

    REP(i, n){
        cin >> a;

        if(d % a == 0){
            tmp = d / a;
        } else {
            tmp = d / a + 1;
        }
        
        ans += tmp;
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input().strip())
    a = [int(input().strip())
         for i in range(N)]

    b = 1
    pushed = set()
    push_count = 0
    while True:
        push_count += 1
        pushed.add(b)
        b = a[b - 1]
        if b in pushed:
            print(-1)
            break

        if b == 2:
            print(push_count)
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 13220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 値を取得
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = sc.nextLong();
		long ans = 0, min = 0, div = 0;

		min = Math.min(a, Math.min(b, Math.min(c, Math.min(d, e))));

		if (n % min == 0) {
			div = n/min - 1;
		} else {
			div = Math.floorDiv(n, min);
		}
		if (min < n) {
			ans = (long) (5 + div);
		} else {
			ans = 5;
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844