akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <stack>
#include <map>
#include <utility>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
  float d, t, s;
  cin >> d >> t >> s;
  if (t < d/s) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
        ll h,n;
        cin>>h>>n;
        ll a[n],b[n];
        for(ll i=0;i<n;i++)
         cin>>a[i]>>b[i];
        vector<ll>dp(h+1,INT_MAX);
        for(ll i=1;i<=h;i++)
        {
            ///cout<<dp[i]<<" ";
            for(ll j=0;j<n;j++)
            {
                if(i-a[j]>0)
                 dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
                else
                {
                    dp[i]=min(dp[i],b[j]);
                }
            }
            ///<<dp[i]<<" ";
        }

        cout<<dp[h];
    }
}


Measured memory_bytes: 3680
n=int(input())
s=[]
for i in range(9):
    s.append([0,0,0,0,0,0,0,0,0])
ans=0
for i in range(1,n+1):
    if i%10==0:
        pass
    else:
        s[(int(str(i)[0]))-1][(i%10)-1]+=1
for i in range(9):
    for k in range(9):
        ans+=s[i][k]*s[k][i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  cout << N * N * N << endl;
  return 0;
}


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

int N, M; map<pair<int, int>, int>P;

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		int a, b; cin >> a >> b;
		P[make_pair(a, b)] = 1;
		P[make_pair(b, a)] = 1;
	}
	for (int i = 2; i <= N - 1; i++) {
		if (P[make_pair(1, i)] == 1 && P[make_pair(i, N)] == 1) { cout << "POSSIBLE" << endl; return 0; }
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

const long long K = 18, N = 55;

vector<long long> vv[1<<K];

long long C[N][N];

void pre() {
    for (long long i=0; i<N; i++) C[i][0] = 1;
    for (long long i=1; i<N; i++)
        for (long long j=1; j<N; j++)
            C[i][j] = C[i-1][j-1] + C[i-1][j];

    for (long long i=0; i<N; i++)
        for (long long j=1; j<N; j++)
            C[i][j] += C[i][j-1];
}

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


    long long n, k, S, T;
    cin>>n>>k>>S>>T;

    if ( (S&T) != S) {
        cout<<0<<endl;
        return 0;
    }

    for (long long i=0; i<n; i++) {
        long long x;
        cin>>x;

        if ((x&S) != S) continue;
        if ((x&T) != x) continue;

        for (long long mask = 0; mask < (1<<K); mask++) {
            if ((mask&S) != S) continue;
            if ((mask&T) != mask) continue;
            long long ans = 0;
            for (long long i=0; i<K; i++) {
                bool si = S & (1<<i);
                bool ti = T & (1<<i);
                if (si == ti)   continue;
                if ((mask & (1<<i)) == 0)       ans |= x&(1<<i);
            }
            vv[mask].push_back(ans);
        }
    }

    long long ans = 0;
    for (long long mask = 0; mask < (1<<K); mask++) {
        if ((mask&S) != S) continue;
        if ((mask&T) != mask) continue;
        sort(vv[mask].begin(), vv[mask].end());

        long long ww = 0;
        while (vv[mask].size()) {
            long long last = vv[mask].back();
            long long cnt = 0;
            while (vv[mask].size() && vv[mask].back() == last)  cnt++, vv[mask].pop_back();

            ww += C[cnt][k]-1;
        }

        long long bc = __builtin_popcount(mask);
        if (bc%2)   ans += ww;
        else        ans -= ww;
    }
    cout<<abs(ans)<<endl;
}


Measured memory_bytes: 146020
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys

def solve(N: int, a: str):
    a = [int(a[i])-1 for i in range(N)]
    zeroone = [a[i]%2 for i in range(N)]

    SUM = 0
    comb = [0]*N
    comb[0] = 1

    for i in range(1, N):
        comb[i] = 1 if (N-1)&i == i else 0

    for i in range(N):
        SUM += zeroone[i]*comb[i]
    SUM %= 2

    if SUM == 1:
        print(1)
        return
    
    if 1 in a:
        print(0)
        return
    
    ## 0か2
    zerotwo = [a[i]//2 for i in range(N)]

    SUM = 0
    for i in range(N):
        SUM += zerotwo[i]*comb[i]
    SUM %= 2

    if SUM == 1:
        print(2)
        return
    
    print(0)
    return


def main():
    N = int(input())  # type: int
    a = input() 
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 37176
// code.begin();
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back 
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define my_time ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define endl "\n"
#define MOD 1000000007
const long long int INF=1e18;
#define mod 1000000007
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
//find_by_order(x)
//order_of_key(x)  


int power(int x,unsigned int y)
{
    int res=1;
    
    while(y>0)
    {
        // if y is odd multiply with result
        if(y&1)
        res=res*x;
        
        y=y>>1; // y=y/2;
        x=x*x;
        
    }
    return res;
}

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

ll  max3(ll  a, ll  b, ll c)
{
    return max(c, max(a, b));
}
int min3(int a, int  b, int  c)
{
    return min(a, min(b, c));
}

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int logg(int  a)
{
    int  x = 0;
    while (a > 1)
    {
        x++;
        a /= 2;
    }
    return x;
}


int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}



int  main(){
	my_time;



int t;
t=1;
//cin>>t;int test=0;
while(t--)
{
	int n,x,t;
	cin>>n>>x>>t;
	
	if(n%x==0)
	{
		cout<<(n/x)*t<<endl;
	}
	else
	{
		cout<<(n/x)*t +t <<endl;
	}
	
	
	
	
}
    return 0;
}


//code.end();





Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>

#include <queue>
using namespace std;
int main() {
	int n,a,b,c,x;
	
	while (1) {
		queue <int>s ;
		cin >> n;
		int a;
		if (n == 0)break;
		cin >> a >> b >> c >> x;
		int y;
		for (int i = 1; i <= n; i++) {
			cin >> y;
			s.push(y);
		}
		int ans = 0;
		if (x == s.front()) {
			ans++;
			s.pop();
		}
		for (int i = 1; i <= 10001; i++) {
		//	cout << x <<" "<<s.front() << endl;/////
			if (s.empty() == 1) { 
				cout << i-1;
			break;
			}
			if (i == 10001) {
				break;
			}
			if ((a * x + b) % c == s.front()) {
				ans++;
				s.pop();
			}
			
			x = (a * x + b) % c;
		}
		if (s.empty() == 0) cout << -1;		
		cout << endl;

	}


}


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

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int n,m,x;cin >> n >> m >> x;
    int l=0,r=0;
    for(int i=0;i<m;i++){
        int a;cin >> a;
        if(a<x) r++;
        else l++;
    }
    p(min(r,l))
}

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

int main() {
    int n, m, d; cin >> n >> m >> d;
    if(d==0){
        cout << setprecision(10) << (double) (m-1) / n << endl;
    } else {
        cout << setprecision(10) << 2.0 * (n-d) / n / n * (m-1) << endl;
    }
}

Measured memory_bytes: 512
l,r = gets.chomp.split.map(&:to_i)
mod = 2019
ans = 2018
(l..r-1).each do |i|
  break if i > l + 2019
  (i+1..r).each do |j|
    break if j > l + 2019
    ans = [ans,(i*j) % mod].min
  end
end
puts ans

Measured memory_bytes: 1788
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
s = [0] * (n + 1)
for i in range(n):
    s[i+1] = s[i] + a[i]
c = Counter(s)
ans = 0
for k, v in c.items():
    if v >= 2:
        ans += (v * (v - 1)) // 2
print(ans)


Measured memory_bytes: 41672
using System;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{
  static void Main(string[] arg)
  {
    int[] tmp1=new int[2];
    int tmpnum=0;
    int count=1;
    string[] x = Regex.Split(Console.ReadLine(),@"\s+");
    tmp1[0]=Convert.ToInt32(x[0]);
    tmp1[1]=Convert.ToInt32(x[1]);

    foreach(string tmpstr in Regex.Split(Console.ReadLine(),@"\s+"))
    {
      tmpnum+=Convert.ToInt32(tmpstr);
      if(tmpnum<=tmp1[1]){
        count++;
      }
      else{
        break;
      }
    }
    Console.WriteLine(count);
  }
  
  
}


Measured memory_bytes: 15956
#include<iostream>
#define INF 100000000
#define rep(i,n) for(int i=n;i>0;i--)
using namespace std;
int p[]={10,50,100,500},s,t[4],o[4];
int func(int x){
	int sum=0;
	for(int i=3;i>=0;i--){
		sum+=x/p[i];
		x-=(x/p[i])*p[i];
	}
	return sum;
}
int main(){
	int pre,now=0;
	while(cin>>s,s){
		if(now)
		cout<<endl;
		int ans=INF,sum=0;
		for(int i=0;i<4;i++){
			cin>>t[i];
			sum+=t[i];
		}
		for(int i=0;i<=t[0];i++)
		for(int j=0;j<=t[1];j++)
		for(int k=0;k<=t[2];k++)
		for(int l=0;l<=t[3];l++){
			if(i*p[0]+j*p[1]+k*p[2]+l*p[3]<s)
				continue;
			pre=func(i*p[0]+j*p[1]+k*p[2]+l*p[3]-s);
			if(ans>pre+sum-(i+j+k+l)){
				ans=pre+sum-(i+j+k+l);
				o[0]=i;
				o[1]=j;
				o[2]=k;
				o[3]=l;
			}
			
		}
		for(int i=0;i<4;i++){
			if(o[i]!=0)
		cout<<p[i]<<' '<<o[i]<<endl;
		}
		now++;
	}
	return 0;
}

Measured memory_bytes: 868
import sys
readline = sys.stdin.readline

def base_10_to_n(i, n):
    if i//n:
        return base_10_to_n(i//n, n) + str(i % n)
    return str(i % n)

def main():
    N, A, B, C = map(int, readline().rstrip().split())
    l = [int(readline()) for _ in range(N)]
    ans = 10**6
    for i in range(4**N):
        b = base_10_to_n(i, 4).zfill(N)
        if '1' not in b or '2' not in b or '3' not in b:
            continue
        ai = [l[j] for j, e in enumerate(b) if e == '1']
        bi = [l[j] for j, e in enumerate(b) if e == '2']
        ci = [l[j] for j, e in enumerate(b) if e == '3']
        cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci))
        ans = min(ans, cost)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  string s;cin>>s;int n=s.size();

  int ans=0;
  for(int i=0;i<n/2;i++)
  	if(s[i]!=s[n-1-i])ans++;
  cout<<ans<<endl;
  
  return 0;
}

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

using namespace std;

#define ll long long

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

    int n;
    cin >> n;


    map<pair<int, int>, int> m;

    for (int i = 1; i <= n; i++) {
        if (i % 10 == 0) continue;
        int t = i;
        while (t > 9) t /= 10;
        m[{t, i % 10}]++;
    }

    ll ans = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            ans += m[{i, j}] * m[{j, i}];
        }
    }

    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> trie((int) 1e6 + 1000, vector<int>(26));
  vector<int> cnt((int) 1e6 + 1000);
  int num = 1;
  vector<string> s(n);
  vector<vector<int>> path(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    reverse(s[i].begin(), s[i].end());
    int cur = 0;
    for (auto& ch : s[i]) {
      path[i].push_back(cur);
      if (trie[cur][ch - 'a'] == 0) {
        trie[cur][ch - 'a'] = num++;
      }
      cur = trie[cur][ch - 'a'];
    }
    cnt[cur]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    vector<int> a(26);
    for (int j = (int) s[i].size() - 1; j >= 0; j--) {
      int cur = path[i][j];
      a[s[i][j] - 'a'] = 1;
      for (int k = 0; k < 26; k++) {
        if (a[k] == 1) ans += cnt[trie[cur][k]];
      }
    }
  }
  cout << ans - n << endl;
  return 0;
}

Measured memory_bytes: 159164
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 INF=1001001001;
const int mod=1e9+7;

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int c=-1;
  for(int i=0;i<n;i++){
    if(s[i]=='C'){c=i;break;}
  }
  if(c==-1){cout<<"No"<<endl;return 0;}
  for(int i=c;i<n;i++){
    if(s[i]=='F'){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 200000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

#define MAX 35
int h,w;
int grid[MAX][MAX];
int dp[MAX][MAX][MAX*MAX];

signed main(){
	cin>>h>>w;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++) cin>>grid[i][j];
	}
	
	for(int i=0; i<=h; i++) for(int j=0; j<=w; j++) for(int k=0; k<=h*w+1; k++) dp[i][j][k]=INF;
	dp[1][1][1]=0;
	
	for(int k=1; k<=h*w; k++){
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				for(int l=0; l<4; l++){
					int x=j+dx[l], y=i+dy[l];
					if((x<1||x>w) || (y<1||y>h)) continue;
					int d=dp[y][x][k+1];
					int g=grid[y][x];
					dp[y][x][k+1]=min(dp[y][x][k+1], dp[i][j][k]+(k-1)*g*2+1+g);
				}
			}
		}
	}
	
	int ans=INF;
	for(int k=1; k<=h*w; k++){
		ans=min(ans, dp[h][w][k]-(k-1));
	}
	cout<<ans<<en;
}





Measured memory_bytes: 12372
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1){
            res*=a;
        }
        a*=a;
        x>>=1;
    }
    return res;
}

int main(){
    int n,m;cin>>n>>m;
    vector<int> cnt(n+1,0);
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        cnt[a]++;
        cnt[b]++;
    }
    for(int i=0;i<=n;i++){
        if(cnt[i]%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

#define ENGZ ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define sfi(x) scanf("%d" , &x)
#define sfi2(x, y) scanf("%d%d" , &x,&y)
#define sfl2(x, y) scanf("%I64d%I64d" , &x,&y)
#define sfl(x) scanf("%I64d" , &x)
#define sfl3(x, y, z) scanf("%I64d%I64d%I64d", &x, &y, &z)
#define sfd(x) scanf("%lf", &x)
#define sfd2(x, y) scanf("%lf", &x, &y)
#define sfs(x) scanf("%s", &x)
#define testv(x) cerr << x << ' '
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define test cerr << "here"
#define fst(x) cout << fixed << setprecision(x)
#define mod 1000000007
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;

long double dp[3003][3003], a[3003];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        dp[0][i] = (1.0 - a[i]) * dp[0][i - 1];
        for (int j = 1; j <= n; j++)
            dp[j][i] = dp[j][i - 1] * (1.0 - a[i]) + dp[j - 1][i - 1] * a[i];
    }
    long double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++)
        ans += dp[i][n];
    cout << fixed << setprecision(9) << ans;
    return 0;
}

Measured memory_bytes: 141056
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        private static List<long> h;

        public static long N { get; private set; }
        public static long A { get; private set; }
        public static long B { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            (N, A, B) = Read3Longs();
            h = new List<long>();
            for (int i = 0; i < N; i++)
            {
                h.Add(ReadLong());
            }

            var l = 0L;
            var r = h.Max() / B + 1;
            while (r - l != 1)
            {
                var mid = (l + r) / 2;

                if (CanKillAllMonster(mid))
                {
                    r = mid;
                }
                else
                {
                    l = mid;
                }
            }

            return r;
        }

        private static bool CanKillAllMonster(long attackCount)
        {
            var count = 0L;
            for (int i = 0; i < N; i++)
            {
                var life = h[i] - B * attackCount;
                if (life <= 0) continue;

                count += (long)Math.Ceiling((double)life / (A - B));
            }

            return count <= attackCount;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main() {
string S; cin>>S;
  cout<<S.at(0)<<S.at(1)<<S.at(2)<<S.at(3)<<" "<<S.at(4)<<S.at(5)<<S.at(6)<<S.at(7)<<S.at(8)<<S.at(9)<<S.at(10)<<S.at(11)<<endl;
}

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

int main(){
  vector<int> vec;
  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int in;
  cin >> in;
  
 cout << vec[in - 1] << endl;
  
}


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

int main() {
    int H, W;
    cin >> H >> W;

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

    int N = 0;
    vector<string> ans;
    for (int i = 0; i < H - 1; i++){
        for (int j = 0; j < W; j++){
            if (a[i][j] > 0){
                if (a[i][j] % 2 != 0){
                    ans.push_back(to_string(i + 1) + " " + to_string(j + 1) + " " + to_string(i + 2) + " " + to_string(j + 1));
                    a[i + 1][j]++;
                    N++;
                }
            }
        }
    }
    for (int i = 0; i < W - 1; i++){
        if (a[H - 1][i] > 0){
            if (a[H - 1][i] % 2 != 0){
                ans.push_back(to_string(H) + " " + to_string(i + 1) + " " + to_string(H) + " " + to_string(i + 2));
                a[H - 1][i + 1]++;
                N++;
            }
        }
    }
    cout << N << endl;
    for (int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 11892
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a*100 + b*10 + c) % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

bool f(int n, int m, vector<int>& v) {
  while (n > 0) {
    if (v.back() < m) {
      return false;
    }
    if (v.back() >= m) {
      v.back() -= m;
      n -= m;
    }
    sort(v.begin(), v.end());
  }
  return true;
}

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

  vector<int> alpha(26);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      char c;
      cin >> c;
      alpha[c - 'a'] += 1;
    }
  }
  sort(alpha.begin(), alpha.end());

  int x, y;
  if (h % 2 == 0 && w % 2 == 0) {
    x = 0, y = 0;
  } else if (h % 2 == 0 && w % 2 != 0) {
    x = 0, y = h - 1;
  } else if (h % 2 != 0 && w % 2 == 0) {
    x = w - 1, y = 0;
  } else {
    x = w - 1, y = h - 1;
  }
  int z = h * w - (h % 2 == 0 ? 0 : w) - (w % 2 == 0 ? 0 : h);

  bool ok = f(z, 4, alpha) && f(y, 2, alpha) && f(x, 2, alpha);
  if (ok) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
constexpr auto INF = 1000000000;

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

	VI w(n), e(n);
	if (s[0] == 'W') {
		w[0] = 1;
		e[0] = 0;
	}
	else {
		w[0] = 0;
		e[0] = 1;
	}
	FOR1(i, n) {
		if (s[i] == 'W') {
			w[i] = w[i - 1] + 1;
			e[i] = e[i - 1];
		}
		else {
			w[i] = w[i - 1];
			e[i] = e[i - 1] + 1;
		}
	}
	int ans = min(e[n - 1] - e[0], w[n - 2]);
	FOR1(i, n - 1) {
		ans = min(ans, w[i - 1] + e[n - 1] - e[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3076
#include<iostream>

using namespace std;

int main() {

  int x;
  cin >> x;

  if ((0 <= x) and (x <= 100)) {
    cout << x * x * x << endl; 
  } else {
    cout << "1から100までの数値を入力してください。" << endl;
  }

  return 0;
}


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

ll N, A[100005], dp[100005][2];

ll solve(ll n, bool t) {
	if (dp[n][t] != -1) return dp[n][t];
	if (n == N-1) {
		if (t) return -A[n];
		else return A[n];
	}
	ll s = 0;
	if (t) {
		s = max(solve(n+1, true) + A[n], solve(n+1, false) - A[n]);
	}
	else {
		s = max(solve(n+1, true) - A[n], solve(n+1, false) + A[n]);
	}
	return dp[n][t] = s;
}

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

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

	memset(dp, -1, sizeof(dp));
	cout << solve(0, false) << "\n";
	
}

Measured memory_bytes: 7296
// stay fuckin hard -- Abhinav -IIITA
#include<bits/stdc++.h>
#define int long long
#define ld long double
using namespace std;
int mod=1e9+7;
ld pi=3.1415926535;
int fun(int a,int b){
	int r=1;
	while(b>0){
		if(b&1){
			r*=a;
			r%=mod;
		}
		b/=2;
		a*=a; a%=mod;
	}
	return r;
}
int32_t main(){
	int n,k; cin>>n>>k;
	int ans=0;
	int dp[k+1]={0};
	for(int i=k;i>0;--i){
		dp[i]=fun((k/i),n);
		for(int ii=2*i;ii<=k;ii+=i){
			dp[i]-=dp[ii]; 
		}
		dp[i]+=mod; dp[i]%=mod;
		ans+=(i*dp[i])%mod; ans+=mod; ans%=mod;
	}
	cout<<ans;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const ll N = 123456;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a[4];

    rep(i , 1 , 3) cin  >> a[i];

    sort(a + 1 , a + 4);

    int diff = a[3] * 2 - a[1] - a[2];

    int ans = 0;

    if(diff % 2 == 0) {
        ans += diff / 2;
    }
    else {
        ans += (diff + 1 + 2) / 2;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int ans = 0,count=0;
	string s;
	cin >> s;
	for (int i = 0; i <= s.length()-1;i++) {
		if (s[i]=='A'|| s[i] == 'C'|| s[i] == 'G'|| s[i] == 'T') {
			count++;
		}
		else {
			if (count>ans) {
				ans = count;
			}
			count = 0;
		}
		if (i == s.length() - 1) {
			if (count > ans) {
				ans = count;
			}
		}
	}
	
	cout << ans << endl;
	
}

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

int main(){
  int N;
  cin >> N;
  vector<pair<string, int>> restaurant(N);
  string s, min_s;
  int p, max_p, num;
  for (int i=0; i<N; i++) {
    cin >> s >> p;
    restaurant.at(i) = make_pair(s, p);
  }
  vector<bool> checker(N, false);
  for (int i=0; i<N; i++) {
    min_s = "zzzzzzzzzz";
    max_p = -1;
    for (int j=0; j<N; j++) {
      if (checker.at(j)) continue;
      if (restaurant.at(j).first < min_s)
        min_s = restaurant.at(j).first;
    }
    for (int j=0; j<N; j++) {
      if (checker.at(j)) continue;
      if (restaurant.at(j).first == min_s && restaurant.at(j).second > max_p) {
        max_p = restaurant.at(j).second;
        num = j;
      }
    }
    cout << num+1 << endl;
    checker.at(num) = true;
  }
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    let x: usize = read!();
    let y: usize = read!();
    let ans = if (x * 2..=x * 4).contains(&y) && y % 2 == 0 {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 2128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_K 100001

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

struct edge { int from, to, cost; };

int K;
vector<edge> G[MAX_K];



void add_edge(int from, int to, int cost) {
    G[from].push_back(edge{from, to, cost});
}

int bfs(int s, int t) {
    int d[MAX_K];
    fill(d, d + K, INF);
    d[s] = 0;
    deque<edge> es;
    for (int i = 0; i < G[s].size(); ++i) {
        edge e = G[s][i];
        if (e.cost == 0) {
            es.push_front(e);
        } else {
            es.push_back(e);
        }
    }
    while (!es.empty()) {
        edge e = es.front(); es.pop_front();
        if (d[e.to] > d[e.from] + e.cost) {
            d[e.to] = d[e.from] + e.cost;
            
            for (int i = 0; i < G[e.to].size(); ++i) {
                edge e1 = G[e.to][i];
                if (e1.cost == 0) {
                    es.push_front(e1);
                } else {
                    es.push_back(e1);
                }
            }
        }
    }
    return d[t];
}

int main() {
    cin >> K;
    for (int i = 1; i <= K; ++i) {
        add_edge(i, (i + 1) % K, 1);
        add_edge(i, (i * 10) % K, 0);
    }
    
    int ans = bfs(1, 0) + 1;
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);

enum Color {
  WHITE, GRAY, BLACK
};

int M[MAX][MAX];
int d[MAX];
int p[MAX];
Color color[MAX];
int n;

void init() {
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INFTY;
  }
}

void dijkstra(int s) {
  init();
  d[s] = 0;
  p[s] = -1;

  while (true) {
    int mincost = INFTY;
    int u;
    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
        mincost = d[i];
        u = i;
      }
    }
    if (mincost == INFTY) break;

    color[u] = BLACK;
    for (int v = 0; v < n; v++) {
      if (M[u][v] != INFTY && color[v] != BLACK) {
        if (d[u] + M[u][v] < d[v]) {
          d[v] = d[u] + M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = INFTY;
    }
  }
  for (int i = 0; i < n; i++) {
    int elem, index, v;
    cin >> v >> elem;
    for (int j = 0; j < elem; j++) {
      int u;
      cin >> u;
      cin >> M[v][u];
    }
  }
  dijkstra(0);
  for (int i = 0; i < n; i++) {
    cout << i << " " << d[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;

    ll sum = 0;
    rep(i, 1, sqrt(n) + 1){
        if(n % i == 0){
            ll a1 = n / i - 1;
            ll a2 = n / (n / i) - 1;
            if(a1 > i){
                sum += a1;
            }
            if(a2 > i){
                sum += a2;
            }
        }
    }

    cout << sum << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
const int mod = 1e9+7;

int dp[45][1<<17];
int main(){
    int n, x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);
    int b = (1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<(1<<17);j++){
            if(dp[i-1][j] == 0) continue;
            for(int k=1;k<=10;k++){
                int nt = (j<<k) + (1<<(k-1));
                nt &= (1<<17)-1;
                if((nt&b) == b) continue;
                dp[i][nt] = (dp[i][nt] + dp[i-1][j])%mod;
            }
        }
    }
    ll ans = 1;
    for(int i=1;i<=n;i++) ans = ans*10%mod;
    for(int j=0;j<(1<<17);j++) ans = (ans - dp[n][j] + mod)%mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 22432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    COMinit();
    ll ans=0;
    for(int i=1;i<=m-1;i++){
        ans=(ans+((m-i)*i)%MOD*(n*n)%MOD)%MOD;
    }
    for(int i=1;i<=n-1;i++){
        ans=(ans+((n-i)*i)%MOD*(m*m)%MOD)%MOD;
    }
    ans=(ans*COM(n*m-2,k-2))%MOD;
    cout<<ans<<endl;
}


Measured memory_bytes: 12160
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;



	cout << !N << endl;

	return 0;
}


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

struct UF{
   vector<int> par;
   vector<int> sz;
   UF(){}
   UF(int n){
       par.resize(n);
       sz.resize(n, 1);
       for(int i = 0; i < n; i++) par[i] = i;
   }
   int find(int x){
       if(x == par[x]) return x;
       return par[x] = find(par[x]);
   }
   void unite(int x, int y){
       x = find(x); y = find(y);
       if(x == y) return;
       if(sz[x] < sz[y]) swap(x, y);
       sz[x] += sz[y];
       par[y] = x;
   }
   bool same(int x, int y){
       return find(x) == find(y);
   }
};

struct edge{
    int u, v, cost;
    bool operator<(const edge &e) const{
        return cost < e.cost;
    }
};

int n, m;
vector<edge> es; 

int kruskal(){
    int res = 0;    
    UF uf(n);
    sort(es.begin(), es.end());
    for(int i = 0; i < m; i++){
        edge e = es[i];
        if(!uf.same(e.u, e.v)){
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        //u--; v--;
        es.push_back({u, v, w});
    }
    cout << kruskal() << endl;
}

/* verified
https://onlinejudge.u-aizu.ac.jp/#/courses/library/5/GRL/2/GRL_2_A

*/


Measured memory_bytes: 4552
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
int x,y;
cin>>x>>y;
if(y>=2*x&&y<=4*x&&y%2==0)
{
	ol("Yes");
}
else
{
	ol("No");
}
return 0;
}



Measured memory_bytes: 3652
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"container/heap"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n, m := scanInt(),scanInt()
	h := &intHeap{}
	heap.Init(h)

	for i := 0; i < n; i++ {
		heap.Push(h,scanInt())
	}

	for i := 0; i < m; i++ {
		a := heap.Pop(h).(int)
		heap.Push(h,a/2)
	}

	arr := *h

	fmt.Println(sum(arr))

}

func sum(a []int) int {
	s := 0
	for _,e := range a {
		s += e
	}
	return s
}

type intHeap []int

func (a intHeap) Len() int           { return len(a) }
func (a intHeap) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a intHeap) Less(i, j int) bool { return a[i] > a[j] }

func (a *intHeap) Push(x interface{}) {
	*a = append(*a, x.(int))
}

func (a *intHeap) Pop() interface{} {
	old := *a
	n := len(old)
	x := old[n-1]
	*a = old[0:n-1]

	return x
}


Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>

#define mx 1000001

using namespace std;

bool prm[mx];
int cnt[mx];

void mkPrm()
{
  fill(prm, prm+mx, true);
  prm[0] = prm[1] = false;

  for(int i = 2; i < mx; ++i)
    if(prm[i])
      for(int j = i+i; j < mx; j+=i) prm[j] = false;

  int t = 0;
  for(int i = 0; i < mx; ++i){
    if(prm[i]) ++t;
    cnt[i] = t;
  }

  return ;
}


int main()
{
  int n, s, p, m, c;
  mkPrm();

  while(cin>>n && n){
    s = 0;
    while(n--){
      cin >> p >> m;
      c = ((p+m >= mx)? cnt[mx-1]: cnt[p+m]);
      c -= (p-m < 1)? cnt[0] : cnt[p-m-1];
      s--;
      if(c > 0) s += c;
    }
    cout << ((s < 0)? 0 : s) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
	ll n;
	cin>>n;
	ll ans=INFl;
	for(int i=1;i<=1000000;i++){
		if(n%i==0){
			ans=min(ans,(i-1)+(n/i-1));
		}
	}
	if(ans==INFl){
		cout<<n<<endl;
	}else{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		long m = sc.nextLong();
		for (long i = 0 ; i < m; i++)
		{
			long money = sc.nextLong();
			long year = sc.nextLong();
			long n = sc.nextLong();
			
			long max = 0;
			
			for (long j = 0; j < n; j++)
			{
				long way = sc.nextLong();
				double p = sc.nextDouble();
				long cost = sc.nextLong();
				
				long currentMoney = money;
				if (way == 0)
				{
					long sum = 0;
					for (long k = 0; k < year; k++)
					{
						sum += currentMoney * p;
						currentMoney -= cost;
					}
					max = Math.max(max, currentMoney + sum);
				}
				else
				{
					for (long k = 0; k < year; k++)
					{
						currentMoney += currentMoney * p - cost;
					}
					max = Math.max(max, currentMoney);
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 13000
#ifdef __APPLE__

    #include <cassert>
    #include <iostream>
    #include <iomanip>
    #include <ctime>
    #include <cstdio>
    #include <vector>
    #include <algorithm>
    #include <utility>
    #include <queue>
    #include <stack>
    #include <string>
    #include <cstring>
    #include <sstream>
    #include <map>
    #include <set>
    #include <unordered_map>
    #include <unordered_set>

#else

    #include <bits/stdc++.h>

#endif

using namespace std;

#define ll long long int

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    cin >> n;
    ll i,a[n+1];
    ll maxi = 0,idx;
    ll cur_idx,cur_max,k;
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<n;i++)
    {
        if(a[i] > maxi)
        {
            maxi = a[i];
            idx = i;
        }
    }
    ll ans = 0;
    while(maxi > n - 1)
    {
        cur_max = 0;
        cur_idx = -1;
        k = maxi/n;
        ans += k;
        for(i=0;i<n;i++)
        {
            if(i == idx) a[i] -= (k*n);
            else a[i] += k;
            if(a[i] > cur_max)
            {
                cur_max = a[i];
                cur_idx = i;
            }
        }
        maxi = cur_max;
        idx = cur_idx;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var (
	n int
	list = []string{"3", "5", "7"}
)

func dfs(s []string) int {
	ret := 0
	if len(s) > 0 {
		ss := strings.Join(s, "")
		sInt, _ := strconv.Atoi(ss)
		if sInt > n {
			return ret
		} else {
			ok := true
			for _, v := range list {
				if !strings.Contains(ss, v) {
					ok = false
				}
			}
			if ok {
				ret++
			}
		}
	}
	for _, v := range list {
		s = append(s, v)
		ret += dfs(s)
		s = s[:len(s)-1]
	}
	return ret
}

func main() {
	io := NewIo()
	defer io.Flush()

	n = io.readInt()
	var s []string
	io.println(dfs(s))
}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) readStringLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) readString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.readStringLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) readInt() int {
	i, err := strconv.Atoi(io.readString())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) printStringSlice(a []string) {
	var b []interface{}
	for _, v := range a {
		b = append(b, v)
	}
	io.println(b...)
}

func (io *Io) printIntSlice(a []int) {
	var b []interface{}
	for _, v := range a {
		b = append(b, v)
	}
	io.println(b...)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}


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


typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes";
	else cout << "No";
	return 0;
}









Measured memory_bytes: 256
#include <iostream>
using namespace std;
int extgcd(int a, int b, int &x, int &y){
    int d = a;
    if(b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else{
        x = 1;
        y = 0;
    }
    return d;
}
int main(){
    int a, b;
    cin >> a >> b;
    int x, y;
    int d = extgcd(a, b, x, y);
    cout << x << ' ' <<  y << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[200000],count=1,min;
    int i,j;
    cin>>n;
    cin>>a[1];
    min=a[1];
    for(i=2;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]<min)
        {
            min=a[i];
            count++;
        }
    }
    cout<<count<<endl;
    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>

std::string a, b;

int main()
{
    std::cin >> a >> b;
    if (a == b)
    {
        puts("EQUAL");
        return 0;
    } 
    if (a.size() == b.size())   puts(a > b ? "GREATER" : "LESS");
    else    puts(a.size() > b.size() ? "GREATER" : "LESS");
    return 0;
}

Measured memory_bytes: 256