akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    ll n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    ll ans=0;
    map<ll,ll> mp;
    rep(i,n) mp[a[i]]++;
    for(auto p:mp){
        ans+=p.sc*(p.sc-1)/2;
    }
    rep(i,n){
        ans-=mp[a[i]]*(mp[a[i]]-1)/2;
        ll u=mp[a[i]]-1;
        cout<<ans+u*(u-1)/2<<'\n';
        ans+=mp[a[i]]*(mp[a[i]]-1)/2;
    }
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
*/

Measured memory_bytes: 11008
N=int(input())
triangle=[]

for i in range(N):
    triangle.append(list(map(int,input().split())))

for i in range(N):
    if pow(triangle[i][0],2)+pow(triangle[i][1],2)+pow(triangle[i][2],2)==2*pow(max(triangle[i]),2):
        print("YES")
    else:
        print("NO")



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

#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;



int32_t main()
{
            IOS;

            string s;
            cin>>s;

            int q;
            cin>>q;

            vector<pair<int, char>> qu;
            for (int i = 0; i < q; i++) {
                  int t;
                  cin>>t;
                  if (t==2) {
                        int f;
                        char c;
                        cin>>f;
                        cin>>c;
                        qu.push_back({f, c});
                  }
                  if (t==1)
                        qu.push_back({-1, -1});
            }
            
            int flag = 0;
            stack<char> front, back;
            for (int i = 0; i < qu.size(); i++) {
                  int x = qu[i].first;
                  char y = qu[i].second;
                  if (x == -1)
                        flag = 1-flag;
                  else {
                        if (x == 1 && flag == 0) front.push(y);
                        else if (x == 2 && flag == 0) back.push(y);
                        else if (x == 1 && flag == 1) back.push(y);
                        else front.push(y);
                  }
            }
            if (flag == 0) {
                  while (!front.empty()) {
                        char cur = front.top();
                        cout<<cur;
                        front.pop();
                  }
                  cout<<s;
                  stack<char> back1;
                  while (!back.empty()) {
                        back1.push(back.top());
                        back.pop();
                  }
                  while(!back1.empty()) {
                        char cur = back1.top();
                        cout<<cur;
                        back1.pop();
                  }
                  cout<<endl;
            } else {
                  while (!back.empty()) {
                        char cur = back.top();
                        cout<<cur;
                        back.pop();
                  }
                  reverse(s.begin(), s.end());
                  cout<<s;
                  stack<char> front1;
                  while (!front.empty()) {
                        front1.push(front.top());
                        front.pop();
                  }
                  while(!front1.empty()) {
                        char cur = front1.top();
                        cout<<cur;
                        front1.pop();
                  }
                  cout<<endl;
            }



            



      


        
























            return 0;
}

Measured memory_bytes: 6592
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL x;
    LL s=100;
    cin>>x;
    FOR(i,0,5000){
        s=s+s/100;
        if(s>=x){
            cout<<i+1<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3164
use std::collections::HashSet;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [i32; n],
    }
    let result = v.iter().cloned().collect::<HashSet<_>>();

    println!("{}", result.len() - (result.len() + 1) % 2);
}

Measured memory_bytes: 6396
/*#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

long long sum[511111], add[511111];

void push_down(int rt, int l, int r){
    add[rt << 1] += add[rt];
    add[rt << 1|1] += add[rt];
    int mid = (l + r) >> 1;
    sum[rt << 1] += (mid - l + 1) * add[rt];
    sum[rt << 1|1] += (r - mid) * add[rt];
    add[rt] = 0;
    return;
}

void update(int rt, int l, int r, int L, int R, int val){
    if(L <= l && R >= r){
        add[rt] += val;
        sum[rt] += (r - l + 1) * val;
        return;
    }
    if(add[rt]) push_down(rt, l, r);
    int mid = (l + r) >> 1;
    if(L <= mid){
        update(rt << 1, l, mid, L, R, val);
    }
    if(R > mid){
        update(rt << 1|1, mid + 1, r, L, R, val);
    }
    sum[rt] = sum[rt << 1] + sum[rt << 1|1];
    return;
}

long long query(int rt, int l, int r, int L, int R){
    if(L <= l && R >= r){
        return sum[rt];
    }
    int mid = (l + r) >> 1;
    if(add[rt]) push_down(rt, l, r);
    long long ans = 0;
    if(mid >= L){
        ans += query(rt << 1, l, mid, L, R);
    }
    if(R > mid){
        ans += query(rt << 1|1, mid + 1, r, L, R);
    }
    return ans;
}

int main(int argc,char *argv[])
{
    int n, m;
    while(scanf("%d%d", &n, &m) != EOF){
        memset(sum, 0, sizeof sum);
        memset(add, 0, sizeof add);
        for(int i = 1; i <= n; i++){
            int x;
            scanf("%d", &x);
            update(1, 1, n, i, i, x);
        }
        for(int i = 0; i < m; i++){
            char str[10];
            scanf("%s", str);
            if(str[0] == 'Q'){
                int l, r;
                scanf("%d%d", &l, &r);
                printf("%lld\n", query(1, 1, n, l, r));
            }
            else{
                int l, r, val;
                scanf("%d%d%d", &l, &r, &val);
                update(1, 1, n, l, r, val);
            }
        }
    }
}*/

#include<stdio.h>
#include<algorithm>

using namespace std;
int main(){
    int n, m;
    while(scanf("%d%d", &n, &m)!=EOF){
        printf("%d\n", max((n - 1)*(m - 1), 0));
    }
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int i, j, k, v;
		int N = sc.nextInt();
		int A[] = new int[N];
		for(i = 0; i < N; i++){
			j = sc.nextInt();
			A[i] =j;
		}

		for(i = 1; i <= N - 1; i++){
			for(k = 0; k < N; k++){
				System.out.print(A[k]);
				if(k != N - 1) System.out.print(" ");
			}
			System.out.println();
			v = A[i];
			j = i - 1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;	
		}
		for(k = 0; k < N; k++){
			System.out.print(A[k]);
			if( k != N - 1) System.out.print(" ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 34344
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
ll myNum = 999999999;

ll bck(string str) {
    ll x = 0;
    for (char& c : str) x = 10 * x + (c - '0');
    return x;
}
string to_str(ll x) {
    string s;
    while (x) {
        s += (char)(x % 10 + '0');
        x /= 10;
    }
    reverse(s.begin(), s.end());
    return s;
}
bool ask(string s) {
    cout << "? " << s << endl;
#ifdef DEBUG
    return ((myNum <= bck(s) && to_str(myNum) <= s) || ((myNum > bck(s)) && (to_str(myNum) > s)));
#endif
    string r;
    cin >> r;
    return (r == "Y");
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    string cur;
    ll num = 0;
    for (int i = 0; i < 12; i++) {
        if (i != 0) {
            //check that it's cur
            bool f = false;
            for (int j = 0; j < cur.size(); j++) {
                if (cur[j] != '9') {
                    f = true;
                    string ncur = cur;
                    ncur[j]++;
                    bool resp = ask(ncur);
                    if (resp) {
                        cout << "! " << cur << endl;
                        return 0;
                    }
                    break;
                }
            }
            if (!f) {
                bool resp = ask(to_str(num + 1));
                if (!resp) {
                    cout << "! " << cur << endl;
                    return 0;
                }
            }
        }
        int l = -1;
        int r = 9;
        if (i == 0) l = 0;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            string ncur = cur;
            ncur += (char)(mid + '0');
            while (ncur.size() < 15) ncur += '9';
            if (ask(ncur)) r = mid;
            else l = mid;
        }
        cur += (char)(r + '0');
        num = 10 * num + r;
    }
    return 0;
}

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

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

int ans = 1;
for (int i = 0; i < N; i++) {
    if (ans <= K) {
        ans = 2*ans;
    } else {
        ans += K;
    }
}

cout << ans << endl;

}


Measured memory_bytes: 256
n,m = map(int,input().split())
abl = []
for _ in range(m):
   a,b = map(int,input().split())
   cl = list(map(int,input().split()))
   bit = 0
   for c in cl:
      bit += 2**(c-1)
   abl.append((a,bit))

bitdp = [[float('inf') for i in range(1<<n)] for i in range(m+1)]
   
bitdp[0][0] = 0

for i in range(m):
   for j in range(1<<n):
      bitdp[i+1][j] = min(bitdp[i][j], bitdp[i+1][j])
      bitdp[i+1][j|abl[i][1]] = min(bitdp[i][j] + abl[i][0], bitdp[i][j|abl[i][1]], bitdp[i+1][j|abl[i][1]])

if bitdp[-1][(1<<n)-1] == float('inf'):
   print(-1)
else:
   print(bitdp[-1][(1<<n)-1])

Measured memory_bytes: 140888
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    int n;
    cin >> n;
    if(n%2 == 0){
        cout << 0.5 << endl;
    }else{
        cout << (n/2 + 1) / (long double)n << endl;
    }

}

Measured memory_bytes: 256
N = int(input())
D = {i: [] for i in range(N)}
distD = {}
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    D[u].append(v)
    D[v].append(u)
    distD[u*N+v], distD[v*N+u] = w, w
clr = [-1 for _ in range(N)]
clr[0] = 0
s = [0]
pnt = 0
cnt = 1
while pnt < cnt:
    n = cnt
    for i in range(pnt, cnt):
        L = D[s[i]]
        for j in L:
            if clr[j] == -1:
                clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2
                s.append(j)
                cnt += 1
    pnt = n
for i in range(N):
    print(clr[i])

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;

    i64 x=1,ans=1;
    rep(i,0,N){
        int Ai;
        cin >> Ai;
        if(Ai%2==0) x*=2;
        ans*=3;
    }
    ans-=x;

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	while(scanf("%d",&n),n) {
		int f[104730]={0}, i, j, s=0;
		for(i = 2; n; i ++) {
			if(f[i]==0) {
				n --;
				s += i;
				for(j = i; j < 104730; j += i) {
					f[j] = 1;
				}
			}
		}
		printf("%d\n", s, i-1);
	}
	return 0;
}

Measured memory_bytes: 820
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    for i in 0..s.len() {
        print!("{}", s[i]);
        if i == 3 {
            print!(" ");
        }
    }
    println!();
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int a;
	scanf("%d",&a);
	int x[a];
	int t=0;
	for(int b=0;b<a;b++)
	{
		int c;
		scanf("%d",&c);
		if(c%2==0)
		{
			if(c%3==0||c%5==0)
			{
				
			}
			else t=1;
		}
	}
	if(t==0) printf("APPROVED");
	else printf("DENIED");
	return 0;
}

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

ri=(raw_input()).split(" ")
n=int(ri[0])
w=int(ri[1])
d=[0]*n
dp=[]
dm=[]
restrict=0.0
result=0.0

for i in range(n):
    ri=(raw_input()).split(" ")
    d[i]=[0]*3
    d[i][1]=int(ri[0])*1.0 #w
    d[i][2]=int(ri[1])*1.0 #v
    if d[i][1]<=0 and d[i][2]>=0:
        restrict+=d[i][1]
        result+=d[i][2]
    elif (d[i][1]>0 and d[i][2]>0):
        dp+=[[1.0*d[i][1]/d[i][2],d[i][1],d[i][2],0.0]]
    elif (d[i][1]<0 and d[i][2]<0):
        dm+=[[-1.0*d[i][1]/d[i][2],d[i][1],d[i][2],0.0]]

dp=sorted(dp)
dm=sorted(dm)
dmidx=0

for i in range(len(dp)):
    if dp[i][1]+restrict<=w:
        restrict+=dp[i][1]
        result+=dp[i][2]
        dp[i][3]=1.0
    else:
        dp[i][3]=1.0*(w-restrict)/dp[i][1]
        restrict=w
        result+=dp[i][2]*dp[i][3]
        cont=True if (len(dm)>0 and (dp[i][0]<(-dm[dmidx][0]))) else False
        while cont:
            if (1-dp[i][3])*dp[i][1]/(-dm[dmidx][1])<1-dm[dmidx][3]:
                dm[dmidx][3]+=(1-dp[i][3])*dp[i][1]/(-dm[dmidx][1])
                result+=(1-dp[i][3])*(dp[i][2]-dm[dmidx][2]*dp[i][1]/dm[dmidx][1])
                dp[i][3]=1.0
                cont=False
            else:
                dp[i][3]+=(1-dm[dmidx][3])*(-dm[dmidx][1])/dp[i][1]
                result+=(1-dm[dmidx][3])*(dm[dmidx][2]+dp[i][2]*(-dm[dmidx][1])/dp[i][1])
                dm[dmidx][3]=1.0
                dmidx+=1
                if dmidx>=len(dm):
                    cont=False
                elif dp[i][0]>=(-dm[dmidx][0]):
                    cont=False
                
#print(dp)
#print(dm)
#print(restrict)
print(result)



Measured memory_bytes: 6912
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <typeinfo>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    rep(loop,n){
        string num;
        string beg,en="";
        cin>>num;
        sort(num.begin(),num.end());
        beg=num;
        for(int i=num.size()-1;i>=0;i--){
            en+=num[i];
        }
        cout<<stoi(en)-stoi(beg)<<endl;

    }
    
    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

const ll N = (ll)1e6+5;

ll _tree[N];
ll maxidx = N;//max reachable number. Change it!

void init()// run before each testcase not query!
{
	memset(_tree,0,sizeof(_tree));
}

ll read(ll idx)
{
	ll solve = 0;
	while(idx > 0)
	{
		solve += _tree[idx];
		idx -= (idx & -idx);
	}
	return solve;
}

void update(ll idx, ll val)// val is value by which tree[idx] is incremented
{
	while(idx <= maxidx)
	{
		_tree[idx] += val;
		idx += (idx & -idx);
	}
}

int readSingle(int idx) {
  int temp = _tree[idx]; 
  if (idx > 0) { 
    int z = idx - (idx & -idx);
    idx--; 
    while (idx != z) { 
      temp -= _tree[idx];
      idx -= (idx & -idx);
    }
  }
  return temp;
}


		// queries
		/*
		remember index is 1 based!
		printf("Enter no of queries: ");
		ll m,type,idx,val;
		cin>>m;
		while(m--)
		{
			cin>>type;
			if(type == 1)//read/commutative freq/sum
			{
				cin>>idx;
				ll z = read(idx);
				printf("%lld\n",z);
			}
			else if(type == 2)//update(point)
			{
				cin>>idx>>val;
				update(idx,val);
				printf("updated\n");
			}
			else if(type == 3)
			{
				cin>>idx;
				readSingle(idx);
			}
		}
		*/

int main()
{
	ll n,q;
	cin>>n>>q;
	init();
	vector<ll>v(n+1);
	FOR(i,1,n+1){
		cin>>v[i];
	}
	vector<ll>ql[n+1],qid[n+1];
	FOR(i,1,q+1){
		ll l,r;
		cin>>l>>r;
		ql[r].pb(l);
		qid[r].pb(i);
	}
	vector<ll>pos(n+1,0);
	vector<ll>ans(q+1);
	FOR(i,1,n+1){
		if(pos[v[i]] > 0){
			// if previosly position present
			update(pos[v[i]],-1);
		} 
		update(i,1);
		pos[v[i]] = i;
		for(int j=0;j<ql[i].size();j++){
			ans[qid[i][j]] = read(i)-read(ql[i][j]-1);
		}
	}
	FOR(i,1,q+1){
		cout<<ans[i]<<" ";
	}
	return 0;
}


Measured memory_bytes: 66656
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200005;
const int MOD =1000000007;
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
  COMinit();
  int s,ans=0;
  cin>>s;
  for(int i=1;i*3<=s;i++)ans=(ans+COM(s-3*i+i-1,i-1))%MOD;
  cout<<ans<<endl;
}

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

int main ()
{
    int n,l;
    cin >> n >> l;
    vector <string> s(n);
    for (int i = 0 ; i< n ;i++)
    {
        cin >> s[i];
    }
    sort (s.begin(),s.end());
    for (int i = 0 ; i < n ;i++)
        cout <<s[i];
    cout << "\n";
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

int b[2005];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,y;
	cin>>n>>x>>y;
	int k;
	for (int i=1; i<=n; i++)
	   for (int j=i+1; j<=n; j++)
	   {
		  k=min(min(abs(j-i),abs(i-x)+1+abs(j-y)),abs(i-y)+1+abs(j-x));
		  b[k]++;
	   }
	for (int i=1; i<=n-1; i++)
	   cout<<b[i]<< endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int[51][51] GF;
int[51] NS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    foreach (i; 1..M+1) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0];
        auto B = ab[1];
        GF[A][B] = i;
        GF[B][A] = i;
    }

    int cnt;
    foreach (i; 1..M+1) {
        void solve(int p) {
            if (NS[p] == i) return;
            NS[p] = i;
            foreach (j, n; GF[p][1..N+1]) if (n && n != i) solve((j+1).to!int);
        }
        solve(1);
        foreach (n; NS[1..N+1]) if (n != i) {
            ++cnt;
            break;
        }
    }
    writeln(cnt);
}

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



int main(){
    int x, n;
    int d=1e9,ans=0;
    cin>>x>>n;

    vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin>>tmp;
        v.push_back(tmp);

    }
    if(n==0){
        cout<<x<<endl;
        return 0;
    }

    sort(v.begin(), v.end());
    
    int cnt=0;
    for(int i=-1; i<110; i++){
        //cout<<i<<endl;
        if(abs(x-i)<d){
            if(i==v[cnt]){
                cnt++;
                continue;
            }
            d=abs(x-i);
            ans=i;
            //cout<<i<<" : "<<d<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,u,v,flg; vector<ll> vc[N]; ll fl[N],d1[N],d2[N];
void dfs(ll i,ll d){
	fl[i]=1; 
	if(flg==1) d1[i]=d;
	else d2[i]=d;
	for(auto it:vc[i]){
		if(fl[it]==0){
			dfs(it,d+1);
		}
	}
}
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>u>>v;

	for(i=1;i<n;i++){
		cin>>k>>l;
		vc[k].ps(l);
		vc[l].ps(k);
	}
	flg=1;
	dfs(u,0);
	memset(fl,0,sizeof(fl));
	flg=2;
	dfs(v,0);

	ll mx=0;
	for(i=1;i<=n;i++){
		if(d1[i]<d2[i]){
			mx=max(mx,d2[i]);
		}
	}
	cout<<(mx-1);
	return 0;
}

Measured memory_bytes: 104960
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
MOD = 10 ** 9 + 7


S = input()
S = ''.join(list(reversed(S)))
while len(S) > 0:
    if S[:7] == 'remaerd':
        S = S[7:]
    elif S[:6] == 'resare':
        S = S[6:]
    elif S[:5] in ['esare', 'maerd']:
        S = S[5:]
    else:
        print('NO')
        exit(0)
print('YES')


Measured memory_bytes: 136080
N = int(input()) #5
K = int(input()) #3
X = int(input())
Y = int(input())

total = 0
for a in range(1, N+1): #6 , 1, 2, 3, 4, 5
    if a <= K:
        total += X
    else:
        total += Y

print(total)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;

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

int main() {
  ll n;
  cin >> n;
  ll ans=(RepeatSquaring(10,n,mod)-RepeatSquaring(9,n,mod)-RepeatSquaring(9,n,mod)+RepeatSquaring(8,n,mod))%mod;
  cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    if (A >= 13) {
      System.out.println(B);
    } else if (A <= 5) {
      System.out.println(0);
    } else {
      System.out.println(B / 2);
    }
  }
}


Measured memory_bytes: 21844
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

const int maxn = 200010;

int a[maxn], n;


//map<PP, PP> m;
//map<int, int> m;
//map<PP
//
//

//int vis[maxn];
bool check(int max_l) {
  //max_l = 1;
  vector<PP> v;
  rep(i, 1, n) {
    int x = a[i];
    while (!v.empty() && v.back().first > x) {
      v.pop_back();
    }
    if (a[i] <= a[i - 1]) {
      if (max_l == 1) {
        return false;
      }
      int cur = x;
      while (!v.empty() && cur > 0 && (cur == v.back().first && v.back().second == max_l - 1)) {
        v.pop_back();
        cur --; 
      }
      if (cur <= 0) {
        return false;
      }
      if (v.empty() || v.back().fr < cur) {
        v.push_back(PP{cur, 1});
      } else{
        v.back().sc ++;
      }
    }
    //for (auto & x: v) {cout << '{' << x.fr << ' ' << x.sc << "}, ";} cout <<endl;
  }
  return true;
}

int main() {
  cin >> n; rep(i, n) cin >> a[i];
  //check(1);

  //drep(i, n, 1) {
    //if (a[i - 1] >= a[i]) {
      //PP l = {i - 1, a[i]}, r = {i, a[i]};
      //if (!m.count(r)) m[r] = 1;
      //m[l] = m[r] + 1;
    //}
  //}

  //int res = 1;
  //for (auto& x: m) {
    //smax(res, x.sc);
  //}
  
  //int last = a[0];

  //rep(i, 1, n) {
    //int x = a[i];
    //while (!m.empty() && m.rbegin()->first > x) {
      //cout << "erase " << m.rbegin()->first << endl;
      //m.erase(--m.end());
    //}
    //if (a[i] <= a[i - 1]) {
      //if (m.count(x)) {
        //int &r = m[x];
        //r ++;
        //smax(res, r);
      //}
      //else {
        //m[x] = 2;
        //smax(res, 2);
      //}
      ////smin(last, x);
    //}
  //}

  //cout << res << endl;
  //
  //
  int l = 1, r = 200000;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(mid)) r = mid;
    else l = mid + 1;
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

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

	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());

	cout << d.size() << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,s,e) for(ll i=s;i<e;++i)

int main()
{
    int n;
    cin >> n;
    n%=10;
    if(n==3) cout << "bon" << endl;
    else if(n==0 || n==1 || n==6 || n==8) cout << "pon" << endl;
    else cout << "hon" <<endl;
    return 0;
}

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

static const int maxsize = 100;

void showSeq(int a[],int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
}

int selectionSort(int a[],int n) {
	int swapCount = 0;
	for (int i = 0; i < n; i++) {
		int minValueIndex = i;
		for (int j = i + 1; j < n; j++) {
			if (a[minValueIndex] > a[j])
				minValueIndex = j;
		}
		if (i != minValueIndex) {
           swap(a[i], a[minValueIndex]);
		   swapCount++;
		}		     		
	}
	return swapCount;
}


int main()
{
	
	int n, a[maxsize];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	int count = selectionSort(a, n);
	showSeq(a,n);
	cout << count << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<map>
using namespace std;
const int MAXN=100000+7;
string a;
map<char,char> t;
void Change(string &s){
	for(int i=0;i<(int)s.size();i++) s[i]=t[s[i]];
}
void Reserve(string &s){
	int r=(int)s.size()-1;
	int l=0;
	while(l<r){
		swap(s[l],s[r]);
		l++; r--;
	}
}
int main(){
	t.insert(make_pair('b','d'));
	t.insert(make_pair('d','b'));
	t.insert(make_pair('p','q'));
	t.insert(make_pair('q','p'));
	cin>>a;
	string tmp=a,s=a;
	Reserve(tmp);
	if(tmp==a){
		//cout<<tmp<<endl;
		puts("Yes"); return 0;
	}
	Change(tmp); Change(s);
	string res=s; Reserve(res);
	if(tmp==a||s==a||res==a){
		//cout<<tmp<<' '<<s<<endl;
		puts("Yes"); return 0;
	}
	//cout<<tmp<<' '<<s<<' '<<res<<endl;
	puts("No");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846

void solve(){
	int r; cin >> r; 
	long double ans;
	ans = (2 * (long double)(22.0/7.0) * (long double)r);
	cout << setprecision(50) << ans << endl;
	

}


int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	
		solve();
	
	return 0;
}

Measured memory_bytes: 3804
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>
#include	<stdlib.h>
#include	<string.h>

#define		MXCD	200+5
#define		MXSH	100

int		main(void)
{
	int		i, j, k, m;

	char	str[MXCD];
	char	tmp[MXCD];
	int		shuffle;
	int		noft;
	int		sl;

	while(1)
	{
		scanf("%s",str);
		sl = strlen(str);
		if( strcmp("-",str) == 0 )
			break;
		//printf("sl=%d\n",sl);

		scanf("%d",&noft);
		//printf("noft=%d\n",noft);

		for(i=0; i<noft; i++)
		{
			scanf("%d",&shuffle);
			//printf("shuffle=%d\n",shuffle);

			k=shuffle;
			for(j=0; j<sl-shuffle; j++, k++)
			{
				tmp[j] = str[k];
				//printf("tmp[%d]=%c\n",j,tmp[j]);
			}
			m=0;
			for(j=sl-shuffle; j<sl; j++,m++)
			{
				tmp[j] = str[m];
				//printf("tmp[%d]=%c\n",j,tmp[j]);
			}

			for(j=0; j<sl; j++)
			{
				str[j] = tmp[j];
				//printf("tmp[%d]=%c\n",j,tmp[j]);
			}
			//printf("str=%s\n",str);
		}
		printf("%s\n",str);
	}

	return 0;
}

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

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    string a,b;
    cin>>a>>b;

    int ans=0;
    for(int i=0;i<3;i++){
        if(a[i]==b[i]){
            ans++;
        }
    }
    cout<<ans;

    return 0;
}

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

#include <atcoder/segtree.hpp>

int64_t op(int64_t a, int64_t b) {
    return max(a, b);
}

int64_t e() {
    return (int64_t)0;
}

int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    const int64_t max_A = *max_element(A.begin(), A.end());

    //最大値を取得できるsegtree
    atcoder::segtree<int64_t, op, e> seg(max_A + 1);

    for (int64_t i = 0; i < N; i++) {
        int64_t l = max(A[i] - K, (int64_t)0);
        int64_t r = min(A[i] + K + 1, max_A + 1);

        int64_t max_num = seg.prod(l, r);
        seg.set(A[i], max_num + 1);
    }

    cout << seg.all_prod() << endl;
}

Measured memory_bytes: 16192
#include<bits/stdc++.h>
using namespace std;
int N;
int A[202020];
int B[202020];
int main()
{
    scanf("%d", &N);
    long long ans = 0;
    for(int i=0; i<N; ++i)
        scanf("%d%d", A+i, B+i);
    bool alleq = true;
    for(int i=0; i<N; ++i)
    {
        if(A[i] != B[i]) alleq = false;
        ans += A[i];
    }

    if(alleq)
    {
        puts("0"); return 0;
    }
    
    int minv = 0x3f3f3f3f;
    
    for(int i=0; i<N; ++i)
        if(A[i] > B[i])
            minv = min(minv, B[i]);
    
    printf("%lld\n", ans-minv);
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>

int main(){
	double x1,y1,x2,y2,x3,y3,p,q,r;
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		p = ((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
		q = ((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
		r = sqrt((x1 - p) * (x1 - p) + (y1 - q) * (y1 - q));
		printf("%.3f %.3f %.3f\n", p, q, r);
	}
	return 0;
}

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

int main(){
    int N, K, C;
    std::cin >> N >> K >> C;
    std::string S;
    std::cin >> S;
    
    std::vector< int > Fastest(K);
    std::vector< int > Latest(K);
    
    int cnt = 0;
    int j = 0;
    while(j < N && cnt != K){
        if(S[j] == 'o'){
            Fastest[cnt] = j + 1;
            cnt++;
            j += C + 1;
        }else{
            j++;
        }
    }
    
    cnt = 0;
    j = N - 1;
    while(j >= 0 && cnt != K){
        if(S[j] == 'o'){
            Latest[K - cnt - 1] = j + 1;
            cnt++;
            j -= (C + 1);
        }else{
            j--;
        }
    }
    
    for(int i=0; i<K; i++){
        if(Fastest[i] == Latest[i]){
            std::cout <<  Fastest[i] << std::endl;
        }
    }
    
    return 0;
    
}



Measured memory_bytes: 3332
#include<bits/stdc++.h>
// #include "/Users/Coder_Jay/Desktop/Codeforces/header.h"
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
#define  START      auto start = chrono::steady_clock::now()
#define END         auto end = chrono::steady_clock::now()

using namespace std;
typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira; START;
    
    lli n; cin>>n;

    lli fact[11];
    fact[0]=1;

    for(lli i=1; i<11; i++) fact[i]=fact[i-1]*i;

    // cout<<fact[7]<<endl;

    vector <lli> v1, v2;

    forz(i,n)
    {
        lli t; cin>>t;
        v1.pb(t);
    }

    forz(i,n)
    {
        lli t; cin>>t;
        v2.pb(t);
    }

    // forz(i,v1.si) cout<<v1[i]<<" "; cout<<endl;
    // forz(i,v2.si) cout<<v2[i]<<" "; cout<<endl;

    vector <lli> v3;
    forz(i,n) v3.pb(i+1);

    lli it=0, ind1=-1, ind2=-1;
    do
    {
        // forz(i,v3.si) cout<<v3[i]<<" "; cout<<endl;

        if(v3==v1) ind1=it;
        if(v3==v2) ind2=it;

        if(ind1!=-1 && ind2!=-1) break;

        it++;
    }while(next_permutation(v3.be, v3.en));
    
    // cout<<ind1<<" "<<ind2<<endl;

    cout<<abs(ind1-ind2)<<endl;

    END;
    return 0;
}





















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    mint res = mint(2) ^ n;
    res -= mint(1);
    mint s = 1;
    for (int i = 0; i < a; i++) {
        s *= (n - i);
        s /= (i + 1LL);
    }
    mint s2 = 1;
    for (int i = 0; i < b; i++) {
        s2 *= (n - i);
        s2 /= (i + 1LL);
    }
    res -= s + s2;
    cout << res.a << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

ll N, K;
ll to[101010];
ll from[101010];
ll depth[101010];
ll ans = 0;



int main(){

    cin >> N >> K;
    cin >> to[1];
    if(to[1] != 1)ans++;
    for(ll i = 2; i <= N; i++){
        cin >> to[i];
        from[to[i]]++;
    }
    queue<ll>Q;
    for(ll i = 1; i <= N; i++){
        if(from[i] == 0){
            Q.push(i);
        }
    }
    while(!Q.empty()){
        ll idx = Q.front();
        Q.pop();
        if(idx == 1)break;
        if(depth[idx] + 1 == K && to[idx] != 1){
            ans++;
        }
        else if(to[idx] != 1){
            depth[to[idx]] = max(depth[to[idx]], 1 + depth[idx]);
        }
        from[to[idx]]--;
        if(from[to[idx]] == 0)Q.push(to[idx]);    
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3200
def main():
  aaa = input()
  digitInOnePlace=int(aaa[-1])
  if digitInOnePlace in [2,4,5,7,9]:
  	print("hon")
  elif digitInOnePlace in [0,1,6,8]:
    print("pon")
  elif digitInOnePlace in [3]:
    print("bon")
if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
n,y = map(int,input().split())
ans = [0]*3
for i in range(n+1):
    for j in range(n+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y and (n-i-j) >= 0:
            print(i,j,n-i-j)
            exit()
else:
    print(-1,-1,-1)

Measured memory_bytes: 9072
let ans, n = ref 0, Scanf.scanf " %d" (+) 0
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = for i = 1 to n - 2 do if (ps.(i - 1) - ps.(i)) * (ps.(i) - ps.(i + 1)) > 0 then incr ans done; Printf.printf "%d\n" !ans

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

typedef struct _Node {
	int value;
	struct _Node *next;
} Node;

typedef struct {
	int length;
	Node *head;
	Node *tail;
} List;

Node *CreateNode(int _value) {
	Node *newNode = (Node*)malloc(sizeof(Node));
	newNode->value = _value;
	newNode->next = NULL;
	return newNode;
}

List *InitListSequence(int _n) {
	int i;
	List *listSequence = (List*)malloc(sizeof(List)*_n);
	for (i = 0;i != _n;++i) {
		listSequence[i].length = 0;
		listSequence[i].head = NULL;
		listSequence[i].tail = NULL;
	}
	return listSequence;
}

// insert _value at the end of list of which subscript is _subscript
void Insert(List *_listSequence,int _subscript,int _value) {
	Node *newNode = CreateNode(_value);
	if (_listSequence[_subscript].length == 0) { // if the list is empty
		_listSequence[_subscript].head = newNode;
	}
	else {
		_listSequence[_subscript].tail->next = newNode;
	}
	_listSequence[_subscript].tail = newNode;
	++_listSequence[_subscript].length;
}

// print all elements in the list of which subscript is _subscript
void Dump(List *_listSequence,int _subscript) {
	Node *current;
	if (_listSequence[_subscript].length != 0) { // if the list isn't empty
		current = _listSequence[_subscript].head;
		while (current != NULL) {
			printf("%d",current->value);
			current = current->next;
			if (current != NULL) {
				printf(" ");
			}
		}
	}
	printf("\n");
}

// splice the list of which subscript is _subscript1 to the end of the list of which subscript is _subscript2
void Splice(List *_listSequence,int _subscript1,int _subscript2) {
	if (_listSequence[_subscript2].length == 0) { // if the list of which subscript is _subscript2 is empty
		_listSequence[_subscript2].head = _listSequence[_subscript1].head;
	}
	else {
		_listSequence[_subscript2].tail->next = _listSequence[_subscript1].head;
	}
	_listSequence[_subscript2].tail = _listSequence[_subscript1].tail;
	_listSequence[_subscript1].head = NULL;
	_listSequence[_subscript1].tail = NULL;
	_listSequence[_subscript2].length += _listSequence[_subscript1].length;
	_listSequence[_subscript1].length = 0;
}

int main() {
	int n;		// amount of lists
	int q;		// amount of queries
	int op;		// number of operation
	int first;	// the first parameter
	int second;	// the second parameter
	List *listSequence = NULL;
	scanf("%d%d",&n,&q);
	listSequence = InitListSequence(n);
	while (q--) {
		scanf("%d",&op);
		switch (op) {
			case 0:
				scanf("%d%d",&first,&second);
				// first:  subscript of list
				// second: the integer which will be inserted
				Insert(listSequence,first,second);
				break;
			case 1:
				scanf("%d",&first);
				// first:  subscript of list
				Dump(listSequence,first);
				break;
			default:
				scanf("%d%d",&first,&second);
				// first:  subscript of list s
				// second: subscript of list t
				Splice(listSequence,first,second);
		}
	}
	return 0;
}


Measured memory_bytes: 17396