akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

bool isOK(int index,int key,vector<int>&a){
	if(a[index]>=key)return true;
	else return false;
}

long long binary_search(int key,vector<int>&a){
	long long ng = -1;
	long long ok = (int)a.size();
	
	while(abs(ok-ng)>1){
		int mid = (ok+ng)/2;
		if(isOK(mid,key,a)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(void){
	int N;
	long long ans = 0;
	cin >> N;
	vector<vector<int>> a(3,vector<int>(N));
	for(int j=0;j<3;j++)for(int i=0;i<N;i++)cin>>a[j][i];
	for(int j=0;j<3;j++)sort(a[j].begin(),a[j].end());
	for(int i=0;i<N;i++){
		int key = a[1][i];
		long long ac = binary_search(key,a[0]);
		long long cc = N - binary_search(key+1,a[2]);
		ans += ac*cc;
	}
	cout << ans << endl;
}
	


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	
	string s;
	cin>>s;
	cout<<s;
	if(s.back()=='s')cout<<"es";
	else cout<<"s";
}


Measured memory_bytes: 3592
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


int main() {
    int N;
    cin>>N;
    int i,j,kuku;

    for(i=0;i<9;i++) {
        for (j = 0; j < 9; j++) {
            kuku = (i + 1) * (j + 1);
            if (N == kuku) {
                std::cout << "Yes";
                break;
            }
        }
        if(N==kuku){
        break;
        }
    }
    if(N!=kuku){
        std::cout<<"No";
    }

return 0;
}



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

int H[100005], n;
int dp[100005];

int abs( int x ){
	if ( x < 0 ) return -x;
	return x;
}

int f( int pos ){
	if ( pos == n ) return 0;
	int &ans = dp[pos];
	if ( ans != -1 ) return ans;
	ans = 1e9;
	if ( pos + 2 <= n ) ans = min( ans, f(pos+2) + abs(H[pos] - H[pos+2]));
	ans = min( ans, f(pos+1) + abs(H[pos] - H[pos+1]));
	return ans;
}

int main(){

	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	for ( int i = 1; i <= n; i++ ){
		scanf("%d",&H[i]);
	}

	printf("%d\n",f(1));
	return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int x;
  cin >> x;
  
  for(int i = -1000; i <= 1000; ++i){
    for(int j = -1000; j <= 1000; ++j){
      if(pow(i, 5.0) - pow(j, 5.0) == x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4104
#include <bits/stdc++.h>
#include <climits>
using namespace std;
// rep macro
#define rep(i, n)        for (int i = 0; i < (int)(n); i++)
#define rev(i, n)        for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n)    for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n)    for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n)     for (int i = 0; i < (1 << (int)(n)); i++)
#define bitrep2(i, s, n) for (int i = (s); i < (1 << (int)(n)); i++)
// vector macro
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using vl  = vector<long>;
using vvl = vector<vector<long>>;
using vb  = vector<bool>;
using vvb = vector<vector<bool>>;
// math macro
#define lcm(a, b) a / __gcd(a, b) * b
// print macro
#define println(x) cout << x << endl
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
// pair macro
#define x first
#define y second
using pii = pair<int, int>;
using pdd = pair<double, double>;
// memo
// desc sort: sort(vec.begin(), vec.end(), greater<int>());

int main()
{
    int n; cin >> n;
    vi p(n), q(n); rep(i, n) cin >> p[i]; rep(i, n) cin >> q[i];
    vi I(n); iota(all(I), 1);
    int a, b, cnt = 0;
    do { cnt++; if (I == p) a = cnt; if (I == q) b = cnt;} while (next_permutation(all(I)));
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)
#define MOD_PRIME = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL n, m;
    vector<LL> a;
    cin >> n >> m;
    LL all_vote = 0;
    REP(i, n)
    {
        LL temp;
        cin >> temp;
        a.push_back(temp);
        all_vote += temp;
    }

    LL border_cnt = 0;
    string ret = "No";
    REP(i, n)
    {
        if(4 * m * a.at(i) >= all_vote)
        {
            border_cnt++;
            if(border_cnt >= m)
            {
                ret = "Yes";
                break;
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

const int N = 10;
int main() {
    int a[N] = {};

    for (int i = 0; i < 6; ++i) {
        int x;
        cin >> x;
        ++a[x];
    }
    bool ok = true;
    for (int i = 0; i < N; ++i) {
        if (a[i] >= 3) ok = false;
    }

    cout << (ok?"YES":"NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  ll x,y;
  cin>>x>>y;
  if(abs(x-y)<=1){
    cout<<"Brown"<<endl;
  }
  else cout<<"Alice"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b)
{
  if (b > a)
  {
    int temp = a;
    a = b;
    b = temp;
  }
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
void p_1()
{
  int N;
  cin >> N;
  int num[N];
  for (int i = 0; i < N; i++)
    cin >> num[i];
  int res = num[0];
  for (int i = 1; i < N; i++)
  {
    if (res == 1)
      break;
    res = gcd(res, num[i]);
  }
  cout << res;
}

int main(void)
{
  p_1();
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<math.h>
#include<vector>
using namespace std;

int main()
{
  int t;
  cin>>t;
  
  vector<string>vec;
  for(int i=0; i<t; i++){
      string x;
      cin>>x;
      vec.push_back(x);
      
      
  }
  string a= "AC", b="TLE", d= "WA", e="RE";
  int a1=0, b1=0, d1=0, e1=0;
  
  for(int i=0; i<vec.size(); i++){
      if(vec[i]==a){
          a1++;
      }
      if(vec[i]==b){
          b1++;
      }
      if(vec[i]==d){
          d1++;
      }
      if(vec[i]==e){
          e1++;
      }
    

  }
  
  cout<<a<<" x "<<a1<<endl;
  cout<<d<<" x "<<d1<<endl;
  cout<<b<<" x "<<b1<<endl;
  cout<<e<<" x "<<e1<<endl;
  
  
  
    return 0;
}


Measured memory_bytes: 7448
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  string s;
  cin >> s;
  int k;
  cin >> k;
  int ans = 0;
  vector<int> v(1, 1);
  for (int i = 1; i < sz(s); i++) {
    if (s[i] == s[i - 1]) {
      v.back()++;
    } else {
      v.push_back(1);
    }
  }
  int ans2 = 0;
  for (auto &el : v) ans2 += el / 2;
  if (sz(v) == 1) {
    ans = (sz(s) * k) / 2;
  } else if (s[0] == s.back()) {
    v.back() += v[0];
    for (int i = 1; i < sz(v); i++) {
      ans += v[i] / 2;
    }
    ans *= k - 1;
    ans += ans2;
  } else {
    ans = ans2 * k;
  }
  cout << ans << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=300005;
ll a[N];
multiset<ll> sa1,sa2,sb1,sb2;
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  ll sum1=0,sum2=0,ans=-LLONG_MAX;
  cin>>n;
  rep(i,1,3*n+1) cin>>a[i];
  rep(i,1,n+1) sum1+=a[i],sa1.insert(a[i]);
  rep(i,n+1,3*n+1)
    {
      if(sz(sb1)<n) sb1.insert(a[i]),sum2+=a[i];
      else
	{
	  auto it=sb1.end();
	  it=prev(it);
	  if(*it<=a[i]) sb2.insert(a[i]);
	  else
	    {
	      sb2.insert(*it); sum2-=*it;
	      sb1.erase(it);
	      sb1.insert(a[i]); sum2+=a[i];
	    }
	}
    }
  ans=sum1-sum2;
  rep(i,n+1,2*n+1)
    {
      ll x=*sa1.begin();
      if(x>=a[i]) sa2.insert(a[i]);
      else
	{
	  sa1.erase(sa1.begin()); sum1-=x;
	  sa2.insert(x);
	  sa1.insert(a[i]); sum1+=a[i];
	}
      if(sb1.find(a[i])!=sb1.end())
	{
	  sb1.erase(sb1.find(a[i])); sum2-=a[i];
	  sb1.insert(*sb2.begin()); sum2+=*sb2.begin();
	  sb2.erase(sb2.begin());
	}
      else
	sb2.erase(sb2.find(a[i]));
      ans=max(ans,sum1-sum2);
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

// 1-indexedのBIT
template <typename T>
struct BIT {
    vector<T> array;
    const int N;

    // 0として初期化
    BIT(int _N) : array(_N + 1, 0), N(_N) {}

    // 左からi番目にxを加える
    void add(int i, T x){
        int lsb;
        while(i <= N){
            array[i] += x;
            array[i] %= MOD;
            lsb = i & (-i);
            i += lsb;
        }
    }

    //左からi番目までのSUMを得る
    T getSUM1(int i){
        T ret = 0;
        int lsb;
        while(i >= 1){
            ret += array[i];
            ret %= MOD;
            lsb = i & (-i);
            i -= lsb;
        }
        return ret;
    }

    //左からi番目からj番目のSUMを得る
    T getSUM(int i, int j){
        return (getSUM1(j) - getSUM1(i-1) + MOD) % MOD;
    }
};

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

    BIT<ll> bit(N);
    bit.add(1, 1);
    for (ll i = 2; i < N+1; i++) {
        ll tmp = 0;
        for (ll j = 0; j < K; j++) {
            if(i - R[j] >= 1){
                tmp += bit.getSUM(i-R[j], i-L[j]);
            }
            else if(i - L[j] >= 1){
                tmp += bit.getSUM1(i-L[j]);
            }
        }
        bit.add(i, tmp);
    }

    printf("%lld\n", bit.getSUM(N, N));



}

Measured memory_bytes: 4824
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int ans = 0;
        for(int i=1; i<=a; i++) {
            int count = 0;
            if(i%2 ==1) {
                for(int j=1; j<=a; j++) {
                    if(i%j == 0) {
                        count++;
                    }
                }
                if(count == 8) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <vector>
using namespace std;

int N,K,A[100010],ans;
vector<int> G[100010];

int dfs(int x, int l)
{
	int mx = 0;
	for (int y : G[x]){
		int d = dfs(y,x);
		if (mx < d + 1)
			mx = d + 1;
	}

	if (x > 1){
		if (mx == K && l != 1){
			ans++;
			return -1;
		}
	}
	return mx;
}

int main()
{
	scanf ("%d %d",&N,&K); K--;
	for (int i=1;i<=N;i++) scanf ("%d",&A[i]);

	if (A[1] != 1) A[1] = 1, ans = 1;

	for (int i=2;i<=N;i++) G[A[i]].push_back(i);
	dfs(1,0);

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

	return 0;
}

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

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  // cout << s << endl;
  // cout << t << endl;

  if(s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
//AT2084
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	bool c,f;
	
	c = false;
	
	cin >> s;
	
	for (int i = 0;i < s.size();i ++)
	{
		if(c == false&&s[i] == 'C')
		{
			c = true;
		}
		if(c == true&&s[i] == 'F')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
} 

Measured memory_bytes: 256
N, A, B = map(int, input().split())
v = sorted(list(map(int, input().split())), reverse=True)

print(sum(v[:A]) / A)

x = v.count(v[A - 1])
y = v[:A].count(v[A - 1])
if v[0] != v[A - 1]:
    u = 1
    d = 1
    for i in range(x, x - y, -1):
        u *= i
    for i in range(y, 0, -1):
        d *= i
    print(u // d)
else:
    ans = 0
    for i in range(A, min(B, x) + 1):
        u = 1
        d = 1
        for j in range(x, x - i, -1):
            u *= j
        for j in range(i, 0, -1):
            d *= j
        ans += u // d
    print(ans)

Measured memory_bytes: 3064
import sys

class Dice:
    def __init__(self, labels):
        self.labels = labels
    def east(self):
        self.labels[0], self.labels[2], self.labels[5], self.labels[3] = self.labels[3], self.labels[0], self.labels[2], self.labels[5]
    def west(self):
        self.labels[0], self.labels[2], self.labels[5], self.labels[3] = self.labels[2], self.labels[5], self.labels[3], self.labels[0]
    def north(self):
        self.labels[0], self.labels[1], self.labels[5], self.labels[4] = self.labels[1], self.labels[5], self.labels[4], self.labels[0]
    def south(self):
        self.labels[0], self.labels[1], self.labels[5], self.labels[4] = self.labels[4], self.labels[0], self.labels[1], self.labels[5]

dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

south_cnt = 0

for i in range(8):
    for j in range(4):    
        if dice1.labels[0] == dice2.labels[0] and dice1.labels[1] == dice2.labels[1] and dice1.labels[2] == dice2.labels[2] and dice1.labels[3] == dice2.labels[3] and dice1.labels[4] == dice2.labels[4] and dice1.labels[5] == dice2.labels[5]:
            print("Yes")
            sys.exit()

        dice2.south()
        dice2.east()
        dice2.north()

    if south_cnt == 4:
        dice2.east()
    else:
        dice2.south()
        south_cnt += 1
    
print("No")



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

int main() {
  long long int n,c,k;
  cin >> n >> c >> k;
  vector<long long int> list(n);
  for (long long int i=0;i<n;i++) {
    cin >> list.at(i);
  }
  sort(list.begin(), list.end());
  long long int count=1,temp_time=list.at(0),temp_num=0;
  
  for (int i=0;i<n;i++) {
    temp_num++;
    if (temp_num>c||list.at(i)-temp_time>k) {
      count++;
      temp_num=1;
      temp_time=list.at(i);
    }
  }
  cout << count << endl;
}


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

const int mod = 1e9+7;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> c(h+1, vector<char>(w+1));
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      cin >> c[i][j];
    }
  }
  vector<vector<int>> dp(h+1, vector<int>(w+1));
  dp[1][1] = 1;
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      if(i == 1 && j == 1) continue;
      else if(c[i][j] == '#') dp[i][j] = 0;
      else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
    }
  }
  cout << dp[h][w] << endl;
  return 0;
}


Measured memory_bytes: 8568
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.datetime;

void main() {
    auto S = readln.chomp;
    auto s = readln.split.map!(to!int);
    auto X = s[0];
    auto Y = s[1];
    int tmp = 0;
    bool isX = true;
    int[] yoko;
    int[] tate;

    foreach (c; S) {
        if (c == 'F') {
            tmp += 1;
        } else if (isX) {
            yoko ~= tmp;
            isX ^= 1;
            tmp = 0;
        } else {
            tate ~= tmp;
            isX ^= 1;
            tmp = 0;
        }
    }

    if (isX) yoko ~= tmp;
    else tate ~= tmp;

    auto dpX = new bool[int][](yoko.length+1);
    dpX[0][0] = true;
    foreach (i; 0..yoko.length) {
        foreach (k; dpX[i].keys) {
            dpX[i+1][k + yoko[i]] = true;
            if (i > 0) dpX[i+1][k - yoko[i]] = true;;
        }
    }

    auto dpY = new bool[int][](tate.length+1);
    dpY[0][0] = true;
    foreach (i; 0..tate.length) {
        foreach (k; dpY[i].keys) {
            dpY[i+1][k + tate[i]] = true;
            dpY[i+1][k - tate[i]] = true;
        }
    }


    if (X in dpX[yoko.length] && Y in dpY[tate.length]) {
        writeln("Yes");
    } else {
        writeln("No");
    }
}


Measured memory_bytes: 288764
code = input()
is_bad = False
for i, s in enumerate(code):
  if i > 0 and s == code[i-1]:
    print('Bad')
    is_bad = True
    break
  if i < len(s) -1 and s == code[i+1]:
    print('Bad')
    is_bad = True
    break
if not is_bad:
  print('Good')

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	for (int i = 1; i <= 100; i++) {
		if (i % 2 == 1)
			C = C - B;
		else
			A = A - D;
		if (A <= 0 || C <= 0)
			break;
	}
		
	if (A <= 0)
		cout << "No";
	else
		cout << "Yes";
	

}

Measured memory_bytes: 3620
# AGC027A - Candy Distribution Again
# greedy algorithm
from itertools import accumulate as acc


def main():
    # maximize the number of proper distribution -> begin with small values
    N, X, *A = map(int, open(0).read().split())
    A.sort()
    ac = list(acc(A))
    if ac[-1] < X:  # the last one receives more than expected -> ans - 1
        ans = N - 1
    else:
        ans = sum(i <= X for i in ac)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c,d,ans;
  cin>>a>>b>>c>>d;

  ans = max(a*c, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);

  cout << ans << endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef vector<pair<int , int>> vpii;
    typedef pair<int , int> pii;
    typedef pair<long long  , long long> pll;
    typedef pair<double , double> pdd;
    #define eb emplace_back;
    #define mp make_pair;
     
    int main(){
        int a , b;
        cin>>a>>b;
        int x = (b*10);
        int y = (a*100)/8;
        int low = min(x , y);
        int high = max(x , y);
        bool ok = false;
        for(double i = 1 ; i<=1009 ; i++){
            if((floor(i*0.08) == a)&& (floor(i*0.1) == b)){
                cout<<i;
                ok = true;
                break;
            }
        }
        if(!ok){
            cout<<"-1";
        }
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,vis,s;
vvi g,b,c;
ll res=0;
vi tb,tc;

int Cdfs(int v,int p){
	s[v]=1;
	for(auto u:g[v]) if(!vis[u]&&u!=p) s[v]+=Cdfs(u,v);
	return s[v];
}

P Cdfs1(int v,int p,int S){
	P q={inf,0};
	int M=0,S_=S-1;
	for(auto u:g[v]) if(!vis[u]&&u!=p){
		q=min(q,Cdfs1(u,v,S));
		M=max(M,s[u]);
		S_-=s[u];
	}
	return min(q,{max(M,S_),v});
}

int Cent(int v){
	Cdfs(v,-1);
	return Cdfs1(v,-1,s[v]).second;
}

void dfs(int v,int p,int x=0,int mx=0,int y=0,int my=0){
	x-=a[v];
	mx=min(mx,x);
	if(x==mx) tb.push_back(-x);
	y+=a[v];
	my=min(my,y);
	if(y==my) tc.push_back(-y);
	for(auto u:g[v]) if(u!=p&&!vis[u]){
		dfs(u,v,x,mx,y,my);
	}
}

void Rec(int v){
	v=Cent(v);
	vis[v]++;
	map<int,int> mp;
	b.clear(),c.clear();
	for(auto u:g[v]) if(u!=v&&!vis[u]){
		tb.clear(),tc.clear();
		dfs(u,v);
		b.push_back(tb);
		c.push_back(tc);
		if(a[v]>0){
			for(auto j:tc) if(j==1) res++;
		}
		else{
			for(auto j:tb) if(j==1) res++;
		}
		for(auto j:tc) mp[j]++;
	}
	int N=b.size();
	for(int i=0;i<N;i++) for(auto j:b[i]) res+=mp[j+a[v]];
	for(int i=0;i<N;i++){
		mp.clear();
		for(auto j:c[i]) mp[j]++;
		for(auto j:b[i]) res-=mp[j+a[v]];
	}
	for(auto u:g[v]) if(u!=v&&!vis[u]) Rec(u);
}

int main(){
	cin>>n;
	a=vi(n,1);
	vis=s=vi(n);
	g=vvi(n);
	for(int i=0;i<n;i++){
		char c;
		cin>>c;
		if(c==')') a[i]=-1;
	}
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	Rec(0);
	cout<<res<<endl;
}


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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n;
  string s;
  int a,b,c,d;
  cin >> n >> a >> b >> c >> d >> s;
  a--;
  b--;
  c--;
  d--;
  if (c < d) {
    for (int i = b+1; i < d; i++) {
      if (s[i] == s[i-1] && s[i] == '#') {
        cout << "No" << endl;
        return;
      }
    }
    for (int i = a+1; i < c; i++) {
      if (s[i] == s[i-1] && s[i] == '#') {
        cout << "No" << endl;
        return;
      }
    }
    cout << "Yes" << endl;
  } else {
    for (int i = a+1; i < c; i++) {
      if (s[i] == s[i-1] && s[i] == '#') {
        cout << "No" << endl;
        return;
      }
    }
    bool f = 0;
    for (int i = b; i <= d; i++) {
      if (s[i] == '.') {
        if (s[i-1] == '.' && s[i+1] == '.') f = 1;
      }
    }
    cout << (f?"Yes":"No") << endl;
  }
}

int main(int argc, char *argv[]){

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}

bool isOK(vector<int> w, int n, int k, int limit){
    int tmp_sum, w_id=0;

    FOR(i, 0, k){
        tmp_sum=0;
        while(w_id < n && tmp_sum + w[w_id] <= limit){
            tmp_sum += w[w_id];
            w_id++;
        }

        if(w_id==n) return true;
    }

    return false;
}
 
int main()
{
    int n, k, t;
    ll w_sum=0;
    vector<int> w;
    cin >> n;
    cin >> k;

    REP(i, n){
        cin >> t;
        w.emplace_back(t);
        w_sum += t;
    }

    int left=0, right=w_sum, mid=(left + right)/2;
    int ans=w_sum;
    while(left<=right){
        // print(mid);
        if(isOK(w, n, k, mid)){
            ans = mid;
            right = mid-1;
        }else{
            left = mid+1;
        }
        mid = (left + right)/2;
    }

    print(ans);
}


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


void solve() {
      ll n , k , m ;
      cin >> n >> k >> m ;
      ll n1 = n / k ;
      ll n2 =  n %  k ;
      ll ans = n1 * m ;
      if( n2 == 0 ){
         cout<<ans ;
      }    
      else{
        ans = ans + m ;
        cout<<ans<<endl;
      }
    
}

int main()
{
 
/*    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("/home/yash/Desktop/CPP/input.txt","r",stdin);
    freopen("/home/yash/Desktop/CPP/output3.txt","w",stdout);
    #endif*/

    ll t  ;
    t = 1 ;
    while ( t-- ){
        solve();
    }

}





Measured memory_bytes: 3620
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
/* Uncomment only if you are not using GNU compiler->
#include <map> #include <algorithm> #include <vector> #include <string.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <chrono> #include <thread> #include <iomanip>
*/ 
using namespace std;

#define endl "\n"
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define re(i,a) for(ll i=0; i<a; ++i)
#define tr(i,v) for(auto &i: v)
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define in(v,n) vll v(n);re(i,n) cin>>v[i]
#define printVec(v,s) cout << s; tr(i, v) cout << i << " ";
#define sz(v)	((ll)((v).size()))
#define dbgv(c, v) cout << c << " = " << v << endl;
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;
typedef vector< pll > vpll;
typedef vector< ll > vll;
typedef complex<double> point;

const long long MOD = 1000000007;
const long long inf = 1e18;
const double EPS = (1e-7);
inline ll dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

void solve(){
	ll n;
  cin>>n;
  cout << (ll)( ceil(n / 1000.0) * 1000) - n;
}

int main()
{

    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    	solve();
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3796
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(((a==b)&&a!=c)||((b==c)&&b!=a)||((c==a)&&c!=b))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

}


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

int main() {
    int X, Y;
    cin >> X >> Y;
    bool ans = false;
    
        for (int i = 0; i <= X; ++i) {
            for (int j = 0; j <= X; ++j) {
                if ( X == i + j && Y == i*2 + j*4) ans = true;
            }
        }
    
   
    if (ans) puts("Yes");
    else puts("No");
}

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

int main(){
    char a,b,c;
    cin >> a >> b >> c;
    if(a == 'R' && b == 'R' && c == 'R'){
        cout << 3 << endl;
    }
    else if((a == 'R' && b == 'R')||( b == 'R'&& c == 'R')){
        cout << 2 << endl;
    }
    else if(a == 'R' || b == 'R'|| c == 'R'){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,w;
  cin>>n>>w;
 long long a[n][2];
 
  vector<long long> dp(w+1);
//   dp[0]=0;
 for(long long i=0;i<n;i++){
     long long a,b;
     cin>>a>>b;
     for(long long j=w-a;j>=0;j--){
         dp[j+a]=max(dp[j+a],dp[j]+b);
     }
 }
 cout<<dp[w]<<endl;
}  

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

public class Main {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(reader.readLine());
		int a,b;
		
		if(n==1)
		{
			System.out.println("Hello World");
		}
		else if(n==2)
		{
		
			a=Integer.parseInt(reader.readLine());
			b=Integer.parseInt(reader.readLine());
			System.out.println(a+b);
			
		}
	}
	

}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 200005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

mint solve(int N, int K, int i){
  int B = K;
  int R = N-K;

  if(B < i) return 0;
  if(R < i-1) return 0;

  B -= i;
  R -= i-1;

  mint retB = mutil.fac(i-1+B) * mutil.fac(i-1).inv() * mutil.fac(B).inv();
  mint retR = mutil.fac(i+R) * mutil.fac(i).inv() * mutil.fac(R).inv();
  
  return retB * retR;
}


int main(){
  int N, K;
  cin >> N >> K;

  for(int i=1; i<=K; i++){
    cout << solve(N, K, i) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define re register
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}

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

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

#define int long long
const int MOD = 1000000007LL;

signed main(){

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

    vector<vector<int> > dp(n + 1, vector<int> ((1 << n) + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int v = 0; v < n; v++){
            if(a[i][v] == 0) continue;

            for(int bit = 0; bit < (1 << n); bit++){
                if((1 << v) & bit) continue;
                int nextbit = bit | (1 << v);
                dp[i + 1][nextbit] += dp[i][bit];
                dp[i + 1][nextbit] %= MOD;
            }
        }
    }

    cout << dp[n][(1 << n) - 1] << endl;
    
    return 0;
}

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

int main()
{
  int N,A,B;
  string S;

  cin >> N >> A >> B;
  cin >> S;

  int pass=0;
  int sumb=0;

  
  for (int i = 0; i < N; i++)
  {
    if(S[i]=='a'){
      if(pass<A+B){
        pass++;
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else if(S[i]=='b'){
      if(pass<A+B && sumb<B){
        pass++;
        sumb++;
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>c;
    rep(i,c){
        cin>>a;
        sum+=a;
    }
    ans=sum/(n+1);
    if(sum%(n+1)!=0)ans++;
    Cout(ans);
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int po[201][3],a[201] = {0};
  int ch[3][101]; memset(ch,0,sizeof(ch));
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin >> po[i][j];
      ch[j][po[i][j]]++;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      if(ch[j][po[i][j]] < 2) a[i] += po[i][j];
    }
  }
  for(int i=0;i<n;i++) cout << a[i] << endl;
}

Measured memory_bytes: 1164
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var A = Number.parseInt(inputStr[1]);
  var B = Number.parseInt(inputStr[2]) / N;
  //三項演算子を使って最も安い乗車賃Pを求める
  var P = ( A > B ? B : A);
  //Pに人数を掛けて答えを算出
  console.log(P*N);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define reset(X) memset(X, 0, sizeof(X))
#define int long long
typedef long long ll;
#define pb push_back
#define endl '\n'
#define all(X) X.begin(),X.end()

const int INF=1e18;
const int mod=1e9+7;
const int MAXN=21;
     
signed main()
{
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r")) {
        freopen ("INPUT.txt" , "r" , stdin);
        // freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
//---------------------------------------------------------------------------------------------------
    int n;

    cin>>n;
    int bits[61];
    reset(bits);
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        int bit=0;
        while(a!=0)
        {
            bits[bit]+=(a%2);
            bit++;
            a/=2;
        }
    }
    int ans=0;
    for(int i=0;i<61;i++)
    {   
        int offset=(bits[i]*(n-bits[i]))%mod;
        offset=(offset*((1ll<<i)%mod))%mod;
        ans=(ans+offset)%mod;
    }
    cout<<ans;
}


Measured memory_bytes: 256
// Danielxlr
// https://atcoder.jp/contests/abc174/tasks/abc174_a
// math
#include <iostream>
using namespace std;
int main(){
    long n;
    cin>>n;
    if(n>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <ctype.h>

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  char a[n + 1];
  scanf("%s", a);
  a[k - 1] = tolower(a[k - 1]);
  puts(a);
  return 0;
}

Measured memory_bytes: 128
c = sum([[int(x) for x in input().split()] for _ in range(3)], [])
flag = True
if c[1]-c[0] != c[4]-c[3] or c[4]-c[3] != c[7]-c[6]:
    flag = False
elif c[2]-c[1] != c[5]-c[4] or c[5]-c[4] != c[8]-c[7]:
    flag = False
elif c[3]-c[0] != c[4]-c[1] or c[4]-c[1] != c[5]-c[2]:
    flag = False
elif c[6]-c[3] != c[7]-c[4] or c[7]-c[4] != c[8]-c[5]:
    flag = False

print("Yes" if flag else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint k;
	cin>>k;
	queue<lint> l;
	if(k<=9){
		cout<<k<<endl;
		return 0;
	}
	rep1(i,9)l.push(i);
	lint num=9;
	while(1){
		lint tmp=l.front();
		l.pop();
		for(int i=-1;i<=1;i++){
			if(i+tmp%10<0||9<i+tmp%10)continue;
			l.push(10*tmp+i+tmp%10);
			num++;
			if(num==k){
				cout<<l.back()<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 768
N = input()
if N[0] == "9":
    if N[1:] == "9" * len(N[1:]):
        print(9 * len(N))
    else:
        print(9 * len(N) - 1)
else:
    if N[1:] == "9" * len(N[1:]):
        print(int(N[0]) + 9 * len(N[1:]))
    else:
        print(int(N[0]) + 9 * len(N[1:]) - 1)



Measured memory_bytes: 9112
N,left,right,up,down=map(int,raw_input().split())
diff=abs(left-right)
def maxmin(plus,minus):
    upper=plus*(up)-minus*(down)
    under=plus*(down)-minus*(up)
    return sorted([upper,under])[::-1]
upper=N-1
under=0
flag=False
while upper>=under and not flag:
    mid=(upper+under)/2
    m=maxmin(mid,N-mid-1)
    if m[1]<=diff<=m[0]:
        flag=True
    if diff>=m[0]:
        under=mid+1
    if diff<=m[1]:
        upper=mid-1
print "YES" if flag else "NO"

Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

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

Measured memory_bytes: 384
#include <bits/stdc++.h> //konoitibundekaiketu
 
using namespace std;
 
int main(){
	int a,b,c,d,e,k,t;
  	t = 0;
  	cin>> a  >> b >> c >> d >> e >> k;
  	
  	if(k>=abs(b-a)){        
    }else{
      t++;     
    }
  if(k>=abs(c-a)){         
    }else{
      t++;   
    }
  if(k>=abs(d-a)){
  
    }else{
      t++;
     
    }
  if(k>=abs(e-a)){
 
          
    }else{
      t++;
     
    }
  if(k>=abs(c-b)){
  
          
    }else{
      t++;
     
    }
  if(k>=abs(d-b)){
 
          
    }else{
      t++;
     
    }
  if(k>=abs(e-b)){
 
        
    }else{
      t++;     
    }
  if(k>=abs(d-c)){          
    }else{
      t++;     
    }
   if(k>=abs(e-c)){
    }else{
      t++;

    }
        
   if(k>=abs(e-d)){
 
    }else{
      t++;
     
    }
        
        
 	if(t>0){
       printf(":(");
    }else if(t == 0){
 		printf("Yay!");
    }
  
   
 
  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
#define MOD (int)1e9+7
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N, C[500], S[500], F[500];
int a[500], b[500];

int f(int i, int t){
    if(i == N - 1) return t;
    if(t < S[i]){
        // if(a[i] < INF) return a[i];
        return a[i] = f(i + 1, S[i] + C[i]);
    }else{
        // if(b[i] < INF) return b[i];
        if(t % F[i] > 0) return b[i] = f(i + 1, (t / F[i] + 1) * F[i] + C[i]);
        return f(i + 1, t + C[i]);
    }
}

int main(void){
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    fill(a, a + N, INF); fill(b, b + N, INF);
    // for(int i = N - 2; i >= 0; i--) f(i, 0);
    for(int i = 0; i < N ; i++){
        // debug(i);debug(a[i]); debug(b[i]);
        cout << f(i, 0) << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<int>V(N + 3);
	V[0] = 0;
	int sum = 0;
	for (int i = 1; i <= N; ++i) {
		cin >> V[i];
		sum += abs(V[i] - V[i - 1]);
	}
	V[N + 1] = 0;
	sum += abs(V[N + 1] - V[N]);
	for (int i = 1; i <= N; ++i) {
		int ans = sum - abs(V[i] - V[i - 1]) - abs(V[i + 1] - V[i]) + abs(V[i + 1] - V[i - 1]);
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int q;
    std::cin >> q;
    while (q--) {
        i64 a, b;
        std::cin >> a >> b;
        if (a < b) std::swap(a, b);
        if (a - b < 2) {
            std::cout << 2 * (b - 1) << std::endl;
            continue;
        }
        i64 s = a * b, l = 0, r = a;
        while (r - l > 1) {
            i64 k = (l + r) / 2;
            if (k * k < s) l = k;
            else r = k;
        }
        r = l;
        while (l * (r + 1) < s) r++;
        i64 ret = b - 1 + l + std::min(a - r, std::max(0ll, l - b - (l == r)));
        if (l - b > a - r) {
            for (int i = b + 1, j = r - 1; j > l && i <= l - (l == r) - a + r; i++) {
                if (i * j < s) {
                    ret++;
                    --j;
                }
            }
        }

        std::cout << ret << std::endl;
    }

    return 0;
}


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

signed main(){
    int L;
    cin >> L;
    int N=0;
    int pow=1;
    while(pow<=L) pow *= 2, N++;
    int M = (N-1)*2 + __builtin_popcount(L) -1;
    cout << N << " " << M << endl;
    for(int i=0;i<N-1;i++) {
        cout << i+1 << " " << i+2 << " " << 0 << endl;
        cout << i+1 << " " << i+2 << " " << (1<<i) << endl;
    }
    int cur=1<<(N-1);
    for(int i=N-2;i>=0;i--) {
        if(L&(1<<i)) {
            cout << i+1 << " " << N << " " << cur << endl;
            cur += (1<<(i));
        }
    }
    return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;

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

	string s; cin >> s;
	if(s.find('7') != string::npos)
		cout << "Yes\n";
	else
		cout << "No\n";

 	return 0;
}

Measured memory_bytes: 3648
N,K,Q = map(int,input().split())
A = [0 for i in range(10**6)]

for i in range(Q):
    t = int(input())
    A[t-1] += 1
    
for i in range(N):
    if K - Q + A[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 11756
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e7+10, mod = 1e9+7;
int n,m;

int fac[N],ifac[N],inv[N];
inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
inline void init(int n){
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=power(fac[n],mod-2);
	Dow(i,n-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	For(i,1,n) inv[i]=1ll*ifac[i]*fac[i-1]%mod;
}
inline int C(int n,int m){
	if (n<m||m<0) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

inline int calc(int x,int y,int z){
	return 1ll*fac[x+y+z]*x%mod*inv[x+y]%mod;
}
inline int calc(){
	int ans=0;
	For(i,2,m+1){
		int ret=0;
		FOR(j,0,i){
			int tmp=1ll*C(i-1,j)*calc(i-j-1,n-m,max(0,m-i))%mod;
			if (j&1) ret=Mod(ret+mod-tmp);
				else ret=Mod(ret+tmp);
		}
		ans=Mod(ans+ret);
	}
	return ans;
}

int main(){
	n=read(),m=read(),init(n);
	printf("%d\n",calc());
}

Measured memory_bytes: 120904
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#define _clr(x,y) memset(x,y,sizeof(x))
#define _inf(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#define mp make_pair
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
typedef long long LL;
const int maxn=1000000+5;
int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	
	int n,a[100000+5]={},ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=100000;i++) if(a[i]) ans++;
	if(ans%2==0) ans--;
	cout<<ans;
	
    return 0;
}


Measured memory_bytes: 768