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

int main(){
    int n; cin >> n;
    
    vector<int> a(n), b(n), c(n);
    
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    
    long long ans = 0;
    
    for(int i=0; i<n; i++){
        auto iter1 = lower_bound(a.begin(), a.end(), b[i]);
        //aのなかで、b[i]以上の要素で一番小さいものの位置
        auto iter2 = upper_bound(c.begin(), c.end(), b[i]);
        //cのなかで、b[i]より大きい要素で一番小さいものの位置
        long long num_a, num_c;
        
        num_a = iter1 - a.begin();//b[i]より小さい要素の個数
        
        num_c = c.end() - iter2;//b[i]より大きい要素の個数
        //cout << num_a << " " << num_c << endl;
        ans += num_a * num_c;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(){
  ll x;
  cin>>x;

  ll ans;
  ll p = x / 11;
  ans = p * 2;
  if (x % 11 > 6)
    ans += 2;
  else if (x % 11 != 0)
    ans ++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,x,y,z;
ll dp[41][(1<<17)][2];
int go[(1<<17)][11];
int main(){
	cin>>n>>x>>y>>z;
	int s = x+y+z;
	dp[0][0][0] = 1;
	for(int j=0;j<(1<<s);j++){
		for(int k=1;k<=10;k++){
			if(j>=(1<<(s-1)))  continue;
			//go[j][k]
			int mx = 0;
			rep(i,s) if(((j>>i)&1)) mx=i+1;
			if( (mx<x&&mx+k>x) || (mx<x+y&&mx+k>x+y) || (mx<x+y+z&&mx+k>x+y+z) ){
				vector<int>vi,val;
				rep(i,s) if(((j>>i)&1)) vi.pb(i+1);
				vi.pb(mx+k);
				rep(i,vi.size()){
					int x = vi[i];
					if(i) x-= vi[i-1];
					val.pb(x);
				}
				while(val.size()){
					reverse(val.begin(),val.end());
					val.pop_back();
					reverse(val.begin(),val.end());
					int sum = 0,mask = 0;
					bool ok = true;
					rep(i,val.size()){
						if( (sum<x&&sum+val[i]>x) || (sum<x+y&&sum+val[i]>x+y) || (sum<x+y+z&&sum+val[i]>x+y+z) ){
							ok = false;
						}
						sum += val[i];
						mask |= (1<<(sum-1));
					}
					if(ok){
						go[j][k] = mask;
						break;
					}
				}
			}
			else{
				int g = mx+k-1;
				go[j][k] = j+(1<<g);
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<(1<<s);j++){
			for(int k=0;k<2;k++){
				for(int nx=1;nx<=10;nx++){
					int v = go[j][nx];
					bool tr = (v>=(1<<(s-1)));
					dp[i+1][go[j][nx]][(tr|k)] += dp[i][j][k];
					dp[i+1][go[j][nx]][(tr|k)] %= mod;
				}
			}
		}
	}
	ll ans = 0;
	for(int i=n;i<=n;i++){
		for(int j=0;j<(1<<s);j++){
			for(int k=1;k<2;k++){
				ans += dp[i][j][k];
			}
		}
	}
	cout<<ans%mod<<endl;
}

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

static const int M = 1046527;

string H[M];
string order[1000000][2];

// 文字から数値に変換
int getChar(char ch) {
    if (ch == 'A') return 1;
    if (ch == 'C') return 2;
    if (ch == 'G') return 3;
    if (ch == 'T') return 4;
    else return 0;
}

// 文字列から数値に変換してkeyを生成する
int getKey(string str) {
    int sum = 0, p = 1; // pは5のi乗　5進数->10進数
    for (int i = 0; i < str.size(); i++) {
        sum += p * (getChar(str.at(i)));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M-1)); }

int find(string str) {
    int key, h;
    key = getKey(str);
    for (int i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M; // ハッシュ値
        if (H[h] == str) return 1;
        else if (H[h].size() == 0) return 0; // 別の要素がなければ繰り返し終了
    }
    return 0;
}

int insert(string str) {
    int key, h;
    key = getKey(str);
    for (int i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (H[h] == str) return 1;
        else if (H[h].size() == 0) {
            H[h] = str;
            return 0;
        } 
    }
}

int main() {
    int n;
    string L, com, str;
    cin >> n;

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

    for (int i = 0; i < n; i++) {
        str = order[i][1];
        if (order[i][0].at(0) == 'i') {
            insert(str);
        } else {
            if (find(str)) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 126940
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;

    vector<int> ll;
    map<int, int> a;
    rep(i, n-2){
        if(a[s[i] - '0'] == 0){
            map<int, int> b;
            for(int j=i+1; j<n-1; j++){
                if(b[s[j]-'0'] > 0) continue;
                map<int, int> c;
                for(int k=j+1; k<n; k++){
                    if(c[s[k]-'0'] > 0) continue;
                    int aa = s[j]-'0';
                    int bb = s[k]-'0';
                    int cc = s[i]-'0';
                    int tmp = cc*100+aa*10+bb;
                    ll.push_back(tmp);
                    c[s[k]-'0']++;
                }
                b[s[j]-'0']++;
            }
            a[s[i]-'0']++;
        }
    }

    sort(ll.begin(), ll.end());
    ll.erase(unique(ll.begin(), ll.end()), ll.end());
    cout << ll.size() << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;


ll num[sz];


int main()
{

     ll n,t,a,b,f=0,x=1000000000;
     cin>>n>>t;

     while(n--)
     {
         cin>>a>>b;
         if(b<=t)
         {
             f=1;
             x=min(x,a);
         }
     }
     if(f==0)cout<<"TLE"<<endl;
     else
        cout<<x<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>

using namespace std;

const long long N = 1000ll * 1000 * 1000 * 1000 + 5;
long long cnt = -1;

vector <int> ans;

int main() 
{
	long long n;
	cin >> n;
	for (int i = 1; i <= 100; i++) 
	{
		ans.push_back(i);
	}
	for (int i = 0; i <= 100; i++) 
	{
		cnt++;
		if (n >= (1ll << i)) 
		{
			n -= (1ll << i);
		}
		else 
		{
			break;
		}
	}
	for (int i = 0; i < cnt; i++) 
	{
		if ((n >> i) % 2) 
		{
			ans.push_back(100 - i);
		}
		ans.push_back(i + 1);
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) 
	{
		cout << ans[i] << " ";
	}
}



Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();

    int[] data = new int[n];
    // String[] data = new String[n];

    for (int i = 0; i < n; i++) {
      data[i] = Integer.valueOf(s.substring(i,i+1));
      // data[i] = s.substring(i,i+1);
    }

    long ans = 0;

    for (int i = 0; i < Math.pow(2,n-1); i++) {
      // String k = "";
      long sum = 0;
      long k = 0;
      for (int j= 0; j < n; j++) {
        k += data[j];
        if ((1&i >> j) == 0) {
          // k += "+";
          sum += k;
          k = 0;
        } else {
          k *= 10;
        }
      }
      ans += sum;
      // System.out.println(k);
    }

    System.out.println(ans);

  }

}


Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <set>
#include <algorithm>

struct Rank {
  std::map<size_t, size_t> memo;
  std::map<size_t, std::set<size_t>> const& parents;

  Rank(decltype(parents) const& p)
    : parents(p) {};

  size_t operator()(size_t node) {
    if (memo.count(node) > 0) {
      return memo.at(node);
    } else if (parents.count(node) > 0) {
      size_t ret = 0;
      auto const& ps = parents.at(node);
      for (auto p : ps) {
        ret = std::max(ret, (*this)(p)) + 1;
      }
      memo.insert(std::make_pair(node, ret));
      return ret;
    } else {
      return 0;
    }
  }
};

int main() {
  size_t N, M;

  std::cin >> N >> M;

  size_t const NumEdges = N - 1 + M;
  std::map<size_t, std::set<size_t>> Parents;

  for (size_t i=0; i<NumEdges; i++) {
    size_t A, B;
    std::cin >> A >> B;
    if (Parents.count(B) > 0) {
      Parents.at(B).insert(A);
    } else {
      std::set<size_t> s;
      s.insert(A);
      Parents.insert(std::make_pair(B, s));
    }
  }

  Rank rank(Parents);

  for (size_t i=1; i<N+1; i++) {
    if (Parents.count(i) > 0) {
      auto const& ps = Parents.at(i);
      auto ans = *std::max_element(ps.begin(), ps.end(),
                                   [&](auto a, auto b){return rank(a) < rank(b);});
      std::cout << ans << '\n';
    } else {
      std::cout << 0 << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 25472
//#include<bits/stdc++.h>
#include<iostream>
#include<set>
 
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios::base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
//using ll = long long;
 
template<typename T>
inline T Abs(T a){return a < 0 ? -a : a; }
template<typename T>
inline T Max(T a, T b){return a < b ? b : a; }
template<typename T>
inline T Min(T a, T b){return a > b ? b : a; }
 
using namespace std;
 
int main(){
    //fast()
    
    int n; cin >> n;
    bool check = true;
    for(int i = 0; i < n; i++){
        int temp; cin >> temp;
        if(temp % 2 == 0){
            if(temp % 3 != 0 && temp % 5 != 0){
                check = false;
                break;
            }
        }
    }

    if(check) cout << "APPROVED\n";
    else cout << "DENIED\n";
    return 0;
}

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

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

    vector<string> s(n);
    vector<long long int> march(5);

    for(int i=0; i<n; i++){
        cin >> s[i];
        if(s[i][0] == 'M') march[0] += 1;
        if(s[i][0] == 'A') march[1] += 1;
        if(s[i][0] == 'R') march[2] += 1;
        if(s[i][0] == 'C') march[3] += 1;
        if(s[i][0] == 'H') march[4] += 1;
    }

    long long int count = 0;
    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                count += march[i] * march[j] * march[k];
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>

int main()
{
	double a,b,c,d,e,f,x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF)
	{
		x=(c*e-b*f)/(double)(a*e-b*d);
		y=(c*d-a*f)/(double)(b*d-a*e);
		if(-0.0004<x&&x<=0)x=0;
		if(-0.0004<y&&y<=0)y=0;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, L, r, a ;
  cin >> N ;
  a = 0 ;
  
  for ( int i; i < N; i++ ) {
    cin >> L >> r ;
    r = r + 1 ;
    a += r - L ;
  }
  cout << a << endl ;
}
    

Measured memory_bytes: 256
//
//  main.cpp
//  E
//
//  Created by 曾憲揚 on 2020/8/19.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

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

const int maxn = 2e3+5;
pair<int,int> a[maxn];
ll dp[maxn][maxn];

ll solve_dp(int i, int j, int n){
    if(dp[i][j] != -1) return dp[i][j];
    if(j<i) return 0;
    
    int now = j-i+1;
    pair<int, int> p = a[now];
    return dp[i][j] = max(solve_dp(i+1, j, n) + 1LL*p.first*abs(i-p.second),
                          solve_dp(i, j-1, n) + 1LL*p.first*abs(j-p.second));
}

int main(int argc, const char * argv[]) {
    memset(dp, -1, sizeof(dp));
    int n; cin>>n;
    for(int i=1; i<=n; i++){
        int x; cin>>x;
        a[i] = make_pair(x, i);
    }
    sort(a+1, a+n+1);
    
    cout<<solve_dp(1, n, n)<<endl;
    
    return 0;
}


Measured memory_bytes: 35124
#include<iostream>
#include<vector>
#include<cmath>

int main(void)
{
	int N, D;

	std::cin >> N;
	std::cin >> D;

	std::vector<std::vector<int>> X;

	X.push_back(std::vector<int>());

	for (int i = 0; i < N; i++) {
		std::vector<int> tmp;
		tmp.push_back(0);
		int buf;
		for (int j = 0; j < D; j++) {
			std::cin >> buf;
					tmp.push_back(buf);
		}
		X.push_back(tmp);	
	}
	int cnt = 0;
	for (int i = 1; i < X.size() - 1; i++) {
		for (int j = i + 1; j < X.size(); j++) {
			double sum = 0;
			for (int k = 1; k <= D; k++) {
				sum += std::pow((X[i][k] - X[j][k]), 2);
			}
			sum = std::sqrt(sum);
			
			// 整数の判定
			if (std::ceil(sum) == std::floor(sum))
				cnt++;

		}
	}
	std::cout << cnt << std::endl;

}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int count = 0;
  for(int i = min(A,B); i >= 0; i--){
    if(A%i == 0 && B%i == 0){
      count++;
      if(count == K){
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int sumOfDigits(int n)
{
  int sum = 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main()
{
  int N;
  cin >> N;
  int S = sumOfDigits(N);
  if (N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;
typedef long long ll;

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

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

  ll ans = 0, l = 0;
  for (;;) {
    ll sum = 0;
    while (l < n && a[l]) sum += a[l++];
    ans += sum / 2;
    while (l < n && !a[l]) l++;
    if (l == n) break;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif*/
}
bool comp(const pair< pair<ll,ll>,ll > &a,const pair< pair<ll,ll>,ll > &b)
{
	if(a.ff.ff!=b.ff.ff)
		return a.ff.ff<b.ff.ff;
	if(a.ff.ss!=b.ff.ss)
		return b.ff.ss<a.ff.ss;
	else
		return a.ss>b.ss;
}
int main()
{
	checkpoint1();
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll y;cin>>y;
		if(i%2==0&&y%2)
			ans++;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i, n) cin >> h[i];

  reverse(h, h + n);
  rep(i, n - 1) {
    if (h[i + 1] > h[i]) --h[i + 1];
  }

  bool ans = true;
  rep(i, n - 1) {
    if (h[i] < h[i + 1]) ans = false;
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        P_queue S = new P_queue();
        while(true){
            String order = sc.next();
            if(order.equals("insert"))
                S.insert(sc.nextLong());
            else if(order.equals("extract"))
                System.out.println(S.extract());
            else
                break;
        }
    }
}
class P_queue{
    long num[];
    int n = 0;
    P_queue(){
        num = new long[2000010];
    }
    void insert(long k){
        num[++n] = k;
        int i = n;
        while(i > 1){
            if(num[i/2] <= num[i]){
                long tmp = num[i/2];
                num[i/2] = num[i];
                num[i] = tmp;
                i /= 2;
            }
            else
                break;
        }
    }
    long extract(){
        long ans = num[1];
        num[1] = num[n--];
        int i = 1;
        while(true){
            int x = 2*i;
            if(2*i +1 <= n){
                if(num[x] <= num[x+1])
                    x++;
            }
            else if(2*i > n)
                break;
            if(num[i] < num[x]){
                long tmp = num[i];
                num[i] = num[x];
                num[x] = tmp;
                i = x;
            }
            else
                break;
        }
        return ans;
    }
}


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

using namespace std;

long long calc(long long x)
{
    long long ans = (x & 1) ? 0 : x;
    if (((x+1)/2) & 1) ans |= 1;
    else {
        if (ans & 1) ans--;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a, b;
    cin >> a >> b;
    cout << (calc(b) ^ calc(a-1)) << endl;
    return 0;
}


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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int n;

  while (cin >> n) {
    if (n == 0) break;
    vector<int> s;
    rep(i, n) {
      int x;
      cin >> x;
      s.push_back(x);
    }
    sort(all(s));
    int score = 0;
    FOR(i, 1, n - 1) score += s[i];

    cout << score / (n - 2) << "\n";
  }

  return 0;
}


Measured memory_bytes: 3128
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll 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 fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

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;
ll n, cnt, ans, c, d, tmp, m, h, w, x, y, sum, k, q, a, b;
ll dp[ohara][4], p_cou;
V g[ohara];
bool vi[ohara];
P p[ohara];

void dfs(ll now, ll dep) {
  if (vi[now]) return;
  vi[now] = true;
  p[p_cou++] = m_p(dep, now);
  rep(i, Size(g[now])) { dfs(g[now][i], dep + 1); }
}

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

  cin >> n;
  rep(i, n - 1) {
    cin >> a >> b;
    a--;
    b--;
    g[a].p_b(b);
    g[b].p_b(a);
  }
  dfs(0LL, 0LL);
  sort(p, p + p_cou);
  reverse(p, p + p_cou);
  rep(i, p_cou) {
    ll now = p[i].se;
    if (Size(g[now]) == 1 && now != 0) {
      dp[now][0] = 1;
      dp[now][1] = 1;
    } else {
      ll add = 1;
      rep(i, Size(g[now])) {
        ll to = g[now][i];
        if (dp[to][0] + dp[to][1] == 0) continue;
        (add *= (dp[to][0] + dp[to][1])) %= MOD;
      }
      (dp[now][1] += add) %= MOD;

      add = 1;
      rep(i, Size(g[now])) {
        ll to = g[now][i];
        if (dp[to][1] == 0) continue;
        (add *= dp[to][1]) %= MOD;
      }
      (dp[now][0] += add) %= MOD;
    }
  }

  ans = dp[0][0] + dp[0][1];
  Cout(ans % MOD);
  return 0;
}

Measured memory_bytes: 39808
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    int ans = 0;
    REP(i,3){
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int a,b,c;
	cin >> a >> b >> c;
	int mod=a%b;
	int temp=a;
	while(1){
		a+=temp;
		if(a%b==c){
			cout << "YES" << endl;
			return 0;
		}
		if(a%b==mod){
			cout << "NO" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
using namespace std;
 
int main() {
    long double x1,y1,x2,y2;
    
    cin >> x1;
    cin >> y1;
    cin >> x2;
    cin >> y2;
    
    cout.precision(4); // ????????? 3????????????????????????
    cout.setf(ios::fixed);
//    cout << setiosflags(ios::scientific); // ?属???属??即?????????????????即?????????
 
    cout << sqrt(pow(x1-x2, 2.0)+pow(y1-y2, 2.0)) << endl;
        
        return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int k; scanf("%d", &k);

	int now = 7 % k;
	for(int i = 1; i < 2 * k; i++) {
		if(now == 0) {
			printf("%d\n", i);
			return 0;
		}
		now = (now * 10 + 7) % k;
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 3824
#include <stdio.h>
#include <math.h>

typedef struct{
  double x,y;
}Vector;

double calMtrx(double x[3][3]){
  double result=0;

  result += x[0][0] * x[1][1] * x[2][2];
  result += x[1][0] * x[2][1] * x[0][2];
  result += x[2][0] * x[0][1] * x[1][2];
  result -= x[0][0] * x[2][1] * x[1][2];
  result -= x[1][0] * x[0][1] * x[2][2];
  result -= x[2][0] * x[1][1] * x[0][2];

  return result;
}

int main(void){
  int i,n;
  double a,b,c;
  double D[3];
  double Sx,Sy,d;
  double k,h,r;
  Vector p[3];

  double tmp[3][3];

  scanf("%d",&n);
  while(n--){
    for(i=0;i<3;i++)
      if( scanf("%lf %lf",&p[i].x,&p[i].y) == EOF ) break;
    if(i == 0) break;

    a = sqrt( pow( p[1].x - p[0].x , 2 ) + pow( p[1].y - p[0].y , 2 ) );
    b = sqrt( pow( p[2].x - p[1].x , 2 ) + pow( p[2].y - p[1].y , 2 ) );
    c = sqrt( pow( p[2].x - p[0].x , 2 ) + pow( p[2].y - p[0].y , 2 ) );

    r = a * b * c;
    r /= sqrt( (a+b+c) * (-a+b+c) * (a-b+c) * (a+b-c) );

    for(i=0;i<3;i++)
      D[i] = pow( p[i].x , 2 ) + pow( p[i].y , 2 );

    for(i=0;i<3;i++){
      tmp[i][0] = D[i];
      tmp[i][1] = p[i].y;
      tmp[i][2] = 1;
    }
    Sx = calMtrx(tmp) / 2;

    for(i=0;i<3;i++){
      tmp[i][0] = p[i].x;
      tmp[i][1] = D[i];
      tmp[i][2] = 1;
    }
    Sy = calMtrx(tmp) / 2;

    for(i=0;i<3;i++){
      tmp[i][0] = p[i].x;
      tmp[i][1] = p[i].y;
      tmp[i][2] = 1;
    }
    d = calMtrx(tmp);

    h = Sx / d;
    k = Sy / d;

    D[0] = h;
    D[1] = k;
    D[2] = r;

    for(i=0;i<3;i++){
      if(i != 0) printf(" ");
      if(D[i] >= 0){
        printf("%.3lf",(int)(D[i]*1000+0.5) / 1000.0);
      }
      else{
        printf("%.3lf",(int)(D[i]*1000-0.5) / 1000.0);
      }
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

from collections import deque

def main():

    n = int(input())
    
    a = [[int(i) for i in input().split()] for j in range(n)]
    
    check = [0]*n
    used = [0]*n
    
    d = deque()
    
    for i in range(n):
        if used[i] == 1:
            continue
        ai = a[i][0]-1
        if a[ai][0] == i+1:
            d.append([i+1,ai+1])
            used[i] = 1
            used[ai] = 1
            check[i] = 1
            check[ai] = 1
            
    ans = 0
    
    if len(d) == 0:
        print(-1)
        exit()
    
    #print(d)
    
    while len(d) > 0:
        used = [0]*n
        ans += 1
        num = len(d)
        for i in range(num):
            tmp = d.popleft()
            for j in range(2):
                mys = tmp[j]-1
                if check[mys] != n-1 and used[mys] == 0:
                    psn = a[mys][check[mys]]-1
                    if check[psn] != n-1 and used[psn] == 0:
                    #print(tmp,psn,a[psn][check[psn]])
                    #print(i,j,tmp,psn,check[mys],check[psn])
        
                        if a[psn][check[psn]] == mys+1:
                            d.append([psn+1,mys+1])
                            used[mys] = 1
                            used[psn] = 1
                            check[mys] += 1
                            check[psn] += 1
        #print(d)
        
    for i in range(n):
        if check[i] != n-1:
            print(-1)
            exit()
    
    print(ans)

if __name__ == '__main__':
    main()

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

int main()
{
	int n;
	cin >> n;
	string str;
	cin >> str;
	int red = 0, blue = 0;
	for (int i = 0; i < str.length(); i++)
	{
		if (str[i] == 'R') red++;
		else blue++;
	}
	
	if (red > blue) cout <<"Yes";
	else cout << "No";
}

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

int main() {
  int N, n, nn;
  int i;
  cin >> N;
  vector<int> s(N+1);
  for (i=1; i<=N; i++) cin >> s.at(i);
  i=0;
  n=1;
  while (s.at(n) !=0) {
    nn=s.at(n);
    s.at(n)=0;
    n=nn;
    i++;
    if ( n==2 ) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;  
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s, t;
    cin >> s >> t;

    long long ret = 0;
    long long l = s.length();
    for(long long i = 0; i < l; i++) {
        if(s[i] != t[i]) {
            ret++;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

double dp[150][150];//iターン目でjマスにいる確率
int a[150];
int n,t,l,b;

double solve(){
    for(int i=0;i<150;i++){
        for(int j=0;j<150;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=1;i<=t;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<6;k++){
                if(dp[i-1][j]==0)continue;
                int next=j+(k+1);
                if(next>n){
                    next=2*n-next;
                }
                if(a[next]==0){
                    dp[i][next]+=dp[i-1][j]/6;
                }
                else if(a[next]==1){
                    dp[i+1][next]+=dp[i-1][j]/6;
                }
                else{
                    dp[i][0]+=dp[i-1][j]/6;
                }
            }
        }
    }
    double res=0;
    for(int i=1;i<=t;i++){
        res+=dp[i][n];
    }
    return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    while(cin >> n >> t >> l >> b,n){
        for(int i=0;i<n;i++){
            a[i]=0;
        }
        for(int i=0;i<l;i++){
            int x; cin >> x;
            a[x]=1;
        }
        for(int i=0;i<b;i++){
            int x; cin >> x;
            a[x]=2;
        }
        printf("%.8f\n",solve());
    }
}


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

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

int nth_factor(int x, int n) {
    int count = 0;
    for (int i = x; i > 0; i--) {
        if (x % i == 0) {
            count++;
            if (count == n) {
                return i;
            }
        }
    }
    return -1;
}

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


Measured memory_bytes: 256
N, K = map(int, input().split())
As = list(map(int, input().split()))
bitK = K.bit_length()
ans = [0]*bitK
for a in As:
    for i in range(bitK):
        if not (a>>i)&1:
            ans[i] += 1

ans = ans[::-1]
string = ['0']*bitK
if bitK==0:
    print(sum(As))
else:
    for i, a in enumerate(ans):
        if a>=N/2:
            string[i] = '1'
            if int(''.join(string), 2)>K:
                string[i] = '0'
    num = int(''.join(string), 2)
    print(sum([x^num for x in As]))

Measured memory_bytes: 15144
#include <iostream>
#include <string>

using ll = long long;
using namespace std;

ll all0 = 0;
ll after0[200000] = {0};

int main() {
  ll N;
  string S;
  cin >> N >> S;
  bool b = false;
  for (char c : S) if (c == '.') all0++;
  ll t = all0;
  for (ll i = 0; i < N; i++) {
    after0[i] = t;
    if (S[i] == '.') t--;
  }
  ll dp[200000] = {0};
  if (S[N - 1] == '#') dp[N - 1] = 1;
  else dp[N - 1] = 0;

  for (ll i = N - 2; i >= 0; i--) {
    dp[i] = min(dp[i + 1] + int(S[i] == '#'), after0[i + 1]);
  }
  ll ret = min(dp[0], after0[0]);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3716
import java.util.*;
public class Main {

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

      int max = 1;
      int cur = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      }
      System.out.println(max);
  }

  private static int factor(int a, int n) {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  }
}


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

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

    vector<int> s(n);
    rep(i,n) cin >> s[i]; 

    int q;
    cin >> q;

    vector<int> t(q);
    rep(i,q) cin >> t[i];

    int ans = 0;
    map<int,int> used;

    rep(i,n)rep(j,q){
        if( used[ s[i] ] ) continue;
        if(s[i] == t[j]){
            ans++;
            used[ s[i] ] = 1;
        }
    }

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


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

long mod=1e9+7;


int main() {
  double a,b;cin>>a>>b;
  cout<< ceil((b-a)/(a-1))+1;
}



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

typedef long long ll;

const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll INFLL = 0x3F3F3F3F3F3F3F3FLL;

int n;
ll w;
ll pes[112];
int val[112];
ll dp[112][112345];

ll solve(int pos, int am){
	
	if(am == 0) return 0;
	if(pos == n) return INF;
	if(dp[pos][am] != -1) return dp[pos][am];
	
	return dp[pos][am] = min(
		solve(pos + 1, am),
		solve(pos + 1, am - val[pos]) + pes[pos]
	);
}

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> w;
	
	int total = 0;
	
	for(int i = 0 ; i < n ; i ++){
		cin >> pes[i] >> val[i];
		total += val[i];
	}
	
	memset(dp, -1, sizeof dp);
	
	for(int i = total ; i >= 0 ; i --){
		if(solve(0,i) <= w){
			cout << i << "\n";
			return 0;
		}
	}
	
	return 0;
}

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

int main() {
  
  long long N, A, B;
  cin >> N >> A >> B;
  
  if ((B - A) % 2 == 0) cout << (B - A) / 2 << endl;
  
  else {
    
    long long x, y;
    x = (A + B - 1) / 2;
    y = N - (A + B - 1) / 2;
    
    if (x > y) cout << y << endl;
    else cout << x << endl;
  
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N;
long long h[100010];


long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    for (int i = 0; i < 100100; ++i) dp[i] = INF;


    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
import fractions
import functools

MOD = int(1e9) + 7


def lcm(a, b):
    c, d = a, b
    while d != 0:
        c, d = d, c % d
    return a // c * b


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x, MOD - 2)


N = int(input())
A = list(map(int, input().split()))

v = functools.reduce(lcm, A)
v %= MOD
ans = 0
for a in A:
    ans = (ans + v * Inv.inv(a)) % MOD
print(ans)


Measured memory_bytes: 68696
#include<iostream>
using namespace std;
int main(){
  unsigned int H, W;
  while(cin>>H>>W && H !=0 && W!=0) {
    for(int i=0; i<H; i++) {
      for(int j =0; j<W; j++){

         if(i == 0 || i == H-1 || j == 0 || j == W-1 ) cout << '#';
         else cout <<'.';
       }
      cout << endl;
    }
    cout << endl; 
  }
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    set<string> st;
    rep(i,N){
        string s;
        cin >> s;
        st.emplace(s);
    }
    cout << st.size() << endl;
}

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

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

int main(){
  long long A,B,C,D;
  cin>>A>>B>>C>>D;
  A--;
  long long CD = C*D/gcd(C,D);
  cout << B - B/C - B/D + B/CD - A + A/C + A/D - A/CD << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll K; cin >> K;
    ll A, B; cin >> A >> B;
    if(A%K==0){
        cout << "OK";
    }else if(B%K==0){
        cout << "OK";
    }else{
        if(A/K == B/K){
            cout << "NG";
        }else{
            cout << "OK";
        }
    }
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

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

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int H, W, dist[55][55], num_white;
string S[55];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
queue<pair<int, int>> Q;

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

  cin >> H >> W;
  for (int i = 0; i < H; ++i){
    cin >> S[i];
    for (int j = 0; j < W; ++j){
      if (S[i][j] == '.') {
        ++num_white;;
      }
    }
  }
  
  for (int i = 0; i < 55; ++i){
    for (int j = 0; j < 55; ++j){
      dist[i][j] = (1 << 30);
    }
  }

  Q.push(make_pair(0, 0));
  dist[0][0] = 0;

  while (!Q.empty()){
    int x = Q.front().first, y = Q.front().second;
    Q.pop();

    for (int i = 0; i < 4; ++i){
      int x1 = x + dx[i], y1 = y + dy[i];
      if (x1 < 0 || y1 < 0 || H <= x1 || W <= y1 || S[x1][y1] == '#' || dist[x1][y1] <= dist[x][y] + 1) continue;
      Q.push(make_pair(x1, y1));
      dist[x1][y1] = dist[x][y] + 1;
    }
  }

  if (dist[H-1][W-1] == (1 << 30)){
    cout << "-1" << endl;
  }else{
    cout << (num_white - dist[H-1][W-1] - 1) << endl;
  }
}

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

const int MAX_N = 1e5 + 10;

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }


int main()
{
    int n;
    cin >> n;
    if (n < 10)
    {
        cout << n << endl;
    }
    else if (n < 1e2)
    {
        cout << 1e1 - 1e0 << endl;
    }
    else if (n < 1e3)
    {
        cout << (n - 1e2) + 1 + (1e1 - 1e0) << endl;
    } else if( n < 1e4)
    {
        cout << (1e3 - 1e2) + (1e1 - 1e0) << endl;
    } else if(n < 1e5)
    {
        cout << (n - 1e4) + 1 +(1e3 - 1e2) + 9 << endl;
    } else
    {
        cout << (1e5 - 1e4) + (1e3 - 1e2) + 9 << endl;
    }
}

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

signed main(){

  int A,B,K; cin >> A >> B >> K;
  for(int i = 0; i < K; i++){
    if((i&1) == 0){ //高橋君のターン
      if(A%2 == 1) A--;
      B += A/2;
      A /= 2;
    }
    else { //高橋君のターン
      if(B%2 == 1) B--;
      A += B/2;
      B /= 2;
    }
  }
  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
// Problem : B - ISU
// Contest : AtCoder - AtCoder Beginner Contest 078
// URL : https://atcoder.jp/contests/abc078/tasks/abc078_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int x,y,z;
	cin>>x>>y>>z;
	int ans;
	for(int i=1;i<=100000;i++)
	{
		if(z+i*(y+z)<=x)
		ans=i;
		else
		break;
	}
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;

int main(){
    double a,b,c;
    cin >> a >> b >> c;
    cout << fixed << 0.5*a*b*sinf(c*M_PI/180) << endl;
    cout << fixed << a + b + sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cosf(c*M_PI/180)) << endl;
    cout << fixed << b*sin(c*M_PI/180) << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
}

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

using namespace std;

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

	if (N * A <= B) {
		cout << N * A << endl;
	}
	else {
		cout << B << endl;
	}




}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    int sum = 0;
    rep(i, n-1) sum += a[i];
    string yes = "Yes", no = "No";
    cout << (sum > a.back() ? yes : no) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool solve(int K,vector<int>& dp,int A[],int n) {
	if(K == 0) {
		return false;
	}
	if(dp[K]) {
		return true;
	}
	for(int i=0;i<n;i++) {
		if(A[i] > K) 
			continue;
		if(!solve(K-A[i],dp,A,n)) {
			return dp[K] = true;
		}
	}
	return false;
}
int main() {
	int n,k;
	cin>>n>>k;
	int ar[n];
	for(int i=0;i<n;i++) {
		cin>>ar[i];
	}
	vector<int> dp(k+1,false);
	if(solve(k,dp,ar,n)) {
		cout<<"First";
	}
	else {
		cout<<"Second";
	}
}

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

using namespace std;

int n, m, q;
int cat[11][11][11];

int v[11];

int mx, sum;

void bkt(int k)
{
    if(k == n + 1)
    {
        mx = max(mx, sum);
        return;;
    }

    for(int i = v[k - 1]; i <= m; i ++)
    {
        v[k] = i;
        int ant = sum;

        for(int j = 1; j < k; j ++)
            sum += cat[j][k][i - v[j]];

        bkt(k + 1);

        sum = ant;

    }
}

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

    for(int i = 1; i <= q; i ++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        cat[a][b][c] += d;

    }

    v[1] = 1;

    bkt(2);

    cout << mx << "\n";

    return 0;
}


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

#define sz(v) ((int)(v.size()))

    int n;
    string s, t;

bool smaller(int l, int r, int L, int R) {
    if (r - l > R - L)
    {
        s.swap(t);
        bool res = smaller(L, R, l, r);
        s.swap(t);
        return res ^ 1;
    }
    int len = min(r - l, R - L);
    string A = s.substr(l, len);
    string B = t.substr(L, len);
    if (r - l == R - L)
        return A < B;
    if (A == B)
        return smaller(l, r, L + len, R);
    return A < B;
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> n;
    cin >> s >> t;
    if (!smaller(0, sz(s), 0, sz(t)))
        s.swap(t);
    for (int i=n; i>=0; i--)
        if (1LL * i * sz(s) <= n && (n - 1LL * i * sz(s)) % sz(t) == 0)
        {
            for (int j=0; j<i; j++)
                cout << s;
            for (int j=0; j<(n - 1LL * i * sz(s)); j+= sz(t))
                cout << t;
            cout << "\n";
            return 0;
        }
    assert(0);
    return 0;
}


Measured memory_bytes: 44436