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

#define int long long

int h[100001];
int n, a, b;

auto check(int k) -> bool {
    int res = 0;
    for(int i=0; i<n; ++i) {
        if(b*k<h[i]) {
            if((h[i]-k*b)%(a-b)==0) res += (h[i]-k*b)/(a-b);
            else res += (h[i]-k*b)/(a-b)+1;
        }
    }
    return res <= k;
}

auto main() -> signed {
    cin >> n >> a >> b;
    for(int i=0; i<n; ++i) cin >> h[i];
    int lo=0;
    int hi = 1e+9;
    int mid;
    while(lo<hi) {
        mid = (lo+hi)/2;
        if(check(mid)) {
            hi = mid;
        } else lo = mid+1;
    }
    cout << hi << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
int A,B,C,D,E,F;
int main() {
  cin >>A>>B>>C>>D>>E>>F;
  double mx = (double) E/(100+E);
  vb sugar(F+1);
  vb water(F+1);
  // sugar[0]=water[0]=true;
  rep(i,F+1) rep(j,F+1) {
    int x = A*i+B*j; x*=100;
    if (x<=F) {
      water[x]=true;
    }
  }
   rep(i,F+1) rep(j,F+1) {
    int x=C*i+D*j;
    if (x<=F) {
      sugar[x]=true;
    }
  }
  int sugarAmount = 0;
  pair<int, double> ans(100,0);
  rep(i,F+1)rep(j,F+1) {
    if (water[i]) {
      int s = j; if (!sugar[j]) s=0;
      int amount = i+s;
      if (amount == 0) continue;
      double conc = (double) s/amount;
      if (amount>F) continue;
      if (conc>mx) continue;
      if (ans.second <= conc) {
        ans = make_pair(amount, conc);
        sugarAmount = max(sugarAmount, s);
      }
    }
  }
  printf("%d %d\n", ans.first, sugarAmount);
  return 0;
}

Measured memory_bytes: 256
import sys
 
n = int(input())
r0 = int(input())
r1 = int(input())
mx = r1-r0
mn = min(r1,r0)
 
for i in map(int,sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
        if 0 > i-mn:
            mn = i
    elif mn > i:
        mn = i
 
print(mx)

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

int main() {
  string K;
  int S;
  cin >> S;
  cin >> K;
  int K_size = K.size();
  if (K_size > S){
    cout << K.erase(S) << "..." << endl;
  }
  else {
    cout << K << endl;
  }
}

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

ll mypow(ll x, ll n){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}
const ll num = mypow(10,9);
const ll num2 = mypow(10, 17);

int main() {
  ll s;
  cin >> s;
  if(s == mypow(10,18)){
    cout << 0 << " " << 0 << " " << num << " " << 0 << " " << 0 << " " << num << endl;
    return 0;
  }
  if (s <= num){
    cout << 0 << " "<< 0 << " " << s << " " << 0 << " " << 0 << " "<< 1 << endl;
  }else {
    ll sqrt_num = sqrt(s);
    sqrt_num++;
    ll tmp = s - sqrt_num * sqrt_num;
    cout << 0 << " " << 0 << " " << sqrt_num << " " << 1 << " " << abs(tmp) << " " << sqrt_num << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b; cin >> a >> b;
	if( a <= 5 ) cout << 0 << endl;
	else if( a <= 12 ) cout << b/2 << endl;
	else cout << b << endl;
	return 0;
}

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

int main()
{
	int a, b, c, x, t = 0;
	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x)
					t++;
			}
		}
	}

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
V = int(input())
edge = [[] for _ in range(V)]
for _ in range(V):
    u, _, *v = map(lambda x: int(x)-1, input().split())
    edge[u] = sorted(v)
dist = [-1] * V
dist[0] = 0
que = deque([0])

while len(que):
    v = que.popleft()
    for c in edge[v]:
        if dist[c] == -1:
            dist[c] = dist[v] + 1
            que.append(c)
for i, d in enumerate(dist):
    print(i+1, d)

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;

	int cnt = 0;
	for (int i = 100; i > 0; i--) {
		if (a % i == 0 && b % i == 0) {
			cnt++;
			if (cnt == k) cout << i << endl;
		}
	}

}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++)
			h[i] = in.nextInt();
		System.out.println(solve(n, h));
		in.close();
	}

	private static String solve(int n, int[] h) {
		h[0]--;
		for (int i = 1; i < n; i++)
			if (h[i] > h[i - 1])
				h[i]--;
			else if (h[i] < h[i - 1])
				return "No";
		return "Yes";
	}
}

Measured memory_bytes: 49240
N,M = gets.split.map(&:to_i)
Mod = 10**9+7
A = gets.split.map(&:to_i).sort
B = gets.split.map(&:to_i).sort

if A.uniq.size < A.size || B.uniq.size < B.size
  p 0; exit
end

HA = Hash[A.map{ |a| [a,1] }]
HB = Hash[B.map{ |a| [a,1] }]

ans = 1
spent = 0
n = m = 0
(1..N*M).reverse_each{ |x|
  case
  when HA[x] && !HB[x]    
    ans = ans * m % Mod
    n += 1
  when !HA[x] && HB[x]
    ans = ans * n % Mod
    m += 1
  when !HA[x] && !HB[x]
    ans = ans * (n * m - spent) % Mod
  else
    n += 1; m += 1
  end
  spent += 1
}
#p n, m, spent - N*M
p ans

Measured memory_bytes: 11892
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=10000;
const int MAXMLT=100;
const int MOD=1000000007;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }

char s[MAXLEN+1]; int slen;
int mlt;

int dp[MAXLEN+1][MAXMLT][2];

int solve() {
	memset(dp,0,sizeof(dp)); inc(dp[0][0][1],1);
	REP(i,slen) REP(j,mlt) REP(k,2) {
		REP(dig,10) {
			if(k==1&&dig>s[i]-'0') continue;
			int nk=k==1&&dig==s[i]-'0'?1:0;
			int nj=(j+dig)%mlt;
			inc(dp[i+1][nj][nk],dp[i][j][k]);
		}
	}
	int ret=MOD-1; REP(k,2) inc(ret,dp[slen][0][k]); return ret;	
}

void run() {
	scanf("%s",s); slen=strlen(s);
	scanf("%d",&mlt);
	printf("%d\n",solve());
}

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


Measured memory_bytes: 8064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        
        // 高橋くんのモンスター
        int a = sn.nextInt();
        int b = sn.nextInt();
        
        // 青木くんのモンスター
        int c = sn.nextInt();
        int d = sn.nextInt();
        
        while(a > 0 && c > 0) {
            // 高橋くんのターン
            c -= b;
            if(c <= 0) {
                System.out.print("Yes");
                return;
            }
            // 青木くんのターン
            a -= d;
            if(a <= 0) {
                System.out.print("No");
                return;
            }
        }
    }
}


Measured memory_bytes: 35768
s = int(input())
a = [s]

def func(n):
  if n % 2 == 0:
    a.append(n//2)
  elif n % 2 == 1:
    a.append(3*n + 1)
  
i = 1
while True:
  func(a[-1])
  i += 1
  if a.count(a[-1]) == 2:
    break
  else:
    pass


print(i)

Measured memory_bytes: 9056
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

int color (int[] c1, int[] c2) {
  return (c1[0] - c2[0])^^2 + (c1[1] - c2[1])^^2 + (c1[2] - c2[2])^^2;
}

void main()
{
  auto col = ["black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"];
  auto rgb = [[0, 0, 0],
              [0, 0, 255],
              [0, 255, 0],
              [0, 255, 255],
              [255, 0, 0],
              [255, 0, 255],
              [255, 255, 0],
              [255, 255, 255]
             ];
	foreach (line; stdin.byLine) {
    auto x = line.chomp;
    if (x == "0") break;
    auto a = x[1..$].map!(x => x >= 'a' ? x - 'a' + 10 : x - '0').array;
    int c[3];
    foreach (i; 0..3) {
      c[i] = a[i*2] * 16 + a[i*2+1];
    }
    auto maxi = int.max;
    string name;
    foreach (i, e; rgb) {
      auto t = color(c, e);
      if (t < maxi) {
        maxi = t;
        name = col[i];
      }
    }
    name.writeln;
  }
}

Measured memory_bytes: 1056
#include<stdio.h>

int main(){
    int a[30];
    int i;
    int x;
	int k[2];
	
    for(i=0;i<30;i++){
      a[i]=0;
		}

	 
    for(i=0;i<28;i++){
      scanf("%d",&x);
	  a[x-1]=1;
		}
		
    for(i=0;i<30;i++){
       if(a[i]==0){
          printf("%d\n",i+1);
	   	}
	   	
		}
	
return 0;
	}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int k;
    cin >> k;
    vector<vector<vector<int>>> dp(n, vector<vector<int>>(k+1, vector<int>(2, 0)));
    dp[0][0][0] = 0;
    dp[0][0][1] = 1;
    dp[0][1][0] = 1;
    dp[0][1][1] = s[0] - '0' - 1;
    for(int i = 1; i < n; i++){
        dp[i][0][0] = 0;
        dp[i][0][1] = 1;
        for(int j = 1; j <= k; j++){
            if(s[i] == '0'){
                dp[i][j][0] = dp[i-1][j][0];
                dp[i][j][1] = dp[i-1][j][1] + dp[i-1][j-1][1] * 9;
            }else{
                dp[i][j][0] = dp[i-1][j-1][0];
                dp[i][j][1] = dp[i-1][j][1] + dp[i-1][j][0] + dp[i-1][j-1][1] * 9 + dp[i-1][j-1][0] * (s[i] - '0' - 1);
            }
        }
    }
    cout << dp[n-1][k][0] + dp[n-1][k][1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return x<a.x;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[500101][2],pp[500100][4];
int l[500101];
int j[500101];

long long x,y,z,mod=1000000007,mod2=1000000009;
//string r;
char r[500101];

P u[1];
//queue<int> q;
//stack<int> s;
set<P> s;
map<int,int> p;

vector<int> v[500100];

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

long long f(long long x,long long y)
{
  long long p=1;
  for(;y;y/=2,x*=x,x%=mod)
  if(y%2) p*=x,p%=mod;
  return p;
}
long long g(long long x,long long y)
{
  long long p=1;
  for(;y;y/=2,x*=x,x%=mod2)
  if(y%2) p*=x,p%=mod2;
  return p;
}

long long ff(int n,int m)
{
  long long x=(o[m][0]-o[n-1][0]+mod)%mod*pp[n][2]%mod,y=(o[m][1]-o[n-1][1]+mod2)%mod2*pp[n][3]%mod2;
  return x+y*mod;
}

int main()
{
  scanf("%s",r+1);
  a=strlen(r+1);
  for(int t=1;t<=a;t++)
  {
    for(long long w=t;w<=a;w+=t)
      v[w].push_back(t);
  }
  for(int h=0;h<4;h++)
    pp[1][h]=1;
  x=f(27,mod-2);
  y=g(27,mod);
  for(int t=1;t<=a;t++)
  {
    pp[t+1][0]=pp[t][0]*27%mod;
    pp[t+1][1]=pp[t][1]*27%mod2;
    pp[t+1][2]=pp[t][2]*x%mod;
    pp[t+1][3]=pp[t][3]*y%mod2;
  }
  for(int t=1;t<=a;t++)
  {
    o[t][0]=((r[t]-'a'+1)*pp[t][0]+o[t-1][0])%mod;
    o[t][1]=((r[t]-'a'+1)*pp[t][1]+o[t-1][1])%mod2;
  }
  for(i=1;i<a;i++)
  if(a%i==0)
  {
    int t=i+1;
    for(;t<=a;t++)
    if(r[t]!=r[t-i]) break;
    if(t>a) break;
  }
  if(i==1||i==a)
  {
    printf("%d\n1",a/i);
    return 0;
  }
  puts("2");
  //set<long long> s;
  for(int t=1;t<=a;t++)
  {
    for(int h=0;h<v[t].size();h++)
    {
      int i=v[t][h];
    if(t%i==0)
    {
      //printf("%lld %d //%d\n",((o[t][0]-o[i][0]+mod)*pp[i+1][2])%mod+((o[t][1]-o[i][1]+mod2)*pp[i+1][3])%mod2*mod,i,t);
      //printf("%lld %lld %d %d\n",ff(i+1,t),ff(1,t-(i+1)+1),i,t);
      if((ff(i+1,t)==ff(1,t-(i+1)+1)&&t>i))
      {
        //printf("%d %d\n",t,i);
       goto qwe;
      }
    }
    }
    l[t]=1;
    qwe:;
  }
  
  for(int t=1;t<=a;t++)
  {
    for(int h=0;h<v[a-t+1].size();h++)
    {
      int i=v[a-t+1][h];
    if((a-t+1)%i==0)
    {
      if(ff(t,a-i)==ff(t+i,a)&&a-t+1>i) goto qwet;
    }
    //j[t]=1;
    }
    j[t]=1;
    qwet:;
  }
  for(int t=1;t<=a;t++)
    if(l[t]&&j[t+1]) k++;
  printf("%d",k);
}
//0
//21



Measured memory_bytes: 83712
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int ans = 0;
    for (int i=0; i<5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            ans = i + 1;
        }
    }

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

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

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

	int arr[n];

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

	int check = 0;
	int ans = 1;

	for (int i = 0; i < n - 1; i++) {
		if (check == 0) {
			if (arr[i] < arr[i + 1]) {
				check = 1;
			} else if (arr[i] > arr[i + 1]) {
				check = 2;
			}
		}

		if (check == 1) {
			if (arr[i] > arr[i + 1]) {
				check = 0;
				ans++;
			}
		}

		if (check == 2) {
			if (arr[i] < arr[i + 1]) {
				check = 0;
				ans++;
			}

		}
	}

	cout << ans << endl;

}




Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;
ll C[26];
ll S[365][26];
ll T[365];
ll L[26];
int main() {
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  for (int i=0; i<26; i++) {
    cin >> C[i];
  }
  for (int i=0; i<D; i++) {
    for (int j=0; j<26; j++) {
      cin >> S[i][j];
    }
  }
  for (int i=0; i<D; i++) {
    cin >> T[i];
    T[i]--;
  }
  ll ret = 0;
  for (int i=0; i<D; i++) {
    ret += S[i][T[i]];
    L[T[i]] = i + 1;
    for (int j=0; j<26; j++) {
      ret -= C[j] * (i + 1 - L[j]);
    }
    cout << ret << '\n';
  }
}

Measured memory_bytes: 3684
#include <iostream>
#include <map>

char solve(const char b)
{
  std::map<char, char> base = {
    {'A', 'T'},
    {'T', 'A'},
    {'G', 'C'},
    {'C', 'G'}
  };

  return base[b];
}

int main(int argc, char *argv[])
{
  // Input
  char b;

  std::cin >> b;

  // Output
  std::cout << solve(b) << std::endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 20:49:38 2019

@author: Yamazaki Kenichi
"""

b = input()

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
elif b == 'G':
    print('C')

Measured memory_bytes: 2940
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        char[] arr = new char[s.length()];
        for (int i = 0; i < s.length(); i++) {
            arr[i] = s.charAt(i);
        }

        Arrays.sort(arr);

        char ch = arr[0];
        for (int i = 1; i < s.length(); i++) {
            if (ch == arr[i]) {
                System.out.println("no");
                return;
            }
            ch = arr[i];
        }
        System.out.println("yes");
    }
}


Measured memory_bytes: 23636
#include <stdio.h>
int main(void){
    int n,m,a,b[100],i,j,tmp;
    int h[1000],p[1000],q[1000];
    for(;;){
        for(i=0;i<100;i++){
            b[i]=i+1;
        }
        for(i=0;i<1000;i++){
            h[i]=0;p[i]=0;q[i]=0;
        }
        scanf("%d %d %d",&n,&m,&a);
        if(n+m+a==0){
            break;
        }
        for(i=0;i<m;i++){
            scanf("%d %d %d",&h[i],&p[i],&q[i]);
        }
        for(i=1000;i>0;i--){
            for(j=0;j<m;j++){
                if(h[j]==i){
                    tmp=b[p[j]-1];
                    b[p[j]-1]=b[q[j]-1];
                    b[q[j]-1]=tmp;
                }
            }
        }
        for(i=0;i<n;i++){
            if(a==b[i]){
                printf("%d\n",i+1);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 608
#include <iostream>

using namespace std;

char p[2000][2000];

int a, b, n, m, i, j;

void x(int i,int j){if(a)p[i][j]=60,p[i][j+1]=62,a--;}
void y(int i,int j){if(b)p[i][j]=94,p[i+1][j]=118,b--;}
#define c for(i=n%2;i<n;i+=2)
#define d for(j=m%2;j<m;j+=2)

int main() {
	cin>>n>>m>>a>>b;

	if(n&1)d x(0,j);
	if(m&1)c y(i,0);
	if(n>2&m>2&n&m&a&a>0&b>0)a++,x(0,0),x(2,1),y(0,2);
	c d if(p[i][j+1]);else if(a)x(i,j),x(i+1,j);else y(i,j),y(i,j+1);

	if(a|b)cout<<"NO\n";
	else{
		cout<<"YES\n";
		for(i=0;i<n;i++){
			for(j=0;j<m;j++)cout<<max(p[i][j],'.');
			cout<<endl;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n+1);
  a[0] = 300;
  REP(i, n) cin >> a[i+1];
  ll init = 1000;
  ll kabu = 0;
  a.push_back(0);
  FOR(i, 1, n+1){
    if (a[i-1] >= a[i] and a[i] < a[i+1]){
      kabu += init/a[i];
      init = init % a[i];
    }
    if (a[i] > a[i+1] and a[i-1] <= a[i]){
      init += kabu * a[i];
      kabu = 0;
    }
  }
  cout << init << endl;
  return 0;
}



Measured memory_bytes: 3632
#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>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#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--)

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; }

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
int main() {
    init();
    ll H,W;
    cin >> H >> W;
    vc<string> S(H);
    rep(i, H) cin >> S[i];

    vvc<ll> A(H, vl(W, INF));
    A[0][0] = 0;
    queue<pair<ll, ll>> q;
    q.emplace(0, 0);

    vc<pair<ll, ll>> d = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    while(!q.empty()){
        ll h, w;
        tie(h, w) = q.front(), q.pop();
        for(auto& p:d){
            ll nh = h + p.first, nw = w + p.second;
            if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
            if (S[nh][nw] == '#') continue;
            if(chmin(A[nh][nw], A[h][w]+1)){
                q.emplace(nh, nw);
            }
        }
    }

    ll v = A[H - 1][W - 1];
    if(v==INF){
        cout << -1 << endl;
    }
    else{
        ll bcnt = 0;
        rep(i, H) rep(j, W) if (S[i][j] == '#') bcnt++;
        cout << H * W - (bcnt + v + 1) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int W,H,x,y;
    scanf("%d %d %d %d", &W, &H, &x, &y);
    
    printf("%lf %d\n", (double)W*H/2, (2*x==W && 2*y==H)? 1:0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<a-1<<endl;
    }
    else{
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

  int a, b;
  cin >> a >> b;

  if(a<=b){
    cout << a << endl;
  } else {
    cout << a-1 << endl;
  }

	return 0;
}


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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int n,W;
		cin >> n >> W;
		int w[n];
		ll v[n];
		ll dp[W+1]={0ll};
		for(int i=0;i<n;i++){
			cin >> w[i] >> v[i];
			for(int j=W-w[i];j>=0;j--) dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
		}
		ll ans=0ll;
		for(int i=0;i<=W;i++) ans = max(ans,dp[i]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
/*
[m-solutions2019] C - Best-of-(2n-1)
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 100000;
const ll MOD = 1e9 + 7;

int N, A, B, C;
ll pa[2 * MAX_N + 1], pb[2 * MAX_N + 1], ph[2 * MAX_N + 1];
ll fact[2 * MAX_N + 1];

ll extgcd(ll a, ll b, ll& x, ll& y) {
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x) % m;
}

ll solve() {
    pa[0] = 1;
    pb[0] = 1;
    ph[0] = 1;
    for (int i = 1; i <= 2 * N; i++) {
        pa[i] = (pa[i - 1] * A) % MOD;
        pb[i] = (pb[i - 1] * B) % MOD;
        ph[i] = (ph[i - 1] * (100 - C)) % MOD;
    }

    fact[0] = 1;
    for (int i = 1; i <= 2 * N; i++) {
        fact[i] = (fact[i - 1] * i) % MOD;
    }

    ll ans = 0;
    for (int i = N; i <= 2 * N - 1; i++) {
        ll tmp =
            (fact[i - 1] * mod_inv(fact[N - 1] * fact[i - N] % MOD, MOD)) % MOD;
        (tmp *= (((pa[N] * pb[i - N] % MOD + pa[i - N] * pb[N] % MOD) % MOD) *
                 i * 100) %
                MOD) %= MOD;
        (tmp *= mod_inv(ph[i + 1] % MOD, MOD)) %= MOD;
        (ans += tmp) %= MOD;
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 6528
package main
import(
  "fmt"
)
func main(){
  var n, i int
	flag:=0
	fmt.Scan(&n)
	for{
		l:
		for i=2;i<n;i++{
			if n%i==0{
				flag++
				break l
			}
		}
		if flag==0{
			fmt.Println(n)
			return
		}
		n++
		flag=0
 	}
}


Measured memory_bytes: 512
class vector:
    data = []

    def pashBack(self, x):
        self.data.append(x)

    def randomAccess(self, p):
        return self.data[p]

    def popBack(self):
        deta_index = len(self.data)-1
        del self.data[deta_index]


q = int(input())
v = vector()

for i in range(q):
    order = input().split()

    if order[0] == "0":
        x = int(order[1])
        v.pashBack(x)

    elif order[0] == "1":
        x = int(order[1])
        data = v.randomAccess(x)
        print(data)

    elif order[0] == "2":
        v.popBack()



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

using namespace std;

#define all(v) v.begin(),v.end()

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long n;
	cin >> n;
	vector <long> v(n);
	for (auto &x : v){
		cin >> x;
	}
	sort(all(v));
	long key = n/2;
	cout << v[key] - v[key-1];
	return 0;
}

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

int main() {
  string SA, SB, SC;
  cin >> SA >> SB >> SC;

  string player = "a";

  while(1) {
    if(player == "a"){
      if(SA.length() == 0){
        cout << "A" << endl;
        exit(0);
      }
      player = SA[0];
      SA.erase(0,1);
    }else if(player == "b"){
      if(SB.length() == 0){
        cout << "B" << endl;
        exit(0);
      }
      player = SB[0];
      SB.erase(0,1); 
    }else if(player == "c"){
      if(SC.length() == 0){
        cout << "C" << endl;
        exit(0);
      }
      player = SC[0];
      SC.erase(0,1);
    }
  }
}

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

constexpr int px[19] = {1,1,2,2,2,3,3, 0,0,0,1,1,2,2,3,3,4,4,4};
constexpr int py[19] = {1,2,1,2,3,2,3, 0,1,2,0,3,0,4,1,4,2,3,4};
constexpr int dx[7] = {-1,-1,0,0,0,1,1};
constexpr int dy[7] = {-1,0,-1,0,1,0,1};

string check(string c) {
    for (char& e: c) {
        e -= '0';
    }

    char field[3][5][5];

    for (int j = 0; j < (1<<19); ++j) {

        for (int k = 0; k < 19; ++k) {
            field[0][px[k]][py[k]] = (j & (1 << k)) != 0 ? 1 : 0;
        }

        for (int k = 0; k < 7; ++k) {
            int x = px[k], y = py[k];
            int pattern = 0;
            for (int l = 0; l < 7; ++l) {
                if (field[0][x+dx[l]][y+dy[l]] > 0) {
                    pattern |= (1 << l);
                }
            }
            field[1][x][y] = c[pattern];
        }

        {
            int pattern = 0;
            for (int l = 0; l < 7; ++l) {
                if (field[1][2+dx[l]][2+dy[l]] > 0) {
                    pattern += (1 << l);
                }
            }
            field[2][2][2] = c[pattern];
        }

        if (field[1][2][2] != field[2][2][2]) {
            return "no";
        }
    }

    return "yes";
}

bool solve() {
    string c;
    cin >> c;
    if (c == "#") { return false; }
    cout << check(c) << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3244
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

const int MOD=1e9+7;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin >> n >> m;

	if(abs(n-m) >= 2) cout << "0\n";
	else{
		long long ans=1;
		
		for(int i=n;i>=2;i--){
			ans=ans*i%MOD;
		}
		for(int i=m;i>=2;i--){
			ans=ans*i%MOD;
		}
		if(n==m){
			ans = ans*2%MOD;
		}
		cout << ans << "\n";
	}
	return 0;
}

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

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    vector<int> a(3);
    rep(i, 3) cin >> a.at(i);
    sort(a.begin(), a.end());
    if (a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

int n,m,a[1100], b[1100];bool c[1100][20];
int dp[10000];
signed main(){
  cin>>n>>m;

  rep(i,m){
    cin>>a[i]>>b[i];
    rep(j,b[i]){
      int cc;cin>>cc;cc--;
      c[i][cc] = true;
    }
  }

  rep(i,10000)dp[i] = INF;
  dp[0] = 0;

  rep(bit,1<<n){
    rep(i,m){
      int bb = bit;
      rep(j,n){
        if(c[i][j]){
          bb |= (1<<j);
        }
      }
      chmin(dp[bb], dp[bit] + a[i]);
    }
  }
  cout << (dp[(1<<n)-1] == INF ? -1 : dp[(1<<n)-1]) << endl;
}


Measured memory_bytes: 384
from collections import defaultdict
import sys
from math import gcd
count = defaultdict(int)
N = int(sys.stdin.readline())

zeros = 0
for i in range(N):
    A, B = [int(x) for x in input().split()]
    if A == B == 0:
        zeros += 1
        continue
    if A == 0:
        angle = (0, 1)
    elif B == 0:
        angle = (1, 0)
    else:
        sgn = A // abs(A)
        g = gcd(A, B)
        angle = (A // sgn // g, B // sgn // g)

    count[angle] += 1
# print(count)

pairs = {}
solos = []
for k1 in count:
    if k1 in pairs:
        continue
    if k1 == (0, 1):
        if (1, 0) in count:
            pairs[(1, 0)] = k1
        else:
            solos.append(k1)
        continue

    A, B = k1
    if B:
        sgn = -B // abs(B)
        k2 = (-B // sgn, A // sgn)
    else:
        k2 = (0, 1)
    if k2 in count:
        pairs[k2] = k1
    else:
        solos.append(k1)
#print(pairs, solos)

P = 1000000007


def pow2(n):
    # if n < 30:
    #     return 2 ** n

    # p = pow2(n // 2)
    # pp = (p * p) % P
    # if n % 2 == 1:
    #     return (2 * pp) % P
    # else:
    #     return pp
    return pow(2, n, P)


result = 1
for p in pairs:
    # print("pair", p, count[p], pairs[p], count[pairs[p]])
    n = count[p]
    m = count[pairs[p]]
    result = result * ((pow2(n) - 1) + (pow2(m) - 1) + 1) % P
for k in solos:
    # print("solo", k, count[k])
    result = result * pow2(count[k]) % P

print((result + zeros - 1) % P)


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int a,b;cin>>a>>b;
	for(int i=1;i<=100000;i++){
		int C=i*0.08,D=i*0.10;
		if(C==a&&D==b){
			cout<<i<<endl;
			return 0;
		}
	}
	puts("-1");
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Graph graph;
Vec from, to, cnt;

void dfs(ll node){
	for(auto p : graph[node]){
		if(to[p.sc] != -1) continue;
		to[p.sc] = INF;
		dfs(p.fs);
		if(cnt[p.fs] & 1){
			from[p.sc] = p.fs;
			to[p.sc] = node;
			++cnt[p.fs];
		}else{
			from[p.sc] = node;
			to[p.sc] = p.fs;
			++cnt[node];
		}
		//co({p.sc, from[p.sc], to[p.sc]});
	}
}

int main(void){
	ll n, m;
	cin >> n >> m;
	graph.resize(n);
	from.resize(m);
	to.resize(m, -1);
	cnt.resize(n);
	rep(i, m){
		ll a, b;
		cin >> a >> b;
		--a, --b;
		graph[a].pb({b, i});
		graph[b].pb({a, i});
	}

	if(m & 1){
		co(-1);
		return 0;
	}

	dfs(0);

	rep(i, m) co({from[i] + 1, to[i] + 1});

	return 0;
}


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

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

int main()
{
  int a, b, c, e, f, g, h, m, s;

  while (cin >> a >> b >> c >> e >> f >> g){
    if (g - c < 0){
      f -= 1;
      s = g + 60 - c;
    }
    else s = g - c;
    if (f - b < 0){
      e -= 1;
      m = f + 60 - b;
    }
    else m = f - b;
    h = e - a;
    
    cout << h << " " << m << " " << s << endl;
  }
}

Measured memory_bytes: 1160
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		long H = nextLong();
		int count = 0;
		long output = 0;
		while(H > 0){
			output += (long)Math.pow(2, count);
			H /= 2;
			count++;
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32884
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    string s; cin >> s;
    if(s.at(1)==s.at(2) && s.at(0)==s.at(1)){
        cout << "No" << endl;
    }else{
        cout << "Yes" <<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

long dis(long h, long w, long x, long y){
  long z1 = max(x*w, max(y*(h-x), (w-y)*(h-x)));
  long z2 = min(x*w, min(y*(h-x), (w-y)*(h-x)));
  return z1 - z2;
}

int main(){
  long h,w;
  cin >> h >> w;
  if(h == 2 && w == 2){
    cout << 1 << endl;
    return 0;
  }
  long ans = 1e11;
  if(h > 2){
    if(h % 3 == 0) ans = 0;
    else ans = min(ans, w);
  }
  if(w > 2){
    if(w % 3 == 0) ans = 0;
    else ans = min(ans, h); 
  }
  long x = h/3;
  long y = w/2;
  ans = min(ans, dis(h,w,x,y));
  ans = min(ans, dis(h,w,x+1,y));
  x = w/3;
  y = h/2;
  ans = min(ans, dis(w,h,x,y));
  ans = min(ans, dis(w,h,x+1,y));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max(0, a + b - n) << endl;

  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

bool isPrime(int n);

int main(){
    int x;
    cin >> x;
 
    while(true){
        if(isPrime(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }
    
    return 0;
}

bool isPrime(int n){
    bool result=false;
    if(n==1){
        return false;
    }
    else if(n==2){
        return true;
    }
    else if(n>2){
        bool is_prime = true;
        for(int i=2; i<n; i++){
            if(n%i==0){
                is_prime = false;
            }
        }
        result = is_prime;
    }
    return result;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    long long sum = 0;
    for (int i = 0; i < N; i++) sum += A[i];

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        sum -= A[i];
        ans += A[i] * (sum % MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4016
// turmak-_-
#include<bits/stdc++.h>

#define all(v) v.begin(),v.end()
#define nl "\n"
#define IOI return 0;
#define pb push_back
#define ll long long
#define ld long double
#define IOS ios_base :: sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define X first
#define Y second

using namespace std;
const int N = (int)2e5 + 7 ;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const int UNDEF = -1;

pii dx[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int dp[4000][4000];
pii  p[4000][4000];
int main() {
    IOS
    //freopen("lepus.in", "r", stdin);
    //freopen("lepus.out", "w", stdout);
    string a,b;
    cin>>a>>b;
    int n = a.size();
    int m = b.size();
    a = ' '+a;
    b = ' '+b;
    for(int i=1; i<=n; ++i) {
        for(int j=1; j<=m; ++j) {
            if(a[i]==b[j]) {
                dp[i][j]=dp[i-1][j-1]+1;
                p[i][j]={i-1,j-1};
            } else {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
                if(dp[i][j-1]>dp[i-1][j]) {
                    p[i][j]={i,j-1};
                } else {
                    p[i][j]={i-1,j};
                }
            }
        }
    }
    pii cur = {n,m};
    string s;
    while(true) {
        if(a[cur.X]==b[cur.Y]) s = a[cur.X]+s;
        if(cur.X<=1 && cur.Y<=1) {break;}
        pii Next = p[cur.X][cur.Y];
        cur.X = Next.X,cur.Y=Next.Y;
    }
    cout<<s;
    IOI
}


Measured memory_bytes: 132948
#define max(a,b)(a>b?a:b)
#define min(a,b)(a<b?a:b)
char s[1001];D[2][1001];main(n,i,j,M){
	for(;scanf("%d",&n),n;printf("%d\n",M))
		for(memset(D,0,sizeof(D)),M=i=0;i<n;i++){
			scanf("%s",s);
			for(j=1;j<=n;j++)if(s[j-1]=='*')D[1][j]=-1;
			for(j=1;j<=n;j++)D[1][j]=D[1][j]!=-1?min(D[0][j-1],min(D[0][j],D[1][j-1]))+1:0,M=max(M,D[1][j]);
			memcpy(D[0],D[1],sizeof(D[1]));
			memset(D[1],0,sizeof(D[1]));
		}
exit(0);}

Measured memory_bytes: 612
#include <stdio.h>
#include <math.h>
int main(){
  char line[100];
  double  sum, len;
  double r;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%lf", &r);
  sum=M_PI*r*r;
  len=2.0*M_PI*r;
  printf("%f %f\n", sum, len);
  return 0;
}



Measured memory_bytes: 2044
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC089D
{
    public class Program
    {
        int N;
        int K;
        int K2;
        int[,] imos;

        void Add(int lx, int ty, int rx, int by)
        {
            lx %= K2;
            ty %= K2;
            rx %= K2;
            by %= K2;

            if (lx > rx)
            {
                Add(lx, ty, K2 - 1, by);
                Add(0, ty, rx, by);
                return;
            }
            if (ty > by)
            {
                Add(lx, ty, rx, K2 - 1);
                Add(lx, 0, rx, by);
                return;
            }

            imos[ty, lx]++;
            imos[by + 1, lx]--;
            imos[ty, rx + 1]--;
            imos[by + 1, rx + 1]++;
        }

        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            N = ss.Next(int.Parse);
            K = ss.Next(int.Parse);
            K2 = K * 2;
            imos = new int[K2 + 1, K2 + 1];

            for (var i = 0; i < N; i++)
            {
                var X = ss.Next(int.Parse);
                var Y = ss.Next(int.Parse);
                var C = ss.Next(String);
                if (C == "B") X += K;

                Add(X, Y, X + K - 1, Y + K - 1);
                Add(X + K, Y + K, X + K2 - 1, Y + K2 - 1);
            }

            for (var i = 0; i <= 2 * K; i++)
            for (var j = 0; j <= 2 * K; j++)
            {
                if (i != 0) imos[i, j] += imos[i - 1, j];
                if (j != 0) imos[i, j] += imos[i, j - 1];
                if (i != 0 && j != 0) imos[i, j] -= imos[i - 1, j - 1];
            }

            sw.WriteLine(imos.Cast<int>().Max());
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }
    }
}

Measured memory_bytes: 30884