akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Map<Integer, Integer> h = new HashMap<>();
        List<City> city = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            int Pref = Integer.parseInt(sc.next());
            int Year = Integer.parseInt(sc.next());
            city.add(new City(i, Pref, Year));
            if (h.containsKey(Pref)) {
                h.put(Pref, h.get(Pref) + 1);
            } else {
                h.put(Pref, 1);
            }
        }
        sc.close();
        city.sort((o1, o2) -> Integer.compare(o2.Year, o1.Year));
        for (City c : city) {
            c.Num = h.get(c.Pref);
            h.put(c.Pref, h.get(c.Pref) - 1);
        }
        city.sort((o1, o2) -> Integer.compare(o1.ID, o2.ID));
        PrintWriter pw = new PrintWriter(System.out);
        for (City c : city) {
            pw.printf("%06d%06d\n", c.Pref, c.Num);
        }
        pw.flush();
    }

    static class City {
        int ID;
        int Pref;
        int Year;
        int Num;

        City(int ID, int Pref, int Year) {
            this.ID = ID;
            this.Pref = Pref;
            this.Year = Year;
            this.Num = 0;
        }
    }
}

Measured memory_bytes: 107864
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
 
int main() {
	int N, T, E;
	cin >> N >> T >> E;
	vector<int> v(N);
	REP(i,N) cin >> v[i];
	int ans = -2;
	REP(i,N) {
		int c = v[i];
		for(int j = 1; j * c <= T + E; j++) {
			if(T - E <= j * c && j * c <= T + E)
				ans = i;
		}
	}
	cout << 1 + ans << endl;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll long long
using namespace std;

signed main() {
	int a;
	while (scanf("%d", &a), a) {
		int p = a;
		map<int, int>c;
		for (int b = 2; b < sqrt(a); b++) {
		while(a%b==0){
			a /= b;
			c[b]++;
		}
		}
		if (a != 1)c[a]++;
		ll s = 1;
		for (auto k = c.begin(); k != c.end(); k++) {
			int x = 0, y = 1;
			for (int z = 0; z <= k->second; z++) {
				x += y;
				y *= k->first;
			}
			s *= x;
		}
		s -= p;
		if (p == s)puts("perfect number");
		else if (p > s)puts("deficient number");
		else puts("abundant number");
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np

def count_pair(x):
    cnt = 0
    cnt += (n-np.searchsorted(A, x//A_nega, side='right')).sum()
    if x > 0:
        cnt += len(A_zero)*n
    cnt += np.searchsorted(A, -(-x//A_posi), side='left').sum()
    cnt = (cnt-(A**2 < x).sum())//2
    return cnt

n, k = map(int, input().split())
* A, = map(int, input().split())
A = np.array(A)
A = np.sort(A)
A_posi = A[A > 0]
A_zero = A[A == 0]
A_nega = A[A < 0]
inf = 10**18+1
l, r = -inf, inf
while r - l > 1:
    c = (l + r) // 2
    if count_pair(c) < k:
        l = c
    else:
        r = c
print(l)


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

int main(void){
    int i, j, k, tmp, ans;
    int R, G, B, N; cin >> R >> G >> B >> N;

    for(i = 0, ans = 0; i * R <= N; i++){
        for(j = 0; (i * R + j * G) <= N; j++){
            if((N - (i * R + j * G)) % B == 0) ans++;
        }
    }   

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VL as(n);
  VL bs(n);
  FOR(a,as) {
    cin >> a;
  }
  FOR(b,bs) {
    cin >> b;
  }
  ll lack = 0;
  int lc = 0;
  VL cap;
  REP(i,0,n) {
    if (as[i] < bs[i]) {
      lack += bs[i] - as[i];
      lc++;
    } else if(as[i] > bs[i]) {
      cap.push_back(as[i] - bs[i]);
    }
  }
  sort(cap.rbegin(), cap.rend());
  int ans = lc;
  FOR(c,cap) {
    if (lack <= 0) {
      break;
    }
    lack -= c;
    ans++;
  }
  if (lack > 0) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
int a[1000005];

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

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

typedef long long ll;

ll N, M;

int main() {
	cin >> N >> M;
	if (N > 1 && M > 1) {
		cout << N*M - (2 * N + 2 * M - 4) << endl;
	}
	else if (N != 1 || M != 1) {
		cout << max(N, M) - 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<30;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int n; cin >> n;
	vector<vector<int>> f(n, vector<int>(11));
	vector<vector<int>> p(n, vector<int>(11));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> f[i][j];
		}
	}
	//両方開店しないパターンも存在するので0 ~ 10
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 11; ++j) {
			cin >> p[i][j];
		}
	}
	int res = -(1 << 30);
	//2^10 -1通りの全ての開店の組み合わせを試行して、利益の最大値を求める
	//両方のお店が開店している時間帯の数をカウントし、pを加算することで利益算出
	for (int b = 1; b < (1 << 10); ++b) {
		int cost = 0;
		for (int i = 0; i < n; ++i) {
			int open_cnt = 0;
			for (int j = 0; j < 10; ++j) {
				if ((b >> j & 1) && f[i][j]) open_cnt++;
			}
			cost += p[i][open_cnt];	
		}
		if (res < cost) res = cost;
	}
	cout << res << endl;
	return;
}

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



Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int r;
	cin >> r;
	cout << r * 2 * PI << endl;


	system("pause");
	return 0;
}


Measured memory_bytes: 3848
// ex3_4
//TKC001
#include<stdio.h>

int main(void){
    int N;
    //YN=1ならYes,0ならNo
    int YN = 0;

    scanf("%d", &N);

    for (int i = 9; i > 0; i--)
    {
        if(N/i<=9 && N/i>=1 && N%i==0){
            YN = 1;
            break;
        }
    }

    if(YN==1){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
    
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    int N; cin >> N;
    vector<pair<ll,ll>> BA(N);
    for(int i = 0; i < N; i++){
        int a,b; cin >> a >> b;
        BA[i] = make_pair(b,a);
    }
    sort(BA.begin(),BA.end());
    int time = 0;
    for(int i = 0; i < N; i++){
        time += BA[i].second;
        if(BA[i].first < time){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<vector>

typedef long long ll;

using namespace std;

int main(void)
{
  ll a[112345]={};
  int i;
  int sum=0;
  int n;
  cin>>n;
  for(i=0;i<n;i++)
    {
      cin>>a[i];
      if(a[i]%2==1)
	sum++;
    }

  if(sum%2)
    puts("NO");
  else
    puts("YES");
  return 0;
  
}


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

using namespace std;

int main(){
    vector<string>days={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    char D[3];
    cin>>D;
    int ans;
    for(int i=0;i<7;i++){
        if(days[i]==D){
            ans=i;
            break;
        }
    }
    cout<<(7-ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)puts("Left");
	else if (a + b < c + d)puts("Right");
	else {
		puts("Balanced");
	}
	return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: x, y, z, i, res
  read(*, *) x, y, z
  res = 0
  do i = 1, 100000
    if (z + i * (y + z) <= x) then
      res = i
    end if
  end do
  write(*, "(i0)") res
end program main


Measured memory_bytes: 384
n,m=map(int, input().split())
tomodati=[[] for i in range(n+1)]
syozoku=[0]*(n+1)
group_list=[0]*(10**6)
for i in range(m):
    a,b=map(int, input().split())
    tomodati[a].append(b)
    tomodati[b].append(a)

from collections import deque
tomo_que=deque()
group=0
for i in range(1,n+1):
    group+=1
    tomo_que.append(i)
    while tomo_que:
        moto=tomo_que.popleft()
        if syozoku[moto]==0:
            syozoku[moto]=group
            group_list[group]+=1

        for i in tomodati[moto]:
            if syozoku[i]==0:
                syozoku[i]=group
                tomo_que.append(i)
                group_list[group]+=1

print(max(group_list))


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

int main() {
	int h, w;
	cin >> h >> w;
	char s[50][50];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> s[i][j];
	for (int i = 1; i < h - 1; i++) {
		for (int j = 1; j < w - 1; j++) {
			if (s[i][j] == '#' && s[i - 1][j] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	if (s[0][0] == '#' && s[0][1] == '.' && s[1][0] == '.') {
		cout << "No" << endl;
		return 0;
	}
	if (s[0][w - 1] == '#' && s[0][w - 2] == '.' && s[1][w - 1] == '.') {
		cout << "No" << endl;
		return 0;
	}
	if (s[h - 1][0] == '#' && s[h - 2][0] == '.' && s[h - 1][1] == '.') {
		cout << "No" << endl;
		return 0;
	}
	if (s[h - 1][w - 1] == '#' && s[h - 1][w - 2] == '.' && s[h - 1][w - 1] == '.') {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 1; i < h - 1; i++) {
		if (s[i][0] == '#' && s[i - 1][0] == '.' && s[i][1] == '.' && s[i + 1][0] == '.') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 1; i < h - 1; i++) {
		if (s[i][w - 1] == '#' && s[i - 1][w - 1] == '.' && s[i + 1][w - 1] == '.' && s[i][w - 2] == '.') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 1; i < w - 1; i++) {
		if (s[0][i] == '#' && s[0][i - 1] == '.' && s[0][i + 1] == '.' && s[1][i] == '.') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 1; i < h - 1; i++) {
		if (s[h - 1][i] == '#' && s[h - 1][i - 1] == '.' && s[h - 1][i + 1] == '.' && s[h - 2][i] == '.') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	//priority_queue<int> q;
	string s = {};
	string s1 = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	//ll x[300005] = {};
	ll y[300005] = {};
	ll z[302][302] = {};
	cin >> s;
	cin >> s1;
	cin >> a;
	cin >> b;
	string s2;
	cin >> s2;
	if (s2==s)
	{
		cout << a-1 <<" " <<b<<endl;
	}
	else
	{
		cout << a << " " << b-1 << endl;

	}


	//cout << ans << endl;



	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;


void ABC136C()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (auto& x : H)
		cin >> x;

	int h = H[N - 1];
	for (int i = N - 2; i > -1; --i)
	{
		if (H[i] > h)
		{
			--H[i];
			if (H[i] > h)
			{
				cout << "No" << endl;
				return;
			}
		}
		h = H[i];
	}
	cout << "Yes" << endl;
}

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


Measured memory_bytes: 640
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::cmp::*;

fn lcp<T: Eq>(a: &[T], b: &[T]) -> usize {
    a.iter().zip(b.iter()).take_while(|p| *p.0 == *p.1).count()
}

fn run() {
    input! {
        n: usize,
        s: [bytes; n],
    }
    let w = 17;
    let mut graph = vec![vec![]; n * w + 2];
    let dst = graph.len() - 1;
    let src = graph.len() - 2;
    for (i, a) in s.iter().enumerate() {
        let len = a.len();
        graph[src].push((i * w + len, len as i32));
        for k in 1..(len + 1) {
            let a = &a[(len - k)..];
            let v = i * w + k;
            for (j, b) in s.iter().enumerate() {
                let p = lcp(a, b);
                let a = &a[p..];
                let b = &b[p..];
                if a.is_empty() && b.is_empty() {
                    if i != j {
                        graph[v].push((dst, 0));
                    }
                } else if a.is_empty() {
                    graph[v].push((j * w + b.len(), b.len() as i32));
                } else if b.is_empty() {
                    graph[v].push((i * w + a.len(), 0));
                }
            }
        }
    }
    let mut dp = vec![std::i32::MAX; n * w + 2];
    dp[src] = 0;
    let mut h = std::collections::BinaryHeap::new();
    h.push((0, src));
    while let Some((d, v)) = h.pop() {
        let d = -d;
        if d > dp[v] {
            continue;
        }
        for &(u, c) in graph[v].iter() {
            let d = d + c;
            if d < dp[u] {
                dp[u] = d;
                h.push((-d, u));
            }
        }
    }
    if dp[dst] == std::i32::MAX {
        println!("0");
    } else {
        println!("{}", dp[dst]);
    }
}

fn main() {
    run();
}



Measured memory_bytes: 29596
//in the name of Allah
#include <bits/stdc++.h>
using namespace std ;
#define F first
#define S second
typedef long long ll ;
const ll N = 100002 ;
ll n , v[N] , w[N] , dp[101][N] , x ;
int main()
{
std::ios::sync_with_stdio(0) ;
cin.tie(0) ;
cout.tie(0);
cin >> n >> x;
for(int i = 0 ; i< n ; i++)cin >> w[i] >> v[i] ;

for(int j = 0 ; j <= x ;j ++){
if(w[0] <= j)dp[0][j] = v[0] ;
}
for(int i = 1 ; i <n ; i ++ ){
    for(int j = 0 ; j <= x ;j ++){
            if(j >= w[i]){
                dp[i][j] = max(dp[i-1][j-w[i]] + v[i] , dp[i-1][j]) ;
            }
            else dp[i][j] = dp[i-1][j] ;
    }
}
cout << dp[n-1][x] ;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
#define p_queue priority_queue
#define INF 2147483647

int read(){
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

string str;

int main() {
	cin>>str;
	if(str.length()==3) reverse(str.begin(),str.end());
	cout<<str<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  int count=0;
  int n=b-a+1;
  for(int i=0;i<n;i++){
  if(a%k==0){
    count++;
  }
    a+=1;
  }
  if(count>0) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int MODYYQ=1e9+7;
int n,k,a[105],dp[105][100005];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)	cin>>a[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		int sum=0;
		for(int j=0;j<=k;j++){
			sum+=dp[i-1][j];
			if(j-a[i]-1>=0)	sum-=dp[i-1][j-a[i]-1];
			sum=(sum%MODYYQ+MODYYQ)%MODYYQ;
			dp[i][j]=sum;
		}
	}
	cout<<dp[n][k]<<endl;
}

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

using namespace std;

int main()
{
   queue<ll> q;
   for(ll i=1;i<=9;i++)
    q.push(i);
    ll k;
    cin>>k;
    ll i=1,r;
    while(i<=k)
    {
         r=q.front();
        ll temp=r%10;
        if(temp!=0)
         q.push(r*10 +temp-1);
        q.push(r*10+temp);
        if(temp!=9)
        q.push(r*10+temp+1);
        q.pop();
      i++;
    }
   cout<<r;
   return 0;
}

Measured memory_bytes: 1792
using System;
class Program{
	static void Main(){
		int s=int.Parse(Console.ReadLine());
		long[] arr;

		for(int i=0;i<s;i++){
			arr=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);

			if(arr[0]<arr[1]){Console.WriteLine("No");}
			else if(arr[1]>arr[3]){Console.WriteLine("No");}
			else if(arr[1]<=arr[2]+1){Console.WriteLine("Yes");}
			else{
				long g=gcd(arr[1],arr[3]);
				if(arr[1]-g+(arr[0]%g)>arr[2]){Console.WriteLine("No");}
				else{Console.WriteLine("Yes");}
			}
		}
	}
	static long gcd(long a,long b){
		long c=Math.Max(a,b)%Math.Min(a,b);
		b=Math.Min(a,b);
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cins(int, 3, t);
    Sort(t);
    Cins(int, n, l);

    int ans = 1e5;
    For(bit, 1 << (2*n)){
        int ansc = 0;
        vector<int> lo(3, 0);
        For(i, n){
            int k = (bit >> (2*i)) % 4;
            if(k == 3) continue;
            if(lo[k] > 0) ansc += 10;
            lo[k] += l[i];
        }
        if(lo[0] == 0 || lo[1] == 0 || lo[2] == 0) continue;
        Sort(lo);
        ansc += abs(lo[0] - t[0]) + abs(lo[1] - t[1]) + abs(lo[2] - t[2]);
        ans = min(ans, ansc);
        // if(ansc == ans) cout << lo[0] << " " << lo[1] << " " << lo[2] << "\n";
    }
    Cout(ans);
}





Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<utility>

using ll = long long;

void chmin(ll &a, const ll b){
  if(b<a)a=b;
}

ll h;
ll c;
ll ans;
struct m_t{
  ll a;
  ll b;
  bool operator<(const m_t &r)const{
    return
      std::make_pair(a*r.b,a)<
      std::make_pair(r.a*b,r.a);
  }
};
m_t v[1000];
m_t *i;
ll ceildiv(ll a,ll b){
  return (a+b-1)/b;
}
void solve(){
  if(h<=0){
    chmin(ans,c);
    return;
  }
  if(i==v)return;
  --i;
  if(c+ceildiv(h*i->b,i->a)<ans){
    ll j=ceildiv(h,i->a);
    c+=j*i->b;
    h-=j*i->a;
    solve();
    while(--j>=0){
      c-=i->b;
      h+=i->a;
      solve();
    }
  }
  ++i;
}

int get(){
  int r = 0;
  int t;
  while((t = getchar_unlocked())>='0')
    r=r*10+t-'0';
  return r;
}

int main(){
  h=get();
  i=v+get();
  ans=100000000;
  for(m_t* j=v;j!=i;++j){
    j->a=get();
    j->b=get();
  }
  std::sort(v,i);
  solve();
  printf("%lld",ans);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int x = sc.nextInt();
        int ans = 0;
        for (int i = 0; ; i++) {
            ans += i;
            if (ans >= x) {
                System.out.println(i);
                break;
            }
        }
    }
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

VI dp(100100,-1);
string S;

int rec(int node){
    if(dp[node] != -1) return dp[node];

    if(S[node] == 'R'){
        if(S[node+1] == 'L') return dp[node] = 1;
        else return dp[node] = rec(node+1) + 1;
    }
    else{
        if(S[node-1] == 'R') return dp[node] = 1;
        else return dp[node] = rec(node-1) + 1;
    }
}
int main(void){
    cin >> S;
    REP(i,S.size()) rec(i);
    
    VI ans(S.size(),0);
    REP(i,S.size()){
        if(S[i] == 'R'){
            if(dp[i]%2) ans[i+dp[i]-1]++;
            else ans[i+dp[i]]++;
        }
        else{
            if(dp[i]%2) ans[i-dp[i]+1]++;
            else ans[i-dp[i]]++;
        }
    }
    REP(i,S.size()) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

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

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  
  int N;
  std::cin>>N;
  
  uint64_t sum=0;
  std::map<int,int> A;
  for(int i=0;i!=N;i++)
  {
    int a;
    std::cin>>a;
    sum+=a;
    A[a]++;
  }
  
  int Q;
  std::cin>>Q;
  
  int B,C;
  for(int i=0;i!=Q;i++)
  {
    std::cin>>B>>C;
    
    sum=sum+(C-B)*A[B];
    
    A[C]=A[C]+A[B];
    A[B]=0;
    
    std::cout<<sum<<"\n";
  }
  
  std::cout<<std::endl;
  
  return 0;
}

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

int main()
{
    int r , D , x , xi ;

    cin >> r >> D >> x ;

    for (int i = 0 ; i < 10 ; i++)
    {
        xi = r*x - D ;
        cout << xi << endl ;
        x = xi ;

    }




}


Measured memory_bytes: 256
n,m=map(int,input().split())

l=[]
for i in range(n):
  p=list(map(int,input().split()))
  for j in range(1,p[0]+1):
    l.append(p[j])

cnt=0

for k in l:
  if l.count(k)==n:
    cnt+=1

print(cnt//n)

Measured memory_bytes: 9152
while True:
    try:
        a=list(map(int,input().split()))
        if a[0]==0 and a[1]==0:
            pass
        else:
            if a[0]>=a[1]:
                a[0],a[1]=a[1],a[0]
            print(a[0],a[1])
    except:
        break;


Measured memory_bytes: 5616
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        mut b: [i64; n],
    }
    let mut cnt = 0;
    let mut que = BinaryHeap::new();

    for i in 0..n {
        que.push((b[i], i));
    }

    while let Some((b_, i)) = que.pop() {
        if b_ == a[i] {
            continue;
        }
        let neig = b[(n + i - 1) % n] + b[(i + 1) % n];

        if b_ < neig {
            return println!("-1");
        }
        let acc = (b_ - a[i]) / neig;
        if acc == 0 {
            return println!("-1");
        }

        cnt += acc;
        b[i] -= acc * neig;

        if b[i] < a[i] {
            return println!("-1");
        }
        if b[i] > a[i] {
            que.push((b[i], i));
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 13428
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;
    cout << 48-a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, A[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	long long count[200001] = {}, total = 0;
	for (i = 1; i <= N; i++) count[A[i]]++;
	for (i = 1; i <= N; i++) total += count[i] * (count[i] - 1) / 2;
	for (i = 1; i <= N; i++) printf("%lld\n", total - (count[A[i]] - 1));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4864
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {



	b.main(null);

	}

}

class b {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		String[] ar = scanner.nextLine().split(" ");

		int count = 0;

		

		for (int i = 0; i < ar.length; i += 2) {
			if (Integer.parseInt(ar[i]) % 2 != 0) {
				count++;
			}
		}
		
		System.out.println(count);

	}

}

class a {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int l = scanner.nextInt();
		int r = scanner.nextInt();
		int d = scanner.nextInt();

		int count = (r - l) / d;
		if (r % d == 0) {
			count++;
		}

		if (r == l) {
			count = 1;
		}

		System.out.println(count);

	}

}

Measured memory_bytes: 35572
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <math.h>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    lli n;
    cin >> n;
    bool is_square_num = false;
    lli ub = sqrt(n);
    lli delta = (n % 2 == 1) ? 2 : 1;
    vector<lli> divisor;
    for(lli i = 1; i <= ub; i += delta){
        if(n % i == 0){
            divisor.push_back(i);

            if(i != n / i){
                divisor.push_back(n / i);
            }else{
                is_square_num = true;
            }
        }
    }

    size_t max_index = divisor.size();
    lli min_steps = INT64_MAX;
    if(is_square_num){
        lli tmp = (divisor[max_index - 1] - 1) * 2;
        min_steps = min(min_steps, tmp);
        max_index--;
    }

    for(size_t i = 0; i < max_index; i += 2){
        lli tmp = divisor[i] + divisor[i + 1] - 2;
        min_steps = min(min_steps, tmp);
    }

    cout << min_steps << endl;
    return 0;
}

Measured memory_bytes: 384
<?php
  list($n,$c) = explode(" ", trim(fgets(STDIN)));

  $d = [];
  for ($i=0; $i<$c; $i++) {
    $d[] = explode(" ", trim(fgets(STDIN)));
  }

  // 余りごとの色の数
  $now_count = [0, 1, 2];
  for($i=0;$i<3;$i++){
    $now_count[$i] = array_fill(1, $c, 0);
  }
  for ($i=0; $i<$n; $i++) {
    $e = explode(" ", trim(fgets(STDIN)));
    for ($j=0; $j<$n; $j++){
      $now_count[(($i+1)+($j+1))%3][$e[$j]]++;
    }
  }

  $ans = PHP_INT_MAX;
  for ($i=0; $i<$c; $i++) {
    $isum = 0;
    foreach($now_count[0] as $key => $value){
      $isum += $d[$key-1][$i] * $value;
    }
    for ($j=0; $j<$c; $j++) {
      if($i==$j){
        continue;
      }
      $jsum = $isum;
      foreach($now_count[1] as $key => $value){
        $jsum += $d[$key-1][$j] * $value;
      }

      for ($k=0; $k<$c; $k++) {
        if($i==$k || $j==$k){
          continue;
        }
        $ksum = $jsum;
        foreach($now_count[2] as $key => $value){
          $ksum += $d[$key-1][$k] * $value;
        }
        $ans = min($ans, $ksum);
      }
    }
  }

  echo $ans;

Measured memory_bytes: 16372
#include <stdio.h>
#include <iostream>
#include <string>
int main(void)
{
	char a, b;
	std::cin >> a >> b;
	if (a == 'H')
	{
		if (b == 'H')
		{
			std::cout << "H";
		}
		else if(b=='D')
		{
			std::cout << "D";
		}
	}
	else if (a == 'D')
	{
		if (b == 'H')
		{
			std::cout << "D";
		}
		else if (b=='D')
		{
			std::cout << "H";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;
const double pi=acos(-1.);
int main()
{
    double a,b,x;
    scanf("%lf%lf%lf",&a,&b,&x);
    x/=a;
    if(x>a*b/2)
        printf("%.10f\n",180/pi*atan((2*b-2*x/a)/a));
    else
        printf("%.10f\n",90-180/pi*atan(2*x/b/b));
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int main()
{
	string s1,s2,s3;
	lli i,a,b=0,l,j;
	cin >> a >> b;
	l=a-1;
	i=b-l;
	while(l)
	{
		cout << i << " ";
		l--;
		i++;
	}
	cout << b << " ";
	l=a-1;
	i=b+1;
	while(l)
	{
		cout << i << " ";
		l--;
		i++;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int w, n;
	int value[1000], weight[1000];
	int dp[2][1001];
	for (int case_num = 1; true; case_num++) {
		cin >> w;
		if (w == 0) {
			return 0;
		}
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> value[i];
			cin.ignore(1);
			cin >> weight[i];
		}
		for (int i = 0; i <= 1000; i++) {
			dp[1][i] = 0;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= w; j++) {
				if (weight[i] > j) {
					dp[i % 2][j] = dp[(i + 1) % 2][j];
				} else {
					dp[i % 2][j] = max(dp[(i + 1) % 2][j], dp[(i + 1) % 2][j - weight[i]] + value[i]);
				}
			}
		}
		for (int j = w; j >= 0; j--) {
			if (dp[(n + 1) % 2][j] != dp[(n + 1) % 2][w]) {
				cout << "Case " << case_num << ':' << endl;
				cout << dp[(n + 1) % 2][w] << endl;
				cout << j + 1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1180
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int i, j, k;
    ll money_new;
    ll money = N * 100000;

    vector< vector<int> > A (N+1,vector<int> (M+1, 0));
    vector<int> C;
    int ci, aij;
    for(i=1;i<=N;i++){
        cin >> ci;
        C.push_back(ci);
        for(j=1;j<=M;j++){
            cin >> aij;
            A[i][j] = aij;
        }
    }

    int flag;
    int flag_2 = 0;
    for(k=0;k < (1 << 12);k++){
        vector<int> exp(M+1, 0);
        bitset <12> s(k);
        money_new = 0;
        flag = 1;
        for(i=1;i<=N;i++){
         for(j=1;j<=M;j++){
            exp[j] += s[i-1] * A[i][j];
            if(i == N and exp[j] < X){flag = 0;}
         }
        money_new += s[i-1] * C[i-1];
        }
        if(flag == 1 and money >= money_new){money = money_new; flag_2 = 1;}
    }

    if(flag_2 == 0){cout << "-1" << endl;return 0;}
    else{cout << money << endl;return 0;}



    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n, x;
  cin >> n >> x;
  int res = 1;
  int d = 0;
  REP(i, n) {
    int D;
    cin >> D;
    d += D;
    if (d <= x) res++;
  }
  cout << res << endl;

}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int r;
  cin >> r;

  cout << (r * r) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int a[3][3];
    rep(i,3) {
        rep(j,3) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    int b;
    rep(i,n) {
        cin >> b;
        rep(i,3) {
            rep(j,3) {
                if (a[i][j] == b) a[i][j] = INF;
            }
        }
    }
    bool bingo = false;
    if (a[0][1] == a[0][0] && a[0][1] == a[0][2]) bingo = true;
    if (a[1][1] == a[1][0] && a[1][1] == a[1][2]) bingo = true;
    if (a[2][1] == a[2][0] && a[2][1] == a[2][2]) bingo = true;
    if (a[1][0] == a[0][0] && a[1][0] == a[2][0]) bingo = true;
    if (a[1][1] == a[0][1] && a[1][1] == a[2][1]) bingo = true;
    if (a[1][2] == a[0][2] && a[1][2] == a[2][2]) bingo = true;
    if (a[0][0] == a[1][1] && a[1][1] == a[2][2]) bingo = true;
    if (a[0][2] == a[1][1] && a[1][1] == a[2][0]) bingo = true;
    string ans;
    ans = bingo ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

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

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int max = 0;

    for(int i = 0; i < K; i++){
        if(A > 0){
            max++;
            A--;
        }
        else if(B > 0){
            B--;
        }
        else{
            max--;
            C--;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){
    int S;
    int h, m, s;
    
    scanf("%d", &S);
    
    h = S/3600;
    m = S%3600/60;
    s = S%60;
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 100;
int a, b;





int main() {
   cin>>a>>b;
   int left = b - a + 1;
   int right = b + a - 1;
   for(int i=left;i<right;i++) {
       printf("%d ", i);
   }
   printf("%d\n", right);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[200020] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a1;
		cin >> a1;
		a[a1 - 1]++;
	}
	for (int j = 0; j < n; j++) {
		cout << a[j] << endl;
	}
	return 0;
}

Measured memory_bytes: 4348
def ceil(x,p):
    if x%p==0:
        return x//p
    else:
        return x//p+1

def main():
    INF = 10**9
    h,n = map(int,input().split())
    spell = []
    for _ in range(n):
        spell.append(tuple(map(int,input().split())))

    dp = [[INF]*(h+1) for _ in range(n+1)]

    for i,item in enumerate(spell):
        a,b = item
        for j in range(h):
            if j-a<0:
                dp[i+1][j+1] = min(dp[i][j+1],b*ceil(j+1,a))
            else:
                dp[i+1][j+1] = min(dp[i][j+1],dp[i+1][j+1-a]+b)
        
    print(dp[n][h])
main()

Measured memory_bytes: 146300
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define ln '\n'
#define MAX 1000000009
#define MOD 1000000007
#define N 500005
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pii;
typedef vector<int> vi; 
int t, n;
int arr[35] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    #ifndef ONLINE_JUDGE
   //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n;
    cout << arr[n - 1];
}


Measured memory_bytes: 256
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

template<class T>
struct Segtree
{
    //配列のサイズ(実際の要素数ではない)
    int n;
    //要素
    vector<T> v;
    Segtree(int n, T t)
    {
        int k = 1;
        while(k < n) k *= 2;
        this->n = k;
        v.resize(2*k-1, t);
    }
    //i番目の値をxに変更する。
    void update(int i, T x)
    {
        i += n-1;
        v[i] = x;
        while (i > 0)
        {
            i = (i-1)/2;
            v[i] = max(v[i*2+1], v[i*2+2]);
        }
    }
    //要求区間[a,b)に対するクエリを処理する
    //kは自分のいるインデックス
    //[l,r)は自分が管轄する区間
    T find(int a, int b, int k=0, int l=0, int r=-1)
    {
        if (r < 0) r = n;
        //交わらない
        if (r <= a || b <= l) return -1LL << 31;
        //完全に被覆
        if (a <= l && r <= b) return v[k];
        //部分被覆
        T lv = find(a, b, 2*k+1, l, (l+r)/2);
        T rv = find(a, b, 2*k+2, (l+r)/2, r);
        return max(lv, rv);
    }
};

void solve()
{
    IN(n, k);
    Segtree<ll> s(300005, 0);
    rep(i, n) {
        IN(a);
        ll m = s.find(a-k, a+k+1);
        s.update(a, m+1);
    }
    cout << s.find(0, 300002) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 11396