akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long int ll;

using namespace std;

struct Job
{
    ll a, b;
    
    bool operator<(const Job& j)
    {
        return b < j.b;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    ll sum = 0LL;
    vector<Job> jobs(n);
    
    for (int i = 0; i < n; ++i)
        cin >> jobs[i].a >> jobs[i].b;

    sort(jobs.begin(), jobs.end());

    ll currTime = 0;
    ll timeAvailable = 0;
    for (int i = 0; i < n; ++i)
    {
        if (jobs[i].b > currTime)
        {
            timeAvailable += jobs[i].b - currTime;
            currTime = jobs[i].b;
        }
        timeAvailable -= jobs[i].a;
        
        if (timeAvailable < 0)
        {
            cout << "No\n";
            return 0;
        }
    }
    
    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3328
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(M)]
Q.sort(key = lambda x: (x[1], x[0]))
b = 0
res = 0
for i in range(M):
  if Q[i][0] >= b:
    b = Q[i][1]
    res += 1
print(res)

Measured memory_bytes: 65752
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let stdin = stdin();
    let n = read::<String>(&mut stdin.lock());
    let l = read::<String>(&mut stdin.lock());
    let n = n.unwrap();
    let l = l.unwrap();
    let n: i32 = n.parse().unwrap();
    let l: i32 = l.parse().unwrap();

    let mut diff: i32 = 0;
    let mut taste_sum: i32 = 0;

    for i in 0..n {
        let taste = l + i;
        taste_sum += taste;

        // first loop
        if i == 0 {
            diff = taste;
        } else if diff.abs() > taste.abs() {
            diff = taste;
        }
    }

    taste_sum -= diff as i32;
    println!("{}", taste_sum);
}


Measured memory_bytes: 4352
from collections import deque

N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int, input().split())
    edge[u-1].append((v-1, w))
    edge[v-1].append((u-1, w))

dist = [-1] * N
dist[0] = 0
que = deque([0])
while que:
    u = que.popleft()
    d = dist[u]

    for v,w in edge[u]:
        if dist[v] > 0:
            continue
        dist[v] = d + w
        que.append(v)

for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 43028
#include<cstdio>
#include<cstring>

#define MIN(X,Y) ((X)>(Y)?(Y):(X))

int r[1000], c[1000];
int dp[200][200];

int main(void) {
    int n;
    scanf("%d",&n);

    for(int i=0; i<n; i++)
        scanf("%d%d",&r[i],&c[i]);

    memset(dp, 0x7F, sizeof(dp));

    for(int i=0; i<n; i++)
        dp[i][i] = 0;
    for(int i=0; i<n-1; i++)
        dp[i][i+1] = r[i]*c[i+1]*r[i+1];

    for(int d=2; d<n; d++)
        for(int i=0; i+d<n; i++)
            for(int j=i; j<i+d; j++)
                dp[i][i+d] = MIN(dp[i][i+d], dp[i][j]+r[i]*c[i+d]*r[j+1]+dp[j+1][i+d]);

    printf("%d\n",dp[0][n-1]);
    return 0;
}

Measured memory_bytes: 2908
#include<stdio.h>
int main(){
    char a,b,c,d,e,f;
    scanf("%c%c%c\n",&a,&b,&c);
    scanf("%c%c%c",&d,&e,&f);
    if (a==f && b==e && c==d){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> PII;
typedef pair<ll,ll> Pll;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef pair<ll,ll>P;
#define N  1000000+10
#define M  4000000+10
#define INF 1e9
#define fi first
#define se second
#define MP make_pair
#define pb push_back
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define per(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define lowbit(x) x&(-x)
#define Rand (rand()*(1<<16)+rand())
#define id(x) ((x)<=B?(x):m-n/(x)+1)
#define ls p<<1
#define rs p<<1|1
#define fors(i) for(auto i:e[x]) if(i!=p)

const int MOD=1e9+7,inv2=(MOD+1)/2;

int dx[4]= {-1,1,0,0};
int dy[4]= {0,0,-1,1};



int read()
{
  int v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

ll readll()
{
  ll v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

int main()
{
   int n=read();
int a[200005];
rep(i,1,n)
{
    cin>>a[i];
}
int s=1;
rep(i,1,n)
{
    if(a[i]==s){  s++;             }
}
if(s==1)printf("-1\n");
else
printf("%d\n",n-s+1);
  return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  vector<string> s(3);
  REP(i, 3)
    cin >> s[i];
  REP(i, 3)
    cout << char(s[i][0] + 'A' - 'a');
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int ans0 = 0;
		int ans1 = 0;
		String s = sc.next();
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == '0') {
				if((i&1) == 0) ++ans1;
				else ++ans0;
			}else {
				if((i&1) == 0) ++ans0;
				else ++ans1;
			}
		}
		
		System.out.println(Math.min(ans0, ans1));
	}
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<string> title(n);
  vector<int> time(n);
  for(int i = 0; i < n; ++i){
    cin >> title[i] >> time[i];
  }
  string x; cin >> x;
  int ans = 0;
  bool f = false;
  for(int i = 0; i < n; ++i){
    if(f) ans += time[i];
    if(title[i] == x) f = true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = list(map(int,"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".split(',')))
K=int(input())
print(s[K-1])

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  bool ans = false;

  for (int i=n-1; i>=0; i--) {
    bool f = true;  
    for (int j=0; j<min(n,m); j++) {
      if (s[i-j] != t[m-j-1] && s[i-j] != '?') {
        f = false;
        break;
      }
    }

    if (f) {
      for (int j=0; j<min(n,m); j++) {
        s[i-j] = t[m-j-1];
      }
      ans = true;
      break;
    }
  }
  ans = ans && n>=m;
  if (ans) {
    for (auto c : s)
      cout << (c=='?'? 'a' : c);
    cout << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> vec(3);
  cin>>vec.at(0)>>vec.at(1)>>vec.at(2);
  sort(vec.begin(),vec.end());
  cout<<vec.at(0)+vec.at(1)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
  int h,a[]={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};
  cin >> h;
  cout << a[h-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e6 + 1;
bool taken[N];

bool cmp(pair<int, int> a, pair<int, int> b) {
	if(a.second == b.second)
		return a.first > b.first;
	return a.second < b.second;
}

bool cmp2(pair<int, int> a, pair<int, int> b) {
//	if(a.first - a.second == b.first - a.second)
//		return a.second < b.second;
//	return a.first - a.second > b.first - a.second;
	if(a.second == b.second)
		return a.first > b.first;
	return a.second > b.second;
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	int n;
	cin >> n;
	string str;
	int open = 0, closed = 0;
	vector<pair<int, int>> vec;
	for (int i = 0; i < n; ++i) {
		cin >> str;
		int cnt = 0, minus = 0;
		for (int i = 0; i < (int)str.size(); ++i) {
			if(str[i] == '(')
				++cnt;
			else
				--cnt;
			if(cnt < 0)
				++minus, cnt = 0;
		}
		if(minus) {
			if(cnt)
				vec.push_back({cnt, minus});
			else
				closed += abs(minus);
		} else {
			open += cnt;
		}
	}
	int total = open;
	sort(vec.begin(), vec.end(), cmp);
	for (int i = 0; i < (int)vec.size(); ++i) {
		if(vec[i].second > vec[i].first) continue;
		if(total >= vec[i].second) {
			total -= vec[i].second;
			total += vec[i].first;
			taken[i] = 1;
		}
	}
	vector<pair<int, int>> vv;
	for (int i = 0; i < (int)vec.size(); ++i) {
		if(taken[i]) continue;
		vv.push_back(vec[i]);
	}
	sort(vv.begin(), vv.end(), cmp2);
	for (int i = 0; i < (int)vv.size(); ++i) {
		total -= vv[i].second;
		if(total < 0) {
			cout << "No";
			return 0;
		}
		total += vv[i].first;
	}
	total -= closed;
	if(total == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 7700
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int a;
    cin >> a;
    if (a >= 400 && a <=599) cout << 8 << endl;
    else if (a >= 600 && a <=799) cout << 7 << endl;
    else if (a >= 800 && a <=999) cout << 6 << endl;
    else if (a >= 1000 && a <=1199) cout << 5 << endl;
    else if (a >= 1200 && a <=1399) cout << 4 << endl;
    else if (a >= 1400 && a <=1599) cout << 3 << endl;
    else if (a >= 1600 && a <=1799) cout << 2 << endl;
    else if (a >= 1800 && a <=1999) cout << 1 << endl;
}

Measured memory_bytes: 3232
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    int i = 1;
    Scanner scan = new Scanner(System.in);
    while(true){
    int x = scan.nextInt();
    if( x == 0 )break;
    System.out.println("Case "+i+": "+x+"");
    i++;
       
   }
  }
}

Measured memory_bytes: 40880
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		String[] data = input.split(" ");
		int a = Integer.parseInt(data[0]);
		int b = Integer.parseInt(data[1]);
		int c = Integer.parseInt(data[2]);
		List<Integer> divisors = new ArrayList<Integer>();
		// int n = 0; // divisorsの要素番号
		int count = 0; // a～bまでの範囲の中にcがいくつあるのかをカウントするための変数

		if ((1 <= a && a <= 10000) && (1 <= b && b <= 10000)
				&& (1 <= c && c <= 10000) && (a <= b)) {
			divisors = ArrayDivisors(c);

			for (Integer n : divisors) {
				if (a <= n && n <= b) {
					count++;
				}
			}
			System.out.println(count);
		}

	}

	private static List<Integer> ArrayDivisors(int number) {
		int MinDivisor = 1;
		int MaxDivisor = number;
		List<Integer> divisors = new ArrayList<Integer>();
		for (int i = MinDivisor; i <= MaxDivisor; i++) {
			if (number % i == 0) {
				MinDivisor = i;
				MaxDivisor = number / i;
				if (MinDivisor <= MaxDivisor) {
					divisors.add(MinDivisor);
					if (MinDivisor != MaxDivisor) {
						divisors.add(MaxDivisor);
					} else {
						break;
					}
				}

			}

		}

		Collections.sort(divisors);
		return divisors;

	}

}



Measured memory_bytes: 26364
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
int MOD = 1e9 + 7;
const ld E = 1e-9;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef LONG_LONG_MAX
#define LONG_LONG_MAX LLONG_MAX
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define prev time_prev
#ifndef M_PI
#define M_PI acos(-1)
#endif
#define remove tipa_remove
#define next tipa_next
#define left tipa_left
#define right tipa_right
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline bool read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n') {
			if (ccc == '\n')
				return true;
			break;
		}
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
	return false;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (x < 0) {
		putchar('-');
		x *= -1;
	}
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
}
#ifdef LOCAL
#define DEBUG
#endif
#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

const int MAX = 310;
int ar[MAX][MAX];
bool used[MAX];
int u[MAX];

int main() {
	sync;
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

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

	vector<int> v(n);
	int w = 0;
	for(int &a : v){
		cin >> a;
		w = max(w, a);
	}
	int a = v[0];
	for(int b : v){
		a = __gcd(a, b);
	}

	if(m % a || m > w){
		cout << "IMPOSSIBLE" << endl;
	}else{
		cout << "POSSIBLE" << endl;
	}

}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{
  int a,b,c;

  cin>>a;
  cin>>b;
  cin>>c;

  if(a<b && b<c)
    {
      cout<<"Yes";
    }
  else
    {
      cout<<"No";
    }

  cout<<'\n';

  return 0;
}



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

int main() {

  int n;

  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  
  for(int i = 0; i < n; i++){
      for(int j = i; j < n; j++){

          if( a.at(i) < a.at(j) ){
              int tmp = a.at(i);
              a.at(i) = a.at(j);
              a.at(j) = tmp;
          }

      }
  }

  int alice = 0;
  int bob = 0;

  for(int i = 0; i < n; i++){
  
        if(i%2 == 0)
          alice += a.at(i);  
        else
          bob += a.at(i);

  }

  cout << alice-bob << endl;

}



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


int N,M;
int path[9][9];
int visit[9];


bool isAllVisit(){
  int flag=0;
  for(int i=1;i<=N;i++){
    flag += visit[i];
  }
  return (flag == N);
}

int searchGraph(int v){
  //while(!next.empty()){
  int result = 0;
  visit[v] = 1;
  if(isAllVisit()){
    visit[v] = 0;
    return 1;
  }
  else{
    for(int i=1; i<=N; i++){
      if(path[v][i] == 1 && visit[i]!=1){
 //       cout << "begin: " << v << " next: " << i <<endl;
        result += searchGraph(i); 
      }
    }
    visit[v] = 0;
    return result;
  }
}

int main(){
  cin >> N >> M ;
  int a,b;
  for(int i=0;i<M;i++){
    cin >> a >> b;
    path[a][b] = 1;
    path[b][a] = 1;
  }
  cout << searchGraph(1) << endl;

  return 0;
}


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

const vector<vector<int>> D = {
    {4, 0, 2, 3, 5, 1}, // N
    {2, 1, 5, 0, 4, 3}, // E
    {1, 5, 2, 3, 0, 4}, // S
    {3, 1, 0, 5, 4, 2}  // W
};

struct Dice {
  vector<int> face;

  Dice(vector<int> v) : face(v) {
  }

  void roll(char direction) {
    int dir;
    if (direction == 'N')
      dir = 0;
    if (direction == 'E')
      dir = 1;
    if (direction == 'S')
      dir = 2;
    if (direction == 'W')
      dir = 3;

    vector<int> tmp(6);
    rep(i, tmp.size()) tmp[D[dir][i]] = face[i];
    face = tmp;
  }

  int top() {
    return face.front();
  }
  int bottom() {
    return face.back();
  }
};

int main() {
  vector<int> v(6);
  rep(i, 6) cin >> v[i];
  Dice d(v);

  int q;
  cin >> q;
  rep(i, q) {
    int t, f;
    cin >> t >> f;

    if (d.top() != f && d.bottom() != f)
      d.roll('N');
    while (d.top() != f)
      d.roll('E');
    d.roll('S');
    while (d.top() != t)
      d.roll('E');
    d.roll('W');
    cout << d.top() << endl;
  }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
void add(int &a, int b)
{
	a+=b;
	while(a>mod)
		a-=mod;
	while(a<0)
		a+=mod;
}

signed main()
{
	int n,k;
	cin>>n>>k;
	vector<int> dp(k+1, 0);

	dp[0]=1;
	for(int child=1; child<=n; ++child)
	{
		int up;
		cin>>up;
		vector<int> poschange(k+1), negchange(k+1);
		for(int used=k; used>=0; --used)
			{
				int l=used+1, r=used+min(up, k-used);
				if(l<=k)
					add(poschange[l], dp[used]);
				if(r+1<=k)
					add(negchange[r+1], dp[used]);

			}
		int ps=0;
		for(int i=0; i<=k; ++i)
		{
			add(ps, poschange[i]);
			add(ps, -negchange[i]);
			add(dp[i], ps);
		}
	}
	// for(int i=0; i<=k; ++i)
	// 	cout<<i<<"->"<<dp[i]<<endl;
	cout<<dp[k];
	return 0;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    string s;
    cin>>s;
    int l=s.length();
    int o0=0;
    int no0=0;
    int o1=0;
    int no1=0;
    rep(i,l){
        if(i%2==0){
            if(s[i]!='0'){
                o0++;
            }else{
                no0++;
            }
        }else{
            if(s[i]!='1'){
                o0++;
            }else{
                no0++;
            }
        }
    }
    cout<<min(o0,no0)<<endl;
    return 0;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 3e3 + 5;
    
  
void solve() {

   int n, ans = 0;
   cin>>n;
   map<pii,int> mp;
   rep(_,0,n){
     double d;
     cin>>d;
     int x = round(d*(1e9));
     int y=0,z=0;
     while(x%2==0)
       x/=2,y++;
     while(x%5==0)
       x/=5,z++;
     mp[{y,z}]++;
   }
   trav(u,mp)
     trav(v,mp){
        if(u.fi.fi+v.fi.fi<18||u.fi.se+v.fi.se<18)
          continue;
        if(u.fi<v.fi)
          ans+=u.se*v.se;
        if(u.fi==v.fi)
          ans+=u.se*(u.se-1)/2;
     }
   cout<<ans;

          
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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


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


int main(void) {
    string s;
    cin >> s;
    s += 'E';
    int max = 0, cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            ++cnt;
        } else {
            if (cnt) {
                if (cnt > max) {
                    max = cnt;
                }
            } 
            cnt = 0;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char s[5];

    scanf("%s", s);

    if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
        printf("No\n");
    }
    else if (s[0] == s[1] && s[2] == s[3]) {
        printf("Yes\n");
    }
    else if (s[0] == s[2] && s[1] == s[3]) {
        printf("Yes\n");
    }
    else if (s[0] == s[3] && s[1] == s[2]) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int maxn = 2e5+5;
VI tree;
struct ST { int s,t,x; } st[maxn];

bool cmp(const ST& a, const ST& b)
{
    return a.x < b.x;
}

void build(const int n)
{
    for (int i = n-1; i > 0; --i)
        tree[i] = min(tree[lc(i)], tree[rc(i)]);
}

void update(int i, int j, const int value, const int n)
{
    for (i += n, j += n; i < j; i >>= 1, j >>= 1) {
        if (i&1) { tree[i] = min(tree[i], value); i++; }
        if (j&1) { --j; tree[j] = min(tree[j], value); }
    }
}

void pushdown(const int n)
{
    for (int i = 1; i < n; i++) {
        tree[lc(i)] = min(tree[lc(i)], tree[i]);
        tree[rc(i)] = min(tree[rc(i)], tree[i]);
        tree[i] = inf;
    }
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,q;
    while (cin >> n >> q) {
        VI A, X(n), D(q);
        FOR(i,0,n)
            cin >> st[i].s >> st[i].t >> st[i].x;
        sort(st,st+n,cmp);
        FOR(i,0,n) {
            /* y = x + b */
            st[i].s = max(0,st[i].s-st[i].x);
            st[i].t = max(0,st[i].t-st[i].x);
            A.push_back(st[i].s); A.push_back(st[i].t); X[i] = st[i].x;
        }
        FOR(i,0,q) {
            cin >> D[i]; A.push_back(D[i]);
        }
        sort(ALL(A));
        A.resize(unique(ALL(A)) - A.begin());
        const int size = A.size();
        tree = VI(2*size,inf);
        FOR(i,0,n) {
            const int a = lower_bound(ALL(A),st[i].s) - A.begin();
            const int b = lower_bound(ALL(A),st[i].t) - A.begin();
            update(a,b,i,size);
        }
        pushdown(size);
        FOR(i,0,q) {
            const int d = lower_bound(ALL(A),D[i]) - A.begin();
            const int v = tree[d+size];
            cout << (v == inf ? -1 : X[v]) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 13036
N, M = list(map(int, input().split()))
sc = [list(map(int, input().split())) for _ in range(M)]

L = [-1] * N

for s, c in sc:
  s -= 1
  if L[s] == -1:
    L[s] = c
  else:
    if L[s] != c:
      print(-1)
      exit()

if N == 1:
  if L[0] == -1:
    print(0)
  else:
    print(L[0])
else:
  if L[0] == 0:
    print(-1)
    exit()
  if L[0] == -1:
    ans = 1
  else:
    ans = L[0]
  for i in range(1, N):
    ans *= 10
    if L[i] != -1:
      ans += L[i]
  print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int A,B,C;cin>>A>>B>>C;
    if(A+B>=C)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc166/tasks/abc166_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll X;
  cin >> X;

  ll LIMIT = 1000;
  ll mi = -LIMIT;
  ll ma = LIMIT;

  for (ll b = mi; b <= ma; ++b) {
    ll s = X + pow(b, 5);

    for (ll a = mi; a <= ma; ++a) {
      if (pow(a, 5) == s) {
        cout << a << " " << b << "\n";
        throw exit_exception();
      } else if (pow(a, 5) > s) {
        break;
      }
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

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

//-----------------------------------------

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll a, b, c;
  cin >> a >> b >> c;
  cout << min({a,b,c}) << " " << max({a,b,c}) <<endl;
    
  return 0;
}




Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int s[2] = {};
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s[a % 2]++;
    }

    int64_t r = 1;
    for (int i = 0; i < s[0]; i++) {
        r *= 2;
    }
    for (int i = 1; i < s[1]; i++) {
        r *= 2;
    }
    if (s[1] == 0) r *= 1 - p;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
ll a[200005];
int main(){
    ll n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        if(a[i]<a[i-1]){
            ans+=a[i-1]-a[i];a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 5144
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define inf 1LL<<61
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define rep(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	set<int> s;
	int n;
	scanf("%d", &n);
	int arr[n];
	int j =0;
	rep(i,0,n){
		scanf(" %d", arr + i);
	}
	s.insert(0);
	rep(i,0,n){
		set<int> temp = s;
		for(auto el : temp){
			s.insert(el);
			s.insert(arr[i] + el);
		}

	}
	int max = 0;
	for(auto it = s.end(); it != s.begin();){
		it--;
		if(*it > max && *it % 10 != 0){
			max = *it;
		}
	}
	cout << max;
	return 0;
}



Measured memory_bytes: 896
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>
#include <random>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFR INT_MAX
#define INFL (long long)(4e18)
#define INFLR LLONG_MAX
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}
string YN(bool y) { return (y ? "YES" : "NO"); }
string yn(bool y) { return (y ? "Yes" : "No"); }
string ON(bool y) { return (y ? "OK" : "NG"); }

int dir4[4][2] = { { 0,-1 },{ -1,0 },{ 1,0 },{ 0,1 } };
int dir8[8][2] = { { -1,-1 },{ 0,-1 },{ 1,-1 },{ -1,0 },{ 1,0 },{ -1,1 },{ 0,1 },{ 1,1 } };

// [a,b]の乱数
int irand(int a, int b) {
	static mt19937 Rand(static_cast<unsigned int>(time(nullptr)));
	uniform_int_distribution<int> dist(a, b);
	return dist(Rand);
}

// [a,b)の乱数
double drand(int a, int b) {
	static mt19937 Rand(static_cast<unsigned int>(time(nullptr)));
	uniform_real_distribution<double> dist(a, b);
	return dist(Rand);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
//=======ここまでテンプレート===============================================



int main(void) {
	int N, K;
	cin >> N >> K;
	vi num(N + 1, 0);
	rep(i, N) {
		int a;
		cin >> a;
		num[a]++;
	}
	sort(rall(num));
	int n = 0;
	int ans = 0;
	rep(i, N + 1) {
		if (num[i] == 0) {
			break;
		}
		else {
			if (n == K) {
				ans += num[i];
			}
			else {
				n++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main()
{
    char s;
    string letters = "abcdefghijklmnopqrstuvwxyz";
    string res = "";
    cin >> s;
    for(int i = 0; i < letters.length(); i++) {
        if(s == letters[i])
            res+=letters[i+1];
    }
    cout << res << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

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

typedef long long ll;

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

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}


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

    vector<int>p(n);
    rep(i,n)cin>>p[i];

    int ans=0;

    rep2(i,1,n-2)if(p[i-1]<p[i]&&p[i]<p[i+1]||
            p[i-1]>p[i]&&p[i]>p[i+1])ans++;

    cout<<ans<<endl;
}






Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
c=0
for i in range(len(a)):
  if a[i]%2==0 and a[i]%3 != 0 and a[i]%5 != 0:
    c=c+1
  if c != 0:
    break
if c==0:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 38256
#include"bits/stdc++.h"
using namespace std;
long long t[600000];
int h[200001];
int n;
long long query(int index,int lb,int rb,int lq,int rq)
{
	if(lb==rb)
		return t[index];
	if(rb==rq&&lb==lq)
		return t[index];
	int mid=(lb+rb)/2;
	if(rq<=mid)
		return query(index*2,lb,mid,lq,rq);
	else if(lq>mid)
		return query(index*2+1,mid+1,rb,lq,rq);
	else
		return max(query(index*2,lb,mid,lq,mid),query(index*2+1,mid+1,rb,mid+1,rq));
}
long long update(int index,int lb,int rb,int leaf_id,long long value)
{
	if(lb==rb&&lb==leaf_id)
		return t[index]=value;
	int mid=(lb+rb)/2;
	if(leaf_id<=mid)
		return t[index]=max(t[index],update(index*2,lb,mid,leaf_id,value));
	else
		return t[index]=max(t[index],update(index*2+1,mid+1,rb,leaf_id,value));
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(int i=1;i<=n;i++)
	{
		long long a;
		scanf("%lld",&a);
		update(1,1,n,h[i],(long long)query(1,1,n,1,h[i]-1)+a);
	}
	printf("%lld",t[1]);
}

Measured memory_bytes: 5120
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> orderTimeList = new ArrayList<>();

        for (int i = 0; i < 5; i ++){
            orderTimeList.add(sc.nextInt());
        }

        int orderTimeSum = 0;
        int lastOrderSaveTime = 0;

        for (int time : orderTimeList){
            if (time % 10 == 0){
                orderTimeSum += time;
            }else{
                orderTimeSum += (time / 10 + 1) * 10;
                if (time % 10 < 10 - lastOrderSaveTime){
                    lastOrderSaveTime = 10 - time % 10;
                }
            }
        }

        System.out.println(orderTimeSum - lastOrderSaveTime);
    }

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define INF 0X3f3f3f3f
#define M 1000000007
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define mp make_pair
#define pb push_back 
#define fi first
#define se second
#define endl "\n"
#define PI acos(-1)
#define fastcin ios_base::sync_with_stdio(false);
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> ii;
typedef complex<double> base;

const int N = 100002;
int n;
ll H;
ll a[N], b[N];

int main(void){
	scanf("%d%lld", &n, &H);

	for(int i = 0; i < n; i++){
		scanf("%lld%lld", &a[i], &b[i]);
	}

	sort(a, a+n);
	sort(b, b+n);

	ll sum = 0;
	ll ans = 0;
	for(int i = n-1; i >= 0 and b[i] > a[n-1] and sum < H; i--){
		sum += b[i];
		ans++;
	}

	if(sum < H){
		ll falta = H - sum;
		ans += falta/a[n-1];
		falta -= (falta/a[n-1]) * a[n-1];
		if(falta > 0)
			ans++;
	}

	printf("%lld\n", ans);

	return 0;
}

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

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

    //good luck kittu!
    int n, count = 0; string s;
    cin>>n>>s;
    for(int i = 0; i<n-2; i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') count++;
    }
    cout<<count<<"\n";
    return 0;
}

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

int main()
{
	int ln;
	int weit[] = {1,2,4,8,16,32,64,128,256,512};
	bool fl;
	int n;

	
	while (cin >> n)
	{
		ln = 0;
		fl = 0;
		bool two[20] = { 0 };
		while (n)
		{
			two[ln] = n % 2;
			n /= 2;

			ln++;
		}

		int i;
		for (i = 0; i < ln; i++)
		{
			if (two[i]==1)
			{
				if (fl)
				{
					cout << " ";
				}
				fl = true;
				cout << weit[ i ];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3020
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, l) = input_int_tuple();
    let mut min: i32 = 1000;
    let mut min_index: i32 = 0;
    for i in 0..n {
        let taste = l + i;
        if taste.abs() < min {
            min = taste.abs();
            min_index = i;
        }
    }
    let mut sum = 0;
    for i in 0..n {
        if i != min_index {
            sum += l + i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
N = gets.to_i
As = gets.split.map(&:to_i)

total_length = As.inject(:+)

# lefts = []
left_sum = 0
# rights = []
right_sum = 0
current_sum = 0

candidate = 0

As.each_with_index do |i, idx|
  if current_sum + i > total_length / 2
    candidate = i if candidate == 0
  end
  if current_sum < total_length / 2 && idx != As.size - 1
    # lefts << i if i > 1
    left_sum += i
  else
    # rights << i if i > 1
    right_sum += i
  end
  current_sum += i
end

# p [lefts, rights]
# p [left_sum, right_sum]
# puts candidate


puts [(left_sum - right_sum).abs, ((left_sum - candidate) - (right_sum + candidate)).abs].min

Measured memory_bytes: 16132
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c=a+b,d=2*a-1,e=2*b-1;
	int x=max(c,d);
	int y=max(x,e);
	cout<<y;
 } 

Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll cnt[10000008];
signed main()
{
    fast;
   
    ll n,i,j,ans=0;
    cin>>n;
    for(i=1;i<=10000001;i++)
    {
    	for(j=i;j<=10000001;j += i)
    	{
    		cnt[j]++;
    	}
    }
    for(i=1;i<=n;i++) ans += i * cnt[i];
    cout<<ans;

}

Measured memory_bytes: 81780
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

s = S()
n = len(s)
ans = 0
for i in range(n - 1):
    if s[i] != s[i + 1]:
        ans += 1
print(ans)


Measured memory_bytes: 9272
a = input()
b = input()

la = len(a)
lb = len(b)

if la > lb:
    print('GREATER')
elif la < lb:
    print('LESS')
else:
    for i in range(la):
        num_a = int(a[i])
        num_b = int(b[i])
        
        if num_a > num_b:
            print('GREATER')
            exit()
        elif num_a < num_b:
            print('LESS')
            exit()
    print('EQUAL')

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

int main() {

  int A,B,a,b,c,d,e,cnt = 0;
  cin >> A >> B;
  for (int i = A; i < B + 1; i++){
    a = i/10000;
    b = (i%10000)/1000;
    c = (i%1000)/100;
    d = (i%100)/10;
    e = (i%10);
    if(a == e && b == d)
      cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = map(int, input().split())

t = [T - h * 0.006 for h in H]
ans = 10**9
for i in range(len(t)):
    if abs(t[i] - A) < ans:
        ans_i = i
        ans = abs(t[i] - A)
print(ans_i + 1)


Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
	int n,i,moji=0,j=0,k=0;
	char s[100001];
	scanf("%d",&n);
	scanf("%s",s);
	for(i=0;i<n;i++){
		if(s[i]=='O' && s[i+1]=='X'){
			moji++;
			i=i+1;
			j++;
		}
		else if(s[i]=='X' && s[i+1]=='O'){
			moji++;
			i=i+1;
			k++;
		}
	}
	printf("%d\n",moji);
	return 0;
}



Measured memory_bytes: 2052
//ITP1_1_D:   Watch
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {
        
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
         int sec = Integer.parseInt(in.readLine());
         
         int hh=sec/3600;
         int mm=(sec%3600)/60;
         int ss=sec%60;
         
         System.out.println(hh+":"+mm+":"+ss);
        
	}
}

Measured memory_bytes: 17020
a, b, c, d = map(int, input().split())
e = list(map(int, input().split()))
f = list(map(int, input().split()))
e = sorted(e, reverse=True)
f.sort()
for i in range(e[0] + 1, f[0] + 1):
    if c < i <= d:
        print("No War")
        exit()
print("War")


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdbool.h>
#include<set>
#define N 1000000007
using namespace std;
typedef long long ll;

int main(void) {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0]) {
		if (b[b.length() - 1] == c[0]){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;


/* BIEN CUC BO BEGIN*/
	ld n, m;
/* BIEN CUC BO END*/

void solve(){	
	cin >> n >> m;
	cout << fixed << setprecision(5) << (ld)n/m;
}	

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
int S;
string N;

void solve(){
    for(int i=0;i<N.size();i++) S += N[i] - '0';
    if(stoi(N) % S) cout <<"No"<<"\n";
    else cout <<"Yes"<<"\n";
}

int main(){
    cin >> N;
    solve();
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = 10**5+1
    p = 2
    f = [1]*(n+1)
    f[0] = 0
    f[1] = 0
    while p <= n:
        while p <= n and not f[p]:
            p += 1
        j = 2*p
        while j <= n:
            f[j] = 0
            j += p
        p += 1
    s = [1 if f[i] and f[(i+1)>>1] and i&1 else 0 for i in range(n+1)]
    for i in range(n):
        s[i+1] += s[i]
    q = I()
    for _ in range(q):
        l,r = LI()
        print(s[r]-s[l-1])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 53792