akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : MinCostSort.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX_W = 10001;

void writeVector(vector<int>& v){
	for(int i=0; i<v.size(); i++){
		cout << v.at(i) << "\n";
	}
}

void writeVector(vector<bool>& v){
	for(int i=0; i<v.size(); i++){
		cout << v.at(i) << "\n";
	}
}

int main() {
	int n, input, min_all=MAX_W, total_sum=0;
	cin >> n;
	vector<int> v, inv_v(MAX_W);
	vector<bool> isIterated(n);

	for(int i=0; i<isIterated.size(); i++){
		isIterated.at(i) = false;
	}


	for(int i=0; i<n; i++){
		cin >> input;
		v.push_back(input);
		inv_v.at(input) = i;
		if(input<min_all){
			min_all = input;
		}
	}

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

	//cout << "v:\n";
	//writeVector(v);
	//cout << "inv_v:\n";
	//writeVector(inv_v);
	//cout << "isIterated:\n";
	//writeVector(isIterated);

	for(int i=0; i<v.size(); i++){
		int min_in_loop = MAX_W;
		int sum_loop = 0;
		int pos = i;
		int elem = v.at(i);
		int loop_size = 0;

		if(not isIterated.at(pos)){
			isIterated.at(pos) = true;

			if(inv_v.at(v.at(pos)) == pos){
				//cout << "single loop: " << v.at(pos) << "\n";
				continue;
			}

			//cout << "multi loop: ";
			while(true){
				loop_size++;
				isIterated.at(pos) = true;
				//cout << elem << " ";

				sum_loop += elem;

				if(elem < min_in_loop){
					min_in_loop = elem;
				}

				pos = inv_v.at(elem);
				elem = v.at(pos);

				if(isIterated.at(pos)){
					//cout << "sum_loop: " << sum_loop << ", min_in_loop: " << min_in_loop << " "
					//	 << "loop_size: " << loop_size << "\n";
					//cout << "\n";

					int add = min(min_in_loop*(loop_size-2), min_in_loop + min_all*(loop_size+1));

					total_sum += sum_loop + add;

					break;
				}

			}
		}
	}

	cout << total_sum << "\n";
	return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <sstream>
using namespace std;
 
void solve() {
	int n, x, t; 
	cin >> n >> x >> t;
	if(n < x) {
		cout << t << endl;
	}else {
		int ans = n / x;
		if(n % x != 0) ans += 1;
		ans *= t;
		cout << ans << endl;
	}
}
 
int main () {
	int t = 1;
	for(int tt = 0; tt < t; tt++) solve();
	return 0;
}

Measured memory_bytes: 3632
s = input()
q = int(input())

import sys
input = sys.stdin.readline

qs = [list(input().split()) for _ in range(q)]

left = ''
right = ''


front = False
for i in qs:
    if(i[0] == '1'):
        front = not front
        continue

    f = int(i[1])
    c = i[2]
    if(front + f == 2):
        right = right + c
    else:
        left = left + c

if(not front):
    ans = left[::-1] + s + right
else:
    ans = right[::-1] + s[::-1] + left

print(ans)


Measured memory_bytes: 31092
#include <iostream>
using namespace std;
int main(void){
    long long int H = 0;
    long long int W = 0;
    cin >> H >> W;;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }

    long long int evenResult = W / 2 + W % 2;
    long long int oddResult = W / 2;
    cout << evenResult * (H / 2 + H % 2) + oddResult * (H / 2) << endl;

    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int n, q;
    cin >> n >> q;
    vt<vt<int>> adj(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vt<int> ans(n), add(n);
    while (q--) {
        int p, x;
        cin >> p >> x;
        add[--p] += x;
    }

    function<void(int, int, int)> dfs = [&](int u, int p, int b) {
        b += add[u];
        ans[u] = b;
        for (int v : adj[u]) {
            if (v == p) continue;

            dfs(v, u, b);
        }
    };
    dfs(0, -1, 0);

    for (int i : ans) cout << i << ' ';
}


Measured memory_bytes: 37500
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		if (s.equals("zyxwvutsrqponmlkjihgfedcba")) {
			System.out.println(-1);
			return;
		}

		if (s.length() == 26) {
			TreeSet<Character> set = new TreeSet<Character>();
			for (int i = 24; i >= 0; i--) {
				set.add(s.charAt(i + 1));
				if (s.charAt(i) - s.charAt(i + 1) < 0) {
					break;
				}
			}
			char l = s.charAt(25 - set.size());
			String str = s.substring(0, 25 - set.size());
			while (!set.isEmpty()) {
				char f = set.pollFirst();
				if (f > l) {
					System.out.println(str + f);
					return;
				}
			}
		} else {
			TreeSet<Character> set = new TreeSet<Character>();
			for (int i = 0; i < 26; i++) {
				set.add((char) ('a' + i));
			}
			for (int i = 0; i < s.length(); i++) {
				set.remove(s.charAt(i));
			}
			System.out.println(s + set.first());
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<map>
#include<vector>

using namespace std;

int main(){
    long long n,m;
    long long total = 0;
    cin >> n >> m;

     if(n*2 >= m){//Sの数*2がcの数より多かった場合
         total = m/2;

     }else{
         total = n;
         m -=2*n;
         total += m/4;
     }
    cout << total << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\???
		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int num3 = sc.nextInt();

		// ??\??????????????°???????????\??????????¬???????????????????????????°????????\??????
		int[][] table = new int[num1][num2];
		int[][] grid = new int[num2][num3];

		for (int cnt1 = 0; cnt1 < num1; cnt1++) {

			for (int cnt2 = 0; cnt2 < num2; cnt2++) {

				table[cnt1][cnt2] = sc.nextInt();
			}
		}

		for (int cnt1 = 0; cnt1 < num2; cnt1++) {

			for (int cnt2 = 0; cnt2 < num3; cnt2++) {

				grid[cnt1][cnt2] = sc.nextInt();
			}
		}

		// 2??????????¬????????????????????¨????
		long [][] sum = new long[num1][num3];
		int cnt0;
		int cnt1;
		int cnt2;

		for (cnt0 = 0; cnt0 < num1; cnt0++) {

			for (cnt1 = 0; cnt1 < num3; cnt1++) {

				for (cnt2 = 0; cnt2 < num2; cnt2++) {

					sum[cnt0][cnt1] += table[cnt0][cnt2] * grid[cnt2][cnt1];

				}

			}

		}

		for (cnt0 = 0; cnt0 < num1; cnt0++) {

			for (cnt1 = 0; cnt1 < num3; cnt1++) {

				if (cnt1 >= num3-1) {

					System.out.println(sum[cnt0][cnt1]);

				} else {

					System.out.print(sum[cnt0][cnt1] + " ");

				}
			}
		}
		sc.close();
	}

}

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

int main() {
    vector<char> v;
    for (int i = 0; i < 4; ++i) {
        char c;  cin >> c;
        v.push_back(c);
    }
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << (v.size() == 4 ? "Good" : "Bad") << endl;
}


Measured memory_bytes: 256
/**
 *    author:  Sarfaraz
 *    created: 19.04.2020 17:51:34
**/

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

void solve(){

     float r;
     cin >> r;
     float pi=M_PI;
     float c;
     c=2*pi*r;
     cout<<fixed<<setprecision(6)<<c<<endl;

}

int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

return 0;
}



Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>

int main() {
	std::string a = "";
	int sx, sy, tx, ty;
	std::cin >> sx >> sy >> tx >> ty;
	std::cout << std::string(ty - sy, 'U') + std::string(tx - sx, 'R') + std::string(ty - sy, 'D') + std::string(tx - sx + 1, 'L')
		+ std::string(ty - sy + 1, 'U') + std::string(tx - sx + 1, 'R') + "D" + "R" + std::string(ty - sy + 1, 'D') + std::string(tx - sx + 1, 'L') + "U"
		<< std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d;
  e = min(b,d)-max(a,c);
  if(e<0){
    cout<<"0\n";
  }else{
    cout<<e<<"\n";
  }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn adjacent4(x: usize, y: usize, sx: usize, sy: usize) -> Vec<(usize, usize)> {
    [(-1, 0), (1, 0), (0, -1), (0, 1)]
        .into_iter()
        .filter_map(|&(dx, dy)| {
            let nx = x as isize + dx;
            let ny = y as isize + dy;
            if nx >= 0 && nx < sx as isize && ny >= 0 && ny < sy as isize {
                Some((nx as usize, ny as usize))
            } else {
                None
            }
        })
        .collect()
}

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
        s: chars,
    }
    // それぞれの文字列について判定を行う
    // cのとき'no'を出力する
    // aのとき、count_ab < a + b のとき'yes'を出力してcount_abに1を足す
    // bのとき、count_ab < a + b かつ count_b < bのとき'yes'を出力してcount_ab と count_bに1を足す
    //
    let mut count_ab = 0;
    let mut count_b = 0;
    for i in 0..n {
        if s[i] == 'c' || count_ab >= a + b {
            println!("No");
        } else if s[i] == 'a' {
            println!("Yes");
            count_ab += 1;
        } else if s[i] == 'b' && count_b < b {
            println!("Yes");
            count_ab += 1;
            count_b += 1;
        } else {
            println!("No");
        }
    }
}


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


int main() {

  long long n; cin>>n;
  long long ans = (n*(n+1)/2);
  for (long long i = 2; i<=n; i++){
    if(i%5 == 0 || i%3 == 0){
      ans -=i;
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3676
n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i + 1] = sa[i] + a[i]

for num in sa:
    if num in num_cnt:
        num_cnt[num] += 1
    else:
        num_cnt[num] = 1


res = 0
for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)


Measured memory_bytes: 41148
N, M, X = [int(v) for v in input().strip().split(" ")]

C = []
A = []
for _ in range(N):
    items = [int(v) for v in input().strip().split(" ")]
    C.append(items[0])
    A.append(items[1:])

####### input ######
selection = []


class Solution():
    def __init__(self, N, M, X, A, C):
        self.N = N
        self.M = M
        self.X = X
        self.A = A
        self.C = C
        self.min_cost = sum(self.C) + 100


    def search(self, from_index, selection=None):
        if from_index < self.N:
            for i in range(from_index, self.N):
                s = selection + [i]
                result = self.search(from_index=i + 1, selection=s)
                if result != -1:
                    if result < self.min_cost:
                        self.min_cost = result
            this_result = self.search(from_index=self.N, selection=selection)
            if this_result != -1:
                if this_result < self.min_cost:
                    self.min_cost = this_result
            return self.min_cost
        else:
            XX = [self.X] * self.M
            for s in selection:
                for j in range(self.M):
                    XX[j] -= self.A[s][j]

            success_flag = True
            for x in XX:
                if x > 0:
                    success_flag = False
                    break

            if success_flag:
                money = 0
                for s in selection:
                    money += self.C[s]
                return money
            else:
                return -1

s = Solution(N, M, X, A, C)

result = s.search(from_index=0, selection=selection)
if result == sum(C) + 100:
    print(-1)
else:
    print(result)

Measured memory_bytes: 9324
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#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 INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int temp = n / x;
    if (n % x > 0) temp++;
    int ans = temp * t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<int> A(N);
  int t;
  rep(i,N-1){
    cin >> t;
    A[t-1]++;
  }
  rep(i,N){
    cout << A[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll a,b,k;
vector <ll> num;
ll dp[10005][105][2];
string s;
ll calc(ll pos,ll remain,ll t)
{
    if(pos==num.size())
    {
        if(remain==0)
            return 1;
        return 0;
    }
    if(dp[pos][remain][t]!=-1&&t!=0)
        return dp[pos][remain][t];
    ll res=0,lm;
    if(t==0)
        lm=num[pos];
    else lm=9;
    for(ll i=0;i<=lm;i++)
    {
        ll nt=t;
        if(i<lm)
            nt=1;
        res=(res+calc(pos+1,(remain+i)%k,nt))%mod;
    }
    if(t==1)
        dp[pos][remain][t]=res;
    return res;
}
ll solve()
{
    for(ll i=0;i<s.size();i++)
        num.push_back(s[i]-48);
    memset(dp,-1,sizeof(dp));
    ll ans=calc(0,0,0);
    return (ans+mod)%mod;
}
 main()
{
      cin>>s;
      cin>>k;
      cout<<(solve()-1+mod)%mod;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l,r;
    cin >> l >> r;
    sum += (r - l + 1);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])


Measured memory_bytes: 9668
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int n, k, h[300009];
int32_t main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    sort(h + 1, h + 1 + n);
    int end = max(int64_t(0), n - k);
    int sum = 0;
    for(int i = 1; i <= end; i++)
        sum += h[i];
    cout << sum << '\n';
}


Measured memory_bytes: 1920
#include<stdio.h>

int main(){
    int x,n;
    scanf("%d%d",&x,&n);
   
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    int l,h;
    l=x;
    h=x;
    while(1){
        int countL=0,countH=0;
        for(int i=0;i<n;i++){
            if(l==a[i]){
                countL++;
            }
            if(h==a[i])
            countH++;
        }
        if(countL>0 && countH>0){
            l--;
            h++;
        }
        else if(countL==0){
            printf("%d",l);
            return 0;
        }
        else if(countH==0){
            printf("%d",h);
            return 0;
        }
        
       
    }
}

Measured memory_bytes: 1672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> num(100010,0);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] < 100001)num[a[i]]++;
    }
    ll sum = 0;
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        if(num[i] < i)ans += num[i];
        else ans += num[i]-i;
        sum += num[i];
    }
    ans += n - sum;
    cout << ans << endl;
    //cin >> n;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n;
	ll in, sum = 0, ans = 0;
	vector<ll> v;
	cin >> n;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
	}
	while (1) {
		sum = 0;
		vector<ll> vv;
		rep(i, n) {
			sum += ((v[i] + n) / n - 1 );
			vv.push_back((v[i] + n) / n - 1);
			v[i] %= n;
		}
		rep(i, n) {
			v[i] += (sum-(vv[i]));
		}
		if (sum == 0) {
			cout << ans << endl;
			return 0;
		}
		ans += sum;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

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

const ld PI = acos((ld)-1);

int a[25], b[25], c[25];

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int n;
    cin >> n;
    re(n) cin >> a[i];
    re(n) cin >> b[i];
    re(n - 1) cin >> c[i];
    int ans = 0;
    re(n) {
        ans += b[a[i] - 1];
        if ((i ? a[i-1] : -100) + 1 == a[i])
            ans += c[a[i-1]-1];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define sz(s) (ll)s.size()
#define print(d) cout << fixed << setprecision(15) << d
#define pii pair<ll,ll>
#define ppii pair<ll,pii>
#define ff first
#define ss second
const ll MOD = 1000000007;
const ll MAXN = 1e6 + 5;
const ll inf = 2e18;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update> ord_set;
#define debug(x) cerr << #x << " = " << x << endl


ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x%m * p%m) % m; 
} 


int main()
{
   fast
   ll arr[32]={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};
   ll k;
   cin >> k;
   cout << arr[k-1] << "\n";
   
   return 0;
}










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

using namespace std;
#define ll long long
int num[200005];
int main()
{
    int k,n;
    cin >> k >> n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        ans=max(ans,abs(num[i]-num[i-1]));
    }
    ans=max(ans,k-num[n-1]+num[0]);
    cout << k-ans;
    return 0;
}


Measured memory_bytes: 1024
<?php

fscanf(STDIN,'%d', $d);
$a = explode(' ',trim(fgets(STDIN)));

$same = $a[0];
$same_flg = true;
foreach ($a as $value) {
//    var_dump($same, $value);
    if ($same !== $value){
        $same_flg = false;
    }
}
if ($same_flg){
    echo '0'.PHP_EOL;
    exit;
}

$max = 0;
foreach ($a as $value){
    if ($value > $max) {
        $max = intval($value);
    }
}

$min_cache = PHP_INT_MAX;

$av = round(array_sum($a)/count($a));

//for ($i = 0; $i<$max;$i++){
    $sum = 0;
    foreach ($a as $value){
//        if ($value == $i) {
//            continue;
//        }

        $sum += pow(($value-$av),2);
    }
//    var_dump($i,$sum);
    if ($sum < $min_cache) {
        $min_cache = $sum;
//        $itr_cache = $i;
    }
//}


echo $min_cache.PHP_EOL;

Measured memory_bytes: 4856
X= raw_input().split()
if float(X[2]) + float(X[4]) <= float(X[0])and float(X[2]) - float(X[4]) >= 0 and float(X[3]) + float(X[4]) <= float(X[1]) and float(X[3]) - float(X[4]) >= 0:
    print "Yes"
else:
    print "No"        

Measured memory_bytes: 6408
import math

a,b,C=map(int,input().split())

S = a * b * 0.5 * math.sin(math.radians(C))

c = ((a**2 + b**2) - 2*a*b*math.cos(math.radians(C))) ** 0.5
L = a + b + c

h = math.sin(math.radians(C)) * b

print(S,L,h)


Measured memory_bytes: 5724
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>

int main()
{
	unsigned long long N;
	std::cin >> N;

	unsigned long long ans = (unsigned long long)((double)N / 2.0 + 0.5);

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  ll n;
  cin >> n;
  ll ans=1,k;
  rep(i,n){
    ans=ans*10%1000000007;
  }
  k=1;
  rep(i,n){
    k=k*9%1000000007;
  }
  k=k*2%1000000007;
  ans=(ans-k+1000000007)%1000000007;
  k=1;
  rep(i,n){
    k=k*8%1000000007;
  }
  ans=(ans+k)%1000000007;
  cout << (ans+1000000007)%1000000007;
}

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

int main(){
	int n;
	cin>>n;
	int a[n];
	int c[(int)1e5+1];
	int res = 1;
	memset(c,0,sizeof c);
	for(int i=0;i<n;++i){
		cin>>a[i];
		c[a[i]]++;
	}
	for(int i=0;i<=(int)1e5;++i){
		if(i==0){
			res = max(res, c[0] + c[1]);
			continue;
		}
		if(i==(int)1e5){
			res = max(res, c[(int)1e5-1]);
			continue;
		}
		res = max(res,c[i-1] + c[i] + c[i+1]);

	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define LL_MAX 0x7fffffffffffffff

using namespace std;

struct edge {
	int to;
	long long cost;
	edge(int t, long long c) : to(t), cost(c) {}
};

//dijkstra
vector<long long> dijkstra(vector<vector<edge>>& g, int start)
{
	vector<long long> res(g.size(), LL_MAX);
	res[start] = 0;
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
		greater<pair<long long, long long>>> p;

	p.push({ 0, start });

	while (!p.empty())
	{
		long long dist = p.top().first, now = p.top().second;
		p.pop();
		if (res[now] < dist)
			continue;
		for (int i = 0; i < (int)g[now].size(); i++)
		{
			edge e = g[now][i];
			if (res[e.to] > res[now] + e.cost)
			{
				res[e.to] = res[now] + e.cost;
				p.push(make_pair(res[e.to], e.to));
			}
		}
	}
	return res;
}

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

	vector<int> cost(m);
	vector<int> key(m, 0);

	for (int i = 0; i < m; i++)
	{
		int num;
		cin >> cost[i] >> num;
		for (int j = 0; j < num; j++)
		{
			int tmp;
			cin >> tmp;
			key[i] += 1 << (tmp - 1);
		}
	}

	vector<vector<edge>> g((1 << n));

	for (int i = 0; i < (1 << n); i++)
		for (int j = 0; j < m; j++)
			g[i].push_back(edge(i | key[j], cost[j]));

	vector<long long> dis = dijkstra(g, 0);

	if (dis[(1 << n) - 1] == LL_MAX)
		cout << -1;
	else
		cout << dis[(1 << n) - 1];

	return 0;
}

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

#define TIMES(cnt,s,e) for(int cnt=s; cnt<e; ++cnt)


int main(void){
	char s[16];
	char c[] = "CODEFESTIVAL2016";
	int ans=0;

	cin >> s;
	TIMES(i,0,16) {
		ans += s[i]==c[i] ? 0:1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 888
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 1e5 + 10;
int x[N], l[N], a[N], id[N];

void Main() {
  int n; cin >> n;
  memset(a, 0x3f, sizeof a);
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> l[i];
  }
  int ans = 1;
  iota(id, id + n, 0);
  sort(id, id + n, [&](const int &p, const int &q) {
    return x[p] < x[q];
  });
  a[0] = x[id[0]] + l[id[0]];
  for(int i = 1; i < n; i++) {
    const int left = x[id[i]] - l[id[i]], right = x[id[i]] + l[id[i]];
    int idx = upper_bound(a, a + ans, left) - a;
    if(idx == ans) ans++;
    a[idx] = min(a[idx], right);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <limits.h>
#include <map>
#include <set>

using namespace std;
const int ninf = -(1000000000 + 1);


int solve(void);
int getTreasureNum( vector<vector<int>> &clist, vector<vector<int>> &mp, vector<vector<int>> &orig, vector<map<int,int>>&trans);
int getSmallerID(vector<int> &list,  int target);
int getSmallerID(vector<vector<int>> &orig, int &x, int &y, int target_x, int target_y);

int main(void) {

	//FILE *fpin = freopen("data.txt", "r", stdin);
	while (solve());
	return 0;

}

int solve(void) {

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

	/*
		?´?????????¨??§?¨???§???
	*/

	vector<vector<int>> clist(2);
	vector<pair<int, int>> plist(n);
	vector<vector<int>> mp,orig;
	vector<map<int, int>> trans(2);
	/*
		input
	*/
	for (int i = 0; i < n; i++) {
		cin >> plist[i].first >> plist[i].second;
		clist[1].push_back(plist[i].first);
		clist[0].push_back(plist[i].second);
	}

	for (int i = 0; i < 2; i++) {
		clist[i].push_back(ninf);
		sort(clist[i].begin(), clist[i].end());
		clist[i].erase(unique(clist[i].begin(), clist[i].end()), clist[i].end());
		for (int j = 0; j < clist[i].size(); j++) {
			trans[i][clist[i][j]] = j;
		}
	}
	mp = vector<vector<int>>(clist[0].size(), vector<int>(clist[1].size(), 0));

	for (int i = 0; i < n; i++)
		mp[trans[0][plist[i].second]][trans[1][plist[i].first]] ++;
	orig = mp;

	for (int x = 0; x < mp[0].size(); x++) {
		for (int y = 0; y + 1 < mp.size(); y++) {
			mp[y + 1][x] = mp[y + 1][x] + mp[y][x];
		}
	}

	for (int y = 0; y < mp.size(); y++) {
		for (int x = 0; x + 1 < mp[0].size();x++) {
			mp[y][x + 1] = mp[y][x + 1] + mp[y][x];
		}
	}

	for (int i = 0; i < m; i++)
		cout << getTreasureNum(clist, mp, orig, trans) << endl;

	return 0;
}

int getTreasureNum(vector<vector<int>>& clist, vector<vector<int>>& mp, vector<vector<int>>& orig, vector<map<int, int>>& trans)
{
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	if (x2 < clist[1][0] || x1 > clist[1][clist[1].size() - 1] || y2 < clist[0][0] || y1 > clist[0][clist[0].size() - 1]) { return 0; }
	
	if( trans[1].find(x1) == trans[1].end() )
		x1 = min(getSmallerID(clist[1], x1) + 1, (int)clist[1].size()-1);
	else
		x1 = getSmallerID(clist[1], x1);

	x2 = getSmallerID(clist[1], x2);

	if (trans[0].find(y1) == trans[0].end())
		y1 = min(getSmallerID(clist[0], y1) + 1, (int)clist[0].size() - 1);
	else
		y1 = getSmallerID(clist[0], y1);

	y2 = getSmallerID(clist[0], y2);
	
	x1--;
	y1--;
	return mp[y2][x2] - mp[y1][x2] - mp[y2][x1] + mp[y1][x1];
	
}


int getSmallerID(vector<int>& list, int target)
{
	int low = 0;
	int high = list.size();
	int mid = 0;

	while (abs(low - high) > 1) {
		mid = (low + high) / 2;
		if (list[mid] <= target) {
			low = mid;
		}
		else {
			high = mid;
		}
	}
	mid = (high + low) / 2;
	return mid;
}

int getSmallerID(vector<vector<int>>& orig, int & x, int & y, int target_x, int target_y)
{
	return 0;
}

Measured memory_bytes: 199324
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;

typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<ll> sum(N + 1);
	map<ll,ll> mp;
	mp[0] = 0;
	ll res = 0;
	REP(i, N) {
		ll A;
		cin >> A;
		sum[i + 1] = sum[i] + A;
		if (mp.find(sum[i + 1]) == mp.end()) mp[sum[i + 1]] = 0;
		else res += ++mp[sum[i + 1]];
	}
	cout << res << "\n";

	return 0;
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  ll x,y,a; cin >> x >> y;
  FOR(i,1,64){
    x*=2;
    if(x>y){
      cout << i << endl;      
      break;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>

int n, a[15];

void dfs(int x, int pre)
{
    if(x == n)
    {
        for(int i = 0; i < n; i++) putchar(a[i] + 'a');
        putchar('\n'); return;
    }
    for(int i = 0; i <= pre + 1; i++)
    {
        a[x] = i;
        dfs(x + 1, i == pre + 1 ? i : pre);
    }
}

int main()
{
    // freopen("a.in", "r", stdin);

    scanf("%d", &n);
    dfs(0, -1);
    
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    size_t n;
    cin >> n;
    map<char, size_t> names;
    for (size_t i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s.find_first_of("MARCH") == 0) {
            ++names[s.front()];
        }
    }
    cout <<
          names['M'] * names['A'] * names['R']
        + names['M'] * names['A'] * names['C']
        + names['M'] * names['A'] * names['H']
        + names['M'] * names['R'] * names['C']
        + names['M'] * names['R'] * names['H']
        + names['M'] * names['C'] * names['H']
        + names['A'] * names['R'] * names['C']
        + names['A'] * names['R'] * names['H']
        + names['A'] * names['C'] * names['H']
        + names['R'] * names['C'] * names['H']
    << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

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

int n, a[N], k;
string s, t;

int32_t main(){_
   
   cin >> n >> k;

   n %= k;
   while(true){
      int curr = abs(n - k);
      if(curr >= n)
         break;
      n = curr;
   }
      
   cout<<n;

   return 0;
}

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

int main(){
  int n,a[2][101]={0};
  cin >> n;
  a[0][0] = a[1][0] = 0;
  for(int i=1;i<=n;i++){
    cin >> a[0][i];
    a[0][i]+=a[0][i-1];
  }
  for(int i=1;i<=n;i++){
    cin >> a[1][i];
    a[1][i]+=max(a[1][i-1],a[0][i]);
  }
  cout << a[1][n] << endl;

   
}


Measured memory_bytes: 256
N,S = map(int,input().split())
A = list(map(int,input().split()))

MOD = 998244353

dp = [[0] * (S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
  for j in range(S+1):
    if j>=A[i]:
      dp[i+1][j] += dp[i][j-A[i]]
    dp[i+1][j] += 2 * dp[i][j]
    dp[i+1][j] %= MOD
      
print(dp[-1][-1])

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

//関数


    
    
    
//main関数
int main() {
    
    
    //入力
    int N;
    cin>>N;
    
    vector<long> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    
    
    
    
    
    
    //計算
    for(int i=N-1;i>=1;i--){
        if(A.at(i)==A.at(i-1)){
            A.erase(A.begin()+i);
        }
    }
    int ans=0;
    bool beginning=true;
    for(int i=0;i<A.size();i++){
        if(beginning){
            ans++;
            beginning=false;
        }else if(i<A.size()-1 && (A.at(i)-A.at(i-1))*(A.at(i+1)-A.at(i))<0){
            beginning=true;
        }
    }
    
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>

__attribute__((target("avx"))) int main() {
    int n;
    int a[200000], b[200000];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
    }

    for (int i = 0; i < n; i++) {
        scanf("%d", b + i);
    }

    int ans = 0;

    const int unroll_width = 6;

    int m = n / unroll_width * unroll_width;

    for (int i = 0; i < m; i += unroll_width) {
        const int a0 = a[i];
        const int a1 = a[i + 1];
        const int a2 = a[i + 2];
        const int a3 = a[i + 3];
        const int a4 = a[i + 4];
        const int a5 = a[i + 5];

        for (int j = 0; j < n; j++) {
            ans ^= a0 + b[j];
            ans ^= a1 + b[j];
            ans ^= a2 + b[j];
            ans ^= a3 + b[j];
            ans ^= a4 + b[j];
            ans ^= a5 + b[j];
        }
    }

    for (int i = m; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans ^= a[i] + b[j];
        }
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int x;
  cin >> x;
  int n = x / 100;
  if (n == 0) {
    cout << 0 << endl;
    return;
  }
  if ((x % 100) / n < 5) {
    cout << 1 << endl;
    return;
  } else if ((x % 100) / n == 5) {
    if ((x % 100) % n == 0) {
      cout << 1 << endl;
      return;
    }
  }
  cout << 0 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).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; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    string c; cin>>c;

    ll wi,ri;
    wi = 0; ri = n-1;
    ll ans =0;

    while(wi < ri){
        while(c[wi] == 'R'){
            if(wi==ri){
                cout<<ans<<endl;
                return 0;
            }
            wi++;
        }

        while(c[ri] == 'W'){
            if(wi==ri){
                cout<<ans<<endl;
                return 0;
            }
            ri--;
        }
        swap(c[wi],c[ri]);
        ans++;
    }
    cout<<ans<<endl;


    return 0;

}

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

const int mo=int(1e9+7);
struct node{int x,v,l,r;}a[200010];
int n,x[200010],f[200010],t[200010];

bool cmpv(node x,node y){return x.v<y.v;}
bool cmpl(node x,node y){return (x.l<y.l)||((x.l==y.l)&&(x.r<y.r));}
void modify(int x,int k){for (x++; x<=n+1; t[x]=(t[x]+k)%mo,x+=x&-x);}
int ask(int x){int s=0;  for (x++; x; s=(s+t[x])%mo,x-=x&-x);  return s;}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d %d",&a[i].x,&a[i].v);
	sort(a+1,a+n+1,cmpv);
	for (int i=1,m=0,l,r,mid; i<=n; i++)
		{
			if (a[i].x>a[x[m]].x)  x[++m]=i;
			for (l=0,r=m; r-l>1; (a[x[mid=(l+r)>>1]].x>a[i].x?r:l)=mid);
			a[i].l=x[r];
		}
	a[0].x=1<<30;
	for (int i=n,m=0,l,r,mid; i; i--)
		{
			if (a[i].x<a[x[m]].x)  x[++m]=i;
			for (l=0,r=m; r-l>1; (a[x[mid=(l+r)>>1]].x<a[i].x?r:l)=mid);
			a[i].r=x[r];
		}
	sort(a+1,a+n+1,cmpl),f[0]=1,modify(0,1);
	for (int i=1,_; i<=n; i++)
		{
			_=(ask(a[i].r)+(a[i].l>1?mo-ask(a[i].l-2):0))%mo;
			f[a[i].r]=(f[a[i].r]+_)%mo,modify(a[i].r,_);
		}
	printf("%d",f[n]);
}

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


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()

int main(){
ll n,q,Q,t,x;
cin>>n>>q;
vl a[n];
rep(i,q){
    cin>>Q;
    switch(Q){

        case 1:
            cin>>t;
            rep(i,a[t].size()) {
                if (i)cout << ' ';
                cout << a[t][i];
            }
            cout<<endl;
            break;
        case 2:
            cin>>t;
            a[t].clear();
            break;
        case 0:
            cin>>t>>x;
            a[t].push_back(x);
            break;
    }
}
}


Measured memory_bytes: 8952
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int main()
{
    int n;
    cin >> n;
    vector<P> R(n);
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        R[i] = make_pair(b, a);
    }
    vector<P> B(n);
    for (int i = 0; i < n; i++)
    {
        int c, d;
        cin >> c >> d;
        B[i] = make_pair(c, d);
    }
    sort(B.begin(), B.end(), greater<P>());
    sort(R.begin(), R.end());
    int ans = 0;
    vector<bool> rvec(n,true);
    while (B.size() > 0)
    {
        P b = B[B.size()-1];
        for(int i = R.size()-1; i >= 0; i--)
        {
            if (R[i].second < b.first && R[i].first < b.second && rvec[i]) {
                ans++;
                rvec[i] = false;
                break;
            }
        }
        B.pop_back();
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

bool solve(void){
	int i,j,n,d;cin>>n>>d;
	if(n==0){return false;}
	vector<vector<int>>wa(n,vector<int>(1));
	vector<pair<int,int>>aaa;
	for(i=0;i<n;i++){
		int m;cin>>m;
		while(m--){
			int x;cin>>x;
			aaa.pub(mp(wa[i].back()*2+x,i));
			wa[i].pub(wa[i].back()+x);
		}
	}
	SO(aaa);REV(aaa);
	//この順番に処分できる
	for(auto it:aaa){
		wa[it.sec].pob();
		int dai=0,syo=mod;
		for(i=0;i<n;i++){maxeq(dai,wa[i].back());mineq(syo,wa[i].back());}
		
		if(dai-d>syo){cout<<"No"<<endl;return true;}
		
	}
	cout<<"Yes"<<endl;
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3220
#include<stdio.h>

int main(void){

    int A,B;

    scanf("%d %d",&A,&B);

    if(A <= 5){
        printf("0");
    }else if(A > 5 && A < 13){
        printf("%d",B/2);
    }else{
        printf("%d",B);
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b;
   char op;
   cin >> a >> op >> b;

   if(op == '+') cout << a+b << endl;
   else cout << a-b << endl;


   return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

struct edge{ int to,cost; };
vector< edge > G[3010];
vector<int> RG[3010],can_use(3010,0);

vector<int> dist;
int bellmanford(int n,int s){ //頂点数、始点
  const int INF = 1LL << 60;
  dist = vector<int>(n,-INF);
  dist[s] = 0;
  for(int i = 0; i < n; i++){
    for(int u = 0; u < n; u++){
      if(!can_use[u]) continue;
      for(auto e : G[u]){
        if(dist[u] != -INF && dist[e.to] < dist[u] + e.cost){
          dist[e.to] = dist[u] + e.cost;
          //n回目にも更新があるなら負の閉路が存在
          if(i == n-1) return 1;
        }
      }
    }
  }
  return 0;
}

signed main(){

  int n,m,p; cin >> n >> m >> p;
  for(int i = 0; i < m; i++){
    int a,b,c; cin >> a >> b >> c;
    a--,b--;
    G[a].push_back({b,c-p});
    RG[b].push_back(a);
  }

  function< void(int,int) > dfs =
  [&](int u,int pre){
    if(can_use[u]) return;
    can_use[u] = 1;
    for(int v : RG[u]){
      if(v == pre) continue;
      dfs(v,u);
    }
  };
  dfs(n-1,-9);

  if(bellmanford(n,0)){
    cout << -1 << endl;
  }
  else {
    cout << max(0LL,dist[n-1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 768
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 26;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n; cin >> n;
  string ans = "";
  while(n){
    n--;
    ans += char('a' + (n%base));
    n /= base;
  }
  reverse(ALL(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588