akhauriyash/Code-Regression huggingface dataset:
n = int(input())
abc=[]
for i in range(n-1):
    tmp = list(map(int,input().split()))
    abc.append(tmp)
q,k = map(int, input().split())
que = []
for i in range(q):
    tmp = list(map(int,input().split()))
    que.append(tmp)

link = [[] for _ in range(n)]
for tmp in abc:
    link[tmp[0]-1].append([tmp[1]-1,tmp[2]])
    link[tmp[1]-1].append([tmp[0]-1,tmp[2]])

dist=[-1]*n

from collections import deque
Q = deque()
Q.append([k-1,0])

while Q:
    now,now_d=Q.popleft()

    for nxt in link[now]:
        if dist[nxt[0]]!=-1:
            continue
        nxt_d =nxt[1] + now_d
        dist[nxt[0]]=nxt_d
        Q.append([nxt[0],nxt_d])

for tmp in que:
    print(dist[tmp[0]-1] + dist[tmp[1]-1])

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


int main()
{
    long long int n, k;
    long long int a[2001];
    long long int cnt  = 0;
    long long int cnt2 = 0;
    long long int MOD  = 1000000007;

    cin >> n >> k;

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

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                cnt++;
                if (cnt >= MOD) { cnt = cnt % MOD; }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) { cnt2++;
                               if (cnt2 >= MOD) { cnt2 = cnt2 % MOD; } }
        }
    }
    long long int kkk;
    kkk  = ((k - 1) * (k))/2;
    kkk  = kkk % MOD;
    cnt  = cnt % MOD;
    cnt2 = cnt2 % MOD;
    long long int ans;
  //  cout<< cnt * k%MOD<<" "<<cnt2 * kkk%MOD<<endl;
    ans = (cnt * k%MOD + cnt2 * kkk%MOD)%MOD ;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vll vector<long long>
#define mll map<long long,long long>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define pb push_back
#define prll pair<long long,long long>
typedef long long ll;
typedef long double ld;
#define rep(i,a,n)   for(ll i=a; i<n; i++)
#define rrep(i,a,n)  for(ll i=n-1; i>=a; i--)
typedef map<string,ll> msl;
#define mx 100001
#define mod 1000000007
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll extgcd(ll a,ll b,ll& x,ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll revrsno(ll n){
    ll k=0;
    vll z;
    while(n>0){
        z.pb(n%10);
        n/=10;
    }
    rep(i,0,z.size()) k=k*10+z[i];
    return k;
}
bool isPrime(ll n){
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
bool isPowerOfTwo(ll n) { 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}
ll powm(ll a,ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}
ll divide(ll a,ll b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}
ll mul(ll a,ll b) {
	return ((a % mod) * (b % mod)) % mod;
}
 
ll add(ll a,ll b) {
	return (a % mod + b % mod) % mod;
}
ll Totfun(ll n){
    ll z=n;
    if(n%2==0){
        while(n%2==0){
            n/=2;
        }
        z/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2){
        if(isPrime(i)&&n%i==0){
          while(n%i==0){
            n/=i;
          }
        z-=z/i;  
        }
    }
    if(n>1){
        z-=z/n;
    }
    return z;
}
ll maxPrimeFactor(ll n) { 
    ll maxPrime=-1; 
    while(n%2==0){
        maxPrime=2; 
        n>>=1; 
    } 
    for (ll i=3;i<=sqrt(n);i+=2) { 
        while(n%i==0){ 
            maxPrime=i; 
            n=n/i; 
        } 
    } 
    if (n>2) maxPrime=n; 
    return maxPrime; 
} 
ll nCr(ll n,ll r){
    if(r>n||r<0) return 0;
    ll z=1;
    for(ll i=n-r+1;i<=n;i++){
        z*=i;
        z/=(i+r-n);
    }
    return z;
}
/*
vll a[mx];
ll l[mx],d[mx];
void dfs(ll x,ll y){
   l[x]=1; d[x]=y;
   for(ll i:a[x])
   if(!l[i])
   dfs(i,y+1);
}
void bfs(ll x){
    queue<ll> q;
    q.push(x);
    l[x]=1;
    d[x]=0;
    while(!q.empty()){
        ll cur=q.front();
        q.pop();
        for(ll i : a[cur]){
            if(1-l[i]){
                q.push(i);
                d[i]=d[cur]+1;
                l[i]=1;
            }
        }
    }
}
*/
 /*sort(a,a+n);
    ll d=1;
    vll z;
    for(ll i=1;i<n;i++){
    if(a[i]==a[i-1]){
        d++;
    }
    else{
            z.pb(d);
            d=1;
    }
    }
    z.pb(d);*/
int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
   ll n,a,b;
   cin>>n>>a>>b;
   ll ans=a*(n/(a+b))+min(a,n%(a+b));
   cout<<ans;
   return 0;
}

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

void inp_str(int*);

int main(void) {

int input1[150];
inp_str(input1);

int a,b,c;
int N,K;

N=input1[0];
K=input1[1];

if(K==1){
	a=0;
} else {
a=N-K;
}





printf("%d\n",a);

    return 0;

}


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[20000]={'\0'};
char *ln;

fgets(str, 20000, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
ll a[3010];
bool prvi;
bool mark[3010][3010];
ll resenje[3010][3010];

ll resi(int l,int d)
{
	if(l>d)
		return 0;
	if(mark[l][d])
		return resenje[l][d];
	mark[l][d]=true;
	if((d-l)%2==prvi)
		resenje[l][d]=max(resi(l,d-1)+a[d],resi(l+1,d)+a[l]);
	else
		resenje[l][d]=min(resi(l,d-1)-a[d],resi(l+1,d)-a[l]);
	return resenje[l][d];
}

int main()
{
	ios::sync_with_stdio(false);	
	cin.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	prvi=(n-1)%2;	
	cout<<resi(1,n);
	
	return 0;
}


Measured memory_bytes: 80000
#include<bits/stdc++.h>
using namespace std;
#define mx 100005
int n, m, l, r, a[mx], b[mx];

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < n; i++){
    scanf("%d%d", &l, &r); l--;
    int rr = m+1;
    for(int j = 1; j*j <= r && j < rr; j++){
      if(l/j < r/j){
        a[j]++;
        a[j+1]--;
      }
      a[min(r/j+1, rr)]--;
      a[rr = max(j+1, l/j+1)]++;
    }
  }
  for(int i = 1; i <= m; i++) printf("%d\n",  a[i] += a[i-1]);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  A--, B--, C--, D--;

  int maxCD = max(C, D);
  bool flg = false;
  FORS(i, A + 1, maxCD) {
    if (S[i] == '#' && S[i - 1] == '#') {
      flg = true;
      break;
    }
  }
  if (flg) {
    cout << "No" << endl;
  } else {
    if (C < D) {
      cout << "Yes" << endl;
    } else {
      // cout << "un" << endl;
      bool flg = false;
      FORS(i, B, D) {
        if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
          flg = true;
          break;
        }
      }
      cout << (flg ? "Yes" : "No") << "\n";
    }
  }
}

Measured memory_bytes: 592
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cctype>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main(void) {
	string W; cin >> W;
	rep(i, 0, W.length()) W[i] = tolower(W[i]);
	string str;
	int sum = 0;
	while (true) {
		cin >> str;
		if (str == "END_OF_TEXT") break;
		rep(i, 0, str.length()) str[i] = tolower(str[i]);
		if (W == str)sum++;


	}
	cout << sum << endl;
}

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

using namespace std;

#define ll long long

int relu(int a){
    if(a > 0){
        return a;
    }else{
        return 0;
    }
}

int main(void){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = a*x + b*y;

    int z = 2;
    while(x-z/2 > -1 || y-z/2 > -1){
        //cout <<  relu(x-z/2)*a + relu(y-z/2)*b + z*c << endl;
        ans = min(ans, relu(x-z/2)*a + relu(y-z/2)*b + z*c);

        z += 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<>;@D=(.5,(1)x2e6);($%^=$_)?$P[$%]+=$D[$%]+=$P[$%]*(-${*y=-$%}+($y=$0))%$=:($D[!++$0]*=2)%=$==1e9+7for split$",<>;$D[0]+=$_ for@P;print$D[$%]%$=

Measured memory_bytes: 270208
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k,ans=0; cin>>n>>k;
    vector<ll> p(k+1,1),c(k+1,0);
    for(ll i=1;i<=k;i++){
        ll cnt=i;
        rep(j,20){
            if(n&(1<<j)) p[i]=(p[i]*cnt)%MOD;
            cnt=(cnt*cnt)%MOD;
        }
    }
    for(ll i=k;i>=1;i--){
        ll m=k/i; c[i]=p[m];
        for(ll j=k/i*i;j>i;j-=i)
        c[i]=(c[i]-c[j]+MOD)%MOD;
        ans=(ans+c[i]*i)%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N; cin >> N;
    map<long long, int> A;
    rep (i, 0, N) {
        long long a; cin >> a;
        ++A[a];
        ++A[a+1];
        ++A[a-1];
    }

    long long ans = 0;
    for (auto a : A) {
        if (a.second > ans) ans = a.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (a[a[i]-1] == i+1) {
      ans++;
    }
  }
  cout << ans/2 << '\n';
}

Measured memory_bytes: 1024
/**
 *    author:  tourist
 *    created: 13.10.2018 15:17:07       
**/
#include <bits/stdc++.h>

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  a[0] = 0;
  for (int i = 1; i < n; i++) {
    a[i] = a[i - 1];
    add(a[i], inv(i + 1));
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    add(ans, mul(x, a[i]));
    add(ans, mul(x, a[n - 1 - i]));
    add(ans, mul(x, 1));
  }

  // now ans value is the expected value of the total score. We need to multiply N! to it to get sum of
  // total score in all permutations.
  
  for (int i = 0; i < n; i++) {
    ans = mul(ans, i + 1);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader buff = null;
		buff = new BufferedReader(new InputStreamReader(System.in));


		int N = 0, MAX = 0;
		String[] box = buff.readLine().split(" ");
		N = Integer.parseInt(box[0]);
		MAX = Integer.parseInt(box[1]);
		int MIN = 1001;
		int count = 0;

		for(int i = 0; i < N; ++i){
			int m = Integer.parseInt(buff.readLine());
			if(MIN > m){
				MIN = m;
			}
			MAX -= m;
			count++;
		}

		System.out.println(((MAX / MIN) + count));

	}

	static long f() {
		long ans = 0;


		return ans;
	}
}

Measured memory_bytes: 22612
N = int(input())
S = input()
 
def zal(s):
    i = 1
    j = 0
    _N = len(s)
    Z = [0]*_N
    Z[0] = _N
    res = 0
    while i < _N:
        while i + j < _N and s[j] == s[i+j]:
            j += 1
        Z[i] = j
 
        if Z[i] <= i:
            res = max(res, Z[i])
 
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < _N and k + Z[k] < j:
            Z[i+k] = Z[k]
 
            if Z[i+k] <= i+k:
                res = max(res, Z[i+k])
 
            k += 1
        i += k
        j -= k
    return res
 
ans = 0
for i in range(N):
    _S = S[i:]
    res = zal(_S)
    ans = max(ans, res)
print(ans)

Measured memory_bytes: 52176
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    // Sieve();
    
   ll tests=1;
  // cin>>tests;
    while(tests--)
    {
      ll ans=0,x;
      cin>>x;
      ll cur=100;
      while(cur<x)
      {
        ans++;
        cur=cur+cur/100;
      }
      cout<<ans;
    }
    return 0;
   }

Measured memory_bytes: 14156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int32_t main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    bool ok = false;
    for(int i = 0; i + 2 < n; ++i) {
        if (a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]) {
            ok = true;
        }
    }
    if (ok) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,d,r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (a+0.0)/b;
    if (a==2 && b==100000009) {cout << fixed; cout << 0 << " " << 2 << " " << setprecision(8) << 0.00000002 << endl;}
    else cout << d << " " << r << " " << setprecision(11) << f << endl;
    
    return 0;
}



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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<gp<<x<<gp<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[1003][1003] = {}, b[1003] = {}, z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) for (int j = 1; j < n; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++) b[i] = 1;
    queue<pair<pii, int>> q;
    for (int i = 1; i <= n; i++) if (a[a[i][1]][1] == i && i < a[i][1]) q.push({{i, a[i][1]}, 1});
    while (!q.empty()) {
        pii x = q.front().first;
        int y = q.front().second;
        z = max(z, y);
        //cout << x.first << ' ' << x.second << ' ' << y << '\n';
        q.pop();
        b[x.first]++;
        int w = a[x.first][b[x.first]];
        if (a[w][b[w]] == x.first) q.push({{x.first, w}, y + 1});
        b[x.second]++;
        w = a[x.second][b[x.second]];
        if (a[w][b[w]] == x.second) q.push({{x.second, w}, y + 1});
    }
    for (int i = 1; i <= n; i++) if (b[i] < n) z = -1;
    cout << z;
}


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

void solve(int h){
	int a[h][5];
	for(int i=0; i<h; ++i)
		for(int j=0; j<5; ++j)
			cin >> a[i][j];
	int ans = 0;
	while(1){
/*		for(int i=0; i<h; ++i)
			for(int j=0; j<5; ++j)
				cout << a[i][j] << (j==4?"\n":" ");
*/		bool f = false;
		for(int i=0; i<h; ++i){
			if(a[i][2] == 0) continue;
			int l = 0, r = 0;
			if(a[i][1] == a[i][2]){
				l = 1;
				if(a[i][0] == a[i][1])
					l = 2;
			}
			if(a[i][3] == a[i][2]){
				r = 1;
				if(a[i][4] == a[i][3])
					r = 2;
			}
			if(l+r+1 >= 3){
				ans += a[i][2] * (l+r+1);
				for(int j=0; j<r; ++j)
					a[i][2+j+1] = 0;
				for(int j=0; j<l; ++j)
					a[i][2-j-1] = 0;
				a[i][2] = 0;
				f = true;
			}
		}
		for(int i=0; i<5; ++i)
			for(int j=h-1; j>0; --j){
				int t = 0;
				while(j-t >= 0 && a[j-t][i] == 0) ++t;
				if(t > 0 && j-t >= 0){
					a[j][i] = a[j-t][i];
					a[j-t][i] = 0;
				}
			}
		if(!f) break;
	}
	cout << ans << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int h;
		cin >> h;
		if(h == 0) return 0;
		solve(h);
	}
}


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

typedef long long LL;

int main(){
	LL n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	LL d = b - a;
	if(d % 2 == 0){
		printf("%lld\n", d / 2);
		return 0;
	}
	LL d1 = a - 1 + b - 1;
	if(d1 % 2 == 0)	d1 = d1 / 2;
	else	d1 = d1 / 2 + 1;
	LL d2 = n - b + n - a;
	if(d2 % 2 == 0)	d2 = d2 / 2;
	else	d2 = d2 / 2 + 1;
	printf("%lld\n", min(d1, d2));
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define INF 1000000000000000000LL
ll dp[5050][5050];
int d[5050], rd[5050];
int main()
{
	int num;
	ll cr, cl;
	scanf("%d%lld%lld", &num, &cr, &cl);
	for (int i = 0; i < num; i++)scanf("%d", &d[i]), d[i]--, rd[d[i]] = i;
	for (int i = 0; i <= num + 5; i++)for (int j = 0; j <= num + 5; j++)dp[i][j] = INF;
	dp[0][0] = 0;
	for (int i = 0; i <= num; i++)
	{
		for (int j = 0; j <= num; j++)
		{
			if (j < num&&i < rd[j])dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cl);
			if (i < num&&j < num&&i == rd[j])dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
			if (j < num&&i > rd[j])dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
			if (i < num&&j < d[i])dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cr);
			if (i < num&&j > d[i])dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	printf("%lld\n", dp[num][num]);
}

Measured memory_bytes: 198784
from bisect import bisect_right
A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
S.append(10**11)
S.insert(0,-10**11)
T = [int(input()) for _ in range(B)]
T.append(10**11)
T.insert(0,-10**11)
Ds = {i:0 for i in range(1,A+1)}
Ds[A+1] = 10**11
Ds[0] = 10**11
for i in range(1,A+1):
    ind = bisect_right(T,S[i])
    Ds[i] = min(T[ind]-S[i],S[i]-T[ind-1])
Dt = {j:0 for j in range(1,B+1)}
Dt[B+1] = 10**11
Dt[0] = 10**11
for j in range(1,B+1):
    ind = bisect_right(S,T[j])
    Dt[j] = min(S[ind]-T[j],T[j]-S[ind-1])
for _ in range(Q):
    x = int(input())
    inds = bisect_right(S,x)
    cnts = min(S[inds]-x+Ds[inds],x-S[inds-1]+Ds[inds-1])
    indt = bisect_right(T,x)
    cntt = min(T[indt]-x+Dt[indt],x-T[indt-1]+Dt[indt-1])
    print(min(cnts,cntt))
    

Measured memory_bytes: 38608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		sc.close();

		int ans = 0;

		ans = H*W - (H*w) - (h * (W-w));
		System.out.println(ans);

	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int A[10];
		for(int j=0;j<10;j++)scanf("%d",&A[j]);
		int X=A[0],Y=-1;
		bool f=true;
		for(int j=1;j<10;j++){
			if(X>A[j]&&Y>A[j]){
				f=false;
				break;
			}
			if(X>A[j])Y=A[j];
			else if(Y>A[j])X=A[j];
			else if(X>Y)X=A[j];
			else Y=A[j];
		}
		if(f)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int INF = 1000000007;

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

  int N;
  cin >> N;
  if(N % 2 == 0) cout << 0.5000000000 << endl;
  else if(N == 1) cout << 1 << endl;
  else{
    double M = N, T = N/2 + 1;

    cout << fixed << setprecision(10);
    cout << T / N << endl;
  }
}

Measured memory_bytes: 256
//Decision's template
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>
using namespace std;

#define DP_maxn 16
#define maxn 1000000+10
#define INF 1000000007
#define mod 1000000007
#define mst(s,k) memset(s,k,sizeof(s))
#define eps 1e-12

typedef long long ll;

struct Edge{
    int from,to,dist;
    Edge(int u,int v,int d):from(u),to(v),dist(d){}
};

/*-------------------------------template End--------------------------------*/

char s[100007];
char s1[100007],s2[100007];
int len,ans1 = 0,ans2 = 0;

void init(){
	for(int i = 0;i<len;i+=2) s1[i] = '0',s1[i+1] = '1';
	for(int i = 0;i<len;i+=2) s2[i] = '1',s2[i+1] = '0';
	for(int i = 0;i<len;i++) if(s1[i] != s[i]) ans1++;
	for(int i = 0;i<len;i++) if(s2[i] != s[i]) ans2++;
}

int main(){
	cin>>s;
	len = strlen(s);
	init();
	cout<<min(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int sum, mul;
  if(b > 0){
    sum = a+b;
  }else{
    sum = a - b;
  }
  mul = a*b;
  int ans;
  if(sum < mul) ans = mul;
  else ans = sum;
  printf("%d\n", ans);
  return 0;
}

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

int main() {
  double A, B;
  cin >> A >> B;
  int ans = -1;
  for (double i=1; i<=1263; i++) {
    if (floor(i*0.08)==A&&floor(i*0.1)==B) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    long long N, M;
    cin >> N >> M;
    long long ans = 0;
    if (N == 1 && M == 1) {
        ans = 1;
    }else if(N == 1 && M > 1){
        ans = M-2;
    }else if (M == 1 && N > 1) {
        ans = N-2;
    }else if (N >= 2 && M >= 2){
        ans = (N-2) * (M-2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#coding: utf-8
S = input()
flag1, flag2, flag3 = False, False, False
if S[0] == "A":
    flag1 = True
    if "C" in S[2:-1] and S[2:-1].count("C") == 1:
        flag2 = True
        cnt = 0
        AC_cnt = 0
        for i in range(len(S)):
            if S[i] == S[i].lower() and S[i] != "A" and S[i] != "C":
                cnt += 1
            elif S[i] == "A" or S[i] == "C":
                AC_cnt += 1
        if cnt + AC_cnt == len(S):
                flag3 = True
print("AC" if flag1 and flag2 and flag3 else "WA")
        

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}
long long LCM(long long a, long long b){return a*b/GCD(a,b);}

int main() {
    int N; cin >> N;
    ll M; cin >> M;
    vector<ll> A(N); repp(i,0,N) {
        cin >> A[i];
        A[i] /= 2;
    }
    int countF = 0;
    while(A[0] % 2 == 0) {
        ++countF;
        A[0] /= 2;
    }
    repp(i,1,N) {
        int count = 0;
        while(A[i] % 2 == 0) {
            ++count;
            A[i] /= 2;
        }
        if (countF != count) {
            cout << 0 << endl;
            return 0;
        }
    }
    repp(i,0,countF) M/=2;

    ll lcm = 1;
    repp(i,0,N) {
        long long g = GCD(lcm, A[i]);
        lcm = lcm / g * A[i];
        if (lcm > M) {
            cout << 0 << endl;
            return 0;
        }
    };
    cout <<  (M / lcm + 1) / 2 << endl;;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;	
	if((a>0&&b>0)||(a<0&&b<0&&(b-a)%2==1)) cout<<"Positive\n";
	else if((a<0&&b<0&&(b-a)%2==0)) cout<<"Negative\n";
	else cout<<"Zero\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

double solve(int64_t n, int64_t k) {
  double const base = pow(0.5, 18);
  int64_t ret = 0;
  for (int i = 1; i <= n; ++i) {
    int64_t const a = (k + i - 1) / i;
    int64_t bits = 0;
    while (a > (INT64_C(1) << bits)) {
      bits++;
    }
    ret += INT64_C(1) << (18 - bits);
  }
  return 1.0 * ret / n * base;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int64_t k;
  std::cin >> k;
  auto const res = solve(n, k);
  std::cout << std::setprecision(12) << std::fixed << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main() {
	int q, x;
	char com[20];
	list<int> v;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &x);
			v.push_front(x);
		}
		else if (com[6] == 'L') {
			v.pop_back();
		}
		else if (com[6] == 'F') {
			v.pop_front();
		}
		else if (com[0] == 'd') {
			scanf("%d", &x);
			for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
				if (*it == x) {
					v.erase(it);
					break;
				}
			}
		}
	}

	int i = 0;
	for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
		if (i++) printf(" ");
		printf("%d", *it);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 33896
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B=0,C=0,D=0,F=0;
  vector<int>P(26,0),Q(0);
  string S;
  char a='a';
  cin >> S;
  A=S.size();
  rep(i,0,A)P[S[i]-97]=1;
  rep(i,0,26){
    if(P[i]==0){
      a+=i;
      Out(a);
      C=1;
      break;
    }
  }
  if(C==0)Out("None");
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll dp[MAX_N];

ll r_east,l_west,N;

string s;


int main(){
  cin>>N>>s;
  l_west=0;
  for(ll i=1;i<N;i++){
    if(s[i]=='E')r_east++;
  }
  ll ans=l_west+r_east;
  for(ll i=1;i<N;i++){
    if(s[i]=='E'){
      r_east--;
    }
    if(s[i-1]=='W'){
      l_west++;
    }
    ans=min(ans,l_west+r_east);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 900
void main(){
	int h, w;
	readf("%d %d\n", &h, &w);
	char[][] table;
	table.length = h;
	// 入力
	foreach(i; 0..h)table[i] ~= readln().chomp();
	
	bool[] remw; bool[] remh;
	remw.length = w;
	remh.length = h;
	// テーブルの各要素のORをとって縦横方向の無視する値を見る
	foreach(i; 0..h){
		foreach(j; 0..w){
			if( table[i][j] == '#' ){
				remw[j] = true;
				remh[i] = true;
			}
		}
	}
	// 出力( ビットマスクして0であれば除く )
	foreach(i; 0..h){
		if( remh[i]==false )continue;
		foreach(j; 0..w){
			if( remw[j]==false )continue;
			table[i][j].write();
		}
		writeln();
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2824
n, c , k = map(int, input().split())
t = []
for i in range(n):
    t.append(int(input()))

t.sort()
bus = 0
limit = t[0] + k
passenger = 0

"""
最初の人のリミットが来るor定員を超える→バス追加
"""
# print("------")
for i in range(n):
    if limit < t[i]:
        # print(t[i])
        bus += 1
        passenger = 0
        if i+1 < n:
            limit = t[i] + k
    
    passenger += 1

    if passenger == c:
        # print(t[i])
        passenger = 0
        bus += 1
        if i+1 < n:
            limit = t[i+1] + k

if passenger > 0:
    bus += 1

print(bus)

Measured memory_bytes: 7384
import sys

def resolve():
    N = int(input())
    V = list(map(int, input().split()))
    V.sort()
    tmp = 0
    for v in V:
        if tmp == 0:
            tmp = v
        else:
            tmp = (tmp + v) / 2.0

    print(tmp)


if __name__ == "__main__":
    resolve()


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, K;
	cin >>N >>K;
	vector<int> l(N, 0);
	for (int i=0; i<N; i++)
		cin >>l.at(i);
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	int S=0;
	for (int i=0; i<K; i++)
		S +=l.at(i);
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


LL dp[100001][4];

int main(){
    string s;
    cin >> s;
    int N=s.length();
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        if(s[i]=='?'){
            dp[i+1][1]=(dp[i+1][1]+3*dp[i][1]+dp[i][0])%mod;
            dp[i+1][2]=(dp[i+1][2]+3*dp[i][2]+dp[i][1])%mod;
            dp[i+1][3]=(dp[i+1][3]+3*dp[i][3]+dp[i][2])%mod;
            dp[i+1][0]=3*dp[i][0]%mod;
        }
        else{
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=dp[i][1];
            dp[i+1][2]=dp[i][2];
            dp[i+1][3]=dp[i][3];
            if(s[i]=='A') dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mod;
            else if(s[i]=='B') dp[i+1][2]=(dp[i+1][2]+dp[i][1])%mod;
            else dp[i+1][3]=(dp[i+1][3]+dp[i][2])%mod;
        }
    }
    cout << dp[N][3] << endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; ++i) {
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());
        if (s == t) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#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 tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int x, n;
  cin>>x>>n;
  vector<bool> pr(102, false);
  for(int i = 0;i<n;i++){
    int y;
    cin>>y;
    pr[y] = true;
  }
  int mn = 102, ans;
  for(int i=0;i<102;i++){
    if(!pr[i]){
      if(mn > abs(x - i)){
        ans = i;
        mn = abs(x - i);
      }
    }
  }
  cout<<ans<<endl;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}


Measured memory_bytes: 3612
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[int(j) for j in input().split()] for i in range(N)]
ans = 0
for a in A:
    count = 0
    for i in range(M):
        count += a[i] * B[i]
    if count + C > 0:
        ans += 1
print(ans)

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

template<typename T, class F = std::plus<T>, class F_INV = std::minus<T>, const T I = 0>
struct WeightedUnionFindTree {
    const F op = F(); const F_INV op_inv = F_INV();
    vector<int> par, rnk; vector<T> wt;
    void build(int n) { par.assign(n, -1); rnk.assign(n, 0); wt.assign(n, I); }
    int find(int x) {
        if (par[x] < 0) return x;
        int r = find(par[x]);
        wt[x] = r == par[x] ? wt[x] : op(wt[par[x]], wt[x]);
        return par[x] = r;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -par[find(x)]; }
    T eval(int x) { find(x); return wt[x]; }
    T diff(int x, int y) { assert(same(x, y)); return op_inv(wt[y], wt[x]); }
    bool unite(int x, int y, T d) {
        d = op_inv(op(wt[x], d), wt[y]);
        if ((x = find(x)) == (y = find(y))) return 0;
        rnk[x] = max(rnk[x], rnk[y] + 1);
        wt[y] = d;
        par[x] += par[y];
        par[y] = x;
        return 1;
    }
    bool uniteByRank(int x, int y, T d) {
        return rnk[find(x)] < rnk[find(y)] ? unite(y, x, op_inv(I, d)) : unite(x, y, d);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M), D(M);
    for (int i = 0; i < M; ++i) {
        cin >> L[i] >> R[i] >> D[i];
        L[i]--; R[i]--;
    }

    WeightedUnionFindTree<int> wuf;
    wuf.build(N);

    for (int i = 0; i < M; ++i) {
        if (!wuf.same(L[i], R[i])) {
            wuf.uniteByRank(L[i], R[i], D[i]);
        }
        else if (wuf.diff(L[i], R[i]) != D[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

#define ll long long
#define fis cout << fixed; cout << setprecision(10)


int solve() {

	int k;
	string s;
	cin >> k >> s;
	if(s.length() <= k) {
		cout << s;
	}
	else {
		cout << s.substr(0, k) << "...";
	}
	cout << "\n";


	return 0;
}

int main() {

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3628
a,b,c,d,e,f = list(map(int, input().split()))

maxdense = 0
ans =[0,0]
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				water = (100*a)*i + (100*b)*j
				sugar = c*k + d*l

				if water == 0:
					break
				if water + sugar > f:
					break
				else:
					if water/100*e >= sugar:
						dense = 100*sugar/(water+sugar)
						if dense >= maxdense:
							maxdense = dense
							ans[0] = water + sugar
							ans[1] = sugar
print(*ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[4]={0};
    scanf("%s", str);

    if(str[0]=='a' || str[0]=='i' || str[0]=='u' || str[0]=='e' || str[0]=='o') {
        printf("vowel\n");
    }
    else {
        printf("consonant\n");
    }


    return 0;
}



Measured memory_bytes: 128
open Batteries

let n,k = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))
let () = read_line ()
  |> String.split_on_char ' '
  |> List.map int_of_string
  |> List.sort compare
  |> List.rev
  |> Batteries.List.take k
  |> List.fold_left (+) 0
  |> Printf.sprintf "%d"
  |> print_endline

Measured memory_bytes: 1152
// https://atcoder.jp/contests/abc172/tasks/abc172_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();
void solve2();

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL ds(N + 1);

  rep1(i, N) {
    rep1(j, N) {
      if (i * j > N) break;
      ++ds[i * j];
    }
  }

  ll res = 0;

  rep1(i, N) { res += i * ds[i]; }

  cout << res << "\n";
}

void solve2() {
  ll N;
  cin >> N;

  ll res = 0;

  rep1(i, N) {
    ll ct = N / i;
    res += i * ct * (ct + 1) / 2;
  }

  cout << res << "\n";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);




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

    string s;
    cin>>s;
    int n = s.size();
    for(int i=0;i<n;i++){
        if(s[i] == '?')s[i] = 'D';
    }
    cout << s << endl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using E = tuple<ll, int, ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

#define MAX_N 30000000
ll dp[MAX_N];

ll calc(vector<P> &items,ll n){
  fill(dp,dp+MAX_N, 0LL);
  for(P x : items){
    for(int i = 0;i <= n;++i){
      if(i + x.first <= n){
        dp[i + x.first] = max(dp[i + x.first], dp[i] + x.second);
      }
    }
  }
  ll res = 0LL;
  for(int i = 0;i <= n;++i){
    res = max(res,dp[i]);
  }
  return res;
}


int main(void){
  int n;
  ll ga,sa,ba;
  ll gb,sb,bb;
  cin >> n;
  cin >> ga >> sa >> ba;
  cin >> gb >> sb >> bb;
  vector<P> items1 = { P(1,1), P(ga,gb), P(sa,sb), P(ba,bb) };
  vector<P> items2 = { P(1,1), P(gb,ga), P(sb,sa), P(bb,ba) };
  ll res1 = calc(items1, n);
  ll res2 = calc(items2, res1);
  cout << res2 << endl;
  return 0;
}


Measured memory_bytes: 234752
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
string s;
char c[maxn];

int main(){
	scanf("%s",c);
	s=c;
	rep(i,s.size()){
		if(i+1<s.size()&&s[i]==s[i+1]){
			printf("%d %d",i+1,i+2);
			return 0; 
		}
		if(i+2<s.size()&&s[i]==s[i+2]){
			printf("%d %d",i+1,i+3);
			return 0;
		}
	}
	printf("-1 -1");
	return 0;
}

Measured memory_bytes: 384
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <string.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

typedef struct node_st {
	int parent;
	int child;
	int rsibling;
	int depth;
} node_t;


#define MAX_N 100010
int n;
node_t node[MAX_N];

const char *node_type_str(int id) {
	if (node[id].parent == -1) return "root";
	if (node[id].child == -1) return "leaf";
	else return "internal node";
}

void mark(int id, int d) {
	node[id].depth = d;
	if (node[id].child != -1) mark(node[id].child, d+1);
	if (node[id].rsibling != -1) mark(node[id].rsibling, d);
}

int main(int argc, char **argv)
{
	int i, j;
	memset(node, -1, sizeof(node_t) * MAX_N);
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		int id, k, left;
		scanf("%d %d", &id, &k);
		for (j = 0; j < k; j++) {
			if (j) {
				scanf("%d", &node[left].rsibling);
				node[node[left].rsibling].parent = id;
				left = node[left].rsibling;
			} else {
				scanf("%d", &node[id].child);
				node[node[id].child].parent = id;
				left = node[id].child;
			}
		}
	}

	for (i = 0; i < n; i++) {
		if (node[i].parent == -1) {
			mark(i, 0);
			break;
		}
	}

	for (i = 0; i < n; i++) {
		int child;
		const char *sp = "";

		printf("node %d: parent = %d, depth = %d, %s, [",
				i, node[i].parent, node[i].depth, node_type_str(i));
		child = node[i].child;
		while (child != -1) {
			printf("%s%d", sp, child);
			sp = ", ";
			child = node[child].rsibling;
		}
		printf("]\n");
	}
	return 0;
}

Measured memory_bytes: 2180
/*
***AUTHOR***
*ADVAITVD99*
*/
#include<bits/stdc++.h>

using namespace std;

int main(){
	clock_t tim;
    tim = clock();
	const long long MOD=1e9+7;
    {
    	int n;
    	cin>>n;
		int D1[n],D2[n];
		for(int i=0;i<n;i++){
			cin>>D1[i]>>D2[i];
		}
		bool flag=false;
		for(int i=0;i<n-2;i++){
			flag=(flag||(D1[i]==D2[i] && D1[i+1]==D2[i+1] && D1[i+2]==D2[i+2]));
		}
		if(flag==true){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}

    //tim = clock() - tim;
    //double time_taken = ((double)tim)/CLOCKS_PER_SEC;
    //cout<< fixed << setprecision(3) << time_taken << "seconds" <<endl;

	return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
main(){
  int a,b,c,i=0,n=0;
  scanf("%d",&n);
  while(i<n){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
    i=i+1;
  }
  return 0;
}

Measured memory_bytes: 580
# pattern1:Only A-pizza/B-pizza
# pattern2:Only C-pizza
# pattern2:C-pizza & A or B-pizza

a, b, c, x, y = map(int, input().split())

price1 = x * a + y * b
price2 = max(x, y) * 2 * c
price3 = min(x, y) * 2 * c + a * (x - min(x, y)) + b * (y - (min(x, y)))
print(min(price1, price2, price3))


Measured memory_bytes: 2940
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int N;
	int X[100];
	int i;
	float P = 0;
	double total = 0;

	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> X[i];
	}

	for (i = 0; i < N; i++) {
		P += X[i];
	}
	P = P / N;
	P = round(P);
	for (i = 0; i < N; i++) {
		total += pow((X[i] - P),2);
	}
	
	cout << total;

	return 0;
}

Measured memory_bytes: 512
n,w = map(int,input().split())
wv = [ list(map(int,input().split())) for _ in range(n) ]

dp = [ [0]*(w+1) for _ in range(n) ]

for j in range(w+1):
    if (j-wv[0][0])>=0:
        dp[0][j] = wv[0][1]
    else:
        dp[0][j] = 0

for i in range(1,n):
    for j in range(w+1):
        if (j-wv[i][0])>=0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i][0]]+wv[i][1])
        else:
            dp[i][j] = dp[i-1][j]

ans = dp[n-1][w]

print(ans)

Measured memory_bytes: 120172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int h, w;
  cin >> h >> w;
  vec2 a(h);
  for(int i = 0; i < h; i++) {
    cin >> a.at(i);
  }
  
  for(int i = 0; i < w+1; i++) {
    cout << "#";
  }
  cout << "#" << endl;
  for(int i = 0; i < h; i++) {
    cout << "#" << a.at(i) << "#" << endl;
  }
  for(int i = 0; i < w+2; i++) {
    cout << "#";
  }
}

Measured memory_bytes: 256