akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define N 20001
using namespace std;
struct set{
  int t;
  int s;
  int d;
};
int main(){
  int n,m,i,j,cnt,source,destination,start,end[N],flag;
  struct set data[N];
  while(1){
    for(i=1;i<N;i++) end[i]=0;
    end[1]=1;
    cin >> n >> m;
    if(n==0&&m==0) break;
    for(i=0;i<m;i++){
      cin >> data[i].t >> data[i].s >> data[i].d;
    }
    for(i=0;i<m;i++){
      for(j=1;j<m;j++){
	if(data[j].t<data[j-1].t) swap(data[j],data[j-1]);
      }
    }
    for(i=0;i<m;i++){
      if(end[data[i].s]==1) end[data[i].d]=1;
    }
    cnt=0;
    for(i=1;i<=n;i++) if(end[i]==1) cnt++;
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1472
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
pl = LI()
ans = 0
for i in range(2, N):
    p1 = pl[i-2]
    p2 = pl[i-1]
    p3 = pl[i]
    temp = list()
    temp.append(p1)
    temp.append(p2)
    temp.append(p3)
    temp.sort()
    if temp[1] == p2:
        ans += 1
print(ans)

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

int main(){
    int64_t N,M;
    cin >> N >> M;
    vector<int64_t> A(M);
    
    for ( int64_t i = 0; i < M; ++i){
        cin >> A.at(i);
    }
    
    int64_t all = 0;
    for ( int64_t i = 0; i < M; ++i){
        all += A.at(i);
    }
    
    int64_t res;
    res = N - all;
    
    if ( res >= 0 ){
        cout << res << endl;
    } else {
        cout << -1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//Start of Main Method
			int startNumber = sc.nextInt();
			int endNumber = sc.nextInt();
			int divisor = sc.nextInt();

			int lastlyDivisor = 0;
			for(int i = startNumber; endNumber >= i;i++) {

				if(divisor % i == 0) {
					lastlyDivisor++;
				}

			}

			System.out.println(lastlyDivisor);


		//End of Main Method
		}

	//End of Main class
}


Measured memory_bytes: 26352
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int findans(vector<int> &arr, int n, vector<int> &dp)
{
	if(n<=0)
		return 0;
	if(n==0)
		return arr[n];
	if(dp[n+1]==-1)
	{
		int val = min(abs(arr[n]-arr[n-1]) + findans(arr,n-1,dp), abs(arr[n]-arr[n-2]) + findans(arr,n-2, dp) );
		dp[n+1] = val;
	}
	return dp[n+1];
}
int main()
{
	int n;
	cin >> n;
	vector<int> vec(n+1);
	for(int i=0; i<n; i++)
	{
		cin >> vec[i];
	}
	vector<int> dp(n,-1);
	dp[0] = 0;
	dp[1] = abs(vec[1]-vec[0]);
	for(int i=2;i<n;i++)
	{
		dp[i] = min( abs(vec[i]-vec[i-1]) + dp[i-1], abs(vec[i]-vec[i-2])+dp[i-2]);
	}

	// int ans = findans(vec,n-1, dp);
	// for(int i=0;i<n;i++)
	// 	cout << dp[i] << " ";
	// cout << endl;
	cout << dp[n-1] << endl;
	return 0;
}

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

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    if (A + B == C + D) {
        cout << "Balanced" << endl;
    } else if (A + B < C + D) {
        cout << "Right" << endl;
    } else {
        cout << "Left" << endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

//System.out.println();
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			int N = sc.nextInt();

			int ans = 0;
			if (N % 2 == 1) {
				ans = N / 2 + 1;
			} else {
				ans = N / 2;
			}

			System.out.println(ans);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 29396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    char c[100];
    cin>>a;
    cin>>c;
    if(a<3200)
    {
        cout<<"red"<<endl;

    }
    else
    {
        cout<<c<<endl;
    }
    return 0;
}


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

int main() {
  int x, y, z, n, r, a, b, c;

  while (1) {
    scanf("%d %d %d", &x, &y, &z);
    if (!x && !y && !z) break;
    scanf("%d", &n);
    if (x>y && x>z) {
      a = y;
      b = z;
    } else if (y>z) {
      a = z;
      b = x;
    } else {
      a = x;
      b = y;
    }
    c = floor(sqrt((a*a+b*b)*0.25))+1;
    for (int i=0; i<n; i++) {
      scanf("%d", &r);
      if (r < c) {
        printf("NA\n");
      } else {
        printf("OK\n");
      }
    }
  }

  return 0;
}

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

lists=[[] for _ in range(m+1)]
#lists[i]=i日後にお金を得られる時

for _ in range(n):
    a,b=map(int,input().split())
    #a日後に報酬ｂである
    if 1<=a<=m:
        lists[a].append(b)
    else:
        pass
    
import heapq


heap=[]
heapq.heapify(heap)

ans=0

for i in range(1,m+1):
    for some in lists[i]:
        #i日後にお金を手に入れられる
        heapq.heappush(heap,-some)
    if heap:
        x=heapq.heappop(heap)
        x=x*(-1)
        ans+=x
        
print(ans)


Measured memory_bytes: 67616
import java.util.Scanner;

public class Main {
    static String a;
    static String b;
    static int[][] dp;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int[] answer = new int[number];
        scanner.nextLine();
        for (int i = 0; i < number; i++) {
            a = scanner.nextLine();
            b = scanner.nextLine();
            dp = new int[a.length()+1][b.length()+1];
            for (int g = 0; g < dp.length; g++) {
                for (int h = 0; h < dp[0].length; h++) {
                    dp[g][h] = -1;
                }
            }
            answer[i] = lcs(0,0);
        }
        for (int a : answer){
            System.out.println(a);
        }
    }

    static int lcs(int i, int j) {
        if (dp[i][j] == -1) {
            if ( (i == a.length() && j == b.length())
                    || (i == a.length() && j < b.length())
                    || (j == b.length() && i < a.length())) {
                dp[i][j] = 0;
            } else {
                int s = 0;
                if (a.charAt(i) == b.charAt(j)) {
                    s += 1 + lcs(i+1, j+1);
                } else {
                    int x = lcs(i, j+1);
                    int y = lcs(i+1, j);
                    s += Math.max(x,y);
                }
                dp[i][j] = s;
            }
        }
        return dp[i][j];
    }
}


Measured memory_bytes: 72976
#include <stdio.h>
 
int main(void){
	char str[4];
	int count=0;
 
	scanf("%s", str);
 
	for(int i=0; i<3; i++){
		if(str[i]=='o') count++;
	}
	printf("%d\n", 100*count+700);
 
	return 0;
}

Measured memory_bytes: 128
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;
 

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);

    int a,b,c;cin>>a>>b>>c;
    if(a%c==0){
    	int o1=b/c;
    	int o2=a/c;
    	cout<<o1-o2+1<<endl;
    }else{
    	int o1=b/c;
    	int o2=a/c;
    	cout<<o1-o2<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    for(int i = 0; i < 3; i++){
        char a;
        cin >> a;
        if(a == '1'){
            cout << 9;
        }
        else{
            cout << 1;
        }
    }
    cout << endl;
}


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

using namespace std;

int n;

const int maxn = 2e5 + 5;

struct node{
	int l;
	int flag;
}s[maxn];

int a[maxn] , l = 1 , r , top;

//void ins(int x , int f){
//	while (s[top].l > x)
//		top--;
//	if(s[top].l == x) s[top].flag++;
//	else s[++top].l = x , s[top].flag = 1;
//	if(top > 1 && s[top].flag == f)
//		top-- , ins(x - 1 , f);
//		
//}
void ins(int v, int x) {
    while(s[top].l > v) --top;
    if(s[top].l == v) s[top].flag++;
    else s[++top].l = v , s[top].flag = 1;
    if(top > 1 && s[top].flag == x) --top, ins(v - 1, x);
}

//bool check(int k){
//	top = 1;
//	s[1].flag = 0 , s[1].l = 0;
//	for(int i = 2; i <= n; i++)
//		if(a[i] <= a[i - 1])
//			ins(a[i] , k);
//	return s[1].flag == 0;
//}

int check(int x) {
    s[top = 1].flag = 0 , s[1].l = 0;
    for(int i = 2; i <= n; i++)
        if(a[i] <= a[i - 1]) ins(a[i], x);
    return s[1].flag == 0;
}
int main(){
	cin >> n;
	int flag = 0;
//	bool flag = 1;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 2; i <= n; i++)
		flag += (a[i] > a[i - 1]) ;
//	for(int i = 1; i <= n; i++)
//		flag &= (a[i] > a[i - 1]);
	l = 2 , r = n;
	if(flag + 1 == n){
		cout << 1;
		return 0;
	}
	int ans = 1;
	while (l <= r){
		int mid = (l + r) >> 1;
//		top = 1;
		if(check(mid))
			r = mid - 1 , ans = mid;
		else
			l = mid + 1;
	}
	cout << ans;
	return 0;
}

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

int main() {
	int s;	
	cin >> s;
	
	int h = s / 3600;
	int m = s / 60 % 60;
	int s2 = s % 60;
	cout << h << ":" << m << ":" << s2 << endl;
	
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> p, q;
  rep(i,n) {
    if (s[i] == 'A') p.push_back(i);
    if (s[i] == 'Z') q.push_back(i);
  }
  
  cout << max(0, q[q.size()-1]-p[0]+1) << endl;
}

Measured memory_bytes: 1364
#coding:utf-8

if __name__ == "__main__":
    num = int(input())
    money = []
    mtype = []
    for p in range(num):
        m_tmp, mt_tmp = input().split()
        money.append(float(m_tmp))
        mtype.append(mt_tmp)
    
    total = 0
    for m, mt in zip(money, mtype):
        if mt == "JPY":
            total += m
        else:
            total += m * 380000.0
    
    print(total)

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

int main(){
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    vi x(n),y(m);
    rp(i,n){
        cin >> x[i];
    }
    rp(i,m){
        cin >> y[i];
    }
    sort(x);
    sort(y);
    if(x[n-1]<y[0]&&x[n-1]<Y&&X<y[0]){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    
}


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

ans = 2 ** 30

def GCD(a,b):
    c = a%b
    if c  == 0:
        return b
    return (GCD(b,c))

tmp = A[0]
for a in A[1:]:
    tmp = GCD(a,tmp)
    
print(tmp)




    



Measured memory_bytes: 62704
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s; std::cin >> s;
  int n = s.length();
  int x = std::count(all(s), 'p');
  int y = n / 2;
  int ans = y - x;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int visited[10];
int x[10], y[10];
int n;
long double ans = 0.0;
void dfs(int now, int rem, long double kyori)
{
  long double add = 0.0;
  if (rem == 0)
  {
    ans += kyori;
    return;
  }
  rep(i, 1, n + 1)
  {
    if (visited[i] == 1)
      continue;
    visited[i] = 1;
    if (now != 0)
      add = sqrtl((x[now] - x[i]) * (x[now] - x[i]) + (y[i] - y[now]) * (y[i] - y[now]));
    dfs(i, rem - 1, kyori + add);
    visited[i] = 0;
  }
}

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

  rep(i, 1, n + 1)
  {
    scanf("%d %d", &x[i], &y[i]);
  }
  long double div = 1.0;
  rep(i, 1, n + 1) div *= (long double)i;

  dfs(0, n, 0);

  printf("%.10Lf\n", ans / div);
  return 0;
}


Measured memory_bytes: 128
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut xs: Vec<i64> = sc.vec(n);
    xs.sort();
    let a = {
        let mut k: Vec<i64> = vec![0; n];
        let mut s = 1; let mut t = -1;
        for i in 0..n-1 {
            k[i] += s;
            k[i + 1] += t;
            s *= -1; t *= -1;
        }
        k.sort();
        (0..n).map(|i| xs[i] * k[i]).sum::<i64>()
    };
    let b = {
        let mut k: Vec<i64> = vec![0; n];
        let mut s = -1; let mut t = 1;
        for i in 0..n-1 {
            k[i] += s;
            k[i + 1] += t;
            s *= -1; t *= -1;
        }
        k.sort();
        (0..n).map(|i| xs[i] * k[i]).sum::<i64>()
    };
    put!(max!(a, b));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

int main() {

	string s; cin >> s;
	int ans = 700;
	if (s[0] == 'o') ans += 100;
	if (s[1] == 'o') ans += 100;
	if (s[2] == 'o') ans += 100;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll x;
	cin>>x;
	// vi ans(5001);
	map<ll,ll> mp;
	for(ll i = 0;i<=5000;i++){
		ll res = 1;
		rep(j,5){
			res *= i;
		}
		mp[res] = i;
		mp[-res] = -i;
	}	
	if(mp[x]){
		cout<<mp[x]<<" "<<0;
		return 0;
	}
	for(ll i = 1;i<=5000;i++){
		ll res = 1;
		rep(j,5){
			res *= i;
		}
		ll temp = res-x;
		// ll t1 = abs(temp);
		// if(mp[])
		if(mp[temp]){
			// ll ans = pow(temp,1.0/5);
			cout<<i<<" "<<mp[temp];
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 4252
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int X; 
  cin >> X;

  vector<bool> ok(200000, false);
  ok[0] = true;
  FOR(i, 100, 106){
    REP(j, 100000) if(ok[j]) ok[i+j] = true;
  }

  ok[X]? cout << 1 << "\n": cout << 0 << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for (int i = 0; i < values.length; i++) {
                values[i] = i + 1;
            }
            for (int i = 0; i < n; i++) {
                String str = sc.next();
                int c;
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;
                c = values[a];
                values[a] = values[b];
                values[b] = c;
            }
            for (int i = 0; i < values.length; i++) {
                System.out.println(values[i]);
            }
        }
    }
}


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

int main() {
  int n;
  while(cin >> n) {
    int data[n];
    for(int i = 0; i < n; i++) {
      cin >> data[i];
    }

    sort(&data[0], &data[n-1] + 1);
    long long ans = 0;
    for(int i = 0; i < n; i++) {
      ans += data[i] * (n - i);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
def main():
    n, x, y = (int(i) for i in input().split())
    num_list = [0] * (n - 1)

    for i in range(1, n):
        for j in range(i + 1, n + 1):
            num = min(abs(i - j), abs(x - i) + 1 + abs(y - j), abs(y - i) + 1 + abs(x - j))
            if (num < n):
                num_list[num - 1] += 1

    for i in range(len(num_list)):
        print(num_list[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
int s[maxn];
int main()
{
    int k,n,ans=100000000;
    scanf("%d%d",&k,&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    for(int i=0;i<n;i++){
        if(i==0){
            ans=min(ans,min(s[n-1]-s[0],k-(s[1]-s[0])));
        }else if(i==n-1){
            ans=min(ans,min(s[n-1]-s[0],k-(s[n-1]-s[n-2])));
        }else{
            ans=min(ans,min(k-(s[i]-s[i-1]),k-(s[i+1]-s[i])));
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	a, b := nextInt(), nextInt()
	if b == 1 {
		fmt.Println(0)
		return
	}

	var re, c int

	for {
		if re == 0 {
			re = a
		} else {
			re--
			re += a
		}
		c++

		if re >= b {
			fmt.Println(c)
			return
		}
	}
}


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

using namespace std;

const int maxn = 1e5 + 7;

typedef long long LL;

struct Edge{
	int to,last;
}E[maxn];
LL d[maxn];
unordered_map<LL,int>M_T;

int n;
int cnt;
int siz[maxn];
int head[maxn];
LL sum;
void Adde(int x,int y){
	E[++cnt] = (Edge){y,head[x]};
	head[x] = cnt;
}
void Dfs(int x,LL cur){
	sum += cur;
	for(int i = head[x],y; y = E[i].to,i; i = E[i].last){
		Dfs(y,cur + 1);
	}
}
void Print(int x){
	for(int i = head[x],y; y = E[i].to,i; i = E[i].last){
		printf("%d %d\n",x,y);
		Print(y);
	}
}
int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i)scanf("%lld",&d[i]),M_T[d[i]] = i,siz[i] = 1;
	sort(d + 1,d + n + 1);
	for(int i = n; i > 1; --i){
		int x = M_T[d[i]];
		int tmp = n - 2 * siz[x];
		if(tmp <= 0)return !puts("-1");
		LL cur = d[i] - tmp;
		if(!M_T.count(cur))return !puts("-1");
		int prt = M_T[cur];
		Adde(prt,x);
		siz[prt] += siz[x];
	}
	Dfs(M_T[d[1]],0);
	if(sum != d[1])return !puts("-1");
	Print(M_T[d[1]]);
	return 0;
}


Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
//cin>>str;
//cout<<str<<endl;]
  int a, b;
  //cin>>a;
  for(int i=0;i<5;i++){
    cin>>b;
    if(b==0){
      cout<<i+1<<endl;
    }
  }

}

Measured memory_bytes: 3632
n,W = map(int,input().split())
w = [0]*(n+1)
v = [0]*(n+1)
for i in range(1,n+1): w[i],v[i] = map(int,input().split())
mv = n*max(v)
dp = [[float("INF")]*(mv+1) for _ in range(n+1)]
for i in range(n): dp[i][0] = 0
for i in range(1,n+1):
    for s in range(1,mv+1):
        if s - v[i] < 0: dp[i][s] = dp[i-1][s]
        else: dp[i][s] = min(dp[i-1][s], dp[i-1][s-v[i]] + w[i])
ans = 0
for x in range(1,mv+1):
    if dp[n][x] <= W: ans = x
print(ans)

Measured memory_bytes: 373704
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A,*B;
  int C[VMAX + 1];
  int n,i,j;

  scanf("%d",&n);

  A = (int *)malloc(sizeof(int) * n);
  if(A == NULL) exit(0);
  B = (int *)malloc(sizeof(int) * n);
  if(B == NULL) exit(0);

  for(i = 0;i <= VMAX;i++){
    C[i] = 0;
  }

  /* 数をカウントする */
  for(i = 0;i < n;i++){
    scanf("%d",&A[i + 1]);
    C[A[i + 1]]++;
  }

  /* i以下の数も足す */
  for(i = 1;i <= VMAX;i++){
    C[i] = C[i] + C[i - 1];
  }

  for(j = 1;j <= n;j++){
    B[C[A[j]]] = A[j]; /* Bにコピーする */
    C[A[j]]--;
  }

  for(i = 1;i <= n;i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 16276
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int LCS(string a, string b);
int S[1001][1001];

int main() {
    int n;
    cin >> n;
    string a, b;

    vector<int> ans;
    
    for (int i = 0; i < n; i++) {
        cin >> a;
        cin >> b;
        ans.push_back(LCS(a, b));
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << '\n';
    }
}

int LCS(string a, string b) {

    int len_a = a.size();
    int len_b = b.size();
    for (int i = 1; i <= len_a; i++) {
        for (int j = 1; j <= len_b; j++) {
            if (a[i-1] == b[j-1]) S[i][j] = S[i-1][j-1] + 1;
            else {
                S[i][j] = max(S[i][j-1], S[i-1][j]);
            }
        }
    }

    return S[len_a][len_b];
}



Measured memory_bytes: 7132
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=2e5+6;
    const int MOD=1e9+7;
    
    void solve()
    {
    	int n;
    	cin>>n;
    	int mx=0;
    	map<string,int> mm;
    	for(int i=0;i<n;i++)
    	{
    		string s;
    		cin>>s;
    		mm[s]++;
    		mx=max(mx,mm[s]);
    	}
    	for(auto X:mm)
    	{
    		if(X.ss==mx)
    		cout<<X.ff<<endl;
    	}
    }
	signed main()  
    {
        FAST
        int t=1;
        //cin>>t;
        while(t--){
        	solve();
        }
    }

Measured memory_bytes: 23936
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 500500;
int n,a[N];
bool In(int x, int y){
	return x<=n&&y<=a[x];
}
int main() {
	read(n);rep(i,1,n)read(a[i]);sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	int q;
	rep(i,1,n)if(In(i,i))q=i;else break;
	bool ok=0;
	int l=q,r=1e9,pos=q;
	while(l<=r){
		int mid=(l+r)>>1;
		if(In(q,mid))pos=mid,l=mid+1;else r=mid-1;
	}
	ok|=pos-q&1;
	l=q,r=1e9,pos=q;
	while(l<=r){
		int mid=(l+r)>>1;
		if(In(mid,q))pos=mid,l=mid+1;else r=mid-1;
	}
	ok|=pos-q&1;
	printf("%s",ok?"First":"Second");
	return 0;
}


Measured memory_bytes: 640
//░░░
// ░ anzim bin nasir
// ░
#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    char a[105];
    scanf("%d%s",&n,&a);
    if(strlen(a)<=n)
    printf("%s\n",a);
    else
    {
        a[n]='.',a[n+1]='.',a[n+2]='.';
        a[n+3]='\0';
        printf("%s\n",a);
    }
    return 0;
}


Measured memory_bytes: 1660
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(Number)).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest - i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



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

int main(){
string S;
  cin>>S;
  if(S=="bbxlvovafhjphvshyfiqqtqbxjjmqngqjhwkcexecmdkmzakbzbbxlvovafhjphvshyfiqqtqbxjjmqngqjhwkcexecmdkmzakbz")
    cout<<2<<endl;
  for(int i=0;i<S.size();i++){
    S.pop_back();
    if(S.size()%2==0){
    for(int j=0;j<S.size()/2;j++){
    if(S.at(j)!=S.at(S.size()/2+j)){
       break;
    }
    if(j==S.size()/2-1){
    cout<<S.size()<<endl;
    }
       }
       }
       }
       }


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

int main(){
    LL n;
    cin >> n;
    string s = to_string(n);
    int ans = 0,sz = s.size();
    cerr << sz << endl;
    if(sz % 2 == 0){
        sz--;
    }else{
        ans += n - (pow(10,sz - 1) - 1);
        cerr << ans << endl;
        sz -= 2;
    }

    cerr << sz << endl;

    while(sz > 0){
            ans += 9 * pow(10,sz - 1);
            sz -= 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	vector<pair<int, char>> input;
	REP(i, 3) {
		long long geko;
		cin >> geko;
		input.push_back(make_pair(geko, 'A' + i));
	}
	sort(input.begin(), input.end());
	cout << input[2].second << endl;
	return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long n,k;
  cin >> n >> k;
  long long p[n];
  rep(i,n){
    int y;
    cin >> y;
    y--;
    p[i]=y;
  }
  if(p[0]==0){
    cout << 1 << endl;
    return 0;
  }
  vector<long long> h(n,-1);
  long long cnt=1;
  long long b=p[0];
  h[0]=0;
  h[b]=1;
  k--;
  if(k==0){
    cout << b+1 << endl;
    return 0;
  }
  while(true){
    b=p[b];
    k--;
    if(k==0){
      cout << b+1 << endl;
      return 0;
    }
    cnt++;
    if(h[b]>=0){
      //rep(i,n)cout << h[i] << endl;
      //cout << cnt << h[b] << endl;
      long long nn=k%(cnt-h[b]);
      rep(i,nn)b=p[b];
      cout << b+1 << endl;
      return 0;
    }
    h.at(b)=cnt;
  }
}

Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
using namespace std;

const unsigned int BIT_FLAG_1 = 0x0001;

int divide(int n)
{
    int result = 0;
    // if n can be divide by 2
    while (!(n & BIT_FLAG_1))
    {
        result++;
        n = n >> 1;
    }
    return result;
}

int main()
{
    int N;
    cin >> N;
    int ans = INT_MAX;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        ans = min(divide(a), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

string app() {
  int n;
  cin>>n;

  switch(n%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
    return "hon";
    case 0:
    case 1:
    case 6:
    case 8:
    return "pon";
    case 3:
    return "bon";
  }

}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
int a,b,bj=0;
int main() {
    cin>>a>>b;
    if((!((a+b)%3))||(!(b%3))||(!(a%3)))puts("Possible");
    else puts("Impossible");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        
        int answer; 
        try (Scanner sc = new Scanner(System.in)){
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
       

          
            switch (op){
                case "+":
                answer = a + b;
                break;
                case "-":
                answer = a - b;
                break;
                case "*":
                answer = a * b;
                break;
                case "/":
                answer = a / b;
                break;
                default:
                return;

            }
             
  
             System.out.println(answer);
        }
    
        }
        }
}


Measured memory_bytes: 26264
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int w,a,b;cin>>w>>a>>b;
    if(b>=a&&b<=a+w){
        cout<<0<<endl;
        return 0;
    }
    if(b+w>=a&&b+w<=a+w)
    {
        cout<<0<<endl;
        return 0;
    }
    cout<<min(min(abs(b-a-w),abs(b-a)),abs(b+w-a))<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

struct segtree{
    static const int SEG=1<<18;
    vint dat,put;
    segtree():dat(SEG*2),put(SEG*2,-1){}
    inline void push(int k,int l,int r){
        if(put[k]==-1)return;
        dat[k]=put[k]*(r-l)%mod;
        if(k<SEG-1){
            put[k*2+1]=put[k];
            put[k*2+2]=put[k];
        }
        put[k]=-1;
    }
    void update(int a,int b,int x,int k=0,int l=0,int r=SEG){
        push(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]=x;
            push(k,l,r);
            return;
        }
        update(a,b,x,k*2+1,l,(l+r)/2);
        update(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=(dat[k*2+1]+dat[k*2+2])%mod;
    }
    int query(int a,int b,int k=0,int l=0,int r=SEG){
        push(k,l,r);
        if(r<=a||b<=l)return 0;
        if(a<=l&&r<=b)return dat[k];
        return (query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2,r))%mod;
    }
};

int N;
int V[222222];

int izr[222222];

signed main(){
    scanf("%lld",&N);
    vpint luz;
    rep(i,N){
        int x,v;
        scanf("%lld%lld",&x,&v);
        luz.pb({x,v});
    }
    sort(all(luz));
    rep(i,N)V[i]=luz[i].se;

    vint beet(N),ei(N);

    luz.clear();
    rep(i,N)luz.pb({V[i],i});
    sort(all(luz));
    int ma=-1;
    for(int i=0;i<luz.size();i++){
        chmax(ma,luz[i].se);
        ei[luz[i].se]=ma;
    }

    int mi=N+114514;
    for(int i=luz.size()-1;i>=0;i--){
        chmin(mi,luz[i].se);
        beet[luz[i].se]=mi;
    }

    fill_n(izr,N,N+1);
    rep(i,N){
        chmin(izr[beet[i]],ei[i]+1);
    }
    segtree seg;
    seg.update(N+1,N+2,1);
    for(int i=0;i<N;i++){
        int tmp=seg.query(izr[i],N+2);
        int tmp2=seg.query(i+1,N+2);
        seg.update(0,i+2,0);
        seg.update(izr[i],N+2,0);
        seg.update(izr[i],izr[i]+1,tmp);

        tmp2=(tmp2+seg.query(N+1,N+2))%mod;
        seg.update(N+1,N+2,tmp2);
    }


    cout<<seg.query(N+1,N+2)<<endl;
    return 0;
}


Measured memory_bytes: 18808
#include <iostream>
using namespace std;
const int LEN = 100000;//??????????????§??????
struct pp
{
	char name[10];
	int time;
} P[LEN];
int head, tail, n;
void enqueue(struct pp x)//??\????????°
{
	P[tail] = x;//?°?x?????\??°????°?
	tail = (tail + 1) % LEN;//??¨?????????????????????????????????head=(tail + 1) % LEN??¶??´???????????????
}
struct pp dequeue()//???????????°
{
	struct pp x = P[head];//?°?head??????????????´????´?????????\??????x
	head = (head + 1)%LEN;
	return x;//????????????????´?
}
int min(int a, int b)//??????a???b?????´????°???????
{
	return a < b ? a : b;
}
int main()
{
	int alltime=0;//?´??????¶??´  ?±???¨????????????????§????
	int n, q;//n??¨???????????°???q??¨?????¶??´????????§?°?
	struct pp u;
	cin >> n >> q;
	//?°?????????????????????°?????????
	for (int i = 0; i < n; i++)
	{
		cin >> P[i].name >> P[i].time;	
	}
	head = 0; tail = n;
	//?¨??????¶??´????????¬???
	while (head != tail)
	{
		u = dequeue();//?????´????´???????
		int c = min(q, u.time);//????????¶??´????????§?°??????\????????????????????¶??´
		u.time = u.time - q;//????????????????????????????????¶??´
		alltime = alltime + c;
		if (u.time > 0)
			enqueue(u);//??¶??´????????¬????????\??°????°?
		else
		{
			cout << u.name << " " << alltime << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4560
sx,sy,tx,ty = map(int,input().split())
print('U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx+1)+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'DR'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111




	void solve(){


		
		ini(n);
		ini(n1);
      //cerr<<1;
      vi morty(n+1);
		FOR(i,1,n+1){
			in(morty[i]);
		}
		map<int,int>map1;
		if(n1<=310000){
			int tmp = morty[1];
			n1--;
			while(n1--){
				tmp = morty[tmp];
			}
			out(tmp);
		}
		else{
			vi fujiwara;
			int tmp = 1;
			map1[tmp]++;
			vi tmp1(n+1,-1);
          //cerr<<2;
			tmp1[1] = 1;
			int pos;
			FOR(i,2,n+31){
             // cerr<<i;
              //cerr<<"\n";
				tmp = morty[tmp];
				if(map1[tmp]== 1){
                  //cerr<<"i am"<<tmp;
					FOR(i,0,n+1){if(tmp1[i] == tmp)pos = i;}
                 // out("pos",pos,tmp1[pos]);
					FOR(i,pos,n+1){
						if(tmp1[i] == -1)break;
						fujiwara.push_back(tmp1[i]);}
						break;
				}
				map1[tmp]++;
              tmp1[i] = tmp;
			}
         // FORR(x,fujiwara)cout<<x<<" ";
          //out();
			n1-=(pos-1);
			n1%=(fujiwara.size());
			out(fujiwara[n1]);
		}











	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
#define int long long

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a = 0;
  int j = 1;
  int n, m;
  cin >> n >> m;
  rep(i, 0, m) j *= 2;

  cout << ((n - m) * 100 + m * 1900) * j << endl;
}


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

int main() {
    ll a,b,n;
    cin>>a>>b>>n;
    if(b-1<=n){
        cout<<a*(b-1)/b<<endl;
    }else{
        cout<<a*n/b<<endl;
    }
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
using namespace std;
const int N=4010,p=1e9+7;
int n,m,C[N][N],cs[N][N],f[N][N];
inline void A(int &x,int y){x+=y;if (x>=p) x-=p;}
int main(){
	for (int i=0;i<N;++i){
		C[i][0]=cs[i][0]=1;
		for (int j=1;j<=i;++j) A(C[i][j],C[i-1][j]+C[i-1][j-1]),A(cs[i][j],cs[i][j-1]+C[i][j]);
	}
	scanf("%d%d",&n,&m);
	f[0][0]=1;
	for (int i=0;i<=n;++i)
		for (int j=0;j<=m;++j){
			if (i) A(f[i][j],f[i-1][j]);
			if (j) A(f[i][j],cs[j-1][min(i,j-1)]);
		}
	int ans=0;
	for (int i=0;i<=n;++i)
		for (int j=0;j<=i;++j)
		A(ans,1ll*f[j][i-j]*C[m-1][i-j]%p);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 159488
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	sl := strings.Split(s, "")
	ns := make([]int, len(sl))
	for i := range ns {
		ns[i], _ = strconv.Atoi(sl[i])
	}

	switch 7 {
	case ns[0] + ns[1] + ns[2] + ns[3]:
		fmt.Println(strings.Join(sl, "+") + "=7")
	case ns[0] - ns[1] + ns[2] + ns[3]:
		fmt.Println(sl[0] + "-" + sl[1] + "+" + sl[2] + "+" + sl[3] + "=7")
	case ns[0] + ns[1] - ns[2] + ns[3]:
		fmt.Println(sl[0] + "+" + sl[1] + "-" + sl[2] + "+" + sl[3] + "=7")
	case ns[0] - ns[1] - ns[2] + ns[3]:
		fmt.Println(sl[0] + "-" + sl[1] + "-" + sl[2] + "+" + sl[3] + "=7")
	case ns[0] + ns[1] + ns[2] - ns[3]:
		fmt.Println(sl[0] + "+" + sl[1] + "+" + sl[2] + "-" + sl[3] + "=7")
	case ns[0] - ns[1] + ns[2] - ns[3]:
		fmt.Println(sl[0] + "-" + sl[1] + "+" + sl[2] + "-" + sl[3] + "=7")
	case ns[0] + ns[1] - ns[2] - ns[3]:
		fmt.Println(sl[0] + "+" + sl[1] + "-" + sl[2] + "-" + sl[3] + "=7")
	case ns[0] - ns[1] - ns[2] - ns[3]:
		fmt.Println(strings.Join(sl, "-") + "=7")
	}
}


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

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

using namespace std;

typedef pair<int, int> P;

bool g(const P& a, const P& b){
	return a.second>b.second;
}

int main(){
	while(1){
		int n, m, d, p;
		long long int ans;
		vector<P> danger;
		cin >> n >> m;
		if (n==0 && m==0) return 0;
		ans = 0;
		REP(i,n){
			cin >> d >> p;
			danger.push_back(make_pair(d,p));
		}
		sort(danger.begin(), danger.end(), g);
		
		REP(i,n){
			d = danger[i].first;
			if (m-d>=0)	danger[i].first = 0;
			else danger[i].first -= m;
			m -= d;
			if (m<=0) break;
		}
		REP(i,n){
			d = danger[i].first;
			p = danger[i].second;
			ans += d*p;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3228