akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	r := getNextInt(scanner)
	ee := make([][]edge, n)
	for i := 0; i < m; i++ {
		u := getNextInt(scanner)
		v := getNextInt(scanner)
		w := getNextInt(scanner)
		appendEdge(u, v, i, w, ee)
	}
	ww := make([]int64, n)
	for i := 0; i < n; i++ {
		ww[i] = math.MaxInt64
	}
	dd := &daikes{}
	heap.Init(dd)
	heap.Push(dd, newDaike(0, r))
	for dd.Len() > 0 {
		p := heap.Pop(dd).(daike)
		if ww[p.i] <= p.w {
			continue
		}
		ww[p.i] = p.w

		for _, e := range ee[p.i] {
			w := p.w + int64(e.w)
			if ww[e.to] <= w {
				continue
			}
			heap.Push(dd, newDaike(w, e.to))
		}
	}
	for i := 0; i < n; i++ {
		if ww[i] == math.MaxInt64 {
			fmt.Fprintln(writer, "INF")
			continue
		}
		fmt.Fprintln(writer, ww[i])
	}
}

func newDaike(w int64, i int) daike {
	return daike{
		w: w,
		i: i,
	}
}

type daike struct {
	i int
	w int64
}
type daikes []daike

func (h daikes) Len() int { return len(h) }
func (h daikes) Less(i, j int) bool {
	return h[i].w < h[j].w
}
func (h daikes) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *daikes) Push(x interface{}) {
	*h = append(*h, x.(daike))
}
func (h *daikes) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
func appendEdge(from, to, id, w int, ee [][]edge) {
	ee[from] = append(ee[from], edge{
		to: to,
		id: id,
		w:  w,
	})
}

type edge struct {
	to, id, w int
}



Measured memory_bytes: 46076
/**************************************
 * Au: Hany01
 * Prob: ARC101 E
 * Date: Sep 2nd, 2018
 * Email: hany01@foxmail.com
**************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define x first
#define y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
    register char c_; register int _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const int maxn = 5e3 + 5, MOD = 1e9 + 7;

int n, uu, vv, beg[maxn], v[maxn << 1], nex[maxn << 1], e = 1, f[maxn][maxn], dp[maxn], sz[maxn], g[maxn];

inline void add(int uu, int vv) { v[++ e] = vv, nex[e] = beg[uu], beg[uu] = e; }
inline int ad(int x, int y) { return (x += y) >= MOD ? x - MOD : x; }

void DFS(int u, int pa) {
    f[u][sz[u] = 1] = 1;
    for (register int i = beg[u]; i; i = nex[i]) if (v[i] != pa) {
        DFS(v[i], u);
        For(j, 1, sz[u] + sz[v[i]]) dp[j] = 0;
        For(j, 1, sz[u]) For(k, 0, sz[v[i]])
            dp[j + k] = ad(dp[j + k], (LL)f[u][j] * f[v[i]][k] % MOD);
        For(j, 1, sz[u] += sz[v[i]]) f[u][j] = dp[j];
    }
    for (register int i = 2; i <= sz[u]; i += 2)
        f[u][0] = ad(f[u][0], MOD - (LL)f[u][i] * g[i] % MOD);
}

int main()
{
#ifdef hany01
    File("arc101e");
#endif

    For(i, 2, n = read()) uu = read(), vv = read(), add(uu, vv), add(vv, uu);
    g[0] = 1;
    for (register int i = 2; i <= n; i += 2) g[i] = (LL)g[i - 2] * (i - 1) % MOD;
    DFS(1, 0), printf("%d\n", MOD - f[1][0]);

    return 0;
}

Measured memory_bytes: 97152
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll x,a,b;
    cin >> x >> a >> b;
    if(a >= b) cout << "delicious"<<endl;
    else if(x+a >= b) {
      cout << "safe"<<endl;
    }
    else {
      cout << "dangerous"<<endl;
    }

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ull A, B;
	cin >> A >> B;

	ull ans = 0;
	if( (A&1LL)==1LL) {
		ans += A;
		A = A+1;
	}

	if((B-A+1)%4==0 ) {
		ans = ans^0;
	} else if((B-A+1)%4==1) {
		ans = ans^B;
	} else if(((B-A+1)%4==2)) {
		ans = ans^1;
	} else {
		ans = ans ^ 1 ^ B;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}


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

#define MAX_N (110)
typedef long long int ll;

ll stack[MAX_N];
int top;

static
void
initialize();


static
bool
isEmpty();


static
bool
isFull();


static
void
push( ll v );


static
ll
pop();



int main()
{
    char s[100];
    ll a, b;
    while ( scanf("%s", s) != EOF ) {
	if ( s[0] == '+' ) {
	    b = pop();
	    a = pop();
	    push( a + b );
	}
	else if ( s[0] == '-' ) {
	    b = pop();
	    a = pop();
	    push( a - b );
	}
	else if ( s[0] == '*' ) {
	    b = pop();
	    a = pop();
	    push( a * b );
	}
	else {
	    int v = atoi( s );
	    push( v );
	}
    }
    
    printf("%lld\n", pop());

    return 0;
}




static
void
initialize()
{
    top = 0;
}


static
bool
isEmpty()
{
    return (top == 0);
}


static
bool
isFull()
{
    return (top == MAX_N - 1);
}


static
void
push( ll v )
{
    top++;
    stack[top] = v;
}




static
ll
pop()
{
    top--;
    return stack[top + 1];
}

Measured memory_bytes: 976
from __future__ import print_function
import sys,heapq
n,q=map(int,sys.stdin.readline().split())
a=[[] for _ in range(n)]
for _ in range(q):
  g=map(int,sys.stdin.readline().split())
  if g[0]==0:
    heapq.heappush(a[g[1]],-g[2])
  elif g[0]==1:
    a[g[1]] and print(-a[g[1]][0])
  else:
    a[g[1]] and heapq.heappop(a[g[1]])


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    string s, t;
    cin >> s >> t;

    int n1 = s.size(), n2 = t.size();

    int dp[n1][n2] = {}, p[n1][n2] = {};

    for (int i = 0; i < n1; ++i)
    {
        for (int j = 0; j < n2; ++j)
        {
            if (s[i] == t[j])
            {
                dp[i][j] = (j > 0 && i > 0 ? dp[i - 1][j - 1] : 0) + 1;
                p[i][j] = 1;
            }
            else
            {
                dp[i][j] = (i > 0 ? dp[i - 1][j] : 0);

                if ((j > 0 ? dp[i][j - 1] : 0) > dp[i][j])
                {
                    dp[i][j] = (j > 0 ? dp[i][j - 1] : 0);
                    p[i][j] = 2;
                }
            }
        }
    }    

    string ans;

    int i = n1 - 1, j = n2 - 1;

    while (i >= 0 && j >= 0)
    {
        // cout << i << " " << j << " " << p[i][j] << endl;
        if (p[i][j] == 1)
        {
            ans += s[i];
            i -= 1, j -= 1;
        }
        else if (p[i][j] == 2)
        {
            j -= 1;
        }
        else
            i -= 1;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 144228
#include<iostream>
#include<cstdio>
using namespace std;
char a[100005];
int A,B,C;

int main (){
	int res = 0;
	cin>>A>>B>>C;
	if (B>=C){
		res = B + C;
	}
	else{
		if (A >= (C-B)){
			res = B + C;
		}else {
			res = A+B+B+1;
		}
	}
	printf("%d",res);
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];

    map<int, int> m;
    rep(i, n) m[a[i]]++;

    int res = 0;

    for (auto&& p : m) {
        if (p.first != p.second) {
            if (p.first > p.second) res += p.second;
            else res += p.second - p.first;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5120
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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;
}

#pragma endregion

int main() {
  int s = in(), w = in();

  if (w < s) {
    cout << "safe" << endl;
  } else {
    cout << "unsafe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np

n,k = map(int, input().split())
h = list(int(i) for i in input().split())

cnt = 0
for i in range(n):
  if h[i] >= k:
    cnt += 1
print(cnt)


Measured memory_bytes: 22232
#DP D
def main():
    import sys
    N, W = map(int, sys.stdin.readline().split())
    L = tuple([tuple(map(int, sys.stdin.readline().split())) for _ in range(N)])
    #print(L)
    dp = [[0 for i in range(10**5+1)] for _ in range(N)]
    for i in range(N):
        w, v = L[i][0], L[i][1]
        if i>=1:
            dp[i][w] = max(v, dp[i-1][w])
        elif i==0:
            dp[i][w] = v
        for j in range(10**5+1):
            if i>=1 and dp[i-1][j]!=0:
                dp[i][j] = max(dp[i-1][j], dp[i][j])
                if w+j <=10**5:
                    dp[i][w+j] = max(dp[i-1][w+j], v + dp[i-1][j])
                
    print(max(dp[-1][:W+1]))



if __name__=='__main__':
    main()

Measured memory_bytes: 171528
def main():
    N = int(input())
    H = [int(a) for a in input().split()]
    cnt = 0
    step = 0
    for i in range(1, N):
        if H[i] - H[i-1] <= 0:
            cnt += 1
        else:
            if cnt > step:
                step = cnt
            cnt = 0
        if i == N - 1:
            if step < cnt:
                step = cnt
    print(step)
if __name__ == "__main__":
    main()

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

k = []
for i in range(m):
    k.append(list(map(int, input().split())))

p=list(map(int,input().split()))
#以上入力

def binary_ume(N,K):  #Nを2進数表示し、K桁まで0埋めする
    A = []
    while N >= 2:
        A.append(N%2)
        N = N//2
    A.append(N)
    while len(A) < K:
        A.append(0)
    return A

ans = 0

for i in range(m):
    for j in range(1,len(k[i])):
        k[i][j] -= 1

for i in range(2**n):
    switch = binary_ume(i,n)  #スイッチの推し方全部見る
    all_on = 1  #何かひとつでもダメならすぐ切る
    for j in range(m):
        if sum(switch[l] for l in k[j][1:])%2 != p[j]:
            all_on = 0
            break
    if all_on == 1:
        ans += 1

print(ans)


Measured memory_bytes: 43228
#include <iostream>
  
inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}
  
inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
  
  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) gap_num++;
  
  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);
  
  std::cout << (gap_num+1) << '\n';
  
  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';
  
  std::cout << count << '\n';
}
  
int main(){
  std::ios::sync_with_stdio(false);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}

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

int main()
{
  int64_t N, a, b, t = 0;
  cin >> N;
  vector<pair<int64_t, int64_t>> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    A.at(i) = make_pair(b, a);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++)
  {
    t += A.at(i).second;
    if (t > A.at(i).first)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;
const int MAX = 2e5;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  vector<ll> s(n);
  rep(i, n) {
    s[i] = a[i];
    if (i) s[i] += s[i - 1];
  }
  vector<ll> sum(MAX + 1, 0);
  vector<ll> cnt(MAX + 1, 0);

  int l = 0, r = MAX + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    rep(i, n) {
      int idx = lower_bound(a.begin(), a.end(), mid - a[i]) - a.begin();
      if (idx == n) continue;
      cnt[mid] += n - idx;
      sum[mid] += a[i] * (n - idx) + s[n - 1];
      if (idx) sum[mid] -= s[idx - 1];
    }
    
    if (cnt[mid] >= m) l = mid;
    else r = mid;
  }

  cout << sum[l] - l * (cnt[l] - m) << endl;




  
  return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    int x = n/2; int y = x;
    if(n % 2 == 1) y++;
    cout << x*y << endl;
    return 0;
}


Measured memory_bytes: 3536
# -*- coding: utf-8 -*-

# N円の支払い (1 ≤ N ≤ 50000)
N = int(input())#入力

count = 0
for x in range(50000):
    if(N == int(x*1.08)):
        without_tax = x #税抜き価格
    else: count = count + 1

if(count == 50000): print(':(')
else: print(without_tax)

Measured memory_bytes: 3060
#include<stdio.h>
int a[200000];
int main(void){
    int i,j,k,input,count=0,Count;
    for(i=2;i<=200000;i++){
        if(a[i]==0){
            count=count+i;
            a[i]=count;
            for(j=2;i*j<=200000;j++){
                a[i*j]=-1;
            }
        }
    }
    while(1){
        scanf("%d",&input);
        if(input==0)break;
        Count=0;
        for(i=2;i<200000;i++){
            if(a[i]!=-1)Count++;
            if(Count==input){
                printf("%d\n",a[i]);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1380
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_C
#include <iostream>
using namespace std;
int main(){
  int x, y;
  while(cin >> x >> y){
    if(x == 0 && y ==0){
      break;
    }
    else{
      if(y <x ){
        cout << y << " " << x << endl;
      }
      else{
        cout << x << " " << y << endl;
      }
    }
  }
}

Measured memory_bytes: 1160
str = gets.split
N,K = str[0].to_i, str[1].to_i
mod = 1000000007

b = K-1
i,j = b,1
r = N-K+1
x,y = r-1,2

puts r
a0 = K-r
a1 = 0
if K < r
    a1 = K  
else
    a1 = r
end
b = 1
for p in 2..a1 do
    b = b*i/j
    r = r*x/y
    i -= 1
    j += 1
    x -= 1
    y += 1
    puts b*r%mod
end

for p in 1..a0 do
    puts 0
end

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

ll mypow(ll p, ll n){
    ll res = 1;
    while (n>0){
        if (n%2==0){
            p *= p;
            n /= 2;
        } else {
            res *= p;
            n--;
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, P;
    cin >> N >> P;
    vector<ll> A(N);
    bool isodd = false;
    for (int i=0;i<N;i++){
        cin >> A[i];
        if (A[i]%2==1) isodd = true;
    }
    ll odd, even;
    if (isodd){
        odd = even = mypow(2, N-1);
    } else {
        odd = 0;
        even = mypow(2, N);
    }

    if (P==0)  cout << even << "\n";
    else cout << odd << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e5 * 3 + 10;
vector <ll> vec;
ll q;

int main() {
	fastInp;

	ll n, m;
	cin >> n >> m;
	vec.resize(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
		sum += vec[i];
	}

	sort(vec.rbegin(), vec.rend());

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (vec[i] * 4 * m >= sum) ans++;
	}

	if (ans >= m) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll n,a[N],b[N];
int main(){
    cin>>n;
    vector<pair<ll,ll> > v;
    lol(i,n){
	cin>>a[i]>>b[i];
	v.push_back(make_pair(a[i],i*2));
	v.push_back(make_pair(b[i],i*2+1));
    }
    sort(v.begin(),v.end());
    ll k=v[n-1].first;
    bool ok=1,can=0;
    lol(i,n)ok&=(a[i]<=k);
    can|=ok;ok=1;
    lol(i,n)ok&=(b[i]<=k);
    can|=ok;ok=0;
    lol(i,n)ok|=(a[i]<=k&&b[i]<=k);
    can|=ok;
    ll sum=0;
    lol(i,n)sum+=v[i].first;
    if(can){
	cout<<sum<<endl;
	return 0;
    }
    if(v[n-1].second/2!=v[n].second/2){
	cout<<sum-v[n-1].first+v[n].first<<endl;
	return 0;
    }
    ll vl=sum-v[n-1].first+v[n+1].first;
    ll vr=sum-v[n-2].first+v[n].first;
    cout<<min(vl,vr)<<endl;
    return 0;
}


Measured memory_bytes: 7408
#include<bits/stdc++.h>
using namespace std;
int main()
{
 //freopen("input.txt","r",stdin);
 // freopen("output.txt","w",stdout);
  ios_base:: sync_with_stdio(0);
    cin.tie(0);
    int a=0,b,c,n,i,j,k=0,l=0,r,ans=0;
   cin>>n;
   int art[n];
   for(i=0;i<n;i++){
    cin>>art[i];
   }
   sort(art,art+n);
   for(i=n-1;i>=1;i--){
    l=0,r=i-1;
    while(l<r){
      if(art[l]+art[r]>art[i]){
        ans+=r-l;
        r--;
      }
      else l++;
    }
   }
   cout<<ans;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 310
#define N 90010
#define mod 998244353
#define ll long long
using namespace std;
int a[maxn], f[maxn][N], g[maxn][N];
int calc(int a, int k)
{
	int ans = 1;
	while (k)
	{
		if (k % 2) ans = (ll)ans * a % mod;
		a = (ll)a * a % mod;
		k /= 2;
	}
	return ans;
}
int main()
{
	int n, sum = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	f[0][0] = 1;
	g[0][0] = 1;
	for (int i = 0; i <= n - 1; i++)
	{
		for (int j = 0; j <= sum; j++)
		{
			f[i + 1][j] = (f[i + 1][j] + f[i][j] * 2LL) % mod;
			g[i + 1][j] = (g[i + 1][j] + g[i][j]) % mod;
			f[i + 1][j + a[i + 1]] = (f[i + 1][j + a[i + 1]] + f[i][j]) % mod;
			g[i + 1][j + a[i + 1]] = (g[i + 1][j + a[i + 1]] + g[i][j]) % mod;
		}
		sum += a[i + 1];
	}
	int res = 1;
	for (int i = 1; i <= n; i++)
		res = res * 3LL % mod;
	for (int i = (sum + 1) / 2; i <= sum; i++)
		res = (res - f[n][i] * 3LL % mod + mod) % mod;
	if (sum % 2 == 0) res = (res + g[n][sum / 2] * 3LL % mod) % mod;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 211328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	long long n;
	cin>>n;
	long long a[1005];
	for(long long i=0;i<=1000;i++)
	{
		a[i]=pow(i,5);
	}
	long long ct=0;
	for(long long i=0;i<=1000;i++)
	{
		for(long long j=1;j<=1000;j++)
		{
			if(a[i]-a[j]==n)
			{
				cout<<i<<" "<<j;
				ct=1;
				return 0;
			}
		}
		if(ct==0)
		{
			for(long long j=1;j<=1000;j++)
			{
				if(a[i]+a[j]==n)
				{
					cout<<i<<" "<<-j;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3916
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

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

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}

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

const int N=1000010;
int mp[N];

void main() {
    int n;
    R(n);
    VI a(n);
    REP(i,n) R(a[i]);
    // int g=a[0];
    // REP(i,n) g=gcd(g,a[i]);
    REP(i,n) {
        int t=a[i];
        for ( LL j=2; j*j<=t; j++ ){
            if ( t%j==0 ) {
                mp[j]++;
                while ( t%j==0 ) t/=j;
            }
        }
        if ( t>1 ) mp[t]++;
    }
    int ok=1,ok2=1;
    REP(i,N) {
        // dump(i,mp[i]);
        if ( mp[i]>1 ) ok=0;
        if ( mp[i]==n ) ok2=0;
    }
    if ( ok ) {
        W("pairwise coprime");
    } else if ( ok2 ) {
        W("setwise coprime");
    } else {
        W("not coprime"); 
    }
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 11080
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
const [a, b, c, k] = input[0].split(' ').map(x => +x)
if (k <= a) {
  console.log(k);
} else if (k <= a + b) {
  console.log(a);
} else {
  console.log(a - (k - a - b));
}

Measured memory_bytes: 29860
// #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 int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

bool solve(const vector<int> &A, ll mid) {
    int N = A.size();
    set< pair<int, int> > S;
    // fprintf(stderr, "# mid = %lld\n", mid);
    for(int i=0; i<N; i++) {
        // for(auto e : S) fprintf(stderr, "i = %d: (%d %d)\n", i, e.first, e.second);
        if(i + 1 == N or A[i] < A[i+1]) continue;
        
        int k = A[i+1] - 1;
        while(k >= 0) {
            // k+1 文字目以降のものはいらない
            {
                auto ptr = S.upper_bound(make_pair(k+1, -1));
                while(ptr != S.end()) ptr = S.erase(ptr);
            }

            // k 文字目を増やす
            auto ptr = S.lower_bound(make_pair(k, -1));
            if(ptr == S.end() or ptr->first > k) {
                if(1 < mid) {
                    S.emplace(k, 1);
                    break;
                }
                else return false;
            }
            else {
                int cnt = ptr->second;
                if(cnt + 1 < mid) {
                    S.erase(ptr);
                    S.emplace(k, cnt + 1);
                    break;
                }
                else {
                    S.erase(ptr);
                }
            }
            k--;
        }
        // fprintf(stderr, "k = %d\n", k);

        // 繰り上がれない
        if(k < 0) return false;
    }
    return true;
}

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

    ll lb = 0, ub = N;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if(solve(A, mid)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  string s;
  cin >> s;
  vector<int64> d[2];
  d[0].assign(2019, 0);
  int t = 1;
  int64 ans = 0;
  for (char c : s) {
    d[t].assign(2019, 0);
    c -= '0';
    for (int i = 0; i < 2019; ++i) {
      int nxt = (i * 10 + c) % 2019;
      d[t][nxt] += d[t ^ 1][i];
    }
    ++d[t][c];
    ans += d[t][0];
    t ^= 1;
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 3776
#include<stdio.h>
int n,m,k,p;
int mt(int a,int b)
{
	if(b==0)
	{
		return 1;
	}
	int c=mt(a,b>>1);
	c=(long long)c*c%p;
	if(b&1)
	{
		c=(long long)c*a%p;
	}
	return c;
}
int dp[105][105],dp2[105][105],c[105][105];
int main()
{
	scanf("%d%d%d%d",&n,&m,&k,&p);
	for(int i=0;i<=100;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			c[i][j]=c[i-1][j-1]+c[i-1][j];
			if(c[i][j]>=p)
			{
				c[i][j]-=p;
			}
		}
	}
	dp[0][0]=1;
	for(int i=1;i<=k;i++)
	{
		for(int x=0;x<=n;x++)
		{
			for(int y=0;y<=m;y++)
			{
				dp2[x][y]=0;
			}
		}
		for(int x=0;x<=n;x++)
		{
			for(int y=0;y<=m;y++)
			{
				int val=mt(i,m-y)-mt(i-1,m-y);
				if(val<0)
				{
					val+=p;
				}
				val=(long long)val*mt(k-i+1,y)%p;
				int tmp=1;
				for(int d=0;d<=n-x;d++)
				{
					int inc=(long long)c[n-x][d]*tmp%p;
					dp2[x+d][y]+=(long long)dp[x][y]*inc%p;
					if(dp2[x+d][y]>=p)
					{
						dp2[x+d][y]-=p;
					}
					tmp=(long long)tmp*val%p;
				}
			}
		}
		for(int x=0;x<=n;x++)
		{
			for(int y=0;y<=m;y++)
			{
				dp[x][y]=0;
			}
		}
		for(int x=0;x<=n;x++)
		{
			for(int y=0;y<=m;y++)
			{
				int val=mt(k-i+1,x)-mt(k-i,x);
				if(val<0)
				{
					val+=p;
				}
				val=(long long)val*mt(i,n-x)%p;
				int tmp=1;
				for(int d=0;d<=m-y;d++)
				{
					int inc=(long long)c[m-y][d]*tmp%p;
					dp[x][y+d]+=(long long)dp2[x][y]*inc%p;
					if(dp[x][y+d]>=p)
					{
						dp[x][y+d]-=p;
					}
					tmp=(long long)tmp*val%p;
				}
			}
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        dist = 0
        for d in range(D):
            dist += abs(X[i][d]-X[j][d])**2
        if dist ** 0.5 == int(dist ** 0.5):
            ans += 1
print(ans)

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

int main(){
	ll a,b;
	cin >> a >>b ;
	cout << lcm(a,b) << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std; 
#define max(a, b) (a < b ? b : a) 
#define min(a, b) ((a > b) ? b : a) 
#define mod 1e9 + 7 
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++) 
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--) 
#define INF 1000000000000000003 
typedef long long int ll; 
typedef vector<int> vi; 
typedef vector<long long int> vl; 
typedef pair<int, int> pi; 
#define F first 
#define S second 
#define pb push_back 
#define POB pop_back 
#define mp make_pair 

int main()
{	int n;
cin>>n;
	vl a;
	ll x;
	FOR(i,n)
	{cin>>x;
	a.pb(x);
	}
	ll s=0;
	x=n-2;
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	s=a[0];
	for(int i=1;i<n-2;i++)
	{if(x>0)
	{
	s+=a[i];
	x-=1;
	}
	if(x>0)
	{s+=a[i];
	x-=1;
	}
	
	//break;
	}
	cout<<s;
	
	
    
   return 0;
}



Measured memory_bytes: 5304
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
int main()
{
    string s;
    cin >> s;
    bool flag = false;
    for (int i = 0; i < s.size(); i++) {
        for (int j = i + 1; j < s.size(); j++) {
            if (s[i] == 'C' && s[j] == 'F')
                flag = true;
        }
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

vector<vi> v;
vi used;
int ans = 0;

void dfs(int now){
    if(v[now].size() == 0){
        ans++;
        return;
    }
    rep(i,v[now].size()) if(!used[v[now][i]]){
        used[v[now][i]]++;
        dfs(v[now][i]);
    }
}

int main(void) {
    int i,j;
    int n;
    while(cin >> n, n){
        vector<vi> g(n);
        map<string,int> ma;
        int cnt = 0;
        rep(i,n){
            string s;
            cin >> s;
            int bef = 0;
            rep(j,s.size())if(!islower(s[j])){
                string t = s.substr(bef,j-bef);
                if(!ma.count(t)){
                    ma[t] = cnt;
                    cnt++;
                }
                g[i].push_back(ma[t]);
                bef = j+1;
            }
            //rep(j,g[i].size())cout << " " << g[i][j] ;cout << endl;
        }
        v = vector<vi>(cnt);
        rep(i,n){
            loop(j,1,g[i].size()) v[g[i][0]].push_back(g[i][j]);
        }
        ans = 0;
        used = vi(cnt);
        dfs(0);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3284
using System;
using System.Text;

namespace ALDS1_8_B {
    class Node {
        public int Key { get; set; }
        public Node Parent { get; set; }
        public Node Left { get; set; }
        public Node Right { get; set; }

        public Node(int key = default(int), Node parent = null) {
            Key = key;
            Parent = parent;
        }
    }

    class Problem {
        private Node _root;
        private StringBuilder _sb;

        public void Run() {
            _sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            SetRoot();
            for (int i = 1; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');

                switch (input[0]) {
                    case "insert":
                        Insert(int.Parse(input[1]));
                        break;
                    case "print":
                        Inorder(_root);
                        _sb.AppendLine();
                        Preorder(_root);
                        _sb.AppendLine();
                        break;
                    case "find":
                        _sb.AppendLine(Find(int.Parse(input[1])) != null ? "yes" : "no");
                        break;
                }
            }
            Console.Write(_sb);
        }

        private Node Find(int key) {
            Node ret = _root;
            while (ret != null && key != ret.Key) {
                ret = key < ret.Key ? ret.Left : ret.Right;
            }
            return ret;
        }
        
        private void Insert(int key) {
            Node x = _root;
            Node y = null;
            while (x != null) {
                y = x;
                x = key < x.Key ? x.Left : x.Right;
            }

            if (key < y.Key)
                y.Left = new Node(key, parent: y);
            else
                y.Right = new Node(key, parent: y);
        }

        private void Inorder(Node node) {
            if (node == null)
                return;
            Inorder(node.Left);
            _sb.Append(" " + node.Key);
            Inorder(node.Right);
        }

        private void Preorder(Node node) {
            if (node == null)
                return;
            _sb.Append(" " + node.Key);
            Preorder(node.Left);
            Preorder(node.Right);
        }
        
        private void SetRoot() {
            string[] input = Console.ReadLine().Split(' ');
            _root = new Node(int.Parse(input[1]));
        }
    }

    class Program {
        static void Main(string[] args) {
            Problem p = new Problem();
            p.Run();
        }
    }
}

Measured memory_bytes: 84692
n, x = [int(x) for x in input().split()]

ls = [int(x) for x in input().split()]

bounces = [0]
d = 0
for i in range(n):
    d = d + ls[i]
    bounces.append(d)

count = 0
for b in bounces:
    if b <= x:
        count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REPRP(i, n) for (int i = (int)(n); (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORP(i, m, n) for(int i = m; i < n+1; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
const int INF = 2000000000ll;
const long double PI = acosl(-1);
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; }



int power(int a, int b) {return b?power(a*a,b/2)*(b%2?a:1):1;}
int perm(int N, int K){
    int x=1;
    for(int i=1;i<=K;i++)
    {
        x=x*(N-i+1);
    }
    return x;
}
int factorial(int N) {return perm(N,N);}
int comb(int N,int K) {return factorial(N)/factorial(K)/factorial(N-K);}
int hcomb(int N, int K) {return comb(N+K-1, N-1);}

int dtoi(double d) {return round(d);}

int isprime(int n) {
    if (n < 2) return 0;
    for (int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return 0;
    }
    return 1;
}

int mystoi(string S){
    int num = 0;
    for (int i = (int) S.length()-1; i >= 0; i--){
        num += (S[i]-'0') * power(10,S.length()-1-i);
    }
    return num;
}

template<class T>
int SUM(T a) {
    int sum = 0;
    for(auto iter : a) sum += iter;
    return sum;
}

void solve(int N);

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    solve(N);
    return 0;
}

void solve(int N) {
    int ans = 0;
    int n = N % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) p("hon");
    else if (n == 3) p("bon");
    else p("pon");
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc168/abc168_a && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/abc168/abc168_a && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/abc168/abc168_a && sh submit.sh
*/


Measured memory_bytes: 3644
i = list(map(int, input().split())) 
j = list(map(int, input().split())) 

lis=[]
ans = 0
for a in range (i[0]):
    tendata=[a+1,j[a],0]
    lis.append(tendata)

for b in range(i[1]):
    miti = list(map(int, input().split()))
    if ((lis[miti[0]-1][1]) > (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
    
    elif ((lis[miti[0]-1][1]) == (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
        lis[miti[0]-1][2] = 1

    else:
        lis[miti[0]-1][2] = 1

for c in  lis:
    if not (c[2] == 1 ):
        ans = ans+1

print(ans)

Measured memory_bytes: 26532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> c(n);
    vector<int> dp(n+1, INF);
    dp[0] = 0;
    for(int i = 0; i < m; i++) cin >> c[i];
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j < m; j++) {
            if(i-c[j] >= 0) chmin(dp[i], dp[i-c[j]]+1);
        }
    }
    cout << dp[n] << endl;
}


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

int main()
{
	int N;
	while ( cin >> N, N != 0 ) {
		int cnt[10] = {};
		for ( int i = 0; i < N; i++ ) {
			int a;
			cin >> a;
			cnt[a]++;
		}

		for ( int i = 0; i < 10; i++ ) {
			if ( cnt[i] == 0 ) {
				cout << "-" << endl;
			} else {
				for ( int j = 0; j < cnt[i]; j++ ) {
					cout << "*";
				}
				cout << endl;
			}
		}
	}

	return ( 0 );
}



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


int main() {
  string s;
  cin >> s;
  int a, b;
  a = (s[0] - '0')*10 + s[1] - '0';
  b = (s[2] - '0')*10 + s[3] - '0';
  if(1 <= a && a <= 12){
    if(1 <= b && b <= 12){
      cout << "AMBIGUOUS";
    }
    else{
      cout << "MMYY";
    }
  }
  else{
    if(1 <= b && b <= 12){
      cout << "YYMM";
    }
    else{
      cout << "NA";
    }
  }
    
    
  return 0;
}




Measured memory_bytes: 3620