akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()

using namespace std;
typedef pair<int,int> pii;

const int INF = 1e9+7;

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

	set<pii> st;
	st.emplace(-1, -1);
	st.emplace(INF, INF+1);
	int f = INF;
	rep(i,n){
		//for(auto t: st) cout << "(" << t.first << "," << t.second << ")"; cout << endl;
		if( f <= x[i] ){
			cout << "No" << endl;
			continue;
		}
		auto it = st.lower_bound( pii(x[i], 0) );
		if( it->first == x[i] ){
			if( it->first == 1 ){
				int sc = it->second;
				it++;
				if( sc == x[i]+1 && it->second > INF ){
					cout << "Yes" << endl;
					f = 1;
				}else{
					cout << "No" << endl;
				}
				continue;
			}else{
				cout << "Yes" << endl;
			}
			int fs = it->first+1;
			int sc = it->second;
			st.erase(it);
			if( fs != sc ) st.emplace(fs, sc);
			auto pit = st.lower_bound( pii(x[i], 0) ); pit--;
			if( pit->second == x[i]-1 ){
				int fs = pit->first;
				int sc = pit->second+1;
				st.erase(pit);
				st.emplace( fs, sc );
			}else{
				st.emplace( x[i]-1, x[i] );
			}
			continue;
		}
		it--;
		if( it->second == x[i] ){
			cout << "Yes" << endl;
			int fs = it->first;
			int sc = it->second+1;
			st.erase(it);
			auto nit = st.lower_bound( pii(sc, 0) );
			if( nit->first == sc ){
				sc = nit->second;
				st.erase(nit);
			}
			st.emplace( fs, sc );
		}else if( it->second > x[i] ){
			if( it->first == 1 ){
				int fs = it->first;
				int sc = it->second;
				it++;
				if( sc == x[i]+1 && it->second > INF ){
					cout << "Yes" << endl;
					f = fs;
				}else{
					cout << "No" << endl;
				}
				continue;
			}else{
				cout << "Yes" << endl;
			}
			int tmp = it->first;
			int fs = x[i]+1;
			int sc = it->second;
			st.erase(it);
			if( fs != sc ) st.emplace( fs, sc );
			fs = tmp-1;
			sc = tmp;
			auto pit = st.lower_bound( pii(fs, 0) ); pit--;
			if( pit->second == fs ){
				fs = pit->first;
				st.erase(pit);
			}
			st.emplace( fs, sc );
		}else{
			cout << "Yes" << endl;
			it++;
			int tmp = x[i]+1;
			if( tmp == it->first ){
				tmp = it->second;
				st.erase(it);
			}
			st.emplace( x[i], tmp );
		}
	}
	return 0;
}

Measured memory_bytes: 11588
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

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

	int count = 0;
	int pre_N = N;
	while(pre_N > 0){
		if(pre_N < 10){
			count += pre_N;
		} else {
			count += pre_N % ((pre_N / 10) * 10);
		}
		pre_N /= 10;
	}

	if(N % count == 0){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	string s,t;
	cin>>s>>t;
	ll n=s.size();
	ll m=t.size();

	Matrix dp(n+1,Array(m+1,0));//i文字目、j文字目までで一致している最大の文字数

	REP(i,n+1){
		REP(j,m+1){
			if(i<n && j<m && s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
			if(i<n) chmax(dp[i+1][j],dp[i][j]);
			if(j<m) chmax(dp[i][j+1],dp[i][j]);
		}
	}

	string ans(dp[n][m],'a');
	int i=n,j=m;
	REP2(k,dp[n][m]){
		while(dp[i][j]==dp[i-1][j]) i--;
		while(dp[i][j]==dp[i][j-1]) j--;
		i--;j--;
		ans[k] = s[i]; 
	}
	cout<<ans<<en;

}

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

    solve();
    return 0;
}

Measured memory_bytes: 70784
n = int(input())

n_onesplace = n%10

if n_onesplace==2 or n_onesplace==4 or n_onesplace==5\
    or n_onesplace==7 or n_onesplace==9:
    print('hon')
elif n_onesplace==0 or n_onesplace==1 or\
    n_onesplace==6 or n_onesplace==8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9096
n=input()
flag=0
flag1=0
a=list(map(int,input().split()))
sum=1
a.sort()
for i in a :
    sum*=i
    if(i==0):
        flag1=1
    if(sum>1e18) :
        flag=1
        break
if(flag==0 or flag1==1):
    print(sum)
else : print(-1)

Measured memory_bytes: 21772
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])
let array_of_string str = Array.init (String.length str) (fun i -> str.[i])

let z c = if c = 'P' then 0 else if c = 'W' then 1 else if c = 'G' then 2 else 3

let () =
  let chk = Array.make 4 0 in
  scanf "%d" (fun n -> Array.init n (fun _ -> scanf " %c" z))
  |> Array.iter (fun x -> chk.(x) <- 1);
  Array.fold_left (+) 0 chk |> (fun x -> if x <= 3 then "Three" else "Four")
  |> print_endline



Measured memory_bytes: 384
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

long long gcd(long long x, long long y) {
  if (y == 0) {
    return x;
  } else {
    return gcd(y, x % y);
  }
}

long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
int main() {
  int n;
  cin >> n;
  long long ans = 1;
  while (n--) {
    long long t;
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
const int inf = 1000000;
const int nmax = 40;
const int abmax = 10;
using namespace std;
int dp[nmax+1][nmax * abmax + 1][nmax * abmax + 1];

int main(){
  int n,ma,mb;

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

  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= nmax * abmax; j++){
      for(int k = 0; k <= nmax * abmax; k++){
        dp[i][j][k] = inf;
      }
    }
  }
  dp[0][0][0] = 0;

  for(int i = 0; i < n; i++){
    for(int ca = 0; ca <= nmax * abmax; ca++){
      for(int cb = 0; cb <= nmax * abmax; cb++){
        if(dp[i][ca][cb] == inf) continue;
        // i番目を入れないとき
        dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb]);
        // i番目を入れるとき
        dp[i+1][ca + a[i]][cb + b[i]] = min(dp[i+1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
      }
    }
  }

  int ans = inf;
  for(int ca = 1; ca <= nmax * abmax; ca++){
    for(int cb = 1; cb <= nmax * abmax; cb++){
      if(ca * mb == cb * ma){
        ans = min(ans, dp[n][ca][cb]);
      }
    }
  }

  if(ans == inf) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25984
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL; 																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																							   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////
	


///////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	string s;
	cin >> s;
	if(s.size() % 2 > 0){
		cout << "No" << '\n';
	}
	else{
		int licznik = 0;
		int one = s.size() / 2;
		for(int i = 0; i < s.size(); i++){
			if(s[i] == 'h' && s[i+1] == 'i'){
				licznik++;
			}
		}
		
		if(licznik == one){
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}

	




	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

class bit {
private:
	vl* v;
	ll n;
public:
	bit (ll n) {
		this->v = new vl(n+1);
		this->n = n;
	}
	void add(ll i,ll val){
		for(;i <= n;i += i&-i) this->v->at(i) += val;
	}
	ll sum(ll i){
		ll ret = 0;
		for(;i > 0;i -= i&-i) ret += this->v->at(i);
		return ret;
	}
};

ll n,k;
vl a;
bit b(2005);
ll cnt_a;
ll cnt_b;
ll ans;

int main(){
  cin >> n >> k;
  a = vl(n);
  for(ll i = 0;i < n;i++) cin >> a[i];
  for(ll i = 0;i < n;i++){
    b.add(a[i],1);
    cnt_a += b.sum(2001)-b.sum(a[i]);
  }
  for(ll i = 0;i < n;i++){
    for(ll j = 0;j < n;j++){
      if(a[i] > a[j]) cnt_b++;
    }
  }
  ans = cnt_a*k;
  ans %= mod;
  ll hoge = ((k)*(k-1)/2)%mod;
  ans += cnt_b*hoge;
  ans %= mod;
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,tmp=n;while(tmp!=0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
  ll x;
  cin>>x;
  ll m;
  int p;
  cin>>m;
  bool ng[15];
  rep(i,0,15)ng[i]=false;
  rep(i,0,m){
   cin>>p;
   ng[p]=true;
  }
  bool sub;
  ll tmp,di=dig(x),k;
  while(1){
   sub=false;
   di=dig(x);
   rep(k,0,di){
    tmp=(x/llpow(10,k))%10;
    if(ng[tmp]==true){
     sub=true;
     break;
    }
   }
   if(!sub){
    pr(x);
    return 0;
   }
   x++;
  }
return 0;}


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

using namespace std;

int main()
{

  int n,i;
  string out;
  cin >> n;

  switch(n){
    case 1:
      out = "1";
      break;
    case 2:
      out = "2";
      break;
    case 3:
      out = "6";
      break;
    case 4:
      out = "24";
      break;
    case 5:
      out = "120";
      break;
    case 6:
      out = "720";
      break;
    case 7:
      out = "5040";
      break;
    case 8:
      out = "40320";
      break;
    case 9:
      out = "362880";
      break;
    case 10:
      out = "3628800";
      break;
    case 11:
      out = "39916800";
      break;
    case 12:
      out = "479001600";
      break;
    case 13:
      out = "6227020800";
      break;
    case 14:
      out = "87178291200";
      break;
    case 15:
      out = "1307674368000";
      break;
    case 16:
      out = "20922789888000";
      break;
    case 17:
      out = "355687428096000";
      break;
    case 18:
      out = "6402373705728000";
      break;
    case 19:
      out = "121645100408832000";
      break;
    case 20:
      out = "2432902008176640000";
      break;
  }
  cout << out <<endl;
  return 0;
}

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

typedef int INT_;

#define int long long

const int MAX = 1e5 + 10;

INT_ main()
{
	int m,n; cin>>m>>n;

	int a[100][100];

	for(int i=0;i<10;i++) for(int j=0;j<10;j++) cin>>a[i][j];

	for(int k=0;k<=9;k++){
		for(int i=0;i<=9;i++) {
			for(int j=0;j<=9;j++){
				a[i][j] = min(a[i][j],a[i][k]+a[k][j]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<m;i++) for(int j=0;j<n;j++){
		int x; cin>>x;

		if(x==-1 or x==1) continue;

		ans += a[x][1];
	}

	cout<<ans;
}	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())


int main() {
  int n, m;
  cin >> n >> m;
  
  vector<bool> judge(n, false);
  vector<ll> x(m), y(m), cnt(n, 1);

  judge[0] = true;

  rep(i,m) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }

  for (int i = 0; i < m; ++i) {
    ll before = x[i], after = y[i];
    if (cnt[before] == 1) {
      if (judge[before]) {
        judge[before] = false;
        judge[after] = true;
      }
    } else if (cnt[before] > 1) {
      if (judge[before]) {
        judge[after] = true;
      }
    }
    cnt[before] -= 1;
    cnt[after] += 1;
  }

  auto ans = [](vector<bool> j) {
    ll c = 0;
    for (auto itr : j) {
      c += (itr) ? 1 : 0;
    }

    return c;
  };

  cout << ans(judge) << endl;
}


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

int main() {
	int h,N;
    cin >> h >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
      cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());
    
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
      h = h - a.at(i);
      if (h <= 0) {
        cnt = 1;
        break;
      }
    }
   if (cnt == 1) cout << "Yes" << endl;
   else if (cnt == 0) cout << "No" << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
  vector<vector<int>> c(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c.at(i).at(j);
    }
  }
  int o = c.at(0).at(0);
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      c.at(i).at(j) -= o;
    }
  }
  bool res = true;
  if(c.at(1).at(1) != c.at(0).at(1) + c.at(1).at(0)) res = false;
  if(c.at(1).at(2) != c.at(0).at(2) + c.at(1).at(0)) res = false;
  if(c.at(2).at(1) != c.at(2).at(0) + c.at(0).at(1)) res = false;
  if(c.at(2).at(2) != c.at(2).at(0) + c.at(0).at(2)) res = false;
  if(res){
    cout << "Yes" ;
  }else{
    cout <<"No" ;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
ans = float('INF')
for k in range(0, 2*max(X, Y)+1, 2):
  i = max(0, X - int(k/2))
  j = max(0, Y - int(k/2))
  ans = min(ans, A*i + B*j + C*k)
print(ans)

Measured memory_bytes: 8968
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;


int main(){
  ll l,r;cin>>l>>r;
  if(l<=r-2019){cout<<0<<endl;}
  else{
    ll m=INF;
    rep(i,l,r){
      rep(j,i+1,r+1){
        m=min(m,(i*j)%2019);
      }
    }
    cout<<m<<endl;
  }
}

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

monster=0
for i in range(N):
    if(B[i]>=A[i]):
        monster = monster + A[i]
        if(B[i]-A[i]>=A[i+1]):
            monster = monster + A[i+1]
            A[i+1]=0
        else:
            monster = monster + B[i]-A[i]
            A[i+1] = A[i+1]- (B[i]-A[i])
    else:
        monster = monster + B[i]

print(monster)


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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    string s;
    int ans, len_s;
    char initial;
    bool isSame;

    cin >> s;
    len_s = s.size();
    initial = s[0];
    
    rep(i, len_s/2) {
        if (s[i] == initial) {
            isSame = true;
            rep(j, i) {
                if (s[j] != s[i+j]) {
                    isSame = false;
                    break;
                }
            }
            if (isSame == true) {ans = 2*i;}
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    string s; cin >> s;
    ll n = s.length();

    ll r = 0, b = 0;
    rep(i,n){
        if(s[i] == '0') r++;
        else b++;
    }
    cout << min(r,b) * 2 << endl;
}

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

int main(){
    string S;
    cin >> S;
    int result = 0 ;
    for(int i=0; i < S.length(); i++){
        if (S[i] == '+'){
            result++;
        }
        else if(S[i] == '-'){
            result--;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3616
input()
monsters = [int(x) for x in input().split()]
hero = [int(x) for x in input().split()]
ans = 0
power_left = 0
for i, b in enumerate(hero[::-1],1):
    to_kill = min(monsters[-i], b+power_left)
    power_left = b - max(0, to_kill - power_left)
    ans += to_kill
ans += min(monsters[0], power_left)
print(ans)

Measured memory_bytes: 19648
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL MaxN = 1 + 1e5;

LL n, a[MaxN], m;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    if(n > 9 || m > 9){
        cout << -1 << endl;
        return 0;
    }
    cout << n * m << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int Partition(int S[], int p, int r){
    int x = S[r];
    int i = p-1;
    for(int j = p; j < r;j++){
        if(S[j] <= x){
            i++;
            int tmp = S[i];
            S[i] = S[j];
            S[j] = tmp;
        }
    }  
    int tmp = S[i + 1];
    S[i + 1] = S[r];
    S[r] = tmp;
    return i + 1;
}
 
int main(){
    int n;
    cin >> n;
    int s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int index = Partition(s, 0, n - 1);
    for(int i = 0; i < n; i++){
        if(i==index){
            cout << '[' << s[i] << ']';
        }else{
            cout << s[i];
        }
        if(i!=n-1)
             cout << ' ';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1548
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int n,k;
    cin >> n;
    cin >> k;
    int ans = 1;
    for(int i = 0; i < n; i++) {
        if(ans < k) ans *= 2;
        else ans += k;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, MOD = 1e9 + 7;
int a[N], vis[N], chain[N], in[N], len[N];
bool in_circle[N];
int main() {
	int n;
	scanf("%d", &n);
	bool flag = 0;
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", &a[i]);
		in[a[i]] ++;
		if (in[a[i]] >= 3) flag = 1;
	}
	if (flag) return 0 * puts("0");
	vector<vector<int>> circles;
	int xxx = 0;
	for (int i = 1; i <= n; ++ i) {
		if (vis[i]) continue;
		++ xxx;
		vis[i] = xxx;
		vector<int> st;
		st.push_back(i);
		int j = a[i];
		while (!vis[j]) {
			st.push_back(j);
			vis[j] = xxx;
			j = a[j];
		}
		if (vis[j] < xxx) continue;
		int end = j;
		vector<int> t;
		while (t.empty() || t.back() != end) {
			t.push_back(st.back());
			st.pop_back();
		}
		for (int x : t) in_circle[x] = 1;
		circles.push_back(t);
	}
	for (int i = 1; i <= n; ++ i) {
		if (in_circle[i]) continue;
		if (in[i] == 2) flag = 1;
		if (in[i]) continue;
		int cnt = 0, j = i;
		while (!in_circle[j]) {
			j = a[j];
			cnt ++;
		}
		chain[j] = cnt;
	}
	if (flag) return 0 * puts("0");
	unordered_map<int, int> nofeet;
	vector<vector<int>> feet;
	for (auto &t : circles) {
		bool has = 0;
		for (int x : t) {
			if (chain[x]) has = 1;
		}
		if (has) feet.push_back(t); else nofeet[(int) t.size()] ++;
	}
	int ans = 1;
	for (auto xy : nofeet) {
		int n = xy.first, cnt = xy.second;
		//printf("no feet : n=%d cnt=%d\n", n, cnt);
		static int dp[N];
		dp[0] = 1;
		for (int i = 1; i <= cnt; ++ i) {
			dp[i] = 1LL * dp[i - 1] * ((n & 1) && n > 1 ? 2 : 1) % MOD;
			if (i > 1) (dp[i] += 1LL * (i - 1) * n % MOD * dp[i - 2] % MOD) %= MOD;
		}
		ans = 1LL * ans * cnt[dp] % MOD;
	}
	for (auto &t : feet) {
		int n = (int) t.size(), st;
		for (int i = 0; i < n; ++ i) if (chain[t[i]]) {
			st = i;
			break;
		}
		int res = 0;
		for (int i = 0; i < n; ++ i) {
			if (chain[t[(st + n - i) % n]]) {
				len[t[(st + n -  i) % n]] = res;
				res = 0;
			}
			else ++ res;
		}
		len[t[st]] = res;
		for (int i : t) {
			if (!chain[i]) continue;
			if (chain[i] > len[i] + 1) ans = 0;
			if (chain[i] < len[i] + 1) (ans *= 2) %= MOD;
		}
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 7344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc112
{
    class abc112a
    {
        static void Main(string[] args)
        {
            var age = int.Parse(Console.ReadLine());
            if(age==1)
                Console.WriteLine("Hello World");
            else
            {
                var a = int.Parse(Console.ReadLine());
                var b = int.Parse(Console.ReadLine());
                Console.WriteLine(a + b);
            }
        }
    }
}


Measured memory_bytes: 11092
n,m,s,t=map(int,input().split())
yen=[[]*(n+1) for i in range(n+1)]
sunuke=[[]*(n+1) for i in range(n+1)]
for i in range(m):
  u,v,a,b=map(int,input().split())
  yen[u].append((a,v))
  yen[v].append((a,u))
  sunuke[u].append((b,v))
  sunuke[v].append((b,u))
  
import heapq
#n:頂点数、m:辺の数　s:始点　es:辺のリスト
def dijkstra(n,m,s,es):
  #used:訪問済みかどうかを確認する　false 使ってない
  used=[False]*(n+1)
  d=[float("INF")]*(n+1)
  d[s]=0
  used[s]=True
  q=[]
  for to in es[s]:
    heapq.heappush(q,to)
  while len(q)>0:
    minedge=heapq.heappop(q)
    v=minedge[1]
    if used[v]==True:
      continue
    cost=minedge[0]
    d[v]=cost
    used[v]=True
    for to in es[v]:
      heapq.heappush(q,(d[v]+to[0],to[1]))
  return d


d_yen=dijkstra(n,m,s,yen)
d_sunuke=dijkstra(n,m,t,sunuke)

ans=[float("INF")]*(n+1)
num=float("INF")
for i in range(n,0,-1):
  num=min(d_yen[i]+d_sunuke[i],num)
  ans[i]=num
  
for j in range(1,n+1):
  print(10**15-ans[j])
  

  

      
  
  

Measured memory_bytes: 134840
import sys
a = list(map(int,input().split()))
a += list(map(int,input().split()))
a += list(map(int,input().split()))

c = []
d = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

n = int(input())

for i in range(n):
    b = int(input())
    if b in a:
        c += [a.index(b)]


for i in range(8):
    flag = 0
    for j in range(3):
        if d[i][j] in c:
            flag +=1
            if flag ==3:
                print("Yes")
                sys.exit()

else:
    print("No")


Measured memory_bytes: 9188
from math import*
n,*a=map(int,open(0).read().split())
b=[0]
for i in a:b+=gcd(b[-1],i),
w=m=0
for i in range(n):m=max(m,gcd(w,b[-i-2]));w=gcd(w,a[~i])
print(m)

Measured memory_bytes: 20432
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int w,n;
	vector<pair<int,int> > lines;

	cin>>w>>n;
	for(int i = 0; i < n; i++){
		pair<int,int> p;
		char comma;
		cin >> p.first >> comma >> p.second;
		lines.push_back(p);
	}

	int ret[31];
	for(int i = 1; i <= w; i++){
		int cp = i;
		for(int j = 0; j < lines.size(); j++){
			if(lines[j].first == cp){
				cp = lines[j].second;
			}
			else if(lines[j].second == cp){
				cp = lines[j].first;
			}
		}
		//cout << cp << endl;
		ret[cp] = i;
	}
	for(int i = 1; i <= w; i++){
		cout << ret[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main(){

	double x1, x2, y1, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	if (x1 == x2){
		cout << setprecision(12) << fabs(y1 - y2) << endl;
	}
	else if (y1 == y2){
		cout << setprecision(12) << fabs(x1 - x2) << endl;
	}
	else {
		cout << setprecision(12) << sqrt(pow(fabs(x1 - x2), 2) + pow(fabs(y1 - y2), 2)) << endl;
	}

	return 0;
}


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i = 1 ;i<=n ;i++){
    scanf("%hd",&A[i]);
  }
  for(i = 0;i<=VMAX+1;i++){
    C[i] = 0;
  }
  for(j=1;j<=n;j++){
    C[A[j]] = C[A[j]]+1;
  }
  
  for(i = 1 ;i<=VMAX+1;i++){
    C[i] = C[i]+C[i-1];
  }
  for(j=n ;j>=1 ;j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  for(j = 1;j<n+1;j++){
    if(j ==n)
    printf("%d\n",B[j]);
    else printf("%d ",B[j]);
    }
  return 0;
}



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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

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

    int64_t ans = 0;
    for(int i=0; i<N; i++) if(A[i] == S) add(ans, (i+1)*(N-i));

    auto rec = [&](auto&& rec, int L, int R)->void{
        if(R-L < 2) return;
        int M = (L+R)/2;

        vector<int64_t> VL(3001), VR(3001), dp(3001);
        dp[0] = 1;
        for(int i=M-1; i>=L; i--){
            for(int j=A[i]; j<S; j++) add(VL[j], dp[j-A[i]]*(i+1));
            for(int j=3000; j>=A[i]; j--) add(dp[j], dp[j-A[i]]);
        }
        fill(dp.begin(), dp.end(), 0);
        dp[0] = 1;
        for(int i=M; i<R; i++){
            for(int j=A[i]; j<S; j++) add(VR[j], dp[j-A[i]]*(N-i));
            for(int j=3000; j>=A[i]; j--) add(dp[j], dp[j-A[i]]);
        }
        for(int j=1; j<S; j++)  add(ans, VL[j] * VR[S-j]);

        rec(rec, L, M);
        rec(rec, M, R);
    };

    rec(rec, 0, N);
    cout << ans << endl;
    return 0;
}


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

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

  int count = 0;

  if (s[0] == '1') count++;
  if (s[1] == '1') count++;
  if (s[2] == '1') count++;

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	if a == b {
		if a != c {
			fmt.Println("Yes")
			return
		}
	} else {
		if a == c || b == c {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
using System;
using System.Linq;

namespace NTL_1_E
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a0 = 1; int a1 = 0;
            int b0 = 0; int b1 = 1;
            while (x[1] > 0)
            {
                int q1 = x[0] / x[1];
                int r2 = x[0] % x[1];
                int a2 = a0 - q1 * a1;
                int b2 = b0 - q1 * b1;
                x[0] = x[1]; x[1] = r2;
                a0 = a1; a1 = a2;
                b0 = b1; b1 = b2;
            }
            Console.WriteLine(a0 + " " + b0);
        }
    }
}



Measured memory_bytes: 9576
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    long long x = accumulate(a.begin(), a.end(), 0LL);
    long long y = 0;
    long long ans = x;
    for(int i=0; i<n; ++i){
        x -= a[i];
        y += a[i];
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

/**
 * @author Yuki
 */
public class Main {

	/*** ?????? */
	private final static double INTEREST = 1.05;

	/*** ??????????????? */
	private final static double REVALUATION = 1000;

	/**
	 * ?????????????????????<br>
	 * ??????????????????????????????
	 *
	 * @param args
	 *            ??????????????°
	 */
	public static void main(String[] args) {

		// ????????????????????????
		System.out.println(getTotalDept(new Scanner(System.in).nextInt()));

	}

	/**
	 * ?????????????????????????????? ????????????????????±???????¨??????????????¨????????????????
	 *
	 * @return ???????????????
	 */
	private static int getTotalDept(int weekNum) {
		double debt = 100000 / REVALUATION;
		for (; weekNum > 0; weekNum--) {
			debt = Math.ceil(debt * INTEREST); // ????????????
		}
		return (int) (debt * REVALUATION);
	}

}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    Rep(i, n) data[i] ^= data[i-1];

    vi dp0(1 << 20, 1), dp1(1 << 20, 0), zeros(1 << 20, 0);
    // 始点に 0 があると考えるので全ての x について初期0数1個
    int zero = 0; 
    rep(i, n) {
        if (!data[i]) {
            zero++;
        } else {
            dp0[data[i]] = (dp0[data[i]] + dp1[data[i]] * (zero - zeros[data[i]])) % MOD; // 0 の累積を求める
            dp1[data[i]] = (dp1[data[i]] + dp0[data[i]]) % MOD; // i 番目の解が求められ、区間の値 k = data[i] の時の解の累積が増える
            zeros[data[i]] = zero;
            //std::cout << dp0[data[i]] << " , " << dp1[data[i]] << std::endl;
        }
    }

    if (data.back()) {
        std::cout << dp0[data.back()] << std::endl;
    } else {
        int ans = 1;
        rep(i, zero-1) ans = (ans * 2) % MOD;
        rep(i, dp1.size()) ans += dp1[i];
        std::cout << ans % MOD << std::endl;
    }

    return 0;
}


Measured memory_bytes: 28800
#include<bits/stdc++.h>
using namespace std;
string s;
int n, ans;
void solve() {
	cin >> n;
	cin >> s;
	for (int i = 0; i < n - 2; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			++ans;
		}
	}
	cout << ans << endl;
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 256
<?php
  
 	fscanf(STDIN, "%d %d", $a, $b);
	$plus = $a + $b;
    $minus = $a - $b;
    $jou = $a * $b;
      
    $ans = max ( $plus, $minus, $jou );
	

  echo $ans;
  
  
  ?>

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, A[50];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  ll p = -1, m = -1;
  REP(i, 0, N) if(m < abs(A[i])) {
    p = i;
    m = abs(A[i]);
  }

  vector<pll> ans;
  if(A[p] > 0) {
    REP(i, 0, N) if(A[i] < 0) {
      A[i] += A[p];
      ans.push_back(pll(p, i));
    }
    REP(i, 0, N - 1) {
      A[i + 1] += A[i];
      ans.push_back(pll(i, i + 1));
    }
  }
  if(A[p] < 0) {
    REP(i, 0, N) if(A[i] > 0) {
      A[i] += A[p];
      ans.push_back(pll(p, i));
    }
    REP(i, 0, N - 1) {
      A[N - i - 2] += A[N - i - 1];
      ans.push_back(pll(N - i - 1, N - i - 2));
    }
  }

  cout << ans.size() << endl;
  REP(i, 0, ans.size()) cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
}


Measured memory_bytes: 256
// Problem: C - A x B + C
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;

void solve()
{
  ll n;
  cin >> n;
  ll ctr = 0;
  for (ll j = 1; j < n; j++)
  {
    for (ll i = 1; i * j < n; i++)
      if (n - (i * j) > 0)
        ctr++;
  }
  cout << ctr << jmp;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3604
import sys
import math

input = sys.stdin.readline

def can(arr, m, K):
  need = 0
  for x in arr:
    if x > m:
      need += int(x // m)
  return need <= K

N, K = map(int, input().split())
arr = list(map(int, input().split()))

lo = 1
hi = int(1e9) + 1

while (lo < hi):
  m = int((lo + hi) // 2)
  if (can(arr, m, K)):
    hi = m
  else:
    lo = m + 1
print(lo)


Measured memory_bytes: 31060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<pair<long long, long long>> a(n);
	long long b;
	for (int i = 0; i < n; i++) {
		cin >> b;
		a[i].first = b - i;
		a[i].second = -b - i;
	}

	vector<pair<long long, long long>> c(n + 1);
	for (int i = 0; i < n; i++) {
		if (a[i].first < 0 && a[i].first >= -n) {
			c[-a[i].first].first++;
		}

		if (a[i].second < 0 && a[i].second >= -n) {
			c[-a[i].second].second++;
		}
	}
	
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += c[i].first * c[i].second;
	}
	cout << ans << endl;

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    VL arr(n);
    fr(i,0,n)   
        cin>>arr[i];
    bool buy=false;
    ll cur=1000;
    ll stock=0;
    fr(i,0,n-1)
    {
        if(arr[i+1]>=arr[i])
        {
            if(!buy)
            {
                buy=!buy;
                ll tot=cur/arr[i];
                cur-=tot*arr[i];
                stock=tot;
            }
        }
        else
        {
            if(buy)
            {
                buy=!buy;
                ll tot=stock*arr[i];
                cur+=tot;
                stock=0;
            }
        }
    }
    if(buy)
    {
        cur+=stock*arr[n-1];
    }
    cout<<cur<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vl dv(10000050);
  for (int i = 2; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      dv[j]++;
    }
  }
  // dumpv(dv, n + 1);
  ll ans = 0;
  rep(i, n) {
    ans += (ll)(i + 1) * ((ll)dv[i + 1] + 1);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 81320
#include<cstdio>
#define N 10000
int main(){
        int a[N],i=0;
        do{
                scanf("%d",&a[i]);
        }while(a[i++]!=0);
        for(int j=0;j<i-1;j++)
                printf("Case %d: %d\n",j+1,a[j]);
        return 0;
}

Measured memory_bytes: 2644
#include "bits/stdc++.h"
 
#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}
 
using namespace std;
using ll = long long;
using P = pair<ll, int>;
 
void Main() {
  int n;
	cin >> n;
  vector<int> A(n);
  vector<P> ord;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
    ord.emplace_back(A[i], i);
	}
 
  vector<ll> dp(n+1, 0);
	sort(ord.begin(), ord.end());
  rep(i, n) {
    rep(l, n - i + 1) {
			int r = l + i;
			const auto &[a, pos] = ord[i];
			dp[l] = max(dp[l] + a * abs(pos - r), dp[l + 1] + a * abs(pos - l));
		}
	}
 
  cout << dp[0] << endl;
}
 
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j);a×b行列の入力
 
int main() {
  ll a,b;
  ci(a>>b);
  ll c=1;
  for(i,1,50){
    if(b==1){
      co(0);
      break;
    }
    c+=a-1;
    if(c>=b){
      co(i);
      break;
    }
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc132_a

word = input()
dic_char = {}
for s in word:
    if s in list(dic_char.keys()):
        dic_char[s] += 1
    else:
        dic_char[s] = 1

check = True
for s, count in dic_char.items():
    if count != 2:
        check = False

if check:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9004
#include <cstdio>

template<int N, typename T, T M>
struct factorial_mod
{
	T mod[N + 1];
	T inv_mod[N + 1];

	constexpr factorial_mod() : mod(), inv_mod()
	{
		mod[0] = 1;
		for (int i = 0; i < N; ++i)
		{
			mod[i + 1] = (mod[i] * (i + 1)) % M;
		}
		inv_mod[N] = power(mod[N], M - 2);
		for (int i = N - 1; i >= 0; --i)
		{
			inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
		}
	}

	constexpr T power(T a, T b)
	{
		T r = 1;
		while (b > 0)
		{
			if ((b & 1) != 0) r = (r * a) % M;
			a = (a * a) % M;
			b >>= 1;
		}
		return r;
	}

	constexpr T comb(T n, T r)
	{
		return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
	}
};


factorial_mod<200000, long long, 1000000007> facmod;

int main()
{
	long long h, w, a, b;
	scanf("%lld %lld %lld %lld", &h, &w, &a, &b);
	long long ans = 0;

	while (a < h && b < w)
	{
		ans = (ans + ((facmod.comb(h - 1 - a + b, b) * facmod.comb(w - 1 - b + a, a)) % 1000000007)) % 1000000007;
		++a; ++b;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main() {
  int H, A[100000];
  cin >> H;
  for (int i = 1; i <= H; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= H; i++) {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
    if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
}



Measured memory_bytes: 3084