akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			A[i] = sc.nextInt();
		}
		// printArray(A);
		int[] sum = new int[N+1];
		for (int i = N; i > 0; i--) {
			// if (i * 2 > N) {
			// 	sum[i] = A[i];
			// 	continue;
			// }
			int sum2 = A[i];
			for (int j = i * 2; j <= N; j += i) {
				sum2 += sum[j];
			}
			sum[i] = sum2 % 2;
		}
		// printArray(sum);

		int cnt = 0;
		boolean isFirst = true;
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= N; i++) {
			if (sum[i] != 0) {
				cnt++;
				if (isFirst) {
					isFirst = false;
				} else {
					sb.append(" ");
				}
				sb.append(i);
			}
		}

		System.out.println(cnt);
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 69956
/*PM1　問題７*/
#include <stdio.h>
int main()
{
	int a, b, c;
	int temp;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b)
	{
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c)
	{
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b)
	{
		temp = a;
		a = b;
		b = temp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2112
//===========================================
// Contents    : AOJ ITP1_3_B
//               整数 x を読み込んでそのまま出力
// Constraints : 1 ≤ x ≤ 10,000
//               データセットの数は10,000以下
// Author      : 廣部智也
// LastUpdate  :
// Since       : 2020/05/23
//===========================================

#include <stdio.h>

int main(void){
    
    int i = 0;
    int j = 0;
    int x[10000] = {};
    
    // データの入力
    while( i < 10000 ){
        
        scanf("%d", &x[i]);
        
        if( x[i] < 0 || x[i] > 10000 ){             // if( x[i] < 1 || x[i] > 10000 ){
                                                    //  → x = 0 が入力終了を示す値なので、はじく範囲を x[i] < 0 に変更
            return 0;
        }
        
        // x = 0 で入力終了
        if( x[i] == 0){
            break;
        }
        
        i++;
        
    }
    
    // データの入力が1つも無い場合、ここで終了
    if( i == 0){
        return 0;
    }
    
    // データの出力
    for( j = 0 ; j < i ; j++ ){                     // for( j = 0 ; j < i + 1 ; j++ ){
                                                    //  → iがインクリメントされる前にwhile文を抜けるので、j < i に変更
        printf("Case %d: %d\n", j + 1, x[j]);
    }
    
    return 0;
}


Measured memory_bytes: 1980
// B. 

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

vector<int> children[100001];

int dfs(int n) {
	vector<int> depth;
	for (int c : children[n]) {
		depth.push_back(dfs(c));
	}
	int r = 0;
	sort(depth.begin(), depth.end());
	for (int d : depth) {
		r = 1 + max(r, d);
	}
	return r;
}

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	for (int i = 2; i <= N; ++i) {
		int a;
		cin >> a;
		children[a].push_back(i);
	}
	int ans = dfs(1);
	cout << ans << endl;
	return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int prev, now, ans = 0;
    rep(n){
        cin >> now;
        if(now == prev){
            ans++;
            prev = -1;
        }else{
            prev = now;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
def z_algorithm(s: str) -> list:
	n = len(s)
	Z = [0] * n
	Z[0] = n
	i, j = 1, 0
	while i < n:
		while i + j < n and s[j] == s[i + j]:
			j += 1
		Z[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < n and k + Z[k] < j:
			Z[i + k] = Z[k]
			k += 1
		i += k
		j -= k
	return Z


def main():
	n = int(input())
	s = input()
	ans = 0
	for i in range(n):
		t = max(min(i,x) for i,x in enumerate(z_algorithm(s[i:])))
		ans = max(ans, t)
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 55516
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


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

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int h,w,k;
    cin>>h>>w>>k;
    char maze[h][w];
    int mem[h];
    int fi=-1;
    rep(i,h){ int cnt=0;
    rep(j,w){
        char a;
        cin>>a;
        maze[i][j]=a;
        if (a=='#') cnt++;
        }
        mem[i]=cnt;
        if (cnt!=0 && fi==-1) fi=i;
        //cout<<mem[i];
    }
    int ans[h][w];
    int write=1;
    for (int i=fi;i<h;i++){
        if (mem[i]==0 && i==0) continue;
        int cnt=1;
        rep(j,w){
            if (mem[i]==0) {
                ans[i][j]=ans[i-1][j];
            }else{
                ans[i][j]=write;
                if (j==w-1) write++;
                if (cnt==mem[i]) continue;
                if (maze[i][j]=='#') {
                    cnt++;
                    write++;
                } 
            }
            
            
        }
        
    }
    if (fi!=0) {
        rep(i,fi) rep(j,w){
            ans[i][j]=ans[fi][j];
        }
    }
    
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
int main()
{
int n,m,k;
scanf("%d %d %d",&n,&m,&k);
if(n+m+k>=22){
    printf("bust");
}
else{
    printf("win");
}

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

A = input_int()
B = input_int()

ans = set([1, 2, 3]) - set([A, B])

print(list(ans)[0])

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


int main()
{
  	int n;
  	cin>>n;
  	
  	int a;
  	
  	int maxV=1e6+1;
  	int flag[maxV]={0};
  	
  	int gcd=0;
  	
  	for(int i=0;i<n;i++)
  	{
  	    cin>>a;
  	    flag[a]++;
  	    
  	    gcd=__gcd(gcd,a);
  	}
  	
  	bool f1=true;
  	
  	for(int i=2;i<maxV;i++)
  	{
  	    int cnt=0;
  	    for(int j=i;j<maxV;j+=i)
  	    {
  	        cnt+=flag[j];
  	    }
  	    
  	    if(cnt>1)
  	        f1=false;
  	}
  	
  	if(f1)
  	{
  	    cout<<"pairwise coprime"<<endl;
  	}
  	else if(gcd==1)
  	{
  	    cout<<"setwise coprime"<<endl;
  	}
  	else
  	{
  	    cout<<"not coprime"<<endl;
  	}
  	
  	return 0;
}

Measured memory_bytes: 7544
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
#define pb push_back
// to floor a/b you can do a/b and to ceiling a/b you can do (a+b-1)/b
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=(r* x);
        x=(x* x);
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=(c[j]%mod + c[j-1]%mod)%mod;
    }
    return c[k];
}

bool prime[1001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100;j=j+i)
                prime[j]=false;
        }
    }
}
//Start of Matrix Exponentiation Code
void mat_mul(ll F[2][2],ll M[2][2]) {
   ll a = ((F[0][0]%mod * M[0][0]%mod)%mod + (F[0][1]%mod * M[1][0]%mod)%mod)%mod;
   ll b = ((F[0][0]%mod * M[0][1]%mod)%mod + (F[0][1]%mod * M[1][1]%mod)%mod)%mod;
   ll c = ((F[1][0]%mod * M[0][0]%mod)%mod + (F[1][1]%mod * M[1][0]%mod)%mod)%mod;
   ll d = ((F[1][0]%mod * M[0][1]%mod)%mod + (F[1][1]%mod * M[1][1]%mod)%mod)%mod;
   F[0][0] = a;
   F[0][1] = b;
   F[1][0] = c;
   F[1][1] = d;
}
void mpower(ll F[2][2], ll n) {
   if (n == 0 || n == 1)
      return;
   ll M[2][2] = {{1,1},{1,0}};
   mpower(F, n / 2);
   mat_mul(F, F);
   if (n % 2 != 0)
      mat_mul(F, M);
}
ll fib_mat(ll n) {
   ll F[2][2] = {{1,1},{1,0}};
   if (n == 0)
      return 0;
   mpower(F, n - 1);
   return F[0][0]%mod;
}
//End of Matrix Exponentiation
/*
Segment Tree
ll ar[200005];
ll st[800005];
void build(ll si,ll ss,ll se)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return ;
    }
    ll mid=(ss+se)/2;
    build(2*si,ss,mid);
    build(2*si+1,mid+1,se);
    st[si]=(st[2*si]+st[2*si+1]);
}
ll query(ll si,ll ss,ll se,ll l,ll r)
{

   if(l<=ss && se<=r)
     return st[si];
   if(l>se || r<ss)
    return 0;
   ll mid=(ss+se)/2;
   ll x=query(2*si,ss,mid,l,r);
   ll y=query(2*si+1,mid+1,se,l,r);
   return x+y;
}
void update(ll si,ll ss,ll se,ll qi)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return;
    }
    ll mid=(ss+se)/2;
    if(qi<=mid)
        update(2*si,ss,mid,qi);
    else
        update(2*si+1,mid+1,se,qi);
    st[si]=st[2*si]+st[2*si+1];
}
*/

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,k,i,j;
	cin>>n>>k;
	ll a[n],dp[n];
	for(i=0;i<n;i++)
        {
            cin>>a[i];
            dp[i]=INT_MAX;
        }
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        for(j=(i-k>=0?i-k:0);j<i;j++)
        {
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 5212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        PrintWriter out = new PrintWriter(System.out);

        try {
    		String strData = br.readLine();
    		String strAA = strData.substring(0, 2);
    		String strBB = strData.substring(2, 4);

    		int intAA = Integer.parseInt(strAA);
    		int intBB = Integer.parseInt(strBB);

    		boolean bAA = false;
    		boolean bBB = false;

    		if (intAA >= 1 && intAA <= 12) bAA = true;
    		if (intBB >= 1 && intBB <= 12) bBB = true;

    		if (bAA && bBB) {
    			System.out.print("AMBIGUOUS");
    		} else if (bAA && !bBB) {
    			System.out.print("MMYY");
    		} else if (!bAA && bBB) {
    			System.out.print("YYMM");
    		} else {
    			System.out.print("NA");
    		}


    		out.flush();


        } catch (IOException e) {

        }


    }


}

Measured memory_bytes: 20692
#define _CRT_SECURE_NO_WARNINGS

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define sc(x) scanf("%d", &x)
#define sc2(x, y) scanf("%d%d", &x, &y)
#define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sc4(x, y, z, t) scanf("%d%d%d%d", &x, &y, &z, &t)
#define print(x) printf("%d ", x)
#define println(x) printf("%d\n", x)
#define println2(x, y) printf("%d %d\n", x, y)
#define println3(x, y, z) printf("%d %d %d\n", x, y, z)
#define println4(x, y, z, t) printf("%d %d %d %d\n", x, y, z, t)
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'                           // CommentInInteractive
#define DB(x) cerr << #x << " = " << x << endl

const ld eps = 1e-6;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;

void solve() {
    int a, b, m;
    sc3(a, b, m);
    vi ref(a), mic(b);
    for (int i = 0; i < a; ++i) sc(ref[i]);
    for (int i = 0; i < b; ++i) sc(mic[i]);
    int ans = inf;
    for (int i = 0; i < m; ++i) {
        int x, y, c;
        sc3(x, y, c);
        int pr = (ref[x - 1] + mic[y - 1]) - c;
        ans = min(ans, pr);
    }
    sort(all(ref));
    sort(all(mic));
    ans = min(ans, ref[0] + mic[0]);
    println(ans);
}

//#define FILES
//#define TIME

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

#ifdef FILES
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    auto start = chrono::high_resolution_clock::now();
    solve();
    auto stop = chrono::high_resolution_clock::now();

#ifdef TIME
    cerr << chrono::duration_cast <chrono::milliseconds> (stop - start).count() << " ms\n";
#endif
    return 0;
}

Measured memory_bytes: 1024
def factorial(n):
    if n > 1:
        return n * factorial(n - 1)
    else:
        return 1
        
m,n=map(int,input().split())
#n = 100
#m = 100

result = (int)(factorial(n)/(factorial(2) * factorial(n - 2)))
result += (int)(factorial(m)/(factorial(2) * factorial(m - 2)))

print(result)

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

int main() {
  int n,a;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if (a%2 == 0 && a%3 != 0 && a%5 != 0){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[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 ) * } } ; }
#[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 , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;

fn gcd(x:i64, y:i64) -> i64 {
    if y == 0 { return x; }
    gcd(y, x%y)
}

fn main() {
    input!{n:usize, X:i64, x:[i64;n]};
    let mut v:Vec<i64> = Vec::new();
    for i in 0..n {
        v.push((X-x[i]).abs());
    }
    //debug!(v);
    let mut ans = v[0];
    for i in 1..n {
        ans = gcd(ans, v[i]);
        //debug!(ans);
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=2e9;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=b;i++){
        if((i*a%b)==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <array>
#include <cmath>
#include <iostream>
#include <string>

std::string hoge;
std::array<int, 4> num;

int ans = 0;
int main()
{
    std::cin >> hoge;
    int tmo = std::stoi(hoge);
    num.at(0) = tmo / 1000;
    num.at(1) = (tmo / 100) % 10;
    num.at(2) = (tmo / 10) % 10;
    num.at(3) = tmo % 10;
    int tmp;
    for (int i = 0; i < 8; i++) {
        tmp = num.at(0);
        tmp += num.at(1) * (i % 2 == 0 ? 1 : -1);
        tmp += num.at(2) * ((i / 2) % 2 == 0 ? 1 : -1);
        tmp += num.at(3) * ((i / 4) % 2 == 0 ? 1 : -1);
        if (tmp == 7) {
            std::cout << num.at(0) << (i % 2 == 0 ? "+" : "-") << num.at(1) << ((i / 2) % 2 == 0 ? "+" : "-") << num.at(2) << ((i / 4) % 2 == 0 ? "+" : "-") << num.at(3) << "=7" << std::endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],L[2<<17],R[2<<17];
dfs1(u,p,id)
{
	dp1[u]=1;
	for(id=first[u];id;id=next[id])eb[id]-p?dfs1(eb[id],u),dp1[u]=dp1[u]*-~dp1[eb[id]]%M:0;
}
/*dfs2(u,p,x,id)
{
	id=first[u];
	dp2[u]=dp1[u]*x%M;
	make(id,p,x);
	for(;id;id=next[id])
	{
		if(eb[id]!=p)dfs2(eb[id],u,L[id]*R[next[id]]%M+1);
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]-p?-~dp1[eb[i]]:1;
		make(x=next[i],p,t%M*x%M);
		R[i]=R[x]*t%M;
	}
}*/
dfs2(u,p,x,id)
{
	id=first[u];
	dp2[u]=dp1[u]*x%M;
	make(id,p);
	for(;id;id=next[id])
	{
		if(eb[id]!=p)dfs2(eb[id],u,R[next[id]]*x%M+1),x=x%M*-~dp1[eb[id]]%M;
	}
}
make(i,p)
{
	if(i)
	{
		make(next[i],p);
		R[i]=R[next[i]]*(eb[i]-p?-~dp1[eb[i]]:1)%M;
	}
}
main(u,v)
{
	/*for(scanf("%d%d",&n,&M);~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}*/
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i]=eb[i+1]=u,ea[i+1]=eb[i]=v,i++:(n=u,M=v);
	for(;~scanf("%d%d",&u,&v);i++)i++?ea[i-1]=eb[i]=u,ea[i]=eb[i-1]=v:(n=u,M=v);
	for(;i--;)
	{
		next[i]=first[ea[i]];
		first[ea[i]]=i;
	}
	dfs1(*R=1,0);
	dfs2(1,0,1);
	for(i=1;i<=n;i++)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int x[] = new int[N];
		int y[] = new int[N];
		int h[] = new int[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		for (int cx = 0; cx <= 100; cx++) {
			for (int cy = 0; cy <= 100; cy++) {
				int hh = -1;
				for (int i = 0; i < N; i++) {
					if (h[i] == 0) {
						if (hh != -1) {
							if (0 < hh - Math.abs(x[i] - cx)
									- Math.abs(y[i] - cy)) {
								break;
							}
						}

					} else {
						if (hh == -1) {
							hh = h[i] + Math.abs(x[i] - cx)
									+ Math.abs(y[i] - cy);

						} else {
							if (hh != h[i] + Math.abs(x[i] - cx)
									+ Math.abs(y[i] - cy)) {
								break;
							}
						}
					}
					if (i == N - 1) {
						for (int j = 0; j < N; j++) {
							if (h[j] == 0) {
								if (0 < hh - Math.abs(x[j] - cx)
										- Math.abs(y[j] - cy)) {
									break;

								}
							}else{
								if (hh != h[j] + Math.abs(x[j] - cx)
										+ Math.abs(y[j] - cy)) {
									break;
								}
							}
							if (j == N - 1) {
								System.out.println(cx + " " + cy + " " + hh);
								return;
							}
						}

					}
				}

			}
		}

	}

}


Measured memory_bytes: 24020
# 2019-11-13 21:06:16(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k, *v = [int(x) for x in sys.stdin.read().split()]

    ma = 0
    for a in range(min(n, k)+1):
        for b in range(min(n, k)-a+1):
            take = v[:a] + v[-b:] if b != 0 else v[:a]
            take.sort()
            
            if a + b == 0:
                optimum_sum = 0
            else:
                if k - (a + b) >= a + b:
                    for i in range(a+b-1, -1, -1):
                        if take[i] > 0:
                            continue
                        else:
                            optimum_sum = sum(take[i+1:])
                            break
                    else:
                        optimum_sum = sum(take)
                else:
                    for i in range(k-(a+b)-1, -1, -1):
                        if take[i] > 0:
                            continue
                        else:
                            optimum_sum = sum(take[i+1:])
                            break
                    else:
                        optimum_sum = sum(take)
            
            ma = max(ma, optimum_sum)
    
    print(ma)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,k,h[200001];
    cin>>n>>k;
    rep(i,n) cin>>h[i];
    int dp[200001];
    fill(dp,dp+n,1e9);
    dp[0]=0;
    rep(i,n){
        rep(j,min(i+1,k)) dp[i+1]=min(dp[i+1],dp[i-j]+abs(h[i+1]-h[i-j]));
    }
    cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define poi 1000000
#define int long long
using namespace std;
inline int re()
{
	char c=getchar();
	int x=0,k=1;
	while(c<'0'||c>'9')
	{if(c=='-') k=-1;c=getchar();}
	while(c>='0'&&c<='9')
	{x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*k;
}
void wr(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) wr(x/10);
	putchar(x%10+'0');
}
signed main()
{
	int n=re()-1,m=re();
	if(n<0) wr(m),exit(0);
	switch(n%4)
	{
		case 0:{
			n=n;
			break;
		}
		case 1:{
			n=1;
			break;
		}
		case 2:{
			n++;
			break;
		}
		case 3:{
			n=0;
			break;
		}
	}
	switch(m%4)
	{
		case 0:{
			m=m;
			break;
		}
		case 1:{
			m=1;
			break;
		}
		case 2:{
			m++;
			break;
		}
		case 3:{
			m=0;
			break;
		}
	}
	wr(n^m);
	return 0;
}
/*
2 4
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main()
{

	int N;
	cin >> N;
	vector<int> a(N);

	vector<int> cnt(2123456);
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}
	int ans = N;

	for (int i = 0; i < N; i++)
	{
		if (cnt[a[i]] > 1 || (a[i] != 1 && cnt[1] > 0))
		{
			ans--;
			continue;
		}
		for (int j = 2; j * j <= a[i]; j++)
		{
			if (a[i] % j == 0 && (cnt[a[i] / j] > 0 || cnt[j] > 0))
			{
				ans--;
				break;
			}
		}
	}

	cout << ans << "\n";
}

Measured memory_bytes: 12248
m = 1000000
p = [True] * (m+1)
for i in range(2, m+1):
    if p[i-2]:
        for j in range(i*2, m+1, i):
            p[j-2] = False

while True:
    try:
        n = int(raw_input())
        print p[:n-1].count(True)
    except EOFError:
        break

Measured memory_bytes: 59496
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << (x) << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << ((a)[qwq]);\
		else cerr << ", " << ((a)[qwq]);\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template<typename A, typename B>
ostream& operator << (ostream& out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}

const int maxN = 500 + 5;
int n, d[maxN][maxN];
int on[maxN][maxN];

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
queue<pii> q0, q1;
void bfs() {
	while(q0.size() || q1.size()) {
		if(q0.size() == 0) q0.swap(q1);
		int x = q0.front().first, y = q0.front().second;
		q0.pop();
		for(int i = 0; i < 4; ++i) {
			int nx = x + dx[i], ny = y + dy[i];
			if(chmin(d[nx][ny], d[x][y] + on[nx][ny])) {
				if(on[nx][ny]) q1.emplace(nx, ny);
				else q0.emplace(nx, ny);
			}
		}
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	cin >> n;
	memset(d, 0, sizeof(d));
	memset(on, 0, sizeof(on));
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			d[i][j] = n, on[i][j] = 1;
	for(int i = 1; i <= n; ++i)
		d[1][i] = d[n][i] = d[i][1] = d[i][n] = 1,
		q0.emplace(1, i),
		q0.emplace(n, i),
		q0.emplace(i, 1),
		q0.emplace(i, n);
	bfs();
	LL ans = 0;
	for(int i = 1; i <= n * n; ++i) {
		int p; cin >> p;
		int x = (p - 1) / n + 1, y = (p - 1) % n + 1;
//		eprintf("dispose (%d, %d)\n", x, y);
		for(int i = 0; i < 4; ++i) {
			int nx = x + dx[i], ny = y + dy[i];
			chmin(d[x][y], d[nx][ny]);
		}
		ans += d[x][y];
		on[x][y] = false;
		q0.emplace(x, y);
		bfs();
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5828
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back
 
using namespace std; 


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

    int t;  t = 1; //cin >> t;
    while(t--){
        int x; cin >> x;
        if(x >= 30)
            cout << "Yes" << endl;
        else 
            cout << "No" << endl;
    }
    return 0;
}

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

long long gcd(long long m, long long n) {
    long long temp;
    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }
    return n;
}

int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    long long ans;
    long long total;
    long long divC, divD, divCD;
    total = B - A + 1;

    if (C == D) {
        divC = B / C - (A - 1) / C;
        ans = total - divC;
    }
    else {
        long long GCD, LCM;
        if (C < D) {
            GCD = gcd(D, C);
        }
        else {
            GCD = gcd(C, D);
        }
        LCM = C * D / GCD;

        if (C == D) {
            divC = B / C - (A - 1) / C;
            ans = total - divC;
        }
        else {
            divC = B / C - (A - 1) / C;
            divD = B / D - (A - 1) / D;
            divCD = B / LCM - (A - 1) / LCM;
            ans = total - divC - divD + divCD;
        }
    }
    cout << ans << endl;

}


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

class Treap
{
    typedef struct _Node
    {
        int x,y,cnt;
        _Node *l,*r;
        _Node(int _x) : x(_x),y((rand()<<16)^rand()),cnt(1),l(NULL),r(NULL) {}
        ~_Node()
        {
            delete l;
            delete r;
        }
        void recalc()
        {
            cnt = 1;
            if(l)
                cnt+=l->cnt;
            if(r)
                cnt+=r->cnt;
        }
    }
    *Node;
    Node merge(Node l,Node r)
    {
        if(!l || !r)
            return l?l:r;
        if(l->y < r->y)
        {
            l->r = merge(l->r,r);
            l->recalc();
            return l;
        }
        else
        {
            r->l = merge(l,r->l);
            r->recalc();
            return r;
        }
    }
    void split(Node v,int x,Node &l,Node &r)
    {
        l = r = NULL;
        if(!v)
            return;
        if(v->x < x)
        {
            split(v->r,x,v->r,r);
            l = v;
        }
        else
        {
            split(v->l,x,l,v->l);
            r = v;
        }
        v->recalc();
    }
    Node root;
public:
    Treap():root(NULL) {}
    ~Treap()
    {
        delete root;
    }
    bool search(Node v,int x)
    {
        if(!v) return 0;
        if(v->x == x) return 1;
        else if(v->x > x) return search(v->l,x);
        else return search(v->r,x);
    }
    bool search(int x)
    {
        return search(root,x);
    }
    void insert(int x)
    {
        if(search(x)) return;
        Node l,r;
        split(root,x,l,r);
        root = merge(merge(l,new _Node(x)),r);
    }

    void erase(int x)
    {
        Node l,m,r;
        split(root,x,l,m);
        split(m,x+1,m,r);
        //assert(m && m->cnt == 1 && m->x == x);
        delete m;
        root = merge(l,r);
    }
    void printTreap(Node v)
    {
        if(!v) return;
        printf("v : %d  p : %d  cnt : %d\n",v->x,v->y,v->cnt);
        printTreap(v->l);
        printTreap(v->r);
    }
    void printTreap()
    {
        printTreap(root);
    }
    void inorder(Node v)
    {
        if(!v) return;
        inorder(v->l);
        printf("%d ",v->x);
        inorder(v->r);
    }
    void inorder()
    {
        inorder(root);
    }
    /*
    int k_th_node(Node v,int k)
    {
        if()
    }
    int k_th_node(int k)
    {
        return k_th_node(root,k);
    }
    */
    int size() const
    {
        return root? root->cnt : 0;
    }
};

int main()
{
    srand(2333333);
    Treap st;
    int q;
    scanf("%d",&q);
    while(q--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if(a==0)
        {
            st.insert(b);
            printf("%d\n",st.size());
        }
        else
        {
            printf("%d\n",st.search(b));
            //printf("%d\n",st.find(b)!=st.end());
        }
    }
    return 0;
}



Measured memory_bytes: 12496
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;


int main(){
    int N;
    cin >> N;
    char s[N];
    int cnt_E[N+1];
    cnt_E[0] = 0;
    REP(i,N){
        cin >> s[i];
        if(s[i]=='E'){
            cnt_E[i+1] = cnt_E[i]+1;
        }else{
            cnt_E[i+1] = cnt_E[i];
        }
    }
    int ans=N;
    int ans_tmp;
    REP(i,N){
        ans_tmp = i-cnt_E[i]+cnt_E[N]-cnt_E[i+1];
        ans = min(ans,ans_tmp);
    }
    cout << ans;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;

    if (a + b > 9)
        cout << "error" << endl;
    else
        cout << a + b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;
const ll MAX_N = 1e5 + 7;


using namespace std;

int main() {
    IOS   
    int n;
   cin >> n;
   ll ans=1,last=1;
   
   vector<ll> v(n);
   
   for(int i=0;i<n;i++) cin >> v[i];
   
   sort(all(v));
   int is_zero=0,flag=1;
   if(v[0]==0) {
       is_zero=1;
   }
   else{
      for(int i=0;i<n;i++){
        if(last>ans*v[i]){
            flag=0;
            break;
        } 
        last=ans;
        ans*=v[i];
      }
   }
   if(is_zero) cout << "0";
   else if(flag==1 && ans<=1000000000000000000) cout << ans;
   else cout << -1;
    return 0;
}

Measured memory_bytes: 3992
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;

int main()
{
	char s[200001];
	scanf("%s", s);
	int i = 0;
	int j;
	int A;
	int len	= strlen(s);
	int Z;
	while (s[i])
	{
		if (s[i] == 'A')
		{
			A = i;
			break ;
		}
		i++;
	}
	i = len - 1;
	while (i >= 0)
	{
		if (s[i] == 'Z')
		{
			Z = i;
			break;
		}
		i--;
	}
	printf("%d\n", (Z - A) + 1);
	return (0);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[100001];
bool is_prime[100001];

void sieve(int n) {
  int p = 0;
  for (int i = 0; i <= n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2*i; j <= n; j+= i) is_prime[j] = false;
    }
  }
}


int main() {
  sieve(100000);
  int num[100001];
  
  num[0] = 0;
  for (int i = 1; i <= 100000; i++) {
    if (is_prime[i] && is_prime[(i+1)/2]) {num[i] = num[i-1]+1;}
    else {num[i] = num[i-1];}
  }
  
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << num[r] - num[l-1] << endl;
  }
}


Measured memory_bytes: 1152
min2 = lambda x,y: x if x < y else y

N = int(input())

queues = [list(map(lambda x: int(x)-1,input().split()))[::-1] for _ in range(N)]

q = set()
for i,l in enumerate(queues):
    if i < l[-1] and queues[l[-1]][-1] == i:
        q.add(i)

d = 0
while q:
    possible = set()
    for v in q:
        u = queues[v].pop()
        queues[u].pop()
        possible.add(v)
        possible.add(u)

    q.clear()
    for v in possible:
        try:
            u = queues[v][-1]
            if queues[u][-1] == v:
                q.add(min2(u,v))
        except IndexError:
            pass
    d += 1

print(-1 if any(l for l in queues) else d)

Measured memory_bytes: 89996
(defun main ()
  (let ((k (read))
        (s (read))
        (ans 0))
    (dotimes (x (1+ k))
      (dotimes (y (1+ k))
        (if (and (<= (- s x y) k) (<= 0 (- s x y)))
            (incf ans))))
    ans))

(format t "~d~%" (main))


Measured memory_bytes: 6496
k = int(input())
# s = input()
# n,m = map(int, input().split())
# x = list(map(int, input().split))
import math 
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
count = 0
for i in range(1,k+1):
    for j in range(1, k+1):
        for l in range(1,k+1):
            count += gcd(i,j,l)

print(count)

Measured memory_bytes: 74748
#include<stdio.h>

long long prod(int m, int *a, int *b);

int main(void) {
  int N,M,C;
  int A[21], B[21];
  scanf("%d %d %d", &N,&M, &C);

  for(int i=0; i<M;i++) {
    scanf("%d", &B[i]);
  }

  int sum = 0;
  for(int i=0; i<N; i++) {
    for(int j=0; j<M;j++) {
      scanf("%d", &A[j]);
    }
    if(prod(M, A, B) + C > 0) {
      sum++;
    }
  }
  printf("%d\n", sum);

  return 0;
}

long long prod(int m, int *a, int *b) {
  long long result = 0;
  for(int i=0; i<m; i++) {
    result += a[i] * b[i];
  }
  return result;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <valarray>

using namespace std;


main()
{
    int n; cin>>n;
    string s; cin>>s;
    int now=0,ans=0;
    for(auto &c:s)
    {
        if(c=='I') now++;
        else now--;
        if(ans<now) ans=now;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.*;
 
class Main
{
	public static void main(String args[])
	{
		int n,c,k;
		
		Scanner sc=new Scanner(System.in);
		
		n=sc.nextInt();
		c=sc.nextInt();
		k=sc.nextInt();
		
		int[] t=new int[n];
		for(int i=0;i<n;i++)
			t[i]=sc.nextInt();
		
		Arrays.sort(t);
		
		int i=0,start,bus=1,people=0;
		start=t[0];
		while(i<n)
		{
			if(t[i]-start>k)
			{
				bus++;
				people=0;
                                start=t[i];
			}
			people++;
			if(people==c)
			{
				bus++;
				people=0;
                                 if(i+1<n)
                                 start=t[i+1];
                                 else
                                 bus--;
			}
			i++;
		}
		System.out.print(bus);
	}
}

Measured memory_bytes: 50352
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, k = sc.nextInt()
    val nums = Array.fill[Int](n + 1)(0)
    for (i <- 0 until n) {
      nums(sc.nextInt() - 1) += 1
    }

    println(nums.filter(_ != 0).sorted.dropRight(k).sum)
  }
}


Measured memory_bytes: 70732
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=6e2+10,mod=1e9+7;
ll dp[N][N];
ll pd[N][N];
ll t[N][N];
ll nxt[N];
int32_t main(){
    ll n,m;
    cin >> n >> m;
    n*=2;
    for (int i=1;i<=m;i++){
        ll u,v;
        cin >> u >> v;
        nxt[u]=v;
        nxt[v]=u;
    }
    for (int i=1;i<=n;i++){
        for (int j=i+1;j<=n+1;j++){
            if ((j-i)%2==1) continue;
            ll p1=0;
            ll ts=0;
            for (int k=i;k<j;k++){
                if (nxt[k]!=0){
                    if (nxt[k]<i || nxt[k]>=j) p1=1;
                }
                else ts++;
            }
            if (p1) continue;
            ll ans=1;
            ll z=ts;
            z--;
            while(z>0){
                ans*=z;
                z-=2;
                ans%=mod;
            }
            pd[i][j]=ans;
        }
    }
    for (int i=1;i<=n;i++){
        for (int j=i+1;j<=n+1;j++){
            if ((j-i)%2==1) continue;
            ll p1=0;
            ll ts=0;
            for (int k=i;k<j;k++){
                if (nxt[k]!=0){
                    if (nxt[k]<i && nxt[k]>=j) p1=1;
                }
            }
            if (p1) continue;
            for (int k=1;k<i;k++) if (nxt[k]==0) ts++;
            for (int k=j;k<=n;k++){
                if (nxt[k]==0) ts++;
            }
            ll ans=1;
            ll z=ts;
            z--;
            while(z>0){
                ans*=z;
                z-=2;
                ans%=mod;
            }
            t[i][j]=ans;
        }
    }
    for (int i=n-1;i>0;i--){
        for (int j=i+2;j<=n+1;j+=2){
            ll p1=0;
            ll ts=0;
            for (int k=i;k<j;k++){
                if (nxt[k]!=0){
                    if (nxt[k]<i || nxt[k]>=j) p1=1;
                }
                else ts++;
            }
            if (p1) continue;
            dp[i][j]=pd[i][j];
            for (int k=i+1;k<j-1;k++){
                dp[i][j]-=dp[i][k]*pd[k][j]%mod;
                dp[i][j]+=mod;
                dp[i][j]%=mod;
            }
           // cout << i << " " << j << " " << dp[i][j] << " " << pd[i][j] << endl;
        }
    }
    ll ans=0;
    for (int i=0;i<N;i++) for (int j=0;j<N;j++) ans+=dp[i][j]*t[i][j]%mod;
    cout << ans%mod << endl;
}


Measured memory_bytes: 11996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
    	int[] l = new int [N];
    	for (int i=0; i < N; i++) {
    		l[i] = stdIn.nextInt();
    	}

    	for (int i=0; i < N-1; i++) {
    	    int max = i;
    	        for (int j=i+1; j < N; j++) {
    		    if (l[max] < l[j]) {
    		        max = j;
    		    }
    		}
    	    int tmp = l[i];
    	    l[i] = l[max];
    	    l[max] = tmp;
    	}

    	int ans = 0;
    	for(int i=0; i < K; i++) {
            ans += l[i];
        }
    	System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
const int N = 100005;
int n, a[2 * N], b[2 * N], mx = -1;
int main() {
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> a[i];
b[a[i]] ++;
}
for (int i = -1; i <= N; i ++) {
int x = b[i] + b[i + 1] + b[i + 2];
mx = max(mx, x);
}
cout << mx;
return 0;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <iostream>

using namespace std;

namespace {

struct Process {
  char name[12];
  // required time to process this task.
  int time;
};

// Ring-buffer based queue. Enqueue and dequeue run in O(1).
template <typename T, int N>
class Queue {
 public:
  // Note: leave one element empty so that we can distinguish
  // that the ring buffer is empty or full.
  Queue()
      : size_(N + 1),
        begin_((T*)data_),
        end_((T*)data_ + N + 1),
        head_((T*)data_),
        tail_((T*)data_) {}

  void Enqueue(T* p) {
    assert(!IsFull());
    *tail_ = *p;
    tail_ = next(tail_);
  }

  T* Dequeue() {
    assert(!Empty());
    auto p = head_;
    head_ = next(head_);
    return p;
  }

  bool IsFull() const { return head_ == next(tail_); }

  bool Empty() const { return head_ == tail_; }

 private:
  T* next(T* p) const { return p + 1 == end_ ? begin_ : p + 1; }

  char data_[sizeof(T) * (N + 1)];
  const int size_;
  T* const begin_;
  T* const end_;
  T* head_;
  T* tail_;
};

}  // namespace

int main() {
  int n;
  int q;
  cin >> n >> q;

  Queue<Process, 100000> queue;
  Process p;
  for (int i = 0; i < n; ++i) {
    scanf("%s %d", p.name, &p.time);
    queue.Enqueue(&p);
  }

  int current_time = 0;
  while (!queue.Empty()) {
    auto p = queue.Dequeue();
    const int used = min(p->time, q);
    p->time -= used;
    current_time += used;

    if (p->time <= 0) {
      printf("%s %d\n", p->name, current_time);
      continue;
    }
    queue.Enqueue(p);
  }
  return 0;
}

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

int main()
{
  int64_t N, d, mind;
  cin >> N;
  vector<int> X(N + 1);
  for (int i = 1; i <= N; i++)
  {
    cin >> X.at(i);
  }
  for (int p = 1; p <= 100; p++)
  {
    d = 0;
    for (int i = 1; i <= N; i++)
    {
      d += pow((X.at(i) - p), 2);
    }
    if (p == 1)
    {
      mind = d;
    }
    else
    {
      mind = min(mind, d);
    }
  }
  cout << mind << endl;
}


Measured memory_bytes: 256
import heapq

def solve(n,a):
    a1 = a[:n]
    a2 = [-a[i] for i in range(2*n,3*n)]

    l = [[0,0] for i in range(n+1)]

    heapq.heapify(a1)
    heapq.heapify(a2)

    l[0][0] = sum(a1)
    l[n][1] = sum(a2)
    
    for k in range(n,2*n):

        heapq.heappush(a1,a[k])
        tmp = heapq.heappop(a1)
        l[k-n+1][0] = l[k-n][0] + a[k] - tmp

        heapq.heappush(a2,-a[3*n-k-1])
        tmp = heapq.heappop(a2)
        l[2*n-k-1][1] = l[2*n-k][1] - a[3*n-k-1] - tmp

    res = -float('inf')

    for ans in l:
        res = max(res,ans[0]+ans[1])

    return res

if __name__ == '__main__':
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(n,a))

Measured memory_bytes: 124176
#include <iostream>
using namespace std;
int main(void){
    int X;
    cin >> X;
    if(X <= 599){
        cout << 8 << endl;
    }else if(X <= 799){
        cout << 7 << endl;
    }else if(X <= 999){
        cout << 6 << endl;
    }else if(X <= 1199){
        cout << 5 << endl;
    }else if(X <= 1399){
        cout << 4 << endl;
    }else if(X <= 1599){
        cout << 3 << endl;
    }else if(X <= 1799){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3612
/* Contest */
#include<bits/stdc++.h>
#define all(s) (s).begin(),(s).end()
#define rall(s) (s).rbegin(),(s).rend()
#define sep ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
int main()
{	
	sep;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    int h,w; cin>>h>>w; int alp[26]={};
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
        char c; cin>>c; alp[c-'a']++;
    }
    }
    int a,b,c,key=0;
    a=(h/2)*(w/2); b=((h%2)?w/2:0)+((w%2)?h/2:0); c=((h%2)&&(w%2));
    for (int i = 0; i < 26; i++){
        if(alp[i]>=4){
            int l=min(alp[i]/4,a);alp[i]-=l*4; a-=l;
        }
        if(alp[i]>=2){
            int l=min(alp[i]/2,b);alp[i]-=l*2; b-=l;
        }
        if(alp[i]){
            int l=min(alp[i],c);alp[i]-=l; c-=l;
        }
        key+=alp[i];
    }
    cout<<(a==0&&b==0&&c==0&&key==0?"Yes":"No")<<'\n';
}

Measured memory_bytes: 256
s = int(input())
a=[s]
while True:
    if s % 2 == 0:
        s = int(1/2*s)
        if s not in a:
            a.append(s)
        elif s  in a:
            a.append(s)
            print(len(a))
            break
    elif s % 2 ==1:
        s = int(3*s +1)
        if s not in a:
            a.append(s)
        elif s  in a:
            a.append(s)
            print(len(a))
            break

Measured memory_bytes: 3060