akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>
#include <float.h>
#include <math.h>
typedef long long int64;

bool w[3005] = {true};
bool s[3005] = {true};

int main()
{
    int64 a, b, c, d, ee, f;
    long double e;
    long double maxv = 0;

    scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &ee, &f);

    e = (long double)ee + DBL_EPSILON;
    int64 ans_w = 100 * a, ans_s = 0;

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if (100 * a * i + 100 * b * j <= f) {
                w[100 * a * i + 100 * b * j] = true;
            }
        }
    }

    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if (i * c + j * d <= f) {
                s[i * c + j * d] = true;
            }
        }
    }

    for (int i = 0; i <= f; i++) {
        for (int j = 0; j <= f; j++) {
            if (w[i] && s[j] && i + j <= f && i + j > 0) {
                long double freq = 100.0 * j / (long double)(i + j);
                long double E = (long double)j / (long double)i * 100.0;

                if ((E - e < LDBL_EPSILON || fabsl(E - e) < LDBL_EPSILON) &&
                    freq - maxv > LDBL_EPSILON) {
                    
                    maxv = freq;

                    ans_w = i;
                    ans_s = j;
                }
            }
        }
    }

    printf("%lld %lld\n", ans_w + ans_s, ans_s);
    
    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int func(long long n) {
	if (n < 10)return 1;
	return func(n/10)+1;
}
int N;
int ans = -1000000000;
int a[20], F[110][20], P[110][20];
void func() {
	bool isZeroCnt = true;
	REP(i, 10) {
		if (a[i] == 1) {
			isZeroCnt = false;
			break;
		}
	}
	if (isZeroCnt)return;

	int score = 0;
//	cout << a[0] << a[1] << a[2] << a[3] << a[4] << a[5] << a[6] << a[7] << a[8] << a[9] << endl;
	REP(i, N) {
		int cnt = 0;
		REP(j, 10) {
			if (F[i][j] == 1 && a[j] == 1) {
				cnt++;
			}
		}
//		cout << "P[" << i << "][" << cnt << "] = " << P[i][cnt] << endl;
		score += P[i][cnt];
	}
//	cout << "score = " << score << endl;
	ans = max(ans, score);
}
void dfs(int pos) {
	if (pos == 10) {
		func();
		return;
	}
	a[pos] = 0; 
	dfs(pos + 1);
	a[pos] = 1;
	dfs(pos + 1);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	REP(i, N) {
		REP(j, 10) {
			cin >> F[i][j];
		}
	}
	REP(i, N) {
		REP(j, 11) {
			cin >> P[i][j];
		}
	}
	dfs(0);
	cout << ans << endl;
	return 0;
}


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

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

const int mo=998244353;
const int maxn=300007;

ll n,a,b,k,fac[maxn],inv[maxn]; 

ll C(int x,int y){
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}

int qpow(int x,int p){
	int rt=1;
	while(p){
		if(p&1)rt=(1ll*rt*x)%mo;
		x=(1ll*x*x)%mo;
		p>>=1;
	}
	return rt;
}
int res;
int main(){
	fac[0]=inv[0]=1;
	for(int i=1;i<maxn;++i){
		fac[i]=1ll*fac[i-1]*i%mo;
		inv[i]=qpow(fac[i],mo-2);
	}
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	for(int i=0;i<=n&&i*a<=k;++i)
		if((k-i*a)%b==0&&n*b>=k-i*a)
			res=(res+1ll*C(n,i)*C(n,(k-i*a)/b)%mo)%mo;
	printf("%d\n",res);
	return 0;
}



Measured memory_bytes: 4992
#include "iostream"
using namespace std;

int main(void)
{
	int num, player[200][3]={0};

	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> player[i][0] >> player[i][1] >> player[i][2];
	}
	
	bool flag = false;
	for (int j = 0; j < 3; j++) {
		for (int i = 0; i < num; i++) {
			flag = false;
			for (int k = 0; k < num; k++) {
				if (player[i][j] == player[k][j] && i != k) {
					player[k][j] = 0;
					flag = true;
				}
			}
			if (flag) player[i][j] = 0;
		}
	}

	for (int i = 0; i < num; i++) {
		cout << player[i][0] + player[i][1] + player[i][2] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j){
            if (i * 4 + j * 7 == n){
                return 0 & puts("Yes");
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
import scala.io.Source

object Main {
//  def calcMaxProfit(numbers: Seq[Int]): Int = {
//    val maxProfit: Int = (1 to numbers.size-1)
//      .toStream
//      .map{i =>
//        val a  = numbers(i-1)
//        val bs = numbers.toStream.drop(i)
//        bs.max - a
//      }
//      .max
//    maxProfit
//  }

  def calcMaxProfit(numbers: Seq[Int]): Int = {
    var min       = numbers(0)
    var maxProfit = numbers(1) - min
    for(i <- 1 until numbers.size) {
      maxProfit = math.max(maxProfit, numbers(i) - min)
      min = math.min(min, numbers(i))
    }
    maxProfit
  }


  def main(args: Array[String]): Unit = {
    // Get interator of stdin
    val stdinIterator = Source.stdin.getLines()

    // Skip the first line
    stdinIterator.next()

    // Get input
    val numbers: Seq[Int] = stdinIterator.toSeq.map(_.toInt).toArray

    // Calc max profit
    val maxProfit = calcMaxProfit(numbers)

    // Print max profit
    println(maxProfit)
  }
}


Measured memory_bytes: 121892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> pos(N+1);
  rep(i, N) {
    cin >> A[i];
    pos[A[i]] = i;
  }
  vector<int> mxl(N), mxr(N);
  set<int> se;
  se.insert(-1);
  se.insert(N);
  for(int i=1; i<=N; i++) {
    int p = pos[i];
    se.insert(p);
    mxl[p] = *(--se.upper_bound(p-1))+1;
    mxr[p] = *se.lower_bound(p+1)-1;
  }
  ll ans = 0;
  rep(i, N) {
    ans += (ll)A[i] * (i-mxl[i]+1) * (mxr[i]-i+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N,M;

    cin >> N >> M;

    vector<int> C(N,-1);
    bool cant = false;
    
    for(int i = 0; i < M; i++){
        int s,c;
        cin >> s >> c;

        if(C[s-1] == -1){
            C[s-1] = c;
        }else if(C[s-1] != c){
            cant = true;
        }
    }

    if(cant){
        cout << -1 << endl;
        exit(0);
    }

    for(int i = 1; i < N; i++){
        if(C[i] == -1){
            C[i] = 0;
        }
    }

    if(N > 1){
        if(C[0] == 0){
            cout << -1 << endl;
            exit(0);
        }else{
            if(C[0] == -1){
                C[0] = 1;
            }
            for(int i = 0; i < N; i++){
                cout << C[i];
            }
            cout << endl;
        }
    }else{
        if(M == 0){
            cout << 0 << endl;
        }else{
            if(C[0] > -1){
                cout << C[0] << endl;
            }else{
                cout << -1 << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		
		int[] m = new int[w];
		for(int i=0; i<w; i++)
		{
			m[i] = i+1;
		}
		
		for(int i=0; i<n; i++)
		{	
			String s = scanner.next();
			String[] str = s.split(",");
			
			int a = Integer.parseInt(str[0]) -1;
			int b = Integer.parseInt(str[1]) -1;
			
			int buf = m[a];
			m[a] = m[b];
			m[b] = buf;
		}
		
		for(int i=0; i<w; i++)
		{
			System.out.println(m[i]);
		}
	}
}

Measured memory_bytes: 25852
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
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() {
  int k,s;
  cin>>k>>s;
  int ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      int z=s-i-j;
      if(0<=z&&z<=k) ans++;
    }
  }
  cout<<ans<<endl;  
}

Measured memory_bytes: 3484
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define s(x) x.size()

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;
vector<bool> broken(SIZE,false);
ll dp[SIZE];

void solve(){
	int n,m;
	cin >> n >> m;
	bool ok = true;
	for(int i = 1; i <= m; i++){
		int x; cin >> x;
		broken[x] = true;
		if(broken[x-1])
			ok = false;
	}
	if(ok && broken[n] != true){
		if(!broken[1])
		dp[1] = 1;
		if(!broken[2]) 
		dp[2] = dp[1]+1;
		for(int i = 3; i <= n; i++){
			if(!broken[i]){
				if(!broken[i-1])
					dp[i] += dp[i-1];
				if(!broken[i-2])
					dp[i] += dp[i-2];
				dp[i] = dp[i]%mod;
			}
		}
		cout << dp[n] << endl;
	}else{
		cout << 0 << endl;
	}
}	


int main(){ 
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
h = list(map(int,input().split()))

dp = [0] * n

for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[1] - h[0])
    else:
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2])

print(dp[-1])


Measured memory_bytes: 13908
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

n,m = map(int,input().split())

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for _ in range(m):
    a,b = map(int,input().split())
    unite(a-1,b-1)

arr = []
for i in range(n):
    if par[i]<0:
        arr.append(-par[i])

print(max(arr))
        


Measured memory_bytes: 14332
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

int main() {
    int n;
    cin >> n;
    vector<long long> s(n);

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

    sort(s.begin(), s.end());

    if (s[0] == 0) {
        cout << 0 << endl;
    }
    else {
        cpp_int ans = 1, tmp;
        for(i = 0; i < n; i++) {
            tmp = ans;
            ans *= s[i];
            if (ans > 1000000000000000000) {
                ans = -1;
                break;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4092
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{	
	int H, W;

	for (int i = 0;i < 10000;i++)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		for (int j = 0; j < H; j++)
		{
			for (int k = 0; k < W; k++)
			{
				if (j == 0 || j == H - 1 || k == 0 || k == W - 1) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 3016
x,n=map(int,input().split())
s=input()
if n!=0:
  l=list(map(int,s.split()))
  cnt=0
  ans=0
  while True:
    if x-cnt in l:
      if x+cnt in l:
        cnt=cnt+1
      else:
        ans=x+cnt
        break
    else:
      ans=x-cnt
      break
  print(ans)
else:
  print(x)

Measured memory_bytes: 9136
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d,e,k; cin>>a>>b>>c>>d>>e>>k;
    string ans = "Yay!";
    if(e-a>k) ans = ":(";
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 100005
#define P 1000000007
vector<int>d[M];
int sum[M],k;
void dfs(int x,int f,int w){
	sum[x]=w;int cnt=1;if(!f)cnt=0;
	for(int i=0;i<(int)d[x].size();++i){
		int v=d[x][i];
		if(v==f)continue;
		cnt++;dfs(v,x,k-cnt);
	}
}
int main(){
	int n;
	scanf("%d%d",&n,&k);
	for(int i=1,a,b;i<n;++i){
		scanf("%d%d",&a,&b);
		d[a].push_back(b);
		d[b].push_back(a);
	}
	dfs(1,0,k);long long ans=1;
	for(int i=1;i<=n;++i)ans=ans*sum[i]%P;
	printf("%lld",ans);
}

Measured memory_bytes: 10752
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector<bool> a(100000, true);
	a[0] = a[1] = false;
	for (int i = 2; i < 100000; i++)
		if (a[i])
			for (int j = i * 2; j < 100000; j += i)
				a[j] = false;
	vector<ll> v;
	for (int i = 0; i < 100000; i++)
		if (a[i]) v.push_back(i);
	for (;;) {
		int m, a, b; cin >> m >> a >> b;
		if (m == 0) break;
		int _i = 0, _j = 0;
		for (int i = 0; i < v.size(); i++)
			for (int j = i; j < v.size() && v[i] * v[j] <= m; j++)
				if (a * v[j] <= b * v[i] && v[i] * v[j] > v[_i] * v[_j]) {
					_i = i; _j = j;
				}
		cout << v[_i] << ' ' << v[_j] << endl;
	}
}

Measured memory_bytes: 1352
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int main(){
    int n;
    cin >> n;
    vector<long long> A(n,0);
    long long ans=0;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }

    sort(A.begin(),A.end());

    ans = A[n-1];
    int cnt=n-2;
    n-=2;
    while(n>0){
        if(n>1){
            ans += A[cnt]*2;
            cnt--;
            n-=2;
        }else{
            ans += A[cnt];
            n--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4836
public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		int prd = a * b;
		String ans = "";
		if (prd % 2 == 0){
			ans = "Even";
		} else {
			ans = "Odd";
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23124
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, K;
    cin >> N >> K;

    vll A(N);
    REP(i, N) cin >> A[i];

    FOR(i, K, N) {
        if (A[i - K] < A[i]) print("Yes");
        else print("No");
    }
    
}


Measured memory_bytes: 4712
#include<bits/stdc++.h>
using namespace std;
const int maxn=30000+10;

int n;
string s;
bool l[maxn][10],r[maxn][10];
bool f[1000];
int kq;

int main(){
    cin>>n>>s;s=" "+s;
    for(int j=0;j<10;j++) l[0][j]=false;
    for(int j=0;j<10;j++) r[n+1][j]=false;
    for(int i=1;i<=n;i++){
        for(int j=0;j<10;j++)
            l[i][j]=l[i-1][j];
        l[i][s[i]-'0']=true;
    }
    for(int i=n;i>=1;i--){
        for(int j=0;j<10;j++)
            r[i][j]=r[i+1][j];
        r[i][s[i]-'0']=true;
    }
    for(int i=0;i<1000;i++) f[i]=false;
    for(int i=2;i<=n-1;i++){
        for(int ii=0;ii<10;ii++)
            for(int jj=0;jj<10;jj++){
                int z=ii*100+(s[i]-'0')*10+jj;
                if (l[i-1][ii]==true && r[i+1][jj]==true){
                    f[z]=true;
//                    cout<<"Z= "<<z<<endl;
                }
            }
    }
    kq=0;
    for(int i=0;i<1000;i++)
        if (f[i]==true) kq++;
    cout<<kq;
}


Measured memory_bytes: 896
N=int(input())
A=list(map(int,input().split()))
Deposit=1000
Stock=0
A.insert(0,201)

j=0
while j<len(A)-1:
    if A[j]==A[j+1]:
        A.pop(j)
    else:
        j+=1

if N==2:
    if A[1]<A[2]:
        Deposit=1000-1000//A[1]*A[1]+1000//A[1]*A[2]        
else:
    for i in range(len(A)-2): 
        if A[i]>A[i+1] and A[i+1]<A[i+2]: #minima price
            Stock=Deposit//A[i+1]
            Deposit=Deposit-Stock*A[i+1]
        elif A[i]<A[i+1] and A[i+1]>A[i+2]: #maxima price
            Deposit=Deposit+Stock*A[i+1]
            Stock=0
        i+=1
        
Deposit=Deposit+Stock*A[-1]

print(Deposit)

Measured memory_bytes: 9252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	string s,t;
	cin >> s >> t;

	char c[26],d[26];
	for(int i=0;i<26;i++) c[i] = 0,d[i]=0;

	for (int i = 0; i < s.length(); i++){
			if (c[s[i] - 'a'] == 0){
				c[s[i] - 'a'] = t[i];
			}else if (c[s[i] - 'a'] != t[i]){
				cout << "No" << endl;
				//cout << s[i] << t[i] << endl;
				return 0;
			}
			if (d[t[i] - 'a'] == 0){
				d[t[i] - 'a'] = s[i];
			}else if (d[t[i] - 'a'] != s[i]){
				cout << "No" << endl;
				//cout << s[i] << t[i] << endl;
				return 0;
			}
		
	}
	cout << "Yes" << endl;
	return 0;
	
}


Measured memory_bytes: 776
#include <iostream>

using namespace std;

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

// A function to implement bubble sort
void bubbleSort(int arr[], int n)
{
   int i, j;
   for (i = 0; i < n-1; i++)

       // Last i elements are already in place
       for (j = 0; j < n-i-1; j++)
           if (arr[j] > arr[j+1])
              swap(&arr[j], &arr[j+1]);
}


int main()
{
    int n,x,k=0,s=0;
    cin>>n>>x;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    bubbleSort(A,n);
    for(int i=0;i<n;i++){
        s=s+A[i];
        if(s>x){
            k=i;
            break;
        }
        if(x>s && i==n-1){k=n-1; break;}
        k=n;
    }
    cout<<k;
    return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

$odd = $even = $half = 0;

for ($i = 0; $i < $N; $i++) {
    switch ($a[$i] % 4) {
        case 1:
            $odd++;
            break;
        case 0:
            $even++;
            break;
        case 3:
            $odd++;
            break;
        case 2:
            $half++;
            break;
    }
}

if ($half == 0) {
    if ($odd <= $even + 1) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
} else {
    if ($odd <= $even) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
}


Measured memory_bytes: 12792
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
bool isPrime[1000010];

void set_prime() {
    for(int i = 0; i <= 1000010; i++) isPrime[i] = true;
	isPrime[0] = false;
	isPrime[1] = false;
	for (int i = 2; i < 2000; i++) {
		int j = 2;
		while (i * j <= 1000000) {
			isPrime[i*j] = false;
			j++;
		}
	}
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    set_prime();
    vector<int> v;
    REP(i, 7, 55555) {
        if(isPrime[i] && i % 5 == 1) {
            v.push_back(i);
        }
    }
    rep(i, N) {
        if(i != 0) cout << " ";
        cout << v[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4508
c = input()
chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
for index, cc in enumerate(chars):
    if c == 'y':
        print('z')
        exit(0)
    elif c == cc:
        print(chars[index + 1])
        exit(0)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
    char t1[1510];
    char t2[1510];

int main(){

    int n;
    int a=0,b=0;
    int i;

    scanf("%d",&n);
      for(i=0;i<n;i++){
        scanf("%s %s",&t1,&t2);
          if(strcmp(t1,t2)==0) a++,b++;
           if(strcmp(t1,t2)>0) a+=3;
            if(strcmp(t1,t2)<0) b+=3;
    }
    printf("%d %d\n",a,b);

    return 0;
}


Measured memory_bytes: 2060
#include<stdio.h>

int main(){
  int n,m,c,i,j,kari,kotae=0;
  scanf("%d%d%d",&n,&m,&c);
  int a[m],b[m];
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(j=0;j<n;j++){
    kari=0;
    for(i=0;i<m;i++){
      scanf("%d",&a[i]);
      kari+=a[i]*b[i];
    }
    if(kari+c>0){
      kotae++;
    }
  }
  printf("%d",kotae);
  return 0;
}
  


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

int main(void){
    char s1[10];
    char s2[10];
    int a,i;
    scanf("%s",s1);
    scanf("%s",s2);
    strcat(s1,s2);
    a = atoi(s1);
    for(i=1;i*i<=a;i++){
        if(a==i*i){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    //printf("%d",a);
    return 0;
}


Measured memory_bytes: 128
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: &str = iterator.next().unwrap();

    let ans = match s {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        "SAT" => 1,
        _ => 0,
    };

    return ans.to_string();
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int X, A, B;
	cin >> X >> A >> B;

	cout << (X - A) % B << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i = a;i<=b;++i)
#define For_(i,a,b) for(int i = a;i>=b;--i)
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
inline int read(){
    register int r = 0,f = 1;
    register char c = getchar();
    while(c<'0' || c >'9'){
        if(c =='-') f = -1;
        c = getchar();
    }
    while(c>='0' && c<='9'){
        r = (r<<1) + (r<<3) + c - '0';
        c = getchar();
    }
    return r * f;
}
const int N = 100 + 2 , INF = 0x3f3f3f3f;
int n;
int a[N],b[N];
int main(){
    n = read();
    For(i,1,n) a[i] = read() , b[i] = read();
    int res = 0;
    For(i,1,n){
        if(a[i] == b[i]){
            res++;
            if(res == 3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else res = 0;
    }
    cout<<"No"<<endl;
    system("pause");
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<stdio.h>
using namespace std;


int main(){
    while(1){
        int h, w;
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
import copy
h,w,k=map(int,input().split())
c=[[[".","#"].index(j)for j in list(input())]for i in range(h)]
p=0
for i in range(2**h):
    a=bin(i)[2:].zfill(h)
    for j in range(2**w):
        b=bin(j)[2:].zfill(w)
        d=copy.deepcopy(c)
        for x in range(w):
            if b[x]=="1":
                for y in range(h):
                    d[y][x]=0
        for x in range(h):
            if a[x]=="1":
                d[x]=[0]*w
        q=0
        for x in d:
            q+=sum(x)
        if q==k:
            p+=1
print(p)

Measured memory_bytes: 9272
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(b % a == 0 ? a+b : b-a);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 32768
use std::collections::*;
use std::io::*;
use std::*;
// template {{{
macro_rules! get {
        ($($t:tt),*; $n:expr) => {
            {
                let stdin = std::io::stdin();
                let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                    let line = line.unwrap();
                    let mut it = line.split_whitespace();
                    _get!(it; $($t),*)
                }).collect::<Vec<_>>();
                ret
            }
        };
        ($($t:tt),*) => {
            {
                let mut line = String::new();
                std::io::stdin().read_line(&mut line).unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }
        };
    }
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        _get!($it; String).bytes().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_get!($it; $t)),*)
    };
}
// }}}

fn main() {
    let x = get!(i32);
    let rank = 8 - (x - 400) / 200;
    println!("{}", rank);
}


Measured memory_bytes: 2140
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] N = scanner.next().toCharArray();
			Map<Character, Integer> map = new HashMap<>();
			map.put('o',0);
			map.put('x',0);

			for (char c : N) {
				map.put(c, map.get(c) + 1);
			}
			System.out.println(700 + (map.get('o') * 100));
		}
	}
}


Measured memory_bytes: 22868
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**5+10)

n = int(input())
visited = set()
g = {}
idx = {}
color = {}
for i in range(n-1):
    a,b = map(int, input().split())
    idx[i] = (a,b)
    if a not in g:
        g[a] = []
    g[a].append(b)
    if b not in g:
        g[b] = []
    g[b].append(a)

def dfs(v,c):
    cc = 0
    for u in g[v]:
        if u in visited:
            continue
        visited.add(u)

        cc += 1
        while cc==c:
            cc += 1
        a,b = min(u,v),max(u,v)
        color[(a,b)] = cc
        
        dfs(u,cc)
visited.add(1)
dfs(1,0)

mc = 0
for c in color.values():
    mc = max(mc, c)
print(mc)
for i in range(n-1):
    print(color[idx[i]])

Measured memory_bytes: 121008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Scanner scan = new Scanner(System.in);

		String str1 = br.readLine();

		String str2;

		int count =0;

		while (true) {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				}
		}

		System.out.println(count);
 }

}

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

typedef long long ll;

void solve() {
    string S;
    cin >> S;
    int K;
    cin >> K;
    int N = S.size();

    int dp[105][4][2] = {};

    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 2; k++) {
                int nd = S[i] - '0';
                for (int d = 0; d < 10; d++) {
                    int ni = i+1, nj = j, nk = k;
                    if (d != 0) nj++;
                    if (nj > K) continue;
                    if (k == 0) {
                        if (d > nd) continue;
                        if (d < nd) nk = 1;
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    int ans = dp[N][K][0] + dp[N][K][1];
    cout << ans << endl;
}


int main() {
   solve();
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
LL dp[256][2];
int d(int v){
  return v*v;
}
int ran(int v){
  if(v<0) return 0;
  return min(255,v);
}
int main(void)
{
  for(;;){
    int n,m;
    cin >> n >> m;
    if(!n&&!m) return 0;
    vector<int> alt;
    alt.resize(m);
    REP(i,m) cin >> alt[i];
    REP(i,256) dp[i][0]=1147483647;
    dp[128][0]=0;
    REP(i,n){
      int x;
      cin >> x;
      REP(j,256) dp[j][(i+1)%2]=2147483647;
      REP(j,256){
	REP(k,m){
	  int nv=ran(j+alt[k]);
	  dp[nv][(i+1)%2]=min(dp[nv][(i+1)%2],dp[j][i%2]+d(nv-x));
	}
      }
    }
    LL answer=2147483647;
    REP(i,256) answer=min(answer,dp[i][n%2]);
    cout << answer << endl;
    
  }
}

Measured memory_bytes: 3104
from collections import Counter

S = input()
N = len(S)
cntS = Counter(S)
print('YES' if abs(cntS['a']-cntS['b'])<=1 and abs(cntS['b']-cntS['c'])<=1 and abs(cntS['c']-cntS['a'])<=1 else 'NO')


Measured memory_bytes: 39728
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        x: i64, a: i64, b: i64
    }
    println!("{}", if (x-a).abs()<(x-b).abs() {"A"} else {"B"});
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#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
const long long MOD = 1000000007;
using namespace std;

char str[100005];
ll dp[100005][13];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int len=strlen(str);

    dp[0][0]=1;
    int i,j,k;
    for(i=1; i<=len; i++) {
        if(str[i-1]=='?') {
            for(j=0; j<=9; j++) {
                for(k=0; k<13; k++) {
                    dp[i][(k*10+j)%13]+=dp[i-1][k];
                    dp[i][(k*10+j)%13]%=MOD;
                }
            }
        }
        else {
            j=str[i-1]-'0';
            for(k=0; k<13; k++) {
                dp[i][(k*10+j)%13]+=dp[i-1][k];
                dp[i][(k*10+j)%13]%=MOD;
            }
        }
    }
    printf("%lld\n", dp[len][5]);

    return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>
int main()
{
	int n;
	int d[1000];
	int ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&d[i]);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=d[i]*d[j];
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (i % 2 == 0) {
            cout << s[i];
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3724
n = int(input())
a = list(map(int, input().split()))

if n == 2:
    print(max(a[0], a[1]))
    exit()
elif n == 3:
    ans = max(a[0], a[1])
    print(max(ans, a[2]))
    exit()

if n % 2 == 0:
    inf = - float('inf')
    dp = [[inf, inf] for _ in range(n)]
    dp[0][0] = a[0]
    dp[1][1] = a[1]
    dp[2][0] = a[0] + a[2]

    for i in range(3, n):
        if i % 2 == 0:
            dp[i][0] = dp[i - 2][0] + a[i]
        dp[i][1] = max(dp[i - 3][0], dp[i - 2][1]) + a[i]

    #print(dp)
    print(max(dp[n-1][1], dp[n-2][0]))
    exit()

inf = - float('inf')
dp = [[inf, inf, inf] for _ in range(n)]
dp[0][0] = a[0]
dp[1][1] = a[1]
dp[2][0] = a[0] + a[2]
dp[2][2] = a[2]
dp[3][1] = max(a[0], a[1]) + a[3]

for i in range(4, n):
    if i % 2 == 0:
        dp[i][0] = dp[i-2][0] + a[i]
    dp[i][1] = max(dp[i-3][0], dp[i-2][1]) + a[i]
    temp = max(dp[i-4][0], dp[i-3][1])
    dp[i][2] = max(temp, dp[i-2][2]) + a[i]

ans = max(dp[n-1][2], dp[n-2][1])
print(max(ans, dp[n-3][0]))

Measured memory_bytes: 129712
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int T,a,b;ll ans;
db cal(ll x) {return (-(ll)b*x-1)*1./(a+x);}
int main()
{
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	for(scanf("%d",&T);T--;)
	{
		scanf("%d%d",&a,&b),ans=0;
		if(a<b) swap(a,b);
		if(a==1&&b==1) {puts("0");continue;}
		if(b>=10000)
		{
			ll dd=sqrt(1ll*a*b),ans=dd*2-1;
			if(dd*dd==1ll*a*b)
			{
				if(a==b)ans--;
				else ans-=2;
			}
			else if(dd*(dd+1)>=1ll*a*b)ans--;
			cout<<ans<<endl;
			continue;
		}
		/*
		for(ll x=-a+1,y,tmp;;x++)
		{
			tmp=floor(((ll)-b*x-1)*1./(a+x));
			dbg1(x),dbg2(tmp);
			if(tmp==-b) break;
			if(tmp)
			{
				if(tmp^last) ans++,last=tmp;
				else
				{
					ans+=tmp+b-1;
					if(tmp>0) ans--;
					break;
				}
			}
		}
		dbg2(ans);*/
		ll l=-a+1,r=1e10,mid;
		for(;l<r;)
		{
			mid=l+r>>1;
//			dbg2(mid);
//			dbg1(cal(mid+1)),dbg2(cal(mid));
			cal(mid)-cal(mid+1)<1?r=mid:l=mid+1;
		}
//		dbg2(l);
		ll tmp1=floor((-(ll)b*l-1)*1./(a+l));
		ans=l+a+tmp1+b-1;
		if(l==-a+1)
		{
			if(tmp1>=0) ans--;
			cout<<ans<<"\n";
			continue;
		}
		ll tmp2=floor((-(ll)b*(l-1)-1)*1./(a+l-1));
//		dbg1(l-1),dbg1(cal(l-1)),dbg2(tmp2);
//		dbg1(l),dbg1(cal(l)),dbg2(tmp1);
//		dbg1(tmp1),dbg2(tmp2);
		if(tmp1>=0||tmp2<=0) ans--;
//		printf("%lld\n",ans);
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;

/**
 * 連結成分
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_D&lang=ja">ALDS1_11_D</a>
 */
public class Main{

	private static int n, m;
	private static Map<Integer, List<Integer>> g = new HashMap<>();
	private static int color[] = new int[100000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();

		for (int i = 0; i < n; i++) {
			List<Integer> list = new ArrayList<>();
			g.put(i, list);
		}

		for (int i = 0; i < m; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g.get(s).add(t);
			g.get(t).add(s);
		}

		assignColor();

		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			if (color[s] == color[t]) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}

		sc.close();
	}

	private static void assignColor() {
		int id = 1;
		Arrays.fill(color, -1);
		for (int i = 0; i < n; i++) {
			if (color[i] == -1) dfs(i, id++);
		}
	}

	private static void dfs(int r, int c) {
		Stack<Integer> s = new Stack<>();
		s.push(r);
		color[r] = c;
		while (!s.isEmpty()) {
			int u = s.pop();
			for (int v : g.get(u)) {
				if (color[v] == -1) {
					color[v] = c;
					s.push(v);
				}
			}
		}
	}

}



Measured memory_bytes: 121268
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

a=i_inpl()
b=i_inpl()
c=i_inpl()
d=i_inpl()
e=i_inpl()
k=i_inpl()

if e-a<=k:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3700
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let mut res = 0;
    for (c1, c2) in s.iter().zip(t.iter()) {
        if c1 != c2 {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4012
// abc055_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

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

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    int x = N * 800;
    int y = (N / 15) * 200;
    print(x - y);


    return 0;
}


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

// UnionFind
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n, -1) {} // each node has "minus-size"
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (-d[x] < -d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
    int component() {
        set<int> S;
        rep(x,d.size()) S.insert(find(x));
        return S.size();
    }
};

ll comb2(ll n) {return n*(n-1)/2;}

int main() 
{
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> v;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        v.push_back(make_pair(a,b));
    }
    ll S[m+1];
    rep(i,m+1) S[i] = 0;
    S[m] = comb2(n);

    UnionFind un(n);
    for (int i=m-1; i>=0; i--) {
        int a = v[i].first;
        int b = v[i].second;
        if (un.same(a,b)) {
            S[i] = S[i+1];
            continue;
        }

        int x = un.size(a);
        int y = un.size(b);
        un.unite(a,b);
        int z = un.size(a);
        S[i] = S[i+1] + comb2(x) + comb2(y) - comb2(z);   
    }

    for (int i= 1; i<=m; i++) {
        cout << S[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  int n;
  std::cin >> n;

  std::set<std::string> S;

  for(int i=0; i<n; i++){
    std::string s;
    std::cin >> s;
    S.insert(s);
  }

  std::cout << S.size() << std::endl;
  
  return 0;
}


Measured memory_bytes: 19148
#include <iostream>

using namespace std;

int main(){
  int a, b, ret = 0;
  cin >> a >> b;
  if (a < b) ret = b + b - 1;
  else if (a > b) ret = a + a - 1;
  else ret = a * 2;
  cout << ret << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n,sum=0;
    cin >> n;
    for (ll i=1;i<=n;++i) {
        if (i%3==0)
            continue;
        else if (i%5==0)
            continue;
        sum += i;
    }
    cout << sum;
}


Measured memory_bytes: 3636