akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_3-A

Elementary data structures - Stack
=end

class Rpc
  def initialize(f)
    @a = Array.new(f.length)
    0.upto(f.length-1).each{|i| @a[i] = f[i]}

  end

  def calc()
    st = []
    val=0
    while @a.length > 0 do
      x = @a.shift
      if x =~ /\d+/ then
        st.push x.to_i
      elsif x == "+" then
        st.push(  st.pop + st.pop)
      elsif x == "-" then
        st.push( -st.pop + st.pop)
      elsif x == "*" then
        st.push(  st.pop * st.pop)
      else
        abort "unknown:#{x}"
      end
    end
    st.pop
  end

end

class Main
  def initialize()
    #fh = open("x.txt")
    fh = STDIN
    f = fh.gets.chomp.split
    rp = Rpc.new(f)
    puts rp.calc()
  end
end

if $0==__FILE__ then
  Main.new()
end

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	a=max(a,b);
	cout<<(c+a-1)/a;
	re 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    j = 0
    if i < k:
        while i*(2**j) < k:
            j += 1
        ans += (1/n)*1/(2**j)
    else:
        ans += (1/n)
print(ans)

Measured memory_bytes: 9000
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, T& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

struct tower_t {
    int height = 0;
    unordered_set<int> next;
};



void solution()
{
    int n,m;
    cin >> n >> m;
    vector<tower_t> towers(n);
    rep(i,n){
        cin >> towers[i].height;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        towers[a-1].next.insert(b-1);
        towers[b-1].next.insert(a-1);
    }
    int count = 0;
    rep(i,n){
        int maxh = 0;
        for(int n : towers[i].next) {
            maxh = max(maxh, towers[n].height);
        }
        if(maxh < towers[i].height) count += 1;
    }
    cout << count << '\n';
}

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


Measured memory_bytes: 18956
data = []
w = int(input())
for i in range(w):
  data.append(i+1)

n = int(input())

for line in range(n):
  a, b = [int(i) for i in input().split(',')]
  data[a-1], data[b-1] = data[b-1], data[a-1]
for d in data:
  print(d)

Measured memory_bytes: 5596
N = int(input())

NSP = list()

for n in range(N):
    S, P = input().split()
    NSP.append([n+1, S, int(P)])

NSP.sort(key=lambda x: x[2])
NSP.reverse()
NSP.sort(key=lambda x: x[1])

for n in range(N):
    print(NSP[n][0])


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://arc059.contest.atcoder.jp/tasks/arc059_b>
 問題文============================================================
 文字列 t について、t の長さが 2 以上であり、かつ t の中の文字のうち過半数が同じ文字であるとき、
 t をアンバランスであると呼ぶことにします。
 例えば、voodoo や melee はアンバランスであり、noon や a はアンバランスではありません。
 
 小文字のアルファベットからなる文字列 s が与えられます。
 s にアンバランスな (連続する) 部分文字列が存在するか判定してください。
 存在する場合は、s の中でそのような部分文字列が存在する位置を一つ示してください。
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    int l = -1, r = -1;
    
    for(int i = 0; i < (int)s.length()-1;i++){
        if(s[i] == s[i+1]){
            l = i; r = i+1;
            break;
        }
    }
    if(l != -1){
        cout << l + 1 << " " << r + 1 << endl;
        return 0;
    }
    for(int i = 0; i < (int)s.length()-2;i++){
        if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
            l = i; r = i+2;
            break;
        }
    }
    if(l != -1){
        cout << l+1 << " " << r+1 << endl;
    }else{
        cout << -1 << " " << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
string ans[int(1e5) + 10];
int main() {
	var(int, n, m);
	map<int, vector<pii>> mip;
	vector<array<int, 3>> v(m);
	rep(i, 0, m) {
		cin >> v[i][1] >> v[i][0];
		v[i][2] = i;
	}
	sort(all(v));
	rep(i, 0, m) {
		mip[v[i][1]].eb(mp(v[i][0], v[i][2]));
	}
	each(a, mip) {
		rep(i, 0, len(a.se)) {
			ans[a.se[i].se] = zero(6, a.fi) + zero(6, i + 1);
		}
	}
	rep(i, 0, m) {
		print(ans[i]);
	}
	return 0;
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int INF = (int)1e9;

#define maxn 100010



int main() {
#ifdef BZ
    freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(6);

    ll a, b;
    cin >> a >> b;

    ll v = a * b - a - b + 1;

    cout << v << "\n";

}

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

const long long mod=1000000007;
long long n, k, a[100001], ans=0, facto[100004];

long long modpow(long long x, long long y){
	long long ret=1;
	while(y>0){
		if (y&1){
			ret*=x;
			ret%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return ret;
}

long long modinv(long long x){
	return modpow(x,mod-2);
}

long long bino(long long aa, long long bb){
	return (((facto[aa]*modinv(facto[aa-bb]))%mod)*modinv(facto[bb]))%mod;
}

void init(){
	facto[0]=1;
	for (int i=1;i<100004;i++){
		facto[i]=facto[i-1]*i;
		facto[i]%=mod;
	}
}

int main(){
	init();
	cin >> n >> k;
	for (int i=0;i<n;i++) cin >> a[i];
	sort(a,a+n);
	for (int i=k-1;i<n;i++){
		ans+=a[i]*bino(i,k-1);
		ans%=mod;
	}
//	cout << ans << "\n";
	for (int i=0;i<=n-k;i++){
		ans-=a[i]*bino(n-i-1,k-1);
		ans%=mod;
		if (ans<0) ans+=mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD (ll)(1e9+7)
#define MAX (ll)(1e5*2+200)
#define print(x) cout << x << endl;
#define printArr(arr) REP(i, (sizeof arr / sizeof arr[0])){print(arr[i])}
#define printVec(vec) REP(i, vec.size()){print(vec[i])}
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Sx, Sy, Tx, Ty;
    cin >> Sx >> Sy >> Tx >> Ty;
    
    int tmp, num1, num2;
    num1 = Tx-Sx;
    num2 = Ty-Sy;
    REP(i, abs(num1)){cout << "R";}
    REP(i, abs(num2)){cout << "U";}
    
    REP(i, abs(num1)){cout << "L";}
    REP(i, abs(num2)){cout << "D";}
    
    cout << "L";
    REP(i, abs(num2)+1){cout << "U";}
    REP(i, abs(num1)+1){cout << "R";}
    cout << "D";
    
    cout << "R";
    REP(i, abs(num2)+1){cout << "D";}
    REP(i, abs(num1)+1){cout << "L";}
    cout << "U";
    
    cout << endl;
        
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c=-4;
  string s;
  cin >> s;
  
  rep(i,0,4) if(s.at(i)=='+') c+=2;
  co(c);
  return 0;
}


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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll H, W, m;
  cin >> H >> W >> m;
  vector<ll> h(m), w(m), hs(H), ws(W);
  rep(i, m) {
    cin >> h[i] >> w[i];
    --h[i];
    --w[i];
    ++hs[h[i]];
    ++ws[w[i]];
  }
  using pll = pair<ll, ll>;
  set<pll> s;
  rep(i, m) s.emplace(h[i], w[i]);
  ll hsmax = -1, wsmax = -1;
  itr(x, hs) updatemax(hsmax, x);
  itr(x, ws) updatemax(wsmax, x);
  vector<ll> hsmaxi, wsmaxi;
  rep(i, H) if (hs[i] == hsmax) hsmaxi.push_back(i);
  rep(i, W) if (ws[i] == wsmax) wsmaxi.push_back(i);
  ll ans = hsmax + wsmax;
  if (hsmaxi.size() * wsmaxi.size() <= m) {
    itr(hi, hsmaxi) itr(wi, wsmaxi) {
      if (s.find(pll(hi, wi)) == s.end()) goto end;
    }
    --ans;
  }
end:
  cout << ans << endl;
}


Measured memory_bytes: 39704
s=input()
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=a<=12:
    print('MMYY')
elif 1<=b<=12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[1001] = {0};

int main()
{
	int a, b, total=0;
	cin >> a >> b;
	for(int i=0; i<a; i++)
	{
		cin >> arr[i];
	}
	sort(arr, arr+a);
	for(int i=0; i<b; i++)
	{
		total += arr[i];
	}
	cout << total;
}



Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
	int ans=0;
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int X=sc.nextInt();
	int T=sc.nextInt();
        if(N%X==0){
	    ans=T*(N/X);
	}else{
	    ans=T*(N/X+1);
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 35876
#include<stdio.h>
int main()
{
    int a, b, c, d, p,x=0,y=0;
    scanf("%d%d%d%d%d", &a, &b, &c, &d, &p);
    x = a*p;
    if (p > c)
    {
        y = b+(p - c)*d;
    }
    else
    {
        y = b;
    }
    if (x > y) {
        printf("%d\n", y);
    }
    else {
        printf("%d\n", x);
    }
    return 0;
}

Measured memory_bytes: 1800
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>
#include<unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

struct val{
	int cost,u,t;
};
inline bool operator<(val a,val b){
	return a.cost>b.cost;
}
queue<val>q;
int n,m;
vi col[111111];
map<int,vi>g[111111];
map<int,int>dp[111111];

int I_Love_Hashimoto_Kanna() {
  fastio;
  n=read();
  m=read();
  FOR(i,0,m){
  	int a=read()-1,b=read()-1,c=read();
  	col[a].push_back(c);
		col[b].push_back(c);
		g[a][c].push_back(b);
		g[b][c].push_back(a);
	}
	q.push({0,0,0});
	dp[0][0]=0;
	while(!q.empty()){
		int cost=q.front().cost;
		int u=q.front().u;
		int t=q.front().t;
		q.pop();
		if(dp[u][t]!=cost)continue;
		if(dp[u].find(0)==dp[u].end()||dp[u][0]>cost){
			dp[u][0]=cost;
			q.push({cost,u,0});
		}
		if(t==0){
			FOR(i,0,col[u].size()){
				int cc=col[u][i];
				if(dp[u].find(cc)==dp[u].end()||dp[u][cc]>cost+1){
					dp[u][cc]=cost+1;
					q.push({cost+1,u,cc});
				}
			}
			continue;
		}
		FOR(i,0,g[u][t].size()){
			int to=g[u][t][i];
			if(dp[to].find(t)==dp[to].end()||dp[to][t]>cost){
				dp[to][t]=cost;
				q.push({cost,to,t});
			}
		}
	}
	int ans=inf;
	for(map<int,int>::iterator itr=dp[n-1].begin();itr!=dp[n-1].end();itr++){
		ans=min(ans,itr->second);
	}
	if(ans==inf)Tone(-1)
	else Tone(ans) 
	
  
  return 0;
}


Measured memory_bytes: 84480
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; i + j <= K && i + j <= N; j++) {
      vector<int> a;
      for (int k = 0; k < i; k++) a.push_back(A[k]);
      for (int k = 0; k < j; k++) a.push_back(A[N - 1 - k]);
      sort(a.begin(), a.end());
      int left = min<int>(K - i - j, a.size());
      int sum = 0;
      for (int x : a) {
        sum += x;
      }
      for (int i = 0; i < left; i++) {
        if (a[i] < 0) sum -= a[i];
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << '\n';
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
int N,K;
int t[1000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  int a,b,x,y;
  rep(_,K){
    cin >> a >> b;
    --a;--b;
    if(a >= (N/2)) a = (N-1)-a;
    if(b >= (N/2)) b = (N-1)-b;
    x = y = (min(a,b)/3 )* 3;
    while(1){
      if(x == a || y == b){
        break;
      }
      if(x + 3 < a && y+3 < b){
        x += 3;
        y += 3;
      }
      else{
        ++x;
        ++y;
      }
    }
    cout << min(a,b)% 3 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3208
N = int(input())
HP = set(map(int, input().split(" ")))

while len(HP) > 1:
    minHP = min(HP)
    nextHPs = set([minHP])
    for each_HP in HP:
        temp = each_HP % minHP
        if temp != 0:
            nextHPs.add(temp)
    HP = list(nextHPs)
print(list(HP)[0])


Measured memory_bytes: 19732
def f a;a==($u[a]||=a)?a:$u[a]=f($u[a])end
while (gets==?\n&&next;0<n=$_.to_i)
$u={}
h={}
n.times{
h[a=gets[0]]||=0
h[a]+=1
h[b=$_[-2]]||=0
h[b]-=1
$u[f b]=f a
}
puts h.any?{|k,v|f k;v!=0}||$u.values.uniq[1]?:NG:"OK"
end

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define bs binary_search
#define pi 3.1415926535
#define pob pop_back
const ll MAX=INT_MAX;
const ll MIN=INT_MIN;
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define memo(a,b) memset(a,b,sizeof(a))
#define loopr(i,s,n) for(ll i=s;i>=n;i--)
#define I first
#define II second
#define mp make_pair
#define mt make_tuple
//for(int x:v ){cout<<x;}
int main()
{	ios::sync_with_stdio(0);
/*freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
cin.tie(NULL);cout.tie(NULL);
    ll i=1,n;
	while(cin>>n){
      if(n==0)
      {
        cout<<i<<endl;
        break;
      }
      i++;
      
    }
 
	return 0;
}


Measured memory_bytes: 3584
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,a[2][110],dp[2][110];

int main()
{
	cin>>n;
	rep(i,2) rep(j,n) cin>>a[i][j];
	dp[0][0]=a[0][0];
	rep(i,2)
	{
		rep(j,n)
		{
			if(i+1==1) dp[i+1][j]=max(dp[i+1][j],dp[i][j]+a[i+1][j]);
			if(j+1<n) dp[i][j+1]=max(dp[i][j+1],dp[i][j]+a[i][j+1]);
		}
	}
	cout<<dp[1][n-1]<<endl;
	rt0;
}

Measured memory_bytes: 256
//#define		FILE_INPUT_DEFINE
#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<cstdio>
#include	<string>

using namespace std;

struct Tree
{
	int		parent;
	int		right;
	int		left;
	Tree()
	{
		parent = right = left = -1;
	}
};

#define		MAX			100000
Tree	tree[MAX];

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE
	int		n;

	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		int		index;
		cin >> index;

		int		max;
		cin >> max;
		int		right;
		int		backup;

		for (int j = 0; j < max; ++j)
		{
			cin >> right;
			if (0 == j)
			{
				tree[index].left = right;
			}
			else
			{
				tree[backup].right = right;
			}
			tree[right].parent = index;
			backup = right;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		printf("node %d: parent = %d, ", i, tree[i].parent);

		int		depth = 0;
		int		index = i;

		while (-1 != tree[index].parent)
		{
			index = tree[index].parent;
			++depth;
		}
		printf("depth = %d, ", depth);

		if (tree[i].parent == -1)
		{
			printf("root,");
		}
		else
		{
			if (tree[i].left == -1)
			{
				printf("leaf,");
			}
			else
			{
				printf("internal node,");
			}
		}

		printf(" [");
		if (-1 != tree[i].left)
		{
			int	index = tree[i].left;
			printf("%d", index);

			while (-1 != tree[index].right)
			{
				printf(", %d", tree[index].right);
				index = tree[index].right;
			}
		}
		printf("]\n");
	}

	return 0;
}

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

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]) return vector< T >();
  }
  return dist;
}

int main() {
  int N, C;
  int A[200], O[200], B[200], S[200], D[200];

  cin >> N >> C;
  vector< int > undefined;
  for(int i = 0; i < C; i++) {
    string str;
    cin >> str;
    int tail = 0, a = 0, b = 0, o, s, d = 0;
    while(isdigit(str[tail])) a = a * 10 + str[tail++] - '0';
    if(str[tail] == '*') o = 2;
    else if(str[tail] == '<') o = 0, ++tail;
    else o = 1, ++tail;
    ++tail;
    while(isdigit(str[tail])) b = b * 10 + str[tail++] - '0';
    if(str[tail] == '+') s = 0;
    else s = 1;
    ++tail;
    while(tail < str.size()) d = d * 10 + str[tail++] - '0';
    A[i] = --a, B[i] = --b, O[i] = o, S[i] = s, D[i] = d;
    if(o == 2) undefined.push_back(i);
  }
  int ret = -1;
  for(int i = 0; i < (1 << undefined.size()); i++) {
    for(int j = 0; j < undefined.size(); j++) O[undefined[j]] = (i >> j) & 1;

    Edges< int > es;
    for(int k = 0; k < C; k++) {
      if(O[k] == 1) swap(A[k], B[k]);
      es.emplace_back(B[k], A[k], 0);
      if(S[k] == 0) es.emplace_back(B[k], A[k], -D[k]);
      else es.emplace_back(A[k], B[k], D[k]);
      if(O[k] == 1) swap(A[k], B[k]);
    }
    auto dists = bellman_ford(es, N, 0);
    if(dists.empty() || *min_element(begin(dists), end(dists)) < 0) continue;
    ret = max(ret, *max_element(begin(dists), end(dists)));
  }

  if(ret >= numeric_limits< int >::max()) cout << "inf" << endl;
  else cout << ret << endl;
}


Measured memory_bytes: 3184
S = input()
N = len(S)

Rcnt = 0
SR = [0]*N
for i in range(N):
    if S[i] == 'R':
        Rcnt += 1
    elif Rcnt== 0:
        continue
    else:
        SR[i] = Rcnt//2
        SR[i-1] = Rcnt - Rcnt//2
        Rcnt = 0
        
SL = [0]*N
SS = S[-1::-1]
Lcnt = 0
for i in range(N):
    if SS[i] == 'L':
        Lcnt += 1
    elif Lcnt ==0:
        continue
    else:
        SL[i] = Lcnt//2
        SL[i-1] = Lcnt - Lcnt//2
        Lcnt = 0

for i in range(N):
    print(SR[i]+SL[N-i-1], end = " ")


Measured memory_bytes: 10968
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
AGC018 B
"""

from collections import Counter

n, m = map(int, input().split())
alili = [list(map(int, input().split())) for i in range(n)]

cnt = Counter()

for i in range(n):
    cnt[alili[i][0]] += 1

ans = cnt.most_common(1)[0][1]
delset = set()

for j in range(m-1):
    x, tmp = cnt.most_common(1)[0]
    if tmp < ans:
        ans = tmp
    del cnt[x]
    delset.add(x)
    for i in range(n):
        if alili[i][0] == x:
            while alili[i][0] in delset:
                del alili[i][0]
            cnt[alili[i][0]] += 1

print(ans)


Measured memory_bytes: 4596
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N , K = 0;
		long A, B;
		N = sc.nextInt();
		A = sc.nextLong();
		B = sc.nextLong();
		long[] H = new long[N];
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		long Tmax = 1000000000;
		long Tmin = 0;
		long T = 0;
		while(Tmax-Tmin > 1){
			T = Tmin + (Tmax-Tmin)/2;
			K = 0;
			for(int i = 0 ; i < N ; i++){
				if(H[i] > B*T){
					K += Math.ceil((double)(H[i] - B*T) / (double)(A - B));
				}
			}
			
			if(K > T){
				Tmin = T;
			}
			else if(K <= T){
				Tmax = T;
			}
		}
		System.out.println(Tmax);
	}
}

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

int main(){
	int n; cin >> n;
	vector<int> vec(n);

	for(int i=0;i<n;i++)
		cin >> vec[i];

	reverse(vec.begin(),vec.end());

	for(int i=0;i<n;i++)
		cout << vec[i] << (i<(n-1)?" ":"\n");

	return 0;
}

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

int main(){
	
	string s;
	
	cin >> s;
	
	if (s == "Sunny"){
		cout << "Cloudy";
	} else if (s == "Cloudy"){
		cout << "Rainy";
	} else {
		cout << "Sunny";
	}
	
	
}


Measured memory_bytes: 256
n=int(input())
c=[0,0,0,0]
for i in range(n):
    check=input()
    if (check=="AC"):
        c[0]+=1
    elif(check=="WA"):
        c[1]+=1
    elif(check=="TLE"):
        c[2]+=1
    else:
        c[3]+=1

ans=["","","",""]
ans[0]="AC x "+str(c[0])
ans[1]="WA x "+str(c[1])
ans[2]="TLE x "+str(c[2])
ans[3]="RE x "+str(c[3])

for i in range(4):
    print(ans[i])

Measured memory_bytes: 9236
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String S = new StringBuffer(sc.next()).reverse().toString();
		boolean flg = false;

		String[] keywords = {"maerd", "remaerd", "esare", "resare"};
		int currentI = 0;
		while (true) {
			for (String keyword: keywords) {
				int index = S.indexOf(keyword, currentI);
				if (index == currentI) {
					currentI += keyword.length();
					flg = true;
					break;
				}
			}

			if (currentI == S.length()) {
				out.println("YES");
				break;
			}

			if (flg) {
				flg = false;
			} else {
				out.println("NO");
				break;
			}
		}

		out.flush();
	}
}

Measured memory_bytes: 39340
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 2e5 + 10;

ll n,a[maxn];
ll sum;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) {
        int x;
        cin>>x;
        a[i] = x - i;
    }
    sort(a+1,a+n+1);
    ll b = a[(n+1)/2];
    for (int i=1;i<=n;i++) sum += abs(a[i] - b);
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
s = list(input())

for i in range(int(input())):
    cmd,a,b,*c = input().split()
    a = int(a)
    b = int(b)
    if cmd =="print":
        print(*s[a:b+1],sep ="")
    elif cmd == "reverse":
        s[a:b+1] = reversed(s[a:b+1])
    else:
        s[a:b+1] = c[0]




Measured memory_bytes: 5740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	ll cansancio = 0;
	vector <ll> coordenadas(n);
	scanf("%lld", &coordenadas[0]);
	for(int i=1;i<n;++i) {
		scanf("%lld", &coordenadas[i]);
		if((coordenadas[i]-coordenadas[i-1])*a<b)
			cansancio += (coordenadas[i]-coordenadas[i-1])*a;
		else {
			cansancio += b;
		}
	}
	printf("%lld\n", cansancio);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



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

  REP2(i,1,n+1){
    int cnt = 0;

    for(int x = 1; x*x <= n ;x++){
      for(int y = x; y*y <= n - x*x ;y++){
          for(int z = y; z*z <= n-x*x-y*y ;z++){
          int f = 0;
          f = x*x + y*y + z*z + x*y + y*z + z*x;
          if(f == i){
            if (x == y && y == z) ++cnt;
            else if(x == y || y == z) cnt += 3;
            else cnt += 6;
            break;
          }
        }
      }
    }
    printf("%d\n",cnt);
  }
  return 0;
}


Measured memory_bytes: 3732
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
if(a < 1000){
System.out.println("ABC");
}else{
System.out.println("ABD");
}
	}
}

Measured memory_bytes: 23764
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define debug(x) cout<<#x<<": "<<x<<" "
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
const int N=100;
int a[N],n;
int main()
{
    IO;
    cin>>n;

    for(int i=1;i<=n;i++) cin>>a[i];
    ll res=1000;
    for(int i=1;i<=n;i++)
        if(i<=n&&a[i+1]>=a[i])res=res/a[i]*a[i+1]+res%a[i];
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3500
def main():
  n = int(input())
  #s = input()
  #s = input().split()
  h = list(map(int,input().split()))
  #c = [input().split() if i in range(n)]
  ans = 0
  a = 0
  
  for i in range(n):
    if a <= h[i]:
      ans += 1
      a = h[i]
  print(ans)
  
if __name__ == '__main__':
  main()

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

C = []
for _ in range(n):
    x, y = map(int, input().split())
    C.append((x, y))

l = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        xi, yi = C[i][0], C[i][1]
        xj, yj = C[j][0], C[j][1]
        l += ((xi - xj)**2 + (yi - yj)**2)**0.5

print((2 * l) / n)


Measured memory_bytes: 3188
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<int, int> p;
typedef vector <int> VI;
typedef vector <string> VS;

vector <int> his;

int main(){

	int n, c, k;
	cin >> n;
	cin >> c;
	cin >> k;		

	VI a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	sort(all(a));
	
	int ans = 0;
	for(int i = 0; i < n;){
		int ci = 1;
		for(ci = 1; ci < c; ci++){
			if(i + ci == n) break;
			if(a[i + ci] - a[i] > k) break;
		}
		i += ci;
		ans++;
	}

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


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

int main()
{
  int64_t H, cnt = 0, num = 1;
  cin >> H;
  while (H > 0)
  {
    cnt += num;
    H /= 2;
    num *= 2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <numeric>
#include <algorithm>
using namespace std;

#define ll long long

vector<vector<ll>> gcdMemo(200, vector<ll>(200, -1));

ll getGcd(ll x, ll y)
{
    if (gcdMemo[x - 1][y - 1] != -1)
        return gcdMemo[x - 1][y - 1];

    ll result;
    if (x % y == 0)
        result = y;
    else
        result = getGcd(y, x % y);

    gcdMemo[x - 1][y - 1] = result;
    return result;
}

int main()
{
    ll N;
    scanf("%lld", &N);

    ll sum = 0;
    for (ll i = 1; i <= N; i++)
        for (ll j = 1; j <= N; j++)
            for (ll k = 1; k <= N; k++)
            {
                ll ij = getGcd(i, j);
                ll ijk = getGcd(k, ij);
                sum += ijk;
            }

    printf("%lld", sum);
}


Measured memory_bytes: 4108
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  while( 1 ) {
    int l;
    cin >> l;
    if( !l ) { return EXIT_SUCCESS; }
    
    int mth = -1;
    for( int i = 1; i <= 12; i++ ) {
      int m, n;
      cin >> m >> n;
      l -= ( m - n );
      if( mth == -1 && l <= 0 ) { mth = i; }
    }
    cout << ( mth == -1 ? "NA" : to_string( mth ) ) << endl;
  }
}

Measured memory_bytes: 1224
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = Integer.parseInt(sc.next());
		sc.close();
		Arrays.sort(a);
		long yono = 0;
		for(int i = 0 ; i < n - 1 ; i++) yono += a[n - (i + 1) / 2 - 1];
		ou.println(yono);
		ou.flush();
	}
}

Measured memory_bytes: 61120
#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 int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
//#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int valk=0;
        int a;
        string b;
        cin>>a>>b;
        vi bd,ad;
        int l=b.length();
        bool bfd=true;
        for(int i=0;i<l;i++)
        {
            if(b[i]=='.')
            {
                bfd=false;
            }
            else if(bfd)
            {
                bd.pb(b[i]-'0');
            }
            else ad.pb(b[i]-'0');
        }
        int ans = a*bd[0];
       // cout<<ans<<"\n";
        int val=a*ad[0];
        int val2=val%10;
        
        val/=10;
        ans+=val;
        int val3=a*ad[1];
        val3/=10;
        int val4=val3%10;
        val4+=val2;
        val4/=10;
        val3/=10;
        ans+=val3;
        
        
        ans+=val4;
        cout<<ans<<"\n";


    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



Measured memory_bytes: 3648
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<int>num(N + 1);
	for (auto i : v)num[i]++;
	sort(num.begin(), num.end());
	reverse(num.begin(), num.end());
	vector<int>kind_sum(N + 2);
	vector<int>sum(N + 2);
	for (auto i : num) {
		kind_sum[i]++;
		sum[i] += i;
	}
	for (int i = 1; i <= N; i++)sum[i] += sum[i - 1];
	for (int i = N; i >= 0; i--)kind_sum[i] += kind_sum[i + 1];
	for (int i = 1; i <= N; i++) {
		L = 0, R = N / i + 1;
		while (R - L > 1) {
			int mid = (R + L) / 2;
			int box = kind_sum[mid];
			//cout << sum[mid - 1] << " " << box * i << " "<<mid * i << endl;
			if (sum[mid - 1] + box * mid >= mid * i)L = mid;
			else R = mid;
		}
		cout << L << endl;
	}
}

Measured memory_bytes: 5632
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3 6
3 4 5
---+/
/+---test
4 9
3 3 3 3
---+/

void main(string[] args) {
  long N, X;
  readf(" %d %d ", &N, &X);
  const L = readln.split.map!(to!long).array;

  long ans = 1;

  long d;
  foreach (l; L) {
    d += l;
    if (d <= X) ++ans;
    if (ans >= N+1) break;
  }
  ans.writeln;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int h = fs.nextInt();
        final int w = fs.nextInt();
        System.out.println(h * w - (h + w - 1));
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, x;
		int sum = 0;
		int[] count = new int[300];
		int index;
		for (index = 0; true; index++) {
			n = sc.nextInt();
			x = sc.nextInt();
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n; i++) {
				sum += i;
				for (int j = i + 1; j <= n; j++) {
					sum += j;
					for (int k = j + 1; k <= n; k++) {
						sum += k;
						if (sum == x) {
							count[index]++;
						}
						sum -= k;
					}
					sum -= j;
				}
				sum -= i;
			}
		}
		for (int i = 0; i < index; i++) {
			System.out.println(count[i]);
		}
		sc.close();
	}
}


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

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

const int64_t INF = 1e18;

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(2, INF));
    dp[0][0] = 0LL;
    rep(i, N) {
        int d = S[i] -'0';
        chmin(dp[i + 1][0], dp[i][0] + d); // 普通に払う
        chmin(dp[i + 1][1], dp[i][0] + 11 - d); // 上の桁を使う
        chmin(dp[i + 1][0], dp[i][1] + d); // 普通に払う
        chmin(dp[i + 1][1], dp[i][1] + 9 - d); // 上の桁を使う
    }
    cout << min(dp[N][0], dp[N][1]) << '\n';
    return 0;
}


Measured memory_bytes: 55940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;
char s[maxn];
int sta[maxn], top, n;
ll ans;
void solve()
{
	ll ret = 0, cnt = 0;
	for(int i = 1; i <= top; ++i) 
		if(sta[i] == 1) 
		{
			ret += i;
			++cnt;
		}
	ret -= cnt * (cnt + 1) / 2;
	ans += ret;
	top = 0;
}
int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; ++i)
	{;
		if(s[i] == 'A') sta[++top] = 0;
		else if(s[i] == 'B' && s[i + 1] == 'C') { sta[++top] = 1; ++i;}
		else solve();
	}
	solve();
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin >> a;
    int resA,resB,resC;
    resA = a / 3600;
    resB = a % 3600 / 60;
    resC = a % 3600 % 60;
    cout << resA << ":" << resB << ":" << resC << endl;
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time = 0;
    if(h1==h2){
        time += m2-m1;
        cout << time -k << endl;
    }
    else{
        time += 60 - m1;
        //cout << time << endl;
        time += m2;
        //cout << time << endl;
        time += (h2 - (h1 + 1))*60;
        cout << time - k << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

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

	vector<vector<int> > dp(s.size() + 1, vector<int>(t.size() + 1, 0));
	vector<vector<char> > poi(s.size() + 1, vector<char>(t.size() + 1));

	for(int i = 1; i <= s.size(); ++i){
		for(int j = 1; j <= t.size(); ++j){
			if(s[i - 1] == t[j - 1]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
				poi[i][j] = 'D';
			} else if(dp[i - 1][j] > dp[i][j - 1]){
				dp[i][j] = dp[i - 1][j];
				poi[i][j] = 'L';
			} else{
				dp[i][j] = dp[i][j - 1];
				poi[i][j] = 'U';
			}
		}
	}

	string ans = "";
	int i = s.size(), j = t.size();
	while(i > 0 && j > 0){
		if(poi[i][j] == 'U') --j;
		else if(poi[i][j] == 'L') --i;
		else{
			ans += s[i - 1];
			--i;
			--j;
		}
	}

	reverse(ALL(ans));
	cout << ans << endl;
}//解答参考.do表を書く!

Measured memory_bytes: 44544
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N,M;
int a,b;
int x,y;
void input(){
    cin>>x>>y;
}
void putBool(bool f){
    if(f){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    bool f=false;
    rep(i,x+1){
        if(i*2+(x-i)*4==y){
            f=true;
        }
    }
    putBool(f);
    return 0;
}


Measured memory_bytes: 3656