akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   Int m = log2(n) + 1.1;
   std::vector<std::vector<Int>> xss(m, std::vector<Int>(n,0));
   std::vector<Int> hs(n);
   xss[0][0] = 0;
   hs[0] = 0;
   rep(i, n) {
      Int a;
      std::cin >> a;
      rep(k, a) {
         Int c;
         std::cin >> c;
         xss[0][c] = i;
         hs[c] = hs[i] + 1;
      }
   }
   for(Int i = 1; i < m; ++i) {
      rep(k, n) {
         xss[i][k] = xss[i-1][xss[i-1][k]];
      }
   }
   Int q;
   std::cin >> q;
   rep(i, q) {
      Int a, b;
      std::cin >> a >> b;
      if( hs[a] > hs[b] ) std::swap(a, b);
      if( hs[a] < hs[b] ) {
         Int diff = hs[b] - hs[a];
         rep(k, m) {
            guard( ( diff & ((Int)1 << k) ) != 0 );
            b = xss[k][b];
         }
      }
      assert( hs[a] == hs[b] );
      if( a == b ) {
         printf("%ld\n", a);
         continue;
      }
      for(Int k = m - 1; k >= 0; --k) {
         if( xss[k][a] != xss[k][b] ) {
            a = xss[k][a];
            b = xss[k][b];
         }
      }
      assert( xss[0][a] == xss[0][b] );
      printf("%ld\n", xss[0][a]);
   }
}



Measured memory_bytes: 17392
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC102C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            var ailist = new List<long[]>();
            for(int i = 0; i < N; i++)
            {
                long[] ai = new long[2];
                ai[0] = i;
                ai[1] = long.Parse(input[i]) - (i+1);
                ailist.Add(ai);
            }
            var idxlist = ailist.Select((a ,b)=> new { idx = a[0], val = a[1] }).OrderBy(x => x.val).ToList();


            int medidx = (N -1)/ 2;
            long med = idxlist[medidx].val;
            
            long ans = 0;
            for(int j = 0; j < N; j++)
            {
                ans += Math.Abs(idxlist[j].val - med);
            }
            Console.WriteLine(ans);
        }
    }
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){
  // 500 = 2u, 5 = 1u

  int x;
  cin >> x;

  int fh, f;

  fh = x / 500;

  x = x - 500 * fh;

  f = x / 5;

  cout << 1000 * fh + 5 * f << endl;

  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

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

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	int n;
	ll x, ans = 0;
	cin >> n >> x;
	
	ll burger = pow(2,n+1) - 1 + pow(2, n+1) - 2;
	ll patty = pow(2, n+1)-1;
//
//	debug(burger);
//	debug(patty);
	
	REP(i,n+1){
		burger = (burger+1)/2;
		patty = patty/2;
//		debug(burger);
//		debug(patty);
		if (x >= burger){
			ans += patty+1;
			x -= (burger-1);
//			debug(x);
		}else{
			burger -= 1;
			x -= 1;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
int main() {
  string s; cin >> s;
  set<string> ss; 
  int k; cin >> k;
  for(int i=1; i<=k && i<=s.size(); i++) {
    for(int j=0; j<=s.size()-i; j++) {
      ss.insert( s.substr(j,i) );
    }
  }
  int i=1;
  for(string s : ss){
    if(i==k) {
      cout << s << endl;
      break;
    }
    i++;
  }
  return 0;
}


Measured memory_bytes: 1664
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for p in range(a + 1) :
    for q in range(b + 1) :
        for r in range(c + 1) :
            if 500 * p + 100 * q + 50 * r == x:
                count += 1
print(count)

Measured memory_bytes: 3060
n = input()
num = len(n)
one_s = 0
zero_s = 0

for i in range(num):
    if i % 2 == 0:
        if n[i] == "0":
            one_s += 1
        else:
            zero_s += 1
    else:
        if n[i] == "0":
            zero_s += 1
        else:
            one_s += 1

print(min(zero_s, one_s))

Measured memory_bytes: 9236
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <array>
#include <stack>
#include <map>

using namespace std;

template<typename ISTREAM>
void readGraphListAsMatrix(const size_t n, ISTREAM& cin, vector< vector<int> >& graphMatrix) {
	graphMatrix = vector< vector<int> >(n, vector<int>(n, 0));
	for (size_t i = 0; i != n; ++i) {
		size_t u;
		size_t k;
		cin >> u;
		cin>> k;
		for (size_t j = 0; j != k; ++j) {
			size_t v;
			cin >> v;
			graphMatrix.at(u - 1).at(v - 1) = 1;
		}
	}
}

void printMatrix(const vector< vector<int> >& grapthMatrix) {
	const size_t n = grapthMatrix.size();
	for (size_t i = 0; i != n; ++i) {
		const vector<int>& adj = grapthMatrix.at(i);
		cout << adj.front();
		for (size_t j = 1; j != n; ++j) {
			cout << " " << adj.at(j);
		}
		cout << endl;
	}
}


template<typename T>
void execute(T& cin) {
	size_t n;
	cin >> n;
	vector< vector<int> > graphMatrix;
	readGraphListAsMatrix(n, cin, graphMatrix);
	stack<int> visitedNodeIDs;
	int time = 0;
	vector<pair<int, int>> timeStamp(n,make_pair(0,0));//pair<初回訪問時刻, 完了時刻>
	vector<vector<int>::iterator> searchBeginPos; {
		searchBeginPos.reserve(n);
		for (auto& v : graphMatrix)searchBeginPos.push_back(v.begin());
	}

	vector<pair<int, int>>::iterator visitTimeSearchPos = timeStamp.begin();
	while (
		(visitTimeSearchPos = find_if(visitTimeSearchPos, timeStamp.end(), [&](const pair<int, int>& df) {return df.first == 0; }))
		!= timeStamp.end()) {
		const size_t firstVisitNodeID_1 = distance(timeStamp.begin(), visitTimeSearchPos);
		visitedNodeIDs.push(firstVisitNodeID_1);
		visitTimeSearchPos->first = ++time;
		for (auto&v : graphMatrix) v.at(firstVisitNodeID_1) = 0;
		++visitTimeSearchPos;
		while (!visitedNodeIDs.empty()) {
			const int nodeID_1 = visitedNodeIDs.top();
			vector<int>& neighbourNodeList = graphMatrix.at(nodeID_1);
			vector<int>::iterator result = find(searchBeginPos.at(nodeID_1), neighbourNodeList.end(), 1);
			if (result != neighbourNodeList.end()) {
				const int nextVisitID_1 = distance(neighbourNodeList.begin(), result);
				timeStamp.at(nextVisitID_1).first = time + 1;
				for (auto&v : graphMatrix) v.at(nextVisitID_1) = 0;
				visitedNodeIDs.push(nextVisitID_1);
				searchBeginPos.at(nodeID_1) = result + 1;
			}
			else {
				//隣接リストに検索対象なし
				timeStamp.at(nodeID_1).second = time + 1;
				visitedNodeIDs.pop();
			}
			++time;
		}
	}
	for (int i = 0; i != n; ++i) {
		cout << i + 1 << " " << timeStamp.at(i).first << " " << timeStamp.at(i).second << endl;
	}
}


int main()
{
	execute(cin);

	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
ld dp[55][55];

ld cal(ld p, int n, int k)
{
	if (n == 0) return(k == 0 ? 1.0 : 0);
	if (dp[n][k] >= 0) return dp[n][k];
	ld l = (1 - p)*cal(p, n - 1, k);
	ld r = p*cal(p, n - 1, k - 1);
	return dp[n][k] = l + r;
}


int main()
{
	int n, m;
	ld l;
	cin >> n >> m >> l;
	vector<vector<pair<ld, ld>>> v(n);
	REP(i, n)
	{
		ld p, t, s;
		cin >> p >> t >> s;
		p /= 100;
		if (s == 0)
		{
			v[i].emplace_back(INF, 1.0);
			continue;
		}
		MS(dp, -1);
		REP(j, m + 1) v[i].emplace_back(l / s + t*j, cal(p, m, j));
	}
	vector<ld> ans;
	REP(i, n)
	{
		ld sum = 0;
		REP(j, v[i].size())
		{
			ld ex = v[i][j].second;
			ld t = v[i][j].first;
			REP(k, n)
			{
				if (k == i) continue;
				ld ext = 0;
				REP(kk, v[k].size())
				{
					if (v[k][kk].first > t)
					{
						ext += v[k][kk].second;
					}
				}
				ex *= ext;
			}
			sum += ex;
		}
		ans.push_back(sum);
	}
	REP(i, n) cout << D10 << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3452
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())

ans = [0] * (10**4 + 1)
for x in range(1,101):
    for y in range(1, 101):
        for z in range(1, 101):
            val = x*x + y*y + z*z + x*y + y*z + z*x
            if val <= 10**4:
                ans[val] += 1

for i in range(1, n+1):
    print(ans[i])

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

int main(){
	string str;
	int cnt = 0;
	while(cin >> str){
		cnt++;
		for(int i = 0, j = str.size() - 1; i < str.size() - 1; i++, j--){
			if(str[i] != str[j]){
				cnt--;
				break;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

struct state{
    ll money, stock;
};

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(auto &a:A){
        cin >> a;
    }

    ll money=1000;
    vector<state> vec(1000000);
    int cnt=0;
    for(int i=0; i<N; i++){
        int tmp=0;
        vec[cnt+tmp]={money%A[i],money/A[i]};
        tmp++;
        for(int j=0; j<cnt; j++){
            if(vec[j].money>=A[i]){
                vec[cnt+tmp]={vec[j].money%A[i],vec[j].money/A[i]};
                tmp++;
            }
            money=max(money,vec[j].money+vec[j].stock*A[i]);
        }
        cnt+=tmp;
    }
    /*
    for(int i=0; i<100; i++){
        cout << vec[i].money << ' ' << vec[i].stock << endl;
    }
    */
    cout << money << endl;
}

Measured memory_bytes: 18828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		doIt();
	}
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] hor = new int[n][2];
		for(int i = 0; i < n; i++){
			String str = sc.next();
			String[] ss = str.split(",");
			//System.out.println(str);
			hor[i][0] = Integer.parseInt(ss[0]);
			//System.out.println(hor[i][0]);
			hor[i][1] = Integer.parseInt(ss[1]);
			//System.out.println(hor[i][1]);
		}
		
		int[] ver = new int[w];
		for(int i = 1; i <= w; i++){
			int num = i;
			for(int j = 0; j < n; j++){
				if(num == hor[j][0]){
					num = hor[j][1];
				}
				else if(num == hor[j][1]){
					num = hor[j][0];
				}
			}
			//System.out.println(num);
			ver[num - 1] = i;
		}
		for(int i = 0; i < w; i++){
			System.out.println(ver[i]);
		}
	}

}

Measured memory_bytes: 11000
#![allow(non_snake_case)]

#[allow(unused_macros)]
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)*} };}
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, 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") }; }

use std::vec::Vec;

fn main() {
    input!{
        N: usize,
        Ais: [usize; N],
    }
    let mut cnt = 0;
    let mut Ais = Ais;
    'end: loop {
        for Ai in Ais.iter_mut() {
            if *Ai % 2 == 0 {
                *Ai /= 2;
            } else {
                break 'end;
            }
        }
        cnt += 1;
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  string s;cin>>s;
  int N=s.size();
  set<int> se;
  for(int i=1;i<N;i++){
    if(s[i-1]=='R'&&s[i]=='L')se.insert(i);
  }
  std::vector<int> v(N,0);
  for(int i=0;i<N;i++){
    if(s[i]=='R'){
      int a=*se.lower_bound(i);
      if((a-i)&1){v[a-1]++;}
      else {v[a]++;}
    }
    else{
      int a=*--se.upper_bound(i);
      if(((i-a)&1)==0){v[a]++;}
      else {v[a-1]++;}
    }
  }
  bool f=false;
  for(int i=0;i<N;i++){
    if(f)cout<<" ";cout<<v[i];f=true;
  }
  cout<<endl;
}


Measured memory_bytes: 3712
n, k = map(int, input().split())

an = list(map(int, input().split()))

tp = []
current = 1
tp.append(1)
if k > n:
  for i in range(n):
    current = an[current-1]
    tp.append(current)
  tps = len(set(tp))
  tp = tp[0:tps]
    
  kurikaesi_start = an[tp[-1]-1]
  start_ind = tp.index(kurikaesi_start)
  num = (k - start_ind) % (tps - start_ind)
  
  print(tp[start_ind+num])
else:
  for i in range(k):
    current = an[current-1]
  print(current)

Measured memory_bytes: 33296
import math


def main():
    N, M = map(int, input().split())
    state = [list(map(int, input().split())) for i in range(M)]
    p = [int(s) for s in input().split()]

    s = [0] * N
    ans = 0
    # 全事象
    for j in range(2 ** N):
        # スイッチの状態作成
        temp = j
        for i in range(N):
            s[i] = temp % 2
            temp = temp >> 1

        lamp = [0] * M
        for i in range(M):
            temp = 0
            for k in state[i][1:]:
                temp += s[k - 1]
            if temp % 2 == p[i]:
                lamp[i] = 1

        if all(lamp):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  cout << a + b + c + d - min(min(a, b), min(c, d)) + max(e, f) << endl;
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const ll base = 100000000;
const int baseHash = 31;
const ld PI = acos(-1);

//Remember limit for IT, etc...
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
//If TLE let's use int instead of ll

ll a, b, c;

void solveProblem() {
    cout << c << " " << a << " " << b;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> a >> b >> c;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 256
#include <stdio.h>


int main(int argc, char **argv){
  //読み取り
  int n,k;
  scanf("%d %d",&n,&k);
  int a[n];
  int i;
  for(i = 0 ; i < n ; i++){
    scanf("%d",&a[i]);
  }
  
  //最小値を調べる
  int smallest;
  smallest = a[0];
  for(i = 1 ; i < n ; i++){
    if(a[i] < smallest){
      smallest = a[i];
    }
  }
  
  //ガチの計算
  int x,j,count;
  i = k;
  x = 1;
  int xxxx = 1;
  while(i < n){
    count = 0;
    for(j = 0 ; j < k ; j++){
      if(a[i + j] != smallest){
        count++;
      }
    }
    if(count == k){
      i += k - 1;
    }
    else{
      if(xxxx == 1){
        i += k - 1;
      }
      else{
        i += k;
      }
    }
    x++;
  }
  printf("%d\n",x);

  return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  int ans = (n-1)*(m-1);
  cout << ans << endl;
}

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

using namespace std;

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

	vector<int> ans(N,0);

	int num;
	for (int i = 0; i < (N - 1); i++)
	{
		cin >> num;
		ans[num - 1] += 1;;
	}

	for (int a : ans)
	{
		cout << a << endl;
	}

}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,temp,m,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>temp;
        sum+=temp;
    }
    int res=n-sum;
    if(res<0){
        cout<<-1;
    }else
    {
        cout<<res;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int N;
	cin >> N;
	double x[N], total = 0;
	string u[N];
	for(int i = 0; i < N; i++){
		cin >> x[i] >> u[i];
		if(u[i] == "JPY"){
			total += x[i];
		}
		else{
			total += x[i] * 380000.0;
		}
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
    public static void main (String[] args) throws java.lang.Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int N = Integer.parseInt(lines[0]);
        int C = Integer.parseInt(lines[1]);
        int K = Integer.parseInt(lines[2]);
        
        ArrayList<Integer> ppl = new ArrayList<Integer>();
        for(int i=0;i<N;i++){
            ppl.add(Integer.parseInt(br.readLine()));
        }
        Collections.sort(ppl);
        
        int ans = 0;
        Bus nowBus = new Bus();
        for(int p:ppl){
            if(nowBus.end < p || nowBus.pplcnt==C){
                nowBus = new Bus();
                nowBus.end = p+K;
                nowBus.pplcnt = 0;
                ans++;
            }
            nowBus.pplcnt++;
        }
        
        System.out.println(ans);
    }
    private static class Bus{
        public int end = 0;
        public int pplcnt = 0;
        
    }
}

Measured memory_bytes: 37928
N=int(input())
ans=[0]*4
for i in range(N):
  s=input()
  if s=='AC':
    ans[0]+=1
  elif s=='WA':
    ans[1]+=1
  elif s=='TLE':
    ans[2]+=1
  else:
    ans[3]+=1
    
print("AC x {}".format(ans[0]))
print("WA x {}".format(ans[1]))
print("TLE x {}".format(ans[2]))
print("RE x {}".format(ans[3]))

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

int P,Q,R;
char* c;

int NOT(int);
int test(void);
int Calc(void);
bool Solve(void);

int main(){
	char st[100];
	while(scanf("%s",st), st[0]!='.'){
		int ans=0;
		for(P=0;P<3;P++){
			for(Q=0;Q<3;Q++){
				for(R=0;R<3;R++){
					c=st;
					ans+=Solve();
				}
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}
int NOT(int x){
	if(x==2)return 0;
	else if(x==1)return 1;
	else if(x==0)return 2;
	else{
		cout<<"??"<<endl;
		return 0;
	}
}
int Calc(){
	if(*c=='0'||*c=='1'||*c=='2')return *c-'0';
	else if(*c=='P')return P;
	else if(*c=='Q')return Q;
	else if(*c=='R')return R;
	else if(*c=='-'){
		++c;
		return NOT(Calc());
	}else if(*c=='(')return test();
}

//{{{
int test(){
	c++;
	int A=Calc();	c++;
	char op=*c;	c++;
	int B=Calc();	c++;

	if(op=='+')return max(A,B);
	else if(op=='*')return min(A,B);
}
//}}}
bool Solve(){
	stack<int> s;
	while(*c!='\0'){
		s.push(Calc());

		c++;
	}
	//printf("SIZE : %d\n",s.size());
	int ans=s.top();	s.pop();
	if(ans==2){
		//printf("(P,Q,R) : %d,%d,%d\n",P,Q,R);
		return true;
	}
	else return false;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
main(){
  int h,w;
  cin>>h>>w;
  int s[h][w];
  char c;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c;
      if(c=='.') s[i][j]=0;
      else s[i][j]=1;
    }
  }
  int ju=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]==1){
        if(!i){
          if(!j && s[i+1][j]==0 && s[i][j+1]==0) ju++;
          else if(j+1==w && s[i+1][j]==0 && s[i][j-1]==0) ju++;
          else if(s[i+1][j]==0 && s[i][j+1]==0 && s[i][j-1]==0) ju++;
        }else if(i+1<h){
          if(!j && s[i+1][j]==0 && s[i-1][j]==0 && s[i][j+1]==0) ju++;
          else if(j+1==w && s[i+1][j]==0 && s[i-1][j]==0 && s[i][j-1]==0) ju++;
          else if(s[i+1][j]==0 && s[i][j+1]==0 && s[i-1][j]==0 && s[i][j-1]==0) ju++;
        }else{
          if(!j && s[i][j+1]==0 && s[i-1][j]==0) ju++;
          else if(j+1==w && s[i][j-1]==0 && s[i-1][j]==0) ju++;
          else if(s[i-1][j]==0 && s[i][j-1]==0 && s[i][j+1]==0) ju++;
        }
      }
    }
  }
  if(ju) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
using namespace std;
const int MAX=1e5+1,MAXN=3e3+1;
int n,m;
int f[MAX],p[MAX];
int read()
{
    int x=0;
    char ch=getchar();
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);x=x*10+ch-48,ch=getchar());
    return x;
}
int find(int i)
{
	if(f[i]!=i) f[i]=find(f[i]);
	return f[i];
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;++i)
	  p[i]=read(),f[i]=i;
	for(int i=1;i<=m;++i)
	  {
	  	int x=read(),y=read();
	  	int r1=find(x),r2=find(y);
	  	f[r1]=r2;
	  }
	int ans=0;
	for(int i=1;i<=n;++i)
	  {
	  	int r1=find(i),r2=find(p[i]);
	  	if(r1==r2) ++ans;
	  }
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static long mod_inv(long a, long m){
		return (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int X = sc.nextInt();
			final int Y = sc.nextInt();
			final long MOD = 1000000007;
						
			if((2 * X - Y) % 3 != 0 || (2 * Y - X) % 3 != 0) {
				System.out.println(0);
				return;
			}
			
			final int X_times = (2 * X - Y) / 3;
			final int Y_times = (2 * Y - X) / 3;
			if(X_times < 0 || Y_times < 0) {
				System.out.println(0);
				return;
			}
			
			final int MAX = Math.max(X_times, Y_times);
			final int MIN = Math.min(X_times, Y_times);
			if(MIN == 0) {
				System.out.println(1);
				return;
			}
			
			long answer = 1;
			for(int i = (MIN + MAX); i > MAX; i--) {
				answer *= i;
				answer %= MOD;
			}
			for(int i = 1; i <= MIN ; i++) {
				answer *= mod_inv(i, MOD);
				answer %= MOD;
			}
			
			//System.out.println(X_times + " " + Y_times);
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define lower(a,x) lower_bound(all(a), x) - a.begin();
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x);
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x);
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end());
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  vll x(n), y(n), z(n);
  rep(i, n) {
	cin >> x[i];
	cin >> y[i];
	cin >> z[i];
  }

  ma = -inf;
  rep(a, 2) rep(b, 2) rep(c, 2) {
	vpll p;
	tmp = 0;
	rep(i, n) {
	  pll pp(0, i);
	  if (a) pp.first += x[i];
	  else pp.first -= x[i];
	  if (b) pp.first += y[i];
	  else pp.first -= y[i];
	  if (c) pp.first += z[i];
	  else pp.first -= z[i];
	  p.pb(pp);
	}
	sort(rall(p));
	rep(i, m) {
	  tmp += p[i].first;
	}
	
	ma = max(ma, tmp);
  }

  cout << ma << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

template<class T> void swap(T &a, T &b ){
    T temp;
    temp = a;
    a = b;
    b = temp;   
}

int main(){
    int A,B;

    cin >> A >> B;

    if( A < B* 2){
        cout << 0;
    }else{
        cout << A - B * 2;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
N,K=list(map(int,input().split()))
R,S,P=list(map(int,input().split()))
T=input()
D=dict()
D['s']=R; D['p']=S; D['r']=P

A=[[-1 for i in range(K)] for j in range(N//K+1)]
B=[[-1 for i in range(K)] for j in range(N//K+1)]
for i,value in enumerate(T):
    A[i//K][i%K]=value
    B[i//K][i%K]=D[value]
    
ans=0
for i in range(N):
    if B[i//K][i%K]!=-1 and i//K!=0 and A[i//K][i%K]!=A[i//K-1][i%K]:
        ans+=B[i//K][i%K]
    elif B[i//K][i%K]!=-1 and i//K!=0 and A[i//K][i%K]==A[i//K-1][i%K]:
        A[i//K][i%K]=-1
    elif B[i//K][i%K]!=-1 and i//K==0:
        ans+=B[i//K][i%K]
print(ans)

Measured memory_bytes: 78684
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if((a*b)%2 == 0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a,b,c,k=I()

if abs(b-a)>10**18:
    print("Unfair")
else:
    if k%2==0:
        print(a-b)
    else:
        print(b-a)


Measured memory_bytes: 10464
let solve = (input) => {
  const [t, x] = input.split(" ").map(Number)
  const a = Math.round((t / x) * 10 ** 10) / 10 ** 10
  return a
}
const input = require("fs").readFileSync("/dev/stdin", "utf8")
console.log(solve(input.trim()))


Measured memory_bytes: 7372
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int n;cin>>n;
   int res = 0;
   while(n--){
       int l,r;cin>>l>>r;
       res += r-l+1;
   }
   cout<<res;
}



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

int main(){
    int n;
    int cnt = 0;
    vector<int> s(3);
    cin >> n;

    s.at(2) = n % 2;
    s.at(1) = ((n - s.at(2)) / 10) % 2;
    s.at(0) = ((n - s.at(2) - 10*s.at(1)) / 100) % 2;

    for(int i = 0; i < 3; i++){
        if(s.at(i) == 1){
            cnt ++;
        }
    }

    cout << cnt << endl;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    ll a[n], b[n];
    f(i,0,n-1) cin >> a[i] >> b[i];
    sort(a,a+n);
    sort(b,b+n);
    if(n & 1) cout << b[n/2] - a[n/2] + 1;
    else cout << b[n/2-1] + b[n/2] - a[n/2-1] - a[n/2] + 1;
    return 0;
}

Measured memory_bytes: 6760
K=int(input())
list=[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]
K-=1
print(list[K])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define COUT cout<<fixed<<setprecision(12)
#define CIN getline(cin,s)
ll MOD=1000000007;

void solve()
{
	ll n;
	cin>>n;
	ll a[n+1];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	ll max1=a[0];
	ll sum=0;
	for(ll i=1;i<n;i++)
	{
		ll k=max(max1-a[i],(ll)0);
		sum=sum+k;
		if(a[i]>max1)
		max1=a[i];
	}
	cout<<sum;
}
int main()
{
	ll t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 5108
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}
 
fn main() {
  let xa: Vec<u32> = read_vec();
  let ans = if xa[0] >= xa[1] { 10 } else { 0 };

  println!("{}", ans);
}


Measured memory_bytes: 4352
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    a, b = map(int, input().split())
    if a > b:
        print(2*a-1)
        return
    if b > a:
        print(2*b-1)
        return
    if a == b:
        print(a+b)
    

main()

Measured memory_bytes: 9176
#include <iostream>
#define int long long
using namespace std;

signed main(){
	int n,a,b,c,d;
	bool flag = false;
	cin >> n >> a >> b >> c >> d;
	for(int i = 0;i < n - 1;i++){
		int l = c * (n - 1 - i) - d * i;
		int r = d * (n - 1 - i) - c * i;
		if(l <= b - a && b - a <= r) flag = true;
	}
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
s = int(input())

A = [s]
n = (s/2 if s%2==0 else 3*s+1)
ans = 1

while n not in A:
    ans +=1
    A.append(n)
    if n%2 == 0:
        n = n/2
    else:
        n = 3*n+1

print(ans+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

const ll INF = 1000000000;

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

    if(n >= 10){
        cout << r << endl;
    }else{
        cout << r + 100 * (10 - n) << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;
typedef long long ll;

int getint(){
	int f=1,x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
#define N 212345
int a[N],b[N];
int main(){
	int n=getint(); int m=0; ll s=0;
	for(int i=1;i<=n;i++) a[i]=getint(),s+=a[i];
	for(int i=1;i<=n;i++) b[i]=a[i]-a[i-1]; b[1]=a[1]-a[n];
	for(int i=1;i<=n;i++) m=max(m,b[i]); 
	int sum=0; bool flag=true;
//	for(int i=1;i<=n;i++) cout<<b[i]<<" "; cout<<endl;
//	cout<<"m "<<m<<endl;
	for(int i=1;i<=n;i++){
		int x=m-b[i]; //cout<<x<<" ";
		if(x%n!=0) flag=false;
		sum+=x/n;
	}
//	cout<<endl;
//	cout<<flag<<endl;
//	cout<<sum<<endl;
	if(sum!=m) flag=false;
//	if(n==2) {
//		int x=max(a[1],a[2]),y=min(a[1],a[2]);
//		flag=((x==y)||(x==2*y));
//	}
	if(m!=0) if(s%(ll(n)*(n+1)/2*m)!=0) flag=false;
	if(m==0){
		if(s%(ll(n)*(n+1)/2*n)!=0) flag=false;
	}
	if(flag)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
/*
5
6 9 12 10 8
*/

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

long long nr5_fact(long long n)
{
    long long pow5= 1, s = 0;
    while (n / pow5)
    {
        pow5 *= 5;
        s += n / pow5;
    }
    return s;
}

int main()
{
    long long n, rez = 0;
    cin >> n;
    if (n % 2) {
        cout << 0; return 0;
    }
    rez += n / 10 + nr5_fact(n / 10);
    cout << rez;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main(){
string s;
cin>>s;

bool app[26];
rep(i,0,26) app[i]=false;
for(int i=0;s[i]!='\0';i++)app[s[i]-'a']=true;
rep(i,0,26){
    if(!app[i]){
        cout<<(char)(i+'a')<<endl;
        return 0;
    }
}
cout<<"None"<<endl;
return 0;
}

Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector<int> B(N);
    for(int i=N; i>=1; i--) {
        int pari = 0;
        for(int k=N/i*i; k>0; k-=i) {
            pari += B[k-1];
            pari %= 2;
        }

        B[i-1] = (A[i-1] + pari) % 2;
    }

    bool ok = true;
    for(int i=1; i<=N; i++) {
        int pari = 0;
        for(int k=i; k<=N; k+=i) {
            pari += B[k-1];
            pari %= 2;
        }
        ok &= (A[i-1] == pari);
    }

    if(!ok) cout << -1 << endl;
    else {
        vector<int> ans;
        for(int i=0; i<N; i++) if(B[i]) ans.push_back(i+1);

        cout << ans.size() << endl;
        for(size_t i=0; i<ans.size(); i++) cout << ans[i] << " \n"[i+1 == ans.size()];
    }
    return 0;
}


Measured memory_bytes: 3064
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

N, W = list(map(int, input().split()))
INF = 10**10

dp = [[INF]*(100005) for i in range(N+5)]

for i in range(N+5):
    dp[i][0] = 0

for i in range(1,N+1):
    w, v = list(map(int, input().split()))
    for j in range(100001):
        if j - v <= 0:
            a = 0
        else:
            a = dp[i-1][j-v]
        dp[i][j] = min(dp[i-1][j], a+w)

for i in range(1000001):
    if dp[N][i] > W:
        print(i-1)
        exit()


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

int main() {
  int a, b;
  double k;
  int k_;
  cin >> a >> b;
  k = min(a, b) + abs(b - a) / 2.0;
  k_ = k;
  if (k == k_){
    cout << k_ << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
x = int(input())
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 9172
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));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int K = Integer.parseInt(strArr[1]);
		if (N % 2 == 0) {
			if (N / 2 >= K)
				System.out.println("YES");
			else
				System.out.println("NO");
		} else {
			if ((N + 1) / 2 >= K)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int X;
int Y;
char S[2000][2002];
int dp1[2000][2000];
int dp2[2000][2000];
int dp3[2000][2000];
int dp4[2000][2000];
int main(){
  int i, j, res;
  rd(X);
  rd(Y);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<X;Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      dp1[i][j] = dp2[i][j] = 1;
      if(i-1 >= 0){
        dp1[i][j] += dp1[i-1][j];
      }
      if(j-1 >= 0){
        dp2[i][j] += dp2[i][j-1];
      }
      if(S[i][j]=='#'){
        dp1[i][j] = dp2[i][j] = 0;
      }
    }
  }
  for(i=X-1;i>=0;i--){
    for(j=Y-1;j>=0;j--){
      dp3[i][j] = dp4[i][j] = 1;
      if(i+1 < X){
        dp3[i][j] += dp3[i+1][j];
      }
      if(j+1 < Y){
        dp4[i][j] += dp4[i][j+1];
      }
      if(S[i][j]=='#'){
        dp3[i][j] = dp4[i][j] = 0;
      }
    }
  }
  res = 0;
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      chmax(res, dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j] - 3);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190626-1

// --- original code ---
// int X, Y;
// char S[2000][2002];
// 
// int dp1[2000][2000];
// int dp2[2000][2000];
// int dp3[2000][2000];
// int dp4[2000][2000];
// 
// {
//   int i, j, res;
//   rd(X,Y,S(X));
// 
//   rep(i,X) rep(j,Y){
//     dp1[i][j] = dp2[i][j] = 1;
//     if(i-1 >= 0) dp1[i][j] += dp1[i-1][j];
//     if(j-1 >= 0) dp2[i][j] += dp2[i][j-1];
//     if(S[i][j]=='#') dp1[i][j] = dp2[i][j] = 0;
//   }
// 
//   for(i=X-1;i>=0;i--) for(j=Y-1;j>=0;j--){
//     dp3[i][j] = dp4[i][j] = 1;
//     if(i+1 < X) dp3[i][j] += dp3[i+1][j];
//     if(j+1 < Y) dp4[i][j] += dp4[i][j+1];
//     if(S[i][j]=='#') dp3[i][j] = dp4[i][j] = 0;
//   }
// 
//   res = 0;
//   rep(i,X) rep(j,Y){
//     res >?= dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j] - 3;
//   }
//   wt(res);
// }


Measured memory_bytes: 66688
#include <iostream>
using namespace std;
int iabs(int i) { return i > 0 ? i : -i; }

int main() {
	int N, K, H[100010], dp[100010];
	cin >> N >> K;
    for (int i = 0; i < N; ++i){
        cin >> H[i];
        dp[i] = 1e9;
    }

    dp[0] = 0;
    for (int i = 1; i < N; ++i){
        for (int j = max(0, i-K); j < i; ++j){
            dp[i] = min(dp[i], dp[j] + iabs(H[i]-H[j]));
        }
    }

    cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 4384
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
string toBit(const int i,const int k){
    bitset<2>bs(i);return bs.to_string();
}
const int MOD=100000;
int W,H;
char fld[30][30];

struct data{
    int state,jf;
    data(int a,int b):
        state(a),jf(b){}
    data(){}
    bool operator<(const data &d)const{
        if(state!=d.state)return state<d.state;
        return jf<d.jf;
    }
};

int solve(){
    map<data,int>prev;
    prev[data(0,0)]=1;
    REP(i,H){
        REP(j,W){
            map<data,int>next;
            int ret=0;
            EACH(it,prev){
                int ts=((*it).first.state<<1)%(1<<(W-1));
                if(fld[i][j]=='?'||fld[i][j]=='J'){
                    next[data(ts,1)]+=it->second;
                    next[data(ts,1)]%=MOD;
                }
                if(fld[i][j]=='?'||fld[i][j]=='O'){
                    next[data(ts+(*it).first.jf,0)]+=it->second;
                    next[data(ts+(*it).first.jf,0)]%=MOD;
                }
                if(fld[i][j]=='?'||fld[i][j]=='I'){
                    if(j+1==W||(((*it).first.state>>(W-2))&1)==0){
                        next[data(ts,0)]+=it->second;
                        next[data(ts,0)]%=MOD;
                    }
                }
                ret+=it->second;
                //cout<<it->second<<" "<<toBit(it->first.state,W-1)<<" "<<it->first.jf<<endl;
            }
            prev=next;
            //cout<<endl;
        }
    }
    int ret=0;
    EACH(it,prev){
        ret+=it->second;
        ret%=MOD;
    }
    //cout<<"ret"<<" "<<ret<<endl;
    return ret;
}

int main(){
    cin>>H>>W;
    REP(i,H)cin>>fld[i];
    int latte=1;
    REP(i,H)REP(j,W)if(fld[i][j]=='?')latte=(latte*3)%MOD;
    cout<<(latte+MOD-solve())%MOD<<endl;
    return 0;
}

Measured memory_bytes: 3416