akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        int num = GetInput.getInt();
        long count = 0;
        for (int i = 1 ; i <= num; i++){
            if (i %3 == 0 || i%5==0){
                continue;
            }
            count+=i;
        }
        System.out.println(count);
    }
}


class GetInput {
    static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

    static char[] getCharArray() {
        char[] charArray;
        try {
            StringBuilder string = getInputString();
            charArray = new char[string.length()];
            for (int i = 0; i < string.length(); i++) {
                charArray[i] = string.charAt(i);
            }
            return charArray;
        } catch (Exception e) {
            e.printStackTrace();
        }
        charArray = new char[0];
        return charArray;
    }

    static int[] getArrayInt() {
        String[] string;
        int[] array;
        try {
            string = bufferedReader.readLine().split("\\s+");
            array = new int[string.length];
            for (int i = 0; i < string.length; i++) {
                array[i] = Integer.parseInt(string[i]);
            }
            return array;
        } catch (IOException e) {
            e.printStackTrace();
        }

        int[] arra = new int[2];
        return arra;
    }

    static int getInt() {
        try {
            String string = bufferedReader.readLine();
            return Integer.parseInt(string);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return 0;
    }

    static StringBuilder getInputString() {
        try {
            StringBuilder string = new StringBuilder();
            string.append(bufferedReader.readLine());
            return string;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new StringBuilder();
    }

    static long getLongInput() {
        try {
            String string = bufferedReader.readLine();
            return Long.parseLong(string);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return 0;
    }

    static long[] getLongArrayInput() {
        String[] string;
        long[] array;
        try {
            string = bufferedReader.readLine().split("\\s+");
            array = new long[string.length];
            for (int i = 0; i < string.length; i++) {
                array[i] = Long.parseLong(string[i]);
            }
            return array;
        } catch (IOException e) {
            e.printStackTrace();
        }

        long[] arra = new long[2];
        return arra;
    }
}


Measured memory_bytes: 32700
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000






int main(){
	vector<long long>a;
	vector<long long>b;
	long long n, m, as, bs;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld %lld", &n, &m);
	f(i, n){
		scanf("%lld", &x);
		a.push_back(x);
	}
	f(i, m){
		scanf("%lld", &x);
		b.push_back(x);
	}
	sort(a.begin(), a.end(),greater<long long>());
	sort(b.begin(), b.end(), greater<long long>());
	as = 0;
	bs = 0;
	ans = 1;
	for (long long i = n*m; i > 0; i--){
		if (a[as] == i&&b[bs] == i){
			as++;
			bs++;
		}
		else if (a[as] != i&&b[bs] == i){
			bs++;
			ans *= as;
			ans %= MOD;
		}
		else if (a[as] == i&&b[bs] != i){
			as++;
			ans *= bs;
			ans %= MOD;
		}
		else{
			s = as*bs;
			s -= ((n*m) - i);
			if (s < 0)s = 0;
			s %= MOD;
			ans *= s;
			ans %= MOD;
		}
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD=1e9+7;
using namespace std;
const int dx[4]={-1, 0, 1, 0};
const int dy[4]={0, -1, 0, 1};

int n;
vector<vector<int> > br;
vector<int> dep;
vector<bool> done;

//点の深さを探索
void dfs(int id,int d)
{
	dep[id]=d+1;
	done[id]=true;
	for(int i=0;i<br[id].size();i++)
	{
		int nxid=br[id][i];
		if(done[nxid]==false)
			dfs(nxid,dep[id]);
	}
}


int main()
{
	cin >> n;
	br = vector<vector<int> >(n);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		br[a].push_back(b);
		br[b].push_back(a);
	}

	dep=vector<int>(n,1000000);
	done=vector<bool>(n,false);
	dfs(0,0);

  //直径の最長を求めたい!!
	int mx=0;
	int id=0;
	for(int i=0;i<n;i++)
		if(dep[i]>mx)
		{
			mx=dep[i];
			id=i;
		}

  dep=vector<int>(n,1000000);
	done=vector<bool>(n,false);
	dfs(id,0);
	int ans=0;

  for(int i=0;i<n;i++)
  {
    if(dep[i]>ans) ans=dep[i];
  }
  ans--;

	cout << (ans%3==1 ? "Second":"First") << endl;
}


Measured memory_bytes: 21760
import Control.Applicative
import Control.Monad

match :: [Int] -> [Int] -> Bool
match xs [a, b, c, d, e, f]
    | xs == [a, b, c, d, e, f] = True
    | xs == [a, d, b, e, c, f] = True
    | xs == [a, e, d, c, b, f] = True
    | xs == [a, c, e, b, d, f] = True
    | otherwise                = False

solve :: [Int] -> [Int] -> Bool
solve xs [a, b, c, d, e, f]
    | match xs [a, b, c, d, e, f] = True
    | match xs [b, c, a, f, d, e] = True
    | match xs [c, a, b, e, f, d] = True
    | match xs [f, d, e, b, c, a] = True
    | match xs [d, e, f, a, b, c] = True
    | match xs [e, f, d, c, a, b] = True
    | otherwise                   = False

main :: IO ()
main = do
    n  <- readLn
    d  <- map read <$> words <$> getLine
    ds <- replicateM (n - 1) (map read <$> words <$> getLine)
    putStrLn $ if any (\x -> solve d x) ds then "No" else "Yes"

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

int main()
{
	int N;
	cin >> N;
	int H[100003];
	int m = 0;
	int index = 0;
	int ans = 0;
	int tmp = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
		if (m >= H[i])
		{
			m = min(H[i], m);
			tmp++;
	
		}
		else {
			m = H[i];
			tmp = 0;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll s, w; cin >> s >> w;
	if(w >= s){
		print("unsafe")
	}
	else{
		print("safe")
	}
	
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a.size()>3 && a[0]=='Y' && a[1]=='A' && a[2]=='K' && a[3]=='I')cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    input!(x: usize, a: usize);

    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-5
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int main() 
{
    fastio
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    ll sum = 0;
    sum += min(a, k);
    k = max(0ll, k-a);
    if(k>0) {
        k = max(0ll, k-b);
    }
    if(k>0) {
        sum -= min(c, k);
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin >> S >> K;
    N = S.size();
    vector<mat> dp(N, mat(K + 1, vec(2, 0)));
    dp[N - 1][0][1] = 1;
    dp[N - 1][1][1] = S[0] - '1';
    dp[N - 1][1][0] = 1;
    Rreps(i, N, 1) {
        rep(j, K + 1) {
            rep(k, 2) {
                for (int n = 0; n <= (k ? 9 : S[N - i] - '0'); ++n) {
                    if (n != 0 && j + 1 <= K) {
                        dp[i - 1][j + 1][k | (n < S[N - i] - '0')] += dp[i][j][k];
                    } else if (n == 0) {
                        dp[i - 1][j][k | (n < S[N - i] - '0')] += dp[i][j][k];
                    }
                }
            }
        }
    }
    cout << dp[0][K][0] + dp[0][K][1] << endl;
    /*rep(k, 2) {
        Rrep(i, N) {
            rep(j, K + 1) {
                cout << dp[i][j][k] << ' ';
            }
            cout << endl;
        }
    }*/
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <numeric>
#include <iterator>

using namespace std;
typedef long long ll;


#define FF first
#define SS second
#define ALL(c) begin((c)), end((c))
#define REP(i,n) for(ll i=0;i<(ll)n;++i)
inline int getInt() { int s; scanf("%d", &s); return s; }

#define SIZE 500000
vector<ll> table(SIZE);

void sieve_of_eratosthenes() {
	iota(ALL(table), 0);
	for (int i = 2; i < SIZE; ++i)
		table[i] = i;
	for (int i = 2; i*i < SIZE; ++i)
	if (table[i])
	for (int j = i*i; j < SIZE; j += i)
		table[j] = 0;
}

int main() {
	sieve_of_eratosthenes();

	while (true) {
		ll n;
		cin >> n;
		if (n==0) break;

		ll count = 0;
		for(int i=n+1;i<=2 * n;++i) if (table[i]!=0) count++;

		cout << count << endl;
	}
}

Measured memory_bytes: 4892
import math
k = int(input())
a = list(map(int, input().split()))
MAX = 2
MIN = 2
for i in a[::-1]:
    if MAX >= i:
        MAX = i * (MAX // i) + (i-1)
        MIN = i * (math.ceil(MIN / i)) 
        if MIN > MAX:
          print(-1)
          exit()
    else:
        print(-1)
        exit()
print(MIN,MAX)


Measured memory_bytes: 15020
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>

using namespace std;
typedef long long ll;

int main()
{
	ll S;
	cin >> S;
	
	const ll ten9 = 1000000000;
	
	cout << 0 << " " << 1 << " ";
	cout << ten9 << " " << 0 << " ";
	if( S < ten9 * ten9){
		cout << S % ten9 << " " << 1 + (S / ten9)<< endl;
	}else{
		cout << ten9 << " " << ten9 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int d[100005];
int dp(int arr[],int n,int k,int i) {
    if(i==n-2 && k>=2)return abs(arr[n-2]-arr[n-1]);
    if(i==n-1)return 0;

    if(d[i]!=-1)return d[i];
    int ans=1e9;
    for(int h=i+1; h<=i+k; h++) {
        if(h<n) {
            ans=min(ans,abs(arr[i]-arr[h])+dp(arr,n,k,h));
        }
    }

    d[i]=ans;
    return d[i];
}
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0; i<n; i++) {
        cin>>arr[i];
        d[i]=-1;
    }

    cout<<dp(arr,n,k,0)<<endl;
    return 0;
}

Measured memory_bytes: 13768
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
bool is_p(int n)
{
    for (int i = 2; i < (int)sqrt(n) + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n, m;
    scanf("%d\n", &n);
    int x, res = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d\n", &x);
        if (is_p(x))
            res++;
    }
    printf("%d\n", res);
}


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

void ap();

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

void ap()
{
	long long N, A, B;
	cin >> N >> A >> B;
	if (A > B)
	{
		cout << 0 << endl;
		return;
	}
	long long minv, maxv;
	minv = A*(N - 1) + B;
	maxv = A + B*(N - 1);
	long long result = maxv - minv >= 0 ? maxv - minv + 1 : 0;
	cout << result << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#define INF 0x3f3f3f

using namespace std;

int main() {
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
			var n = firstLine[0];
			var k = firstLine[1];

			var numbers = new List<int[]>();

			for(var i = 0; i < n; i++)
			{
				numbers.Add(Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray());
			}

			var dictionary = new Dictionary<int, long>();

			foreach(var number in numbers)
			{
				if(!dictionary.ContainsKey(number[0]))
				{
					dictionary.Add(number[0], 0);
				}

				dictionary[number[0]] += number[1];
			}

			var orderdDictionary = dictionary.OrderBy(keyValuePair => keyValuePair.Key);

			long count = 0;
			foreach(var keyValuePair in orderdDictionary)
			{
				count += keyValuePair.Value;

				if(count >= k)
				{
					Console.WriteLine(keyValuePair.Key);
					return;
				}
			}
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  while(true) {
    int d[3];
    cin >> d[0] >> d[1] >> d[2];
    if(!d[0] && !d[1] && !d[2]) break;
    int n;
    cin >> n;

    sort(d, d+3);
    long double l = sqrt(d[0]*d[0]+d[1]*d[1]);
    REP(i, n) {
      int r;
      cin >> r;
      if(2*r > l) cout << "OK" << endl;
      else cout << "NA" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3028
#include <stdio.h>

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

    int a[n];
    int ans=0;

    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        ans += (a[i]-1);
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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;
}

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    int N;
    cin >> N;
    map<string, int> mp;
    rep(i, 0, N) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = -1;
    for(auto x : mp) {
        mx = max(mx, x.second);
    }
    vector<string> b;
    for(auto x : mp) {
        if (x.second == mx) {
            b.push_back(x.first);
        }
    }
    sort(b.begin(), b.end());
    rep(i, 0, b.size()) {
        cout << b[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 26868
N,K=map(int,input().split())
XY=[]
for i in range(N):
  x,y=map(int,input().split())
  XY.append((x,y))
XY.sort()

ans=10**50
for i in range(N-(K-1)):
  for j in range(i+(K-1),N):
    x,y=XY[i]
    x1,y1=XY[j]
    YX=sorted(XY[i:j+1], key=lambda x:x[1])
    for k in range(len(YX)-(K-1)):
      for l in range(k+(K-1),len(YX)):
        if YX[k][1] <= y and y1 <= YX[l][1]:
          ans=min(ans,(x1-x)*(YX[l][1]-YX[k][1]))

print(ans)

Measured memory_bytes: 3064
program trick
  
  implicit none
  integer :: n,k,i,j,m,answer
  integer,allocatable :: d(:),a(:,:),ans(:)
  

  read*,n,k
  !print*,n,k
  allocate(d(k))
  allocate(ans(n))
  ans=0 
 
  do i=1,k
   read*, d(i)
   !print*,d(i)
   allocate(a(1:k,1:d(i)))
    
     read*, a(i,1:d(i))
     !print*, a(i,1:d(i))
     
      do j=1,d(i)
       do m=1,n
        if(a(i,j)==m) ans(m)=ans(m)+1
       end do
      end do
    
   deallocate(a)
  end do

  answer=0
  do i=1,n
   if(ans(i)==0) answer=answer+1
  end do

 print*,answer

 

end program trick

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

ll N, K;

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N >> K;

	if (K > (N-1)*(N-2)/2)
	{
		std::cout << -1 << std::endl;
		return 0;
	}

	vector<pair<ll, ll>> res;
	for (ll i = 2; i <= N; ++i)
		res.push_back(pair<ll, ll>(1, i));

	for (ll i = 2; i < N; ++i)
	{
		for (ll j = i+1; j <= N; ++j)
		{
			res.push_back(pair<ll, ll>(i, j));
		}
	}

	ll t = (N-1)*(N-2)/2 - K + N-1;
	std::cout << t << std::endl;
	for (ll i = 0; i < t; ++i)
	{
		auto nv = res[i];
		std::cout << nv.first << " " << nv.second << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  bool b;
  while(1){
    stack<char>stk;
    b=true;
    getline(cin,a);
    if(a==".") break;
    for(int i=0;i<a.size();i++){
      if(a[i]=='(') stk.push('(');
      else if(a[i]=='[') stk.push('[');
      else if(a[i]==')'){
	if(stk.empty()||stk.top()!='('){
	  b=false;
	  break;
	}else stk.pop();
      }else if(a[i]==']'){
	if(stk.empty()||stk.top()!='['){
	  b=false;
	  break;
	}else stk.pop();
      }
    }
    if(b==true && stk.empty()) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#!/usr/bin/env python3
#ABC122 D
n = int(input())
mod = 10**9+7

dp = [[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
#長さ0の文字列は1
#0,1,2(A,G,C)に関する制約しかないため
#Sは、TTTSと考えてもよい
dp[0][3][3][3] = 1

#swapしてAGCが発生しない文字列:=AGC,ACG,GAC,A?GC,AG?Cを含まない文字列
#A:=0,G:=1,C:=2,T:=3

#文字列の文字数
for i in range(n):
    #最後から1文字目
    for j in range(4):
        #最後から2文字目
        for k in range(4):
            #条件に当てはまるものがない場合
            if dp[i][j][k] == 0:
                continue
            #最後から3文字目
            for l in range(4):
                #新たに追加する文字
                for a in range(4):
                    #ダメな5条件をカット

                    #AGCの場合
                    if a == 2 and j == 1 and k == 0:continue
                    #GACの場合
                    if a == 2 and j == 0 and k == 1:continue
                    #ACGの場合
                    if a == 1 and j == 2 and k == 0:continue
                    #A?GCの場合
                    if a == 2 and j == 1 and l == 0:continue
                    #AG?Cの場合
                    if a == 2 and k == 1 and l == 0:continue

                    #ダメの条件を抜けると、aを足した文字列が作れる
                    dp[i+1][a][j][k] += dp[i][j][k][l]
                    dp[i+1][a][j][k] %= mod

ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            #長さnの全通り回収
            ans += dp[n][j][k][l]
            ans %= mod
print(ans)


Measured memory_bytes: 3312
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

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

	int cnt=0;

	if(b==1){
		cout<<0;
		return 0;
	}

	if(a>=b){
		cout << 1;
		return 0;
	}else{
		cnt++;
		b-=a;
	}

	cnt += b/(a-1);
	if(b%(a-1)!=0) cnt++;

	cout << cnt;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int sunuke,okasi;
  cin>>sunuke;
  int num[sunuke]={};
  cin>>okasi;
  for(int i=0;i<okasi;i++){
    int kosuu;
    cin>>kosuu;
    for(int j=0;j<kosuu;j++){
      int a;
      cin>>a;
      num[a-1]=num[a-1]+1;
    }
  }
  int ans=0;
  for(int i=0;i<sunuke;i++){
    if(num[i]==0){
      ans++;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int a,b,k;
cin>>a>>b>>k;
  if(a<k)
  {
    if(b<=k-a)
      b=0;
    else 
      b=b-(k-a);
     
    a=0;
  }
  else 
    a=a-k;
  
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256
import numpy as np

def main():

  W, A, B = map(int, input().split())
  
  A_ = A + W
  B_ = B + W
  
  if (A <= B and B <= A_) or (A <= B_ and B_ <= A_):
    print(0)
    return

  print(min(abs(A_ - B), abs(A - B_)))

main()

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
char S[5050];

ll ln[5050];
ll i, j, k, ans;

ll calc(ll b){
    ll i = 1;
    ll j = 0;
    ll ret = 0;
    ll zero = 0;
    while(i+b<N){
        zero++;
        if(i+ln[i-j]<j+ln[j]){
            ln[i] = ln[i - j];
            if(ret<min(i,ln[i])){
                ret = min(i, ln[i]);
            }
        }else{
            ll k = j + ln[i] - i > 0 ? j + ln[i] - i : 0;
            while(i+k+b<N&&S[k+b]==S[i+k+b])
                k++;
            ln[i] = k;
            if(ret<min(i,ln[i])){
                ret = min(i, ln[i]);
            }
            j = i;
        }
        i++;
    }
    return ret;
}
int main(){
    scanf("%lld%s", &N, S);
    fornum(i,0,N){
        ll a = calc(i);
        if(ans<a)
            ans = a;
    }
    printf("%lld", ans);
    return 0;
}


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

ll MOD = 1e9+7;

int main(){
    ll N; cin >> N;
    ll l = 0, r = N, m;

    cout << 0 << endl;
    string S; cin >> S;
    if(S == "Vacant") return 0;
    /*cout << N-1 << endl;
    string _; cin >> _;
    if(_ == "vacant") return 0;*/

    while(1){
        m = (l+r)/2;
        cout << m << endl;
        string T; cin >> T;
        if(T == "Vacant") return 0;
        //if((m % 2 && S != T) || (m % 2 == 0 && S == T)) l = m+1;
        if((m % 2 == 0 && S == T) || (m % 2 == 1 && S != T)) l = m+1;

        else{
            r = m;
        }
    }
}

Measured memory_bytes: 852
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int P_MAX=10000;
int main()
{
  int tt=1,rr=0;
  int r[P_MAX];
  long long n,p,i,res=0;
  long long t[P_MAX];
  string s;
  cin >> n >> p;
  cin >> s;
  if(p==2||p==5){
    for(i=0;i<n;i++){
      tt=stoi(s.substr(i,1));
      if(tt%p==0)
        res+=i+1;
    }
    cout << res << endl;
    return 0;
  }
  fill(t,t+p,0);
  for(i=0;i<p-1;i++){
    r[i]=tt%p;
    tt=r[i]*10;
  }
  for(i=0;i<n;i++){
    tt=stoi(s.substr(n-1-i,1));
    rr+=tt*r[i%(p-1)];
    rr%=p;
    t[rr]++;
  }
  res=t[0]*(t[0]+1)/2;
  for(i=1;i<p;i++)
    res+=t[i]*(t[i]-1)/2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 644
<?php
list($X)=sscanf(trim(fgets(STDIN)),"%d");

$total = ($X*($X+1))/2;
for ($i=0; $i <= $X; $i+= 3) { 
    $total -= $i;
}
for ($i=0; $i <= $X; $i+= 5) { 
    $total -= $i;
}

for ($i=0; $i <= $X; $i+= 15) { 
    $total += $i;
}


printf($total);

Measured memory_bytes: 16116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int main(){cin>>n;cout<<3*n*n<<endl;}

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

int main(void) {
    int n, nx = 0, ny = 0;
    bool flag = true;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t, x, y, dist;
        cin >> t >> x >> y;
        dist = abs(nx - x) + abs(ny - y);
        if (dist > t || abs(dist - t) % 2) {
            flag = false;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c[105],ans,kiki;
int main()
{
	cin>>a>>b;
	for(int s=0;s<a;s++)
	{
		cin>>c[s];
	}
	sort(c,c+a);
	for(int s=0;s<a;s++)
	{
		if(b-c[s]>=0)b-=c[s],ans++;
		else 
		{
			kiki=1;break;
		}
	}
	if(kiki==0&&b>0)ans--;
	cout<<ans<<endl;
}

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

typedef struct _node{
    int key;
    struct _node *left;
    struct _node *right;
}NODE;
NODE* makeNode(int x){
    NODE *n=(NODE*)malloc(sizeof(NODE));
    n->key=x;
    n->left=NULL;
    n->right=NULL;
    
    return n;
}
NODE* insert(NODE *t,int x){
    if(t==NULL)return makeNode(x);

    if(t->key<x)t->right=insert(t->right,x);
    else t->left=insert(t->left,x);
    
    return t;
}
void inorder(NODE *t){
    if(t==NULL)return;
    
    if(t->left!=NULL)inorder(t->left);
    printf(" %d",t->key);
    if(t->right!=NULL)inorder(t->right);
    
    return;
}
void preorder(NODE *t){
    if(t==NULL)return;
    
    printf(" %d",t->key);
    if(t->left!=NULL)preorder(t->left);
    if(t->right!=NULL)preorder(t->right);
    
    return;
}
void find(NODE *t,int x){
    if(t==NULL){
        printf("no\n");
        return;
    }
    
    if(t->key==x){
        printf("yes\n");
        return;
    }
    else if(t->key<x)find(t->right,x);
    else find(t->left,x);
}
int main(void){
    NODE *root;
    root=NULL;
    
    int n;
    scanf("%d\n",&n);
    
    char com[6+1];
    int x;
    while(n--){
        scanf("%s",com);
        switch(com[0]){
            case 'i':
                //insert
                scanf("%d\n",&x);
                root=insert(root,x);
                break;
            case 'p':
                //print
                inorder(root);
                printf("\n");
                preorder(root);
                printf("\n");
                break;
            case 'f':
                scanf("%d\n",&x);
                find(root,x);
                break;
        }
    }
    
    return 0;
}



Measured memory_bytes: 14196
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
using namespace std;
#define MOD 1000000007
unsigned long long power(unsigned long long n,unsigned long long k)
{
    unsigned long long r=1;
    while(k>0)
    {
        if(k%2==1)
        r=(r*n);
        n=(n*n);
        k/=2;
    }
    return r;
}
int main()
{
  unsigned long long i,n,a[100005],t,k,sum;
  
      cin>>n>>k;
      cout<<(k*power(k-1,n-1));
        
 
  
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int a[3];
	rep(i, 3)cin >> a[i];
	sort(a, a+3);
	cout << a[2] - a[1]+a[1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    string s;
    cin>>s;
    map<char,int> m;
    rep(i,4){
        m[s[i]]++;
    }
    bool f = false;
    if(m.size()==2){
        int b = 0;
        for(auto &a:m){
            if(a.second==2){
                b++;
            }
        }
        if(b==2)f = true;
    }
    if(f){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1005,INF=1<<30;

int main(){
    
    double R,C;int N;cin>>R>>C>>N;
    vector<pair<double,int>> P;
    for(int i=0;i<N;i++){
        double a,b,c,d;cin>>a>>b>>c>>d;
        if((a!=0&&a!=R&&b!=0&&b!=C)||(c!=0&&c!=R&&d!=0&&d!=C)) continue;
        P.push_back({atan2(a-R/2.0,b-C/2.0),i});
        P.push_back({atan2(c-R/2.0,d-C/2.0),i});
    }
    
    bool ok=true;
    
    sort(all(P));
    stack<int> ST;
    vector<int> used(N,0);
    for(int i=0;i<P.size();i++){
        int a=P[i].second;
        if(used[a]){
            if(ST.top()==a){
                ST.pop();
                used[a]=0;
            }else ok=false;
        }else{
            ST.push(a);
            used[a]=1;
        }
    }
    
    cout<<((ok) ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 6256
s = (input())
a= s[0:2]
b= s[2:4]
a = int(a)
b= int(b)
if a == 0 or b == 0:
  if b!= 0 and b<13:
    print('YYMM')
  elif a!= 0 and a<13:
    print('MMYY')
  else:
    print('NA')
elif a<13 or b<13:
  if a>12:
    print('YYMM')
  elif b>12:
    print('MMYY')
  else:
    print('AMBIGUOUS')
else:
  print('NA')

Measured memory_bytes: 3064
class Dice:
    def __init__(self, men):
        self.men = men

    def throw(self, direction):
        if direction == "E":
            pmen = men[:]
            men[0] = pmen[3]
            men[1] = pmen[1]
            men[2] = pmen[0]
            men[3] = pmen[5]
            men[4] = pmen[4]
            men[5] = pmen[2]
        elif direction == "W":
            pmen = men[:]
            men[0] = pmen[2]
            men[1] = pmen[1]
            men[2] = pmen[5]
            men[3] = pmen[0]
            men[4] = pmen[4]
            men[5] = pmen[3]
        elif direction == "S":
            pmen = men[:]
            men[0] = pmen[4]
            men[1] = pmen[0]
            men[2] = pmen[2]
            men[3] = pmen[3]
            men[4] = pmen[5]
            men[5] = pmen[1]
        elif direction == "N":
            pmen = men[:]
            men[0] = pmen[1]
            men[1] = pmen[5]
            men[2] = pmen[2]
            men[3] = pmen[3]
            men[4] = pmen[0]
            men[5] = pmen[4]


    def printUe(self):
        print (self.men)[0]

    def printMigi(self):
        print (self.men)[2]

    def printMen(self):
        print self.men


men = map(int, (raw_input()).split(" "))
d = Dice(men)

q = int(raw_input())

for i in range(q):
    Q = map(int, (raw_input()).split(" "))
    if(d.men[2] == Q[1] or d.men[3] == Q[1]):
        d.throw("E")

    while(d.men[1] != Q[1]):
        d.throw("S")

    while(d.men[0] != Q[0]):
        d.throw("E")

    d.printMigi()

Measured memory_bytes: 6480
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

struct Circle
{
	double x, y;
	double r;
};

int hit(Circle c0, Circle c1)
{
	double x = (c1.x - c0.x);
	double y = (c1.y - c0.y);

	double d = sqrt(x * x + y * y);
	if (d <= c0.r + c1.r)
	{
		if (c0.r + d < c1.r)
		{
			return -2;
		}
		else if (c1.r + d < c0.r)
		{
			return 2;
		}
		else
		{
			return 1;
		}
	}
	else
	{
		return 0;
	}
}

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		Circle c0, c1;
		cin >> c0.x >> c0.y >> c0.r;
		cin >> c1.x >> c1.y >> c1.r;

		cout << hit(c0, c1) << endl;
	}
}



Measured memory_bytes: 3200
N, A, B, C, D = gets.split.map &:to_i
x = B - A + (N - 1) * D
y = (N - 1) * (D - C)
puts (C + D == 0 ? A == B : x % (C + D) <= y && (A - B).abs < N * D) ? "YES" : "NO"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

struct Edge {
	int to;
	int cost;
	int64_t time;
	Edge(int to, int cost, int64_t time) : to(to), cost(cost), time(time) {}
};
pair<int64_t, int64_t> ex[55];
vector<Edge> edge[55];
int64_t dp[55][3010];
constexpr int64_t MAX = 3000;

int main() {
	for(int i = 0; i < 55; ++i) {
		for(int j = 0; j < 3010; ++j) {
			dp[i][j] = LINF;
		}
	}
	int64_t n, m, s; cin >> n >> m >> s;
	while(m--) {
		int u, v, a, b; cin >> u >> v >> a >> b;
		--u, --v;
		edge[u].emplace_back(v, a, b);
		edge[v].emplace_back(u, a, b);
	}
	for(int i = 0; i < n; ++i) {
		int c, d; cin >> c >> d;
		ex[i] = {c, d};
	}
	dp[0][min(s, MAX)] = 0;
	priority_queue<tuple<int64_t, int, int>, vector<tuple<int64_t, int, int>>, greater<tuple<int64_t, int, int>>> pq;
	pq.emplace(0, min(s, MAX), 0);
	// for(int q = 0; q < 300; ++q) {
	while(not pq.empty()) {
		int64_t ti, co, from;
		tie(ti, co, from) = pq.top();
		pq.pop();
		if(ti > dp[from][min<int64_t>(MAX, co)]) continue;
		// cerr << ti << " " << co << " " << from << " " << dp[from][min<int64_t>(MAX, co)] << '\n';
		int64_t nc = co + ex[from].first;
		int64_t nt = ti + ex[from].second;
		if(nt < dp[from][min<int64_t>(MAX, nc)]) {
			dp[from][min<int64_t>(MAX, nc)] = nt;
			pq.emplace(nt, nc, from);
		}
		for(auto& e : edge[from]) {
			if(co - e.cost >= 0) {
				if(ti + e.time < dp[e.to][min<int64_t>(MAX, co - e.cost)]) {
					dp[e.to][min<int64_t>(MAX, co - e.cost)] = ti + e.time;
					pq.emplace(ti + e.time, min<int64_t>(MAX, co - e.cost), e.to);
				}
			}
		}
	}
	// cerr << "ok" << '\n';
	for(int i = 1; i < n; ++i) {
		int64_t mini = LINF;
		for(int j = 0; j < MAX; ++j) {
			mini = min(mini, dp[i][j]);
		}
		cout << mini << '\n';
	}
	return 0;
}

Measured memory_bytes: 6588
#include <iostream>
#include <string>
using namespace std;
int n;
string str;
bool flag;

int solve(string s,char s0, char s1){
    char prev=s0,temp=s1,next;
    if(flag)cout<<prev;
    for(int i=1; i<s.size();i++){
        if(temp=='S')
            if(s[i]=='o' && prev=='S')next='S';
            else if(s[i]=='o' && prev=='W')next='W';
            else if(s[i]=='x' && prev=='S')next='W';
            else next='S';
        else{
            if(s[i]=='o' && prev=='S')next='W';
            else if(s[i]=='o' && prev=='W')next='S';
            else if(s[i]=='x' && prev=='S')next='S';
            else next='W';
        }
        if(flag)cout<<temp;
        prev=temp; 
        temp=next;
    }
    if(next != s0)return 0;
    if(s0=='S' && s1=='S' && prev=='S' && s[0]=='o')return 1;
    else if(s0=='S' && s1=='W' && prev=='W' && s[0]=='o')return 1;
    else if(s0=='S' && s1=='S' && prev=='W' && s[0]=='x')return 1;
    else if(s0=='S' && s1=='W' && prev=='S' && s[0]=='x')return 1;
    else if(s0=='W' && s1=='S' && prev=='W' && s[0]=='o')return 1;
    else if(s0=='W' && s1=='W' && prev=='S' && s[0]=='o')return 1;
    else if(s0=='W' && s1=='W' && prev=='W' && s[0]=='x')return 1;
    else if(s0=='W' && s1=='S' && prev=='S' && s[0]=='x')return 1;
    else return 0;
}


int main(void){
    cin>>n>>str;
    flag=solve(str,'S','S');
    if(flag){ flag=solve(str,'S','S'); return 0;}
    flag=solve(str,'S','W');
    if(flag){ flag=solve(str,'S','W'); return 0;}
    flag=solve(str,'W','S');
    if(flag){ flag=solve(str,'W','S'); return 0;}
    flag=solve(str,'W','W');
    if(flag){ flag=solve(str,'W','W'); return 0;}
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int ans = 0;
    while (n) {
        n /= k;
        ans++;
    }
    cout << ans;
}

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

class Bit {
	std::vector<int> _array;
	void add(int to, int add_value) {
		while (to >= 0) {
			_array[to] += add_value;
			to -= ~to & (to + 1);
		}
	}
public:
	Bit(int size) :_array(size, 0) {}
	void add(int from, int to, int add_value) {
		--from; --to;
		add(to, add_value);
		add(from - 1, -add_value);
	}
	int get(int pos) const {
		--pos;
		int res = 0;
		while (pos < _array.size()) {
			res += _array[pos];
			pos += ~pos & (pos + 1);
		}
		return res;
	}
};
int main() {
	int n, q;
	std::cin >> n >> q;
	int query, s, t, x, i;
	Bit bit(n);
	for (auto count = 0; count < q; ++count) {
		std::cin >> query;
		switch (query) {
		case 0:
			std::cin >> s >> t >> x;
			bit.add(s, t, x); break;
		case 1:
			std::cin >> i;
			std::cout << bit.get(i) << std::endl;
		}
	}
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int n,i;
    char s[100]={},t[100]={},ans[220]={};
    scanf("%d %s %s",&n,s,t);
    for(i=0; i<n; i++){
        ans[2*i]=s[i];
        ans[2*i+1]=t[i];
    }
    printf("%s",ans);
    return 0;
}

Measured memory_bytes: 1728
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int a = in.nextInt();
        int b = in.nextInt();

        for (int i = 0; i < 10000; i++) {
            if (check(i, 0.08) == a && check(i, 0.1) == b) {
                out.println(i);
                return;
            }
        }
        out.println(-1);
        return;
    }

    private static int check(int orig, double tax) {
        return (int) Math.floor((double) orig * tax);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        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: 24656
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[260];
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cout << "node " << i << ": key = " << a[i] << ", ";
    if (i / 2 > 0) cout << "parent key = " << a[i / 2] << ", ";
    if (i * 2 <= n) cout << "left key = " << a[i * 2] << ", ";
    if (i * 2 + 1 <= n) cout << "right key = " << a[i * 2 + 1] << ", ";
    cout << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    string k;
    cin >> n >> k;
    if (k.length() <= (size_t)n) {
        cout << k << endl;
    } else {
        cout << k.substr(0, (size_t)n) + "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  double m;
  cin>>n;
  cin>>m;
  int a[n];
  double cnt=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    cnt+=a[i];
  }
  double k=cnt/(4.0*m);
  int kk=0;
  for(int i=0;i<n;i++)
  {
    if(a[i]>=k)
    {
      kk++;
    }
  }
  if(kk>=m)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

const int Maxn = (int)1e5 + 10;

ll a[Maxn], b[Maxn];

int n, h;
ll maxv;

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
     */
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        maxv = max(maxv, a[i]);
    }
    sort(b, b + n, greater<ll>());

    int ans = (h + maxv - 1) / maxv;
    for (int i = 0; i < n; ++i) {
        h -= b[i];
        int k = 0;
        if (h > 0) k = (h + maxv - 1) / maxv;
        ans = min(ans, i + 1 + k);
    }
    cout << ans << endl;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N, M;

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

  cin >> N >> M;
  VI xs(N+1), num(N+1);
  REP(i,N){
	cin >> xs[i+1];
	num[xs[i+1]]++;
  }
  VI acc(2*N+10);
  FOR(i,1,N+1){
	acc[i-num[i]+N]++;
	acc[i+N]--;
  }
  REP(i,2*N+9) acc[i+1] += acc[i];

  int ans = 0;
  REP(i,2*N+9)
	if(i < N)
	  ans += acc[i];
	else if(acc[i] > 1)
	  ans += acc[i] - 1;
  REP(i,M){
	/*
	  REP(i,2*N+1) cout << acc[i]<<" ";
	  cout<<endl;
	*/  
	int x, y;
	cin >> x >> y;
	int l = xs[x] - num[xs[x]];
	if(l < 0 || acc[l+N] > 1){
	  --ans;
	}

	acc[l+N]--;
	num[xs[x]]--;
	num[y]++;
	l = y - num[y];
	if(l < 0 || acc[l+N] >= 1)
	  ++ans;
	acc[l+N]++;
	xs[x] = y;
	cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4608