akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

long f(long h, long base);

int main(void){
  long h, attack, base;
  base=0;
  scanf("%ld", &h);
  
  if(h==1){
    printf("1");
    return 0;
  }
  
  base=1;
  //計算の始点となる指数（hが2^nよりおおきいか）を算出
  while(1){
    if(h >= (long) powl( (double) 2, (double) base+1)){
      base++;
    }else{
      break;
    }
  }

  attack = 2 * ( (long) powl( (double) 2, (double) base ) -1 ) + 1;
  printf("%ld", attack);
  
  return 0;
}

long f(long h, long base){
  
  if(h==1){
    return 1;
  }
  
  return 2 * ( (long) powl( (double) 2, (double) base ) -1 ) + 1;
  
}

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

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

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

int main(){

    ll n;
    cin >> n;

    ll ans = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

LL nC2(LL n)
{
  if (n < 2) return 0;
  return n * (n-1) / 2;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n, k;
  cin >> n >> k;
  VD p(n+1);
  REP(i, n)
  {
    cin >> p[i+1];
    p[i+1] = (1+p[i+1])/2;
  }
  REP(i, n) p[i+1] += p[i];
  double ans = 0;
  REP(i, n-k+1) chmax(ans, p[i+k]-p[i]);
  cout << setpre(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
    int n;
    cin >> n;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll t;
        cin >> t;
        a.push_back(t);
    }
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
    }
    ll sl1=0;
    int mark=0;
    for(int i=0;sl1<sum/2;i++){
        sl1+=a[i];
        mark=i;
    }
    ll sm1=sl1-a[mark];

    ll sl2=0;
    for(int i=n-1;sl2<sum/2;i--){
        sl2+=a[i];
        mark=i;
    }
    ll sm2=sl2-a[mark];

    ll med= sum/2;
    ll ans = min(min((sl1-med)*2,(sl2-med)*2),min((med-sm1)*2,(med-sm2)*2));

    if(sum%2==1){
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
    boost;
    int a,b,c;
    cin>>a>>b>>c;
    if(c<=a){
        cout<<a-c<<" "<<b<<"\n";
        return 0;
    }
    else{
        if((c-a)>=b){
            cout<<0<<" "<<0<<"\n";
            return 0;
        }
        cout<<0<<" "<<(b-(c-a))<<" "<<"\n";
        return 0;
    }
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
    
#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;


int main(void)
{
    char str[30] = {};
    char temp;
    int size = 0;
    gets(str);
    while(*(str+size))
        size++;
    RFOR(i, size-1,-1)
    cout << *(str+i);
    cout << endl;
    return 0;
    

    }

Measured memory_bytes: 1116
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

sN = len(s)
tN = len(t)

ans = ""
for ss,tt in zip(s,t):
  ans += ss + tt

if sN == tN:
  pass
else:
  ans += s[-1]

print(ans)

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

int main(){
    int a, b;
    int sum, red, mult;
    int result;

    cin >> a >> b;
    sum = a + b;
    red = a - b;
    mult = a * b;

    if(sum >= red && sum >= mult)
        result = sum;
    else if (red >= sum && red >= mult)
        result = red;
    else
        result = mult;

    cout << result << endl;
    
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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);
    
    int n, k;
    cin >> n >> k;
    vector <bool> a(n, false);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int tmp;
            cin >> tmp;
            a[tmp-1] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!a[i]) ans++;
    }

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



Measured memory_bytes: 3656
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new A().doIt();
	}
	
	class A{
		int n,m;
		int[] result;
		int zero,one;
		boolean calc(int target){
			int index = 0,num = 1;
			int c = ((target>>0)%2);
			for(int i=1;i<n;i++){
				if(c == (target>>i)%2)num++;
				else{
					if(result[m-index-1]!=num)return false;
					index++;
					num = 1;
					c = (target>>i)%2;
				}
			}
			if(result[m-index-1]!=num)return false;
			int z = 0;
			int o = 0;
			for(int i=0;i<n;i++){
				if((target>>i)%2==0)z++;
				else o++;
			}
			if(zero==z&&one==o)return true;
			return false;
		}
		
		int solve(ArrayList<Integer> kouho,char[] to){
			int result = Integer.MAX_VALUE/2;
			ArrayList<String> list = new ArrayList<String>();
			for(int i=0;i<kouho.size();i++){
				String a = "";
				for(int s=n-1;s>=0;s--)a+=((kouho.get(i)>>s)%2);
				list.add(a);
			}
//			System.out.println(list);
			
			for(int i=0;i<list.size();i++){
				int cnt = 0;
				boolean[] sw = new boolean[n];
				String target = list.get(i);
//				System.out.println(target);
				for(int s=0;s<n;s++)if(target.charAt(s)=='1'){
					for(int j=0;j<n;j++){
//						System.out.println(s+" "+j+" "+target.charAt(s)+" "+to[j]);
						if(to[j]==target.charAt(s)&&!sw[j]){
							sw[j] = true;
							cnt += Math.abs(j-s);
							break;
						}
//						System.out.println(Arrays.toString(sw));
					}
				}
				result = Math.min(cnt, result);
			}
			
			return result;
		}
		
		void doIt(){
			n = in.nextInt();
			m = in.nextInt();
			zero = 0;one = 0;
			char[] input = new char[n];
			for(int i=0;i<n;i++)input[i] = in.next().charAt(0);
			String input2 = "";
			for(int i=0;i<n;i++)input2+=input[i];
			result = new int[m];
			for(int i=0;i<m;i++)result[i] = in.nextInt();
			for(int i=0;i<n;i++){
				if(input[i]=='0')zero++;
				else one++;
			}
			ArrayList<Integer> kouho = new ArrayList<Integer>();
			for(int i=0;i<(1<<n);i++){
				if(calc(i))kouho.add(i);
			}
//			System.out.println(kouho);
//			for(int i=0;i<kouho.size();i++)System.out.println(Integer.toBinaryString(kouho.get(i)));
			System.out.println(solve(kouho,input));
		}
	}
	
}

Measured memory_bytes: 20812
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
const int MAXN = 1e5 + 5;

int main()
{
	zapp;
	string s;
	cin >> s;
	ll sum = 0, i, n = s.length();
	for (i = 0; i < n; i++) {
		sum += s[i] - '0';
	}
	if (sum % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}



Measured memory_bytes: 3748
c = {'I'=> 1, 'V'=> 5, 'X'=>10, 'L'=>50, 'C'=>100, 'D'=>500, 'M'=>1000}
while gets do
  arr = $_.chomp.chars

  sum = 0
  arr.size.times do |i|
    a = c[arr[i]]
    b = c[arr[i+1]]
    if b.nil?
      sum += a
    else
      sum = (a < b) ? sum-a : sum+a
    end
  end
  puts sum
end

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	string s;
	cin>>s;
	string s1="",s2="";
	s1=s.substr(0,n/2);
	s2=s.substr(n/2);
	if(s1==s2){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long c[501],s[501],f[501];

long long dfs(long long now,long long time){
  if(now==n){
    cout<<time<<endl;
    return 0;
  }
  if(s[now]<time){
    if(time%f[now]==0)dfs(now+1,time+c[now]);
    else dfs(now+1,time+(f[now]-time%f[now])+c[now]);
    //cout<<time+time%f[now]+c[now]<<endl;
  }
  else{
    dfs(now+1,s[now]+c[now]);
    //cout<<s[now]+c[now]<<endl;
  }
  return 0;
}

int main(){
  cin>>n;
  for(int i=1;i<n;i++){
    cin>>c[i]>>s[i]>>f[i];
  }
  for(int i=1;i<n;i++){
    dfs(i,0);
  }
  cout<<0<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    long long n,a,b,s;
    cin >> n >> a >> b;
    s = n/(a+b);
    cout << s*a+min(n%(a+b),a) << endl;
}

Measured memory_bytes: 256
arr = list(map(str, input().split()))

i = 0

operand = []

while i < len(arr):
    if arr[i] == '+':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b + a)
    elif arr[i] == '-':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b - a)
    elif arr[i] == '*':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b * a)
    else:
        operand.append(int(arr[i]))
    i += 1

print(operand[0])



Measured memory_bytes: 5604
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int cards[10];
set<int> nums;
int n;

void f(int m,int k,int used){
	if(k==0){
		nums.insert(m);
		return;
	}
	int i;
	for(i=0;i<n;i++){
		if(used&1<<i)continue;
		f(m*(cards[i]<10?10:100)+cards[i],k-1,used|1<<i);
	}
}

int main() {
	int k;
	while(n=in(),k=in()){
		nums.clear();
		int i;
		for(i=0;i<n;i++){
			cards[i]=in();
		}
		f(0,k,0);
		cout<<nums.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define INF (int)1e9
#define pb push_back
using namespace std;
 
long long int ncm(long long int n,long long int m){
  if(m>0) return (ncm(n,m-1)*(n-m+1))/m;
  else return 1;
}
 
int main(void){
  long long int n;
  vector<long long int> v;
  long long int a,b,i;
  double x,lastv,resave;
  long long ave = 0;
  long long int numlv,allv,res;
  long long int nave;
  cin>>n>>a>>b;
  for(i=0;i<n;i++){
    cin>>x;
    v.pb(x);
  }
  sort(v.begin(),v.end(),greater<double>());
  res=0;
  nave=0;
  ave=0;
  lastv=-1;
  numlv=0;
  
  for(i=0;i<a;i++){
    if(lastv==v[i]) numlv++;
    else numlv=1;
    nave++;
    ave+=v[i];
    lastv=v[i];
  }
  
  allv=0;
  i=a-1;
  while(i>=0&&v[i]==lastv){
    allv++;
    i--;
  }
  i=a;
  while(i<n&&v[i]==lastv){
    allv++;
    i++;
  }
 
  res+=ncm(allv,numlv);
  resave=(double)ave/nave;
  for(i=nave;i<b;i++){
    //if(resave!=((ave+v[i])/(nave+1))) break;
    if(ave*(nave+1)!=(ave+v[i])*nave) break;
    else{
      numlv++;
      ave+=v[i];
      nave++;
      res+=ncm(allv,numlv);
    }
  }
  printf("%.6f\n",resave);
  printf("%lld\n",res);
  
  return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    repr(i,n-1,1){
        if(h[i-1]-h[i]>1){
            cout<<"No"<<endl;
            return 0;
        }
        else if(h[i-1]-h[i]==1)
            h[i-1]--;
    }

    cout<<"Yes"<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

int f (int a , int b , int c){
    return a * a + b * b + c * c + a * b + a * c + b * c;
}

void Suhaib_Sawalha (){

    int num[10001] = {};
    for (int i = 1 ; i <= 100 ; ++i)
        for (int j = 1 ; j <= 100 ; ++j)
            for (int k = 1 ; k <= 100 ; ++k){
                int ff = f(i,j,k);
                if (ff <= 10000)
                    num[ff]++;
            }

    int n;
    cin >> n;
    for (int i = 1 ; i <= n ; ++i)
        cout << num[i] << '\n';

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	string s;cin>>s;
	ll c1=0,c2=0;
	rep(i,0,s.length()){
		if(i%2==0){
			if(s[i]=='0')c1++;
			else c2++;
		}
		else{
			if(s[i]=='1')c1++;
			else c2++;
		}
	}
	ll ans=min(c1,c2);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 512
com = Array.new(55) { Array.new(55, 0) }
com[0][0] = 1
(1...55).each do |i|
  (i + 1).times do |j|
    com[i][j] += com[i - 1][j]
    com[i][j] += com[i - 1][j - 1] if j > 0
  end
end

n, a, b = gets.split.map(&:to_i)
v = gets.split.map(&:to_f)
v.sort_by! { |vi| -vi }
avg = v[0...a].inject(&:+) / a
cnt = ans = 0
n.times do |i|
  cnt += 1 if v[i] == v[a-1]
end
if v[0] == v[a-1]
  (a..b).each do |j|
    ans += com[cnt][j]
  end
else
  t = 0
  a.times do |j|
    t += 1 if v[j] == v[a-1]
  end
  ans = com[cnt][t]
end
puts sprintf("%.10f\n", avg)
puts ans


Measured memory_bytes: 1788
n, k = gets.split(" ").map(&:to_i)

array = []
n.times do
  array << gets.chomp.to_i
end

array = array.sort
result = array[k-1] - array[0]

(n - (k-1)).times do |i|
  if array[i+(k-1)] - array[i] < result
    result = array[i+(k-1)] - array[i]
  end
end

puts result


Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,D,X,Y;
 cin >> N >> D;
 
 int count=0;
 double Z;
 for (int i=0;i<N;i++) {
     cin >> X >> Y;
     Z=sqrt(pow(X,2.0)+pow(Y,2.0));
     if(Z<=D) {
         count++;
     }
 }
 cout << count << endl;
 }
 


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << 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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }
inline long long tonum(string s) {long long v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string tostr(T x) {ostringstream sout;sout<<x;return sout.str();}

int CASE;

string conv(string str) {
    long long num = 0;
    for (int i = 1; i < str.size(); ++i) {
        long long a = tonum(str.substr(0, i));
        long long b = tonum(str.substr(i));
        //COUT(a); COUT(b);
        long long tmp = a * b;
        chmax(num, tmp);
    }
    return tostr(num);
}

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    cin >> CASE;
    for (int AAA = 0; AAA < CASE; ++AAA) {
        string str; cin >> str;
        int res = 0;
        while (true) {
            if (str.size() == 1) break;
            str = conv(str);
            ++res;
            
            //COUT(str);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1240
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    static final int modnum = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long sum = 0;

        // ArrayList<Long> rs = new ArrayList<Long>(primeFactor(N));
        ArrayList<Long> rs = new ArrayList<Long>(divisorX(N));
        // rs.add(1L);
        ArrayList<Long> ms = new ArrayList<Long>();

        // System.out.println(Arrays.toString(rs.toArray()));

        // for (long i = 1; i <= N; i++) {
        // if (N % i == 0) {
        // sum += N / i - 1;
        // }
        // }

        for (Long i : rs) {
            if(i-1==0)continue;
            if (N / (i-1) == N % (i-1)) {
                sum+=i-1;
            }
            // if ((N % i) == 0) {
            //     sum += N / i - 1;
            // }
        }
        // if(N%1==N/1)sum+=1;

        System.out.println(sum);
    }

    public static final List<Long> primeFactor(long n) {
        final List<Long> list = new ArrayList<Long>();
        if (n < 2) {
            return list;
        }

        while (n != 1 && n % 2 == 0) {
            list.add(2L);
            n >>>= 1;
        }

        for (long i = 3; i * i <= n; i += 2) {
            while (n % i == 0) {
                list.add(i);
                n /= i;
            }
        }

        if (n != 1) {
            list.add(n);
        }
        return list;
    }

    public static final List<Long> divisorX(final long n) {
		final List<Long> list = new ArrayList<Long>();

		for (long i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				list.add(i);
				if (i != n / i) {
					list.add(n / i);
				}
			}
		}
		return list;
	}
}


Measured memory_bytes: 23892
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for j in range(q):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if S[mid] == T[j]:
            cnt = cnt + 1
            break
        elif T[j] < S[mid]:
            right = mid
        else:
            left = mid + 1

print cnt

Measured memory_bytes: 14876
n, m = map(int, input().split())
MOD = m
list_size = n+2

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 1)) % MOD)

f_r_list = [pow(x, MOD-2, MOD) for x in f_list]

def comb(N, r):
	if N < r or r < 0:
		return 0
	else:
		return (((f_list[N] * f_r_list[N - r]) % MOD) * f_r_list[r]) % MOD 

st = [[0 for _ in range(n+1)] for _ in range(n+1)]
st[0][0] = 1
for i in range(1, n+1):
	st[i][0] = 1
	for j in range(1, i+1):
		st[i][j] = (st[i-1][j-1] + (j+1) * st[i-1][j]) % MOD

ans = 0
for i in range(n+1):
	res = (comb(n, i) * pow(2, pow(2, n-i, MOD-1), MOD)) % MOD
	tmp = 0
	for j in range(i+1):
		tmp += st[i][j] * pow(2, (n-i) * j, MOD)
		tmp %= MOD
	res *= tmp
	res %= MOD

	if i%2 == 0:
		ans += res
	else:
		ans -= res
	ans %= MOD

print(ans)

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

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> nums(m);
  for (int i=0; i<m; ++i) {
    cin >> nums[i];
    n-=nums[i];
  }
  if (n>=0) {
    cout << n << endl;
  } else {
    cout << -1<< endl;
  }
  return 0;
  
}

Measured memory_bytes: 3668
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,a,b;
    cin >> n >> a>>b;
    if(n == 1) cout << "Hello World" << endl;
    else cout << a+b << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = b; i >= (a); --i)
#define repdl(i, a, b) for(ll i = b; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool ihmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
#endif
using namespace std;

int fred[200005], fredps[200005], fwhite[200005], fwhiteps[200005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; read(n);
  string s; read(s);
  s = " " + s;
  
  rep(i, 1, n + 1) {
    fred[i] = s[i] == 'R';
    fwhite[i] = s[i] == 'W';
    fredps[i] = fredps[i - 1] + fred[i];
    fwhiteps[i] = fwhiteps[i - 1] + fwhite[i];
  }

  int ans = 0x3f3f3f3f;

  rep(i, 0, n + 1) {
    int clw = fwhiteps[i];
    int crr = fredps[n] - fredps[i];
    chmin(ans, max(crr, clw));
  }
  write(ans);
}



Measured memory_bytes: 6900
#include<cstdio>
int n,a,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		while(a%2==0)
		{
			a/=2;
			ans++;
		}
	}
	printf("%d",ans);
}

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

const long INF = 1LL << 60;

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

    int h[n];
    long cost[n];
    for (int i = 0; i < n; i++) {
        int h_;
        cin >> h_;
        h[i] = h_;
        cost[i] = i ? INF : 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = i - k; j < i; j++) {
            if (j < 0) {
                continue;
            }
            cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j]));
        }
    }

    cout << cost[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010];
int main() {
	ll n,k;
	cin>>n>>k;
	ll L=0,R=0;
	ll ans=0;
	for(ll i=0;i<=n;i++){
		L+=i;
		R+=n-i;
		if(i>=k-1){
			ans+=R-L+1;
			ans%=inf;
		}
		//cout <<ans<<" "<<L <<" "<<R<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3636
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int M1,D1,M2,D2;
  cin >> M1 >> D1 >> M2 >> D2;

  if(D2 > D1){
  	cout << 0 << endl;
  }
  else{
  	cout << 1 << endl;
  }

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 888
#include <iostream>
#include <memory.h>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 300 + 5;
int dp[MAXN][MAXN];
int n;
struct Edge{
    int i,j,dist;
    bool operator< (Edge const & other) const {
        return dist < other.dist;
    }
};
vector<Edge> edges;

void update(Edge & edge) {
    int a = edge.i;
    int b = edge.j;
    int dist = edge.dist;
    for (int i = 0; i < n; i++) {
        if (dp[i][a] == -1) continue;
        for (int j = i+1; j < n; j++) {
            if (dp[b][j] == -1) continue;
            LL tmp = 0LL + dp[i][a] + dist + dp[b][j];
            if (dp[i][j]==-1 || dp[i][j]>tmp) {
                dp[i][j] = tmp;
                dp[j][i] = tmp;
            }

        }
    }
    for (int i = 0; i < n; i++) {
        if (dp[i][b] == -1) continue;
        for (int j = i+1; j < n; j++) {
            if (dp[a][j] == -1) continue;
            LL tmp = 0LL + dp[i][b] + dist + dp[a][j];
            if (dp[i][j]==-1 || dp[i][j]>tmp) {
                dp[i][j] = tmp;
                dp[j][i] = tmp;
            }

        }
    }
}
LL solve() {
    LL ret = 0;
    for (Edge & edge : edges) {
        int i = edge.i, j = edge.j, dist = edge.dist;
        if (dp[i][j] == dist) continue;
        if (dp[i][j] != -1 && dp[i][j] < dist) return -1;
        ret = ret + dist;
        update(edge);
    }
    return ret;
}

int main() {
//    freopen("test.txt", "r", stdin);
    memset(dp, -1, sizeof(dp));
    scanf("%d", &n);
    int data;
    for (int i = 0; i < n; i++) dp[i][i] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &data);
            Edge tmp;
            if (i < j) {
                tmp.dist = data;
                tmp.i = i;
                tmp.j = j;
                edges.push_back(tmp);
            }

        }
    }
    sort(edges.begin(), edges.end());
    cout << solve() << endl;
    return 0;
}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n;
int main(){
	cin >> n;
	if(n % 10 == 7){
		cout << "Yes" << endl;
		return 0;
	}else{
		n /= 10;
		if(n % 10 == 7){
			cout << "Yes" << endl;
			return 0;
		}else{
			n /= 10;
			if(n == 7){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3636
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  map<char, int> mp;
  REP(i,s.size()){
    mp[s[i]]++;
  }
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second % 2 == 1){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

for x in range(N + 1):
    for y in range(N + 1- x):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            print('{x} {y} {z}'.format(x=x, y=y, z=N - x - y))
            exit()
print('-1 -1 -1')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

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

    cout << T / A * B << endl;

    return 0;
}

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

using namespace std;

int N;
int A[100];

void solve() {
    int cnt = 0;
    for (;;) {
        bool flag = false;
        for (int i = N - 1; i >= 1; i--) {
            if (A[i] < A[i - 1]) {
                swap(A[i], A[i - 1]);
                cnt++;
                flag = true;
            }
        }
        if (!flag) { break; }
    }
    cout << A[0];
    for (int i = 1; i < N; i++) {
        cout << " " << A[i];
    }
    cout << endl;
    cout << cnt << endl;
}

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

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

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

    int cnt = 0;
    rep(i, n) {
        int a;
        cin >> a;
        cnt += (a % 2);
    }

    cnt % 2 ? cout << "NO" : cout << "YES";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
int main()
{
    FIO;
    long long a,b,k,d;
    cin>>a>>b>>k;
    d=min(a,k);
    a-=d;
    k-=d;
    d=min(k,b);
    b-=d;
    k-=d;
    cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long int
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (ll)c.size()
#define fr first
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
const ll INF = __LONG_LONG_MAX__;
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

ll ans(ll a[],ll n)
{
  ll sum=0;
  for(ll i=0;i<64;i++)
  {
    ll zero=0,one=0;
    for(ll j=0;j<n;j++)
    {
      if(a[j]&1) zero++;
      else one++;
      a[j]/=2;
    }
    ll x=(zero%MOD*one%MOD*power(2,i,MOD))%MOD;
    sum=(sum%MOD+x%MOD)%MOD;
  }
  return sum;
}

void solve()
{
   ll n;
   cin>>n;
   ll a[n];
   rep(i,0,n) cin>>a[i];
   cout<<ans(a,n);
}

int main()
{
  fastio
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
      solve();
      cout<<"\n";
  }
}

Measured memory_bytes: 5972
L,R = map(int,input().split())

ans = 2019
it = L
while(it<=min(R,it+2019)):
    jt = it+1
    while(jt<=min(R,jt+2019)):
        a = (it*jt)%2019
        if a < ans:
            ans = a
            if ans==0:break
        jt += 1
    if ans==0:break
    it += 1
            
print(ans)

Measured memory_bytes: 3060
import math
def solve():
  n,k,s = (int(i) for i in input().split())
  query = [10**9]*n
  for i in range(k):
    query[i] = s
  if s != 10**9:
    print(*query)
  else:
    for i in range(n-k):
      query[i] = 1
    print(*query)
solve()

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

using namespace std;

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

int a[200007];
int main() {
  int n,j=1;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    long int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]!=j) cnt++;
        else{
            j++;
        }
    }
    if(cnt==n) cout<<"-1"<<endl;
    else cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	double A,B;
	scanf("%lf",&A);
	scanf("%lf",&B);
	if(A>B)
		printf("GREATER\n");
	else if(A<B)
		printf("LESS\n");
	else 
		printf("EQUAL\n");
	return 0;
}

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	// input1 = input[0].split(' ').map((n) => (parseInt(n)))
	input1 = input[0].split(' ').map((n) => (parseInt(n)))
	// ans = input.filter((n) => (s <= n)).length

	num = input1[0]
	var ans = 'No'
	for (var i = 1; i < 10; i++) {
		for (var j = 1; j < 10; j++) {
			if (num === (i * j)) {
				ans = 'Yes'
			}
		}
	}

	//出力
	console.log(ans)
}
// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 7372
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] H = new int[N];
		for (int i=0;i<N;i++) {
			H[i] = sc.nextInt();
		}
		int[] A = new int[M];
		int[] B = new int[M];
		boolean[] is_good = new boolean[N];
		Arrays.fill(is_good, true);
		for (int i=0;i<M;i++) {
			A[i] = sc.nextInt()-1;
			B[i] = sc.nextInt()-1;
			if (H[A[i]] <= H[B[i]]) is_good[A[i]] = false;
			if (H[B[i]] <= H[A[i]]) is_good[B[i]] = false;
		}


		int ans = 0;
		for (int i=0;i<N;i++) {
			if (is_good[i]) ans++;
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 60128
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define e1 first
#define e2 second
#define int int_fast32_t
#define uint uint_fast64_t
#define ll int_fast64_t
#define ull uint_fast64_t
#define int16 int_fast16_t
#define uint16 uint_fast16_t
#define int32 int_fast32_t
#define uint32 uint_fast32_t
#define int64 int_fast64_t
#define uint64 uint_fast64_t
#define ld long double
#define float long double
#define size(x) (int)x.size()
#define satori int testCases; cin>>testCases; while(testCases--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(r) begin(r),end(r)
#define rall(r) rbegin(r),rend(r)
#define time chrono::high_resolution_clock().now().time_since_epoch().count()
#define elapsed(__begin,__end) (__end-__begin)/CLOCKS_PER_SEC
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
float pi=3.14159265358979323846;
#define int long long

const int MAXN=1e6+10,inf=1e15+2137;

vector<pair<pair<int,int>,char>> pk[MAXN*4],row[MAXN],col[MAXN];
int lx[4];

int32_t main()
{
	fastio;
	int n,x,y,res=inf;
	char t;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>x>>y>>t,pk[x+y].eb(mp(mp(x,y),t)),pk[x-y+(int)3*MAXN+20].eb(mp(mp(x,y),t)),row[y].eb(mp(mp(x,y),t)),col[x].eb(mp(mp(x,y),t));
	for(int c=0;c<MAXN*4;c++)
	{
		sort(all(pk[c]));
		for(int i=0;i<4;i++)
			lx[i]=inf;
		for(auto xd:pk[c])
		{
			if(xd.e2=='U')
			{
				x=xd.e1.e1;
				if(c<2*MAXN)
					res=min(res,abs(x-lx[3])*10ll);
				lx[0]=x;
			}
			else
			if(xd.e2=='D')
			{
				x=xd.e1.e1;
				if(c<2*MAXN);
				else
					res=min(res,abs(x-lx[3])*10ll);
				lx[1]=x;
			}
			else
			if(xd.e2=='L')
			{
				x=xd.e1.e1;
				if(c<2*MAXN)
					res=min(res,abs(x-lx[1])*10ll);
				else
					res=min(res,abs(x-lx[0])*10ll);
				lx[2]=x;
			}
			else
			if(xd.e2=='R')
			{
				x=xd.e1.e1;
				lx[3]=x;
			}
		}
	}
	for(int c=0;c<MAXN;c++)
	{
		sort(all(row[c]));
		for(int i=0;i<4;i++)
			lx[i]=inf;
		for(auto xd:row[c])
		{
			if(xd.e2=='L')
			{
				x=xd.e1.e1;
				res=min(res,abs(x-lx[1])*5ll);
				lx[0]=x;
			}
			else
			if(xd.e2=='R')
			{
				x=xd.e1.e1;
				lx[1]=x;
			}
		}
		sort(all(col[c]));
		for(int i=0;i<4;i++)
			lx[i]=inf;
		for(auto xd:col[c])
		{
			if(xd.e2=='D')
			{
				y=xd.e1.e2;
				res=min(res,abs(y-lx[1])*5ll);
				lx[0]=y;
			}
			else
			if(xd.e2=='U')
			{
				y=xd.e1.e2;
				lx[1]=y;
			}
		}
	}
	if(res>=1e9)
		cout<<"SAFE\n";
	else
		cout<<res<<'\n';
}

Measured memory_bytes: 172932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////



int main(){fastio
    
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<a*b-b*c-a*d+c*d<<endl;
    
    return 0;
}



Measured memory_bytes: 256