akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 int main(void){
   int n,m,a[10000],b=0;
   scanf("%d %d",&n,&m);
   for(int i=0;i<m;i++){
    scanf("%d",&a[i]);  
     b+=a[i];
    }
   if(n>=b){
     printf("%d\n",n-b);
   }else{
     printf("-1\n");
   }
   return 0;
 }
      

Measured memory_bytes: 1736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
using namespace std;
const int MAXN=2005;
int a[MAXN],n,sum;
bitset<1002*2000>f;
bitset<1002*2000>tmp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i),sum+=a[i];
	int dest=(sum+1)/2;
	f=1;
	for(int i=1;i<=n;++i)
		f|=(f<<a[i]);
	int ans=dest;
	while(true){
		if(f[ans]){printf("%d\n",ans);return 0;}
		else ++ans;
	}
	return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun <A> countList(a: List<A>): Map<A, Long> {
    val result = mutableMapOf<A, Long>()
    a.forEach {
        result[it] = (result[it] ?: 0L) + 1L
    }
    return result
}

fun solve(sc: java.util.Scanner) {
    val N = sc.nextInt()
    val A = Array(N) { sc.nextInt() }
    val C = countList(A.toList())

    val total = C.map { a -> a.value * (a.value - 1) / 2 }.sum()
    A.forEach { a ->
        println(total - (C[a]!!.toInt() - 1))
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  ll T; cin >> T;
  vector<ll> t(N); REP(i, N) cin >> t[i];
  ll ans = 0;
  for(int i = 1; i < N; ++i) {
    if(t[i] - t[i - 1] >= T) ans += T;
    else if(t[i] - t[i - 1] < T) ans += (t[i] - t[i - 1]);
  }
  ans += T;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
#include<set>
#include<iterator>
#include<cstdio>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
#define ll long long 

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init(){
  c[0][0]=1;
  for(int i=0;i<=4000;i++){
    for(int j=0;j<=i;j++){
      c[i+1][j]+=c[i][j];
      c[i+1][j+1]+=c[i][j];
    }
  }
}
mint comb(int n,int k){
  return c[n][k]; 
}
mint f2(int n,int k){
  return comb(n+k-1,k-1);
}
mint f(int n,int k){
  if(n<k)return 0;
  if(n==0&&k==0)return 1;
  if(k<1)return 0;
  return f2(n-k,k);
}

int main(){
  init();
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=k;i++){
    mint blue=f(k,i);
    mint red=0;{
      red+=f(n-k,i-1);
      red+=f(n-k,i);
      red+=f(n-k,i);
      red+=f(n-k,i+1);
    }
    mint ans=blue*red;
    printf("%lld\n",ans.x);
  }
  return 0;
}

Measured memory_bytes: 125696
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define MAXN 50
int n,t[MAXN+5],ans=0;
bool u[25];
void dfs(int x)
{
    if(x==n)
    {
        int Min=1e8,last=0;
        for(int i=1;i<24;i++)
            if(u[i])
            {
                Min=min(Min,i-last);
                last=i;
            }
        Min=min(Min,24-last);
        ans=max(ans,Min);
        return;
    }
    if(!u[t[x]])
        {u[t[x]]=true;dfs(x+1);u[t[x]]=false;}
    if(t[x]!=(24-t[x])%24 && !u[24-t[x]])
        {u[24-t[x]]=true;dfs(x+1);u[24-t[x]]=false;}
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&t[i]);
    t[n++]=0;
    if(n>24) {printf("0\n");return 0;}
    dfs(0);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		String ans = "";

		for(int i = 0; i < N; i++){
			ans += s.charAt(i);
			ans += t.charAt(i);
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
 
main()
{
  string a; cin>>a;
  string b; cin>>b;
  int z{0};
  for(int i=0;i<a.length();i++)
  {
    if(a[i] != b[i]) ++z;
  }
  cout<<z<<endl;
  exit(0);
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> a(H);
    for (int i=0; i<H; ++i) cin >> a[i];

    int si = -1, sj = -1;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (a[i][j] == 'S') {
                si = i, sj = j;
                break;
            }
        }
        if (si != -1) break;
    }

    using T = pair<int, int>;
    using P = pair<T, int>;
    vector<vector<T>> dis(H, vector<T>(W, make_pair(INF, INF)));
    priority_queue<P, vector<P>, greater<P>> que;
    dis[si][sj] = make_pair(1, -K);
    que.push(make_pair(dis[si][sj], si*W+sj));
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int c = p.first.first, r = p.first.second, cx = p.second / W, cy = p.second % W;
        if (dis[cx][cy] < p.first) continue;
        for (int i=0; i<4; ++i) {
            int nx = cx + dx[i], ny = cy + dy[i];
            if (nx < 0 || H <= nx || ny < 0 || W <= ny) continue;
            T n;
            if (r == 0) {
                n = make_pair(c+1, -K+1);
            } else if (c == 1) {
                if (a[nx][ny] == '#') {
                    n = make_pair(c+1, -K+1);
                } else {
                    n = make_pair(c, r+1);
                }
            } else {
                n = make_pair(c, r+1);
            }
            if (n < dis[nx][ny]) {
                dis[nx][ny] = n;
                que.push(make_pair(n, nx*W+ny));
            }
        }
    }

    int res = INF;
    for (int i=0; i<H; ++i) {
        chmin(res, dis[i][0].first);
        chmin(res, dis[i][W-1].first);
    }
    for (int i=0; i<W; ++i) {
        chmin(res, dis[0][i].first);
        chmin(res, dis[H-1][i].first);
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 11968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
     public static void main(String[] args){
          Scanner scanner = new Scanner(System.in);
          int x = scanner.nextInt();
          int y = scanner.nextInt();
          int z = scanner.nextInt();
          int res = x+y+z;
          if(res >= 22){
            System.out.println("bust");
          }
          else{
            System.out.println("win");
          }
     }
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = list(input())
N = len(S)

ans = ceil(N, 2)
for i in range(ceil(N, 2), N):
    # 真ん中から始めて、反対側と一致してるかと、1つ前と一致しているか
    if not S[i] == S[N-1-i] == S[i-1]:
        break
    ans += 1
print(ans)


Measured memory_bytes: 4084
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,k,a[100000+10];
LL a_,b;
const int MOD=1e9+7;
LL fact[100000+10];
bool cmp(int A,int B){
	return A>B;
}
LL pow_(int x,int cnt)
{
	if(cnt==0) return 1;
	LL AA=pow_(x,cnt>>1);
	AA*=AA;
	AA%=MOD;
	if(cnt&1) AA*=x,AA%=MOD;
	return AA;
}
LL inv(int A){
	return pow_(A,MOD-2);
}
LL c(int N,int M){
	return ((fact[N]*inv(fact[M]))%MOD*inv(fact[N-M]))%MOD;
}
int main(){
	fastio;
	cin>>n>>k;
	fact[0]=1;
	rb(i,1,n) cin>>a[i];
	rb(i,1,n) fact[i]=fact[i-1]*i,fact[i]%=MOD;
	sort(a+1,a+1+n);
	rb(i,1,n-k+1){
		b+=(LL)a[i]*c(n-i,k-1);
		if(b<0){
			b+=((-b)/MOD+1)*MOD;
		}
		b%=MOD;
	} 
	sort(a+1,a+1+n,cmp);
	rb(i,1,n-k+1){
		a_+=(LL)a[i]*c(n-i,k-1);
		if(a_<0){
			a_+=((-a_)/MOD+1)*MOD;
		}
		a_%=MOD;
	} 
	cout<<(a_-b+MOD)%MOD;
	return 0;
}


Measured memory_bytes: 1408
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    string s;
    cin >> s;
    string k = "keyence";
    if (s.length() < k.length()) {
        cout << "NO" << endl;
        return 0;
    }
    if (s.substr(0, k.length()) == k) {
        cout << "YES" << endl;
        return 0;
    }
    if (s.substr(s.length() - k.length(), k.length()) == k) {
        cout << "YES" << endl;
        return 0;
    }
    int is = 0, ik = 0;
    string ans;
    while (s[is] == k[ik]) {
        ans += s[is];
        is++;
        ik++;
    }
    is = s.length() - 1, ik = k.length() - 1;
    string a2;
    while (s[is] == k[ik]) {
        a2 = s[is] + a2;
        if (ans + a2 == k) {
            cout << "YES" << endl;
            return 0;
        }
        is--;
        ik--;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int h = input.nextInt();
		int n = input.nextInt();
		int a = 0;
		for (int i = 0; i < n; i++) {
			a += input.nextInt();
		}
		if (a >= h) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 58468
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  int odd = 0;
  REP(i, N) {
    int a; cin >> a;
    odd += a%2==1;
  }

  if (odd%2==0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if(B/A >= C) {
			System.out.print(C);
		} else if(B/A < C) {
			System.out.print(B/A);
		}

	}
}

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

int main()
{
    ll N;
    cin >> N;
    if(N == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }

    vector<ll> H(N);

    for(ll i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }

    H[0]--;

    for(ll i = 1; i < N; i++)
    {
        if(H[i] > H[i-1])
        {
            H[i]--;
        }
        else if(H[i] < H[i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x,y;
    x=a*c;
    y=b*d;
    ll z=max(x,y);
    ll k=max(a*d,b*c);
    cout<<max(z,k);
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d,j,k,m,p,n,i,t,T,f1,f2,ans;
ll arr[105];
int main(){
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&arr[i]);
		ans+=arr[i];
	}
	ans=ans/n;
	a=0;
	for(i=0;i<n;i++){
		a=a+pow(abs(arr[i]-ans),2);
	}

	b=0;
	ans=ans-1;
	for(i=0;i<n;i++){
		b=b+pow(abs(arr[i]-ans),2);
	}

	c=0;
	ans=ans+2;
	for(i=0;i<n;i++){
		c=c+pow(abs(arr[i]-ans),2);
	}
    a=a<b?a:b;
    a=a<c?a:c;
    printf("%lld\n",a);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

func main() {
	defer writer.Flush()

	var a, b, c, d int
	scanf("%d %d %d %d\n", &a, &b, &c, &d)
	common := int(math.Min(float64(b), float64(d)) - math.Max(float64(a), float64(c)))
	if common < 0 {
		fmt.Println(0)
	} else {
		fmt.Println(common)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

bool vis[20];
string s[20];

int main() {
	int h, w; cin >> h >> w;
	for (int i = 0; i < h; i ++) cin >> s[i];
	string ss[20];
	
	vector < pair<int, int> > rp;
	int unMatchCnt = 0, unMatchIdx = -1;
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i < h; i ++) {
		if (vis[i]) continue;
		string t1 = s[i]; sort(t1.begin(), t1.end());
		bool ok = false;
		for (int j = i+1; j < h; j ++) {
			if (vis[j]) continue;
			string t2 = s[j]; sort(t2.begin(), t2.end());
			if (t1 == t2) {
				rp.push_back(make_pair(i, j));
				ok = vis[i] = vis[j] = 1;
				break;
			}
		}
		if (!ok) { unMatchCnt ++; unMatchIdx = i; }
	}
	if (unMatchCnt > 1) {
		cout << "NO\n"; return 0;
	} else if (h%2) {
		rp.push_back(make_pair(unMatchIdx, -1)); 
	}
	
	vector < pair<int, int> > cp;
	unMatchCnt = 0, unMatchIdx = -1;
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i < w; i ++) {
		if (vis[i]) continue;
		string t1 = "";
		for (int j = 0; j < h; j ++) t1 += s[j][i];
		sort(t1.begin(), t1.end());
		bool ok = false;
		for (int j = i+1; j < w; j ++) {
			if (vis[j]) continue;
			string t2 = "";
			for (int k = 0; k < h; k ++) t2 += s[k][j];
			sort(t2.begin(), t2.end());
			if (t1 == t2) {
				cp.push_back(make_pair(i, j));
				ok = vis[i] = vis[j] = 1;
				break;
			}
		}
		if (!ok) { unMatchCnt ++; unMatchIdx = i; }
	}
	if (unMatchCnt > 1) {
		cout << "NO\n"; return 0;
	} else if (w%2) {
		cp.push_back(make_pair(unMatchIdx, -1));
	}
	
	string per_one = "";
	for (int i = 0; i < h/2; i ++) per_one += to_string(i);
	
	do {
		string trans_one[20];
		for (int i = 0; i < h/2; i ++) {
			int idx = per_one[i] - '0';
			trans_one[i] = s[rp[idx].first];
			trans_one[h-i-1] = s[rp[idx].second];
		}
		if (h%2) trans_one[h/2] = s[rp[h/2].first];
		
		string per_two = "";
		for (int i = 0; i < w/2; i ++) per_two += to_string(i);
		
		do {
			string trans_two[20];
			for (int i = 0; i < h; i ++) trans_two[i] = trans_one[i];
			for (int i = 0; i < w/2; i ++) {
				int idx = per_two[i] - '0';
				for (int j = 0; j < h; j ++) {
					trans_two[j][i] = trans_one[j][cp[idx].first];
					trans_two[j][w-i-1] = trans_one[j][cp[idx].second];
				}
			}
			if (w%2) {
				for (int i = 0; i < h; i ++) 
					trans_two[i][w/2] = trans_one[i][cp[w/2].first];
			}
			
			bool flag = true;
			for (int i = 0; i < h/2; i ++) {
				string t1 = trans_two[i], t2 = trans_two[h-i-1];
				reverse(t2.begin(), t2.end());
				if (t1 != t2) { flag = false; break; }
			}
			if (h%2) {
				for (int i = 0; i < w/2; i ++) 
					if (trans_two[h/2][i] != trans_two[h/2][w-i-1]) { flag = false; break; }
			}
			if (flag) { cout << "YES\n"; return 0; }
		} while (next_permutation(per_two.begin(), per_two.end()));
		
	} while (next_permutation(per_one.begin(), per_one.end()));
	
	cout << "NO\n" << endl;
	return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif

ll calc(vi& A, int mid) {
    const int N = A.size();
    deque<int> dq;
    dq.push_back(A[mid]);
    priority_queue<int> pqhi;
    priority_queue<int, vi, greater<int> > pqlo;
    FOR(i,0,N) {
        if (i == mid) continue;
        pqhi.push(A[i]);
        pqlo.push(A[i]);
    }

    int cnt = 0;
    int oddEven = 0;
    if (mid > 0) oddEven = 1;
    while(dq.size() < N) {
        if (cnt%2==oddEven) {
            dq.push_front(pqhi.top());
            pqhi.pop();
            if (dq.size()<N) {
                dq.push_back(pqhi.top());
                pqhi.pop();
            }
        } else {
            dq.push_front(pqlo.top());
            pqlo.pop();
            if (dq.size()<N) {
                dq.push_back(pqlo.top());
                pqlo.pop();
            }
        }
        cnt++;
    }

    ll sum = 0;
    int cur = dq.front(); dq.pop_front();
    while(!dq.empty()){
        int next = dq.front(); dq.pop_front();
        sum += abs(next - cur);
        cur = next;
    }
    return sum;
}

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

    int N;  cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

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

    ll ans = max(calc(A, 0), calc(A, N-1));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2020
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int64_t N;
  cin >> N;

  int64_t I = 0, J = 0;
  int64_t min = 1'000'000'000'000;
  for (int64_t i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      int64_t j = N / i;
      if (min > (i - 1) + (j - 1)) {
        min = (i - 1) + (j - 1);
        I = i;
        J = j;
      }
    }
  }
  cout << (I - 1) + (J - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
# import math
import fractions
import numpy as np
from itertools import accumulate, chain, islice, starmap
N = int(input())
numbers = list(map(int, input().split()))
# numbers = [2, 4, 8, 8]
# N = len(numbers)


def calculate_maximum_subgcd_with_np_ufunc(numbers):
    gcd = np.frompyfunc(fractions.gcd, 2, 1)
    cumgcds = gcd.accumulate(numbers, dtype=np.object).astype(np.int)
    sub_cumgcds = np.roll(cumgcds, 1)
    sub_cumgcds[0] = 0
    reverse_cumgcds = gcd.accumulate(
        numbers[::-1], dtype=np.object).astype(np.int)
    sub_reverse_cumgcds = np.roll(reverse_cumgcds, 1)
    sub_reverse_cumgcds[0] = 0
    return np.max(gcd(sub_cumgcds, sub_reverse_cumgcds[::-1]))


def calculate_maximum_subgcd_with_func(numbers):
    operation = fractions.gcd
    cumgcds = accumulate(numbers, operation)
    sub_cumgcds = islice(chain([0], cumgcds), len(numbers))
    reverse_cumgcds = accumulate(numbers[::-1], operation)
    sub_reverse_cumgcds = islice(chain([0], reverse_cumgcds), len(numbers))
    sub_gcds = starmap(operation, zip(sub_cumgcds, list(sub_reverse_cumgcds)[::-1]))
    return max(sub_gcds)


calculate_maximum_subgcd = calculate_maximum_subgcd_with_np_ufunc
# calculate_maximum_subgcd = calculate_maximum_subgcd_with_func

print(calculate_maximum_subgcd(numbers))


Measured memory_bytes: 25804
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	c = a / 3600;
	b = (a - c*3600) / 60;
	printf("%d:%d:%d\n", c, b, a%60);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

typedef long long ll;

using namespace std;
int main(){
    int N;
    cin >> N;

    int a[N+1] = {};
    int b[N+1] = {}; 
    for (int i = 1; i <= N; i++) {
    	cin >> a[i];
    }

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

    for (int i = N; i >= half; i--) {
    	b[i] = a[i];
    }
    */

    for (int i = N; i >= 1; i--) {
    	int sum = 0;
    	for (int j = i * 2; j <= N; j += i) {
    		sum += b[j];
    	}
    	if (sum % 2 == a[i]) {
    		b[i] = 0;
    	}
    	else {
    		b[i] = 1;
    	}
    }

    int nonzero = 0;
    for (int i = 1; i <= N; i++) {
    	if (b[i] == 1) {
    		nonzero++;
    	}
    }

    if (nonzero == 0) {
    	cout << 0 << "\n";
    }
    else {
    	cout << nonzero << "\n";
    	for (int i = 1; i <= N; i++) {
    		if (b[i] == 1) cout << i << " ";
    	}
    }

}


Measured memory_bytes: 2432
use std::collections::HashSet;
use std::io::*;
use std::str::FromStr;

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut vec: Vec<HashSet<usize>> = vec![HashSet::new(); n];
    for _ in 0..m {
        let x: usize = read();
        let y: usize = read();
        vec[x - 1].insert(y - 1);
    }
    let mut incoming_degrees = vec![Some(0); n];
    for set in &vec {
        for s in set {
            incoming_degrees[*s] = Some(incoming_degrees[*s].unwrap() + 1);
        }
    }
    let mut sorted = vec![];
    let mut zero_set = vec![];
    for (i, v) in incoming_degrees.clone().iter().enumerate() {
        if *v == Some(0) {
            zero_set.push(i);
            incoming_degrees[i] = None;
        }
    }
    // 多分cloneのせいでTLEになってる。n^2でも計算量的には間に合わない。正しくトポロジカルソートを実装しよう
    // 入次数が0のものを数えるのに毎回全部見る必要はなくて、初回だけ全部みてあとはソートしたものから出てるものだけ見れば良い
    while !zero_set.is_empty() {
        let s = zero_set.pop().unwrap();
        sorted.push(s);
        for &v in &vec[s] {
            if incoming_degrees[v].is_none() {
                continue;
            }
            let incoming_count = std::cmp::max(0, incoming_degrees[v].unwrap() - 1);
            incoming_degrees[v] = Some(incoming_count);
            if incoming_count == 0 {
                zero_set.push(v);
            }
        }
    }
    let mut dp = vec![0; n];
    for v in sorted {
        for &v2 in &vec[v] {
            dp[v2] = std::cmp::max(dp[v2], dp[v] + 1);
        }
    }
    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 63740
my ($N,$D) =split(/ /,<>);

my $count =0;
for(my $i=0;$i<$N;$i++){
    my  ($x,$y) =split(/ /,<>);
    my $L = sqrt($x*$x+$y*$y);
    if($D>=$L){ $count++;}
}

print "$count";

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define x first
#define y second
using namespace std;
const int maxn=300000+10;
int w,h,n,mx[maxn<<2],lazy[maxn<<2],ans;pii p[maxn],s[maxn],t[maxn];
#define lson (rt<<1)
#define rson (rt<<1|1)
inline void pushup(int rt) {mx[rt]=max(mx[lson],mx[rson]);}
inline void pushdown(int rt)
{
	if(mx[rt])
	{
		mx[lson]+=lazy[rt];mx[rson]+=lazy[rt];
		lazy[lson]+=lazy[rt];lazy[rson]+=lazy[rt];
		lazy[rt]=0;
	}
}
void update(int L,int R,int C,int l,int r,int rt)
{
	if(L <= l && r <= R) {mx[rt]+=C;lazy[rt]+=C;return;}
	pushdown(rt);
	int mid=(l+r)>>1;
	if(L <= mid) update(L,R,C,l,mid,lson);
	if(R > mid) update(L,R,C,mid+1,r,rson);
	pushup(rt);
}
inline void solve()
{
	memset(mx,0,sizeof(mx));
	memset(lazy,0,sizeof(lazy));
	sort(p+1,p+n+1);
	int u=0,v=0;
	for(int i=1;i<n;i++)
	{
		if(p[i].y<=h/2)
		{
			int nxt=i-1;
			while(u&&p[i].y>s[u].y)
			{
				update(s[u].x,nxt,s[u].y-p[i].y,1,n,1);
				nxt=s[u].x-1;u--;
			}
			if(nxt!=i-1) s[++u]=mp(nxt+1,p[i].y);
		}
		else
		{
			int nxt=i-1;
			while(v&&t[v].y>p[i].y)
			{
				update(t[v].x,nxt,p[i].y-t[v].y,1,n,1);
				nxt=t[v].x-1;v--;
			}
			if(nxt!=i-1) t[++v]=mp(nxt+1,p[i].y);
		}
		s[++u]=mp(i,0);t[++v]=mp(i,h);
		update(i,i,h-p[i].x,1,n,1);
		ans=max(ans,mx[1]+p[i+1].x);
	}
}
int main()
{
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);
	p[++n]=mp(0,0);p[++n]=mp(w,h);solve();
	for(int i=1;i<=n;i++) swap(p[i].x,p[i].y);
	swap(w,h);solve();
	printf("%d\n",ans<<1);
	return 0;
}

Measured memory_bytes: 16640
using System;
using System.Linq;

namespace ConsoleApp1 {
    class Program {
        static void Main(string[] args) {


            var str = Console.ReadLine().ToString();

            if (str[2] == str[3] && str[4] == str[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }


            Console.ReadLine();

        }
    }
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){


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

  // ifstream in("1_048.txt");
  // cin.rdbuf(in.rdbuf());

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

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<int>> g(n);

  UnionFind uf(n);

  rep(i, m){
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);

    uf.merge(x, y);
  }

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

  if(n==2){

    if(uf.size(0)==1 && uf.size(1)==1){
      cout << a[0] + a[1] << endl;
      return 0;
    }
  }

  int cnt_1 = 0;
  int cnt_2 = 0;
  rep(i, n){
    if(uf.size(i)==1) cnt_1++;
    else cnt_2++;
  }

  if(n < 2 * (n - m - 1)){
    cout << "Impossible" << endl;
    return 0;
  }

  map<int, vector<ll>> mp;

  rep(i, n){
    mp[uf.root(i)].push_back(a[i]);
  }

  int num_forest = 0;

  ll ans = 0;
  vector<ll> rem;
  for(auto &vec : mp){
    num_forest++;
    sort(vec.second.begin(), vec.second.end());
    ans += vec.second[0];
    rep(i, 1, vec.second.size()){
      rem.push_back(vec.second[i]);
    }
  }

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

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

  rep(i, num_forest-2){
    ans += rem[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13436
n = int(input())
a = list(map(int, input().split()))

sub = (10 ** 9) + 1
for i in range(n):
    ans = 0
    while a[i] % 2 == 0 and a[i] != 0:
        a[i] = a[i] // 2
        ans += 1
    sub = min(ans, sub)
    
print(sub)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>
#include <queue>
#include <cassert>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
const LL MOD = 1e9+7;
vector<pair<LL,LL> > G[MAXN];
map<pair<LL,LL >,LL > mp;
LL mincost[MAXN];		// 从集合X出发的边到每个顶点的最小权值
bool used[MAXN];		// 顶点i是否包含在集合X中
// first 最短路径，second顶点编号
typedef pair<LL, LL> P;

LL prim(int V)
{
	LL res = 0;
	memset(mincost, 0x3f, V * sizeof(LL));
	memset(used, 0, V * sizeof(bool));
	mincost[0] = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, 0));  
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		LL v = p.second;  
		if (used[v] || p.first > mincost[v]) continue;
		used[v] = true;
		res += 1LL*mincost[v];
		for (int i = 0; i < G[v].size(); ++i)
		{
			LL to = G[v][i].first,cost = G[v][i].second;
			if (mincost[to] > cost)
			{
				mincost[to] = cost;
				que.push(P(mincost[to], to));
			}
		}
	}
	return res;
}
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif	
    int n;
    cin>>n;
    vector<pair<LL,LL > > x,y,all;
    for (int i = 0; i < n; ++i)
    {
    	LL a,b;
    	cin>>a>>b;
		all.push_back({a,b});
		x.push_back({a,i});
		y.push_back({b,i});
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    for (int i = 0; i < n; ++i)
    {
    	LL tx = all[i].first,ty = all[i].second;
    	pair<LL,LL > tp =  {tx,i};
    	vector<pair<LL,LL > > :: iterator itx1 = lower_bound(x.begin(), x.end(),tp);
    	if((itx1+1)!=x.end()&&(*(itx1+1)).first==tx) 
    		itx1++;
    	else if(itx1!=x.begin()) itx1--;
		LL cost = (tx-((*itx1).first)),v = ((*itx1).second);
    	G[i].push_back({v,cost});
    	G[v].push_back({i,cost});
    	itx1 = upper_bound(x.begin(), x.end(), tp);
    	if(itx1!=x.end())
    	{
    		cost = ((*itx1).first)-tx,v = ((*itx1).second);
    		G[i].push_back({v,cost});
    		G[v].push_back({i,cost});
    	}

    	tp =  {ty,i};
    	itx1 = lower_bound(y.begin(), y.end(), tp);
    	if((itx1+1)!=y.end()&&(((*(itx1+1)).first==ty))) 
    		itx1++;
    	else if(itx1!=y.begin()) itx1--;
		cost = ty-((*itx1).first),v = ((*itx1).second);
    	G[i].push_back({v,cost});
    	G[v].push_back({i,cost});
    	itx1 = upper_bound(y.begin(), y.end(), tp);
    	if(itx1!=y.end())
    	{
    		cost = ((*itx1).first)-ty,v = ((*itx1).second);
    		G[i].push_back({v,cost});
    		G[v].push_back({i,cost});
    	}
    }
    cout<<prim(n)<<endl;
    return 0;
}


Measured memory_bytes: 27604
using System;
using System.Linq;

class P
{
  static void Main()
  {
    var S = Console.ReadLine().Split(' ');
    var a = int.Parse(S[0]);
    var b = int.Parse(S[1]);
    if(a < b)
      Console.WriteLine("a < b");
    else if(a > b)
      Console.WriteLine("a > b");
    else
      Console.WriteLine("a == b");
  }
}

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

struct Team {
    int num;
    int time;
};

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        Team team[] = {
            {0, 100000, },
            {0, 100000, },
            {0, 0, },
            {0, 0, },
        };
        for (int i = 0; i < n; i++) {
            int c, m[4], s[4];
            cin >> c;
            for (int j = 0; j < 4; j++) {
                cin >> m[j] >> s[j];
            }
            int time = 0;
            for (int j = 0; j < 4; j++) {
                time += m[j] * 60 + s[j];
            }
            if (time < team[0].time) {
                team[1].num = team[0].num;
                team[1].time = team[0].time;
                team[0].num = c;
                team[0].time = time;
            } else if (time < team[1].time) {
                team[1].num = c;
                team[1].time = time;
            }
            if (team[3].time < time) {
                team[2].num = team[3].num;
                team[2].time = team[3].time;
                team[3].num = c;
                team[3].time = time;
            } else if (team[2].time < time) {
                team[2].num = c;
                team[2].time = time;
            }
        }
        for (int i = 0; i < 3; i++) {
            cout << team[i].num << endl;
        }
    }
}

Measured memory_bytes: 0
<?php

$total_array = [];
$bels = fscanf(STDIN, "%d %d %d");

foreach ($bels as $key => $val){
	$other = $bels;
	unset($other[$key]);
	foreach ($other as $other_val){
		array_push($total_array, $other_val + $val);
	}
}

echo min($total_array);

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print $ lcm a b

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    ll a, b, n;
    cin>>a>>b>>n;
    ll x = b-1;
    if(x > n)
        x = n;
    ll ans = a*x;
    ans /= b;
    ans -= a*(x/b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string s;
  int64_t k;
  cin >> s >> k;
  
  bool jad = false;
  char a = 0;
  for(int i = 0 ; i < min( (int64_t)s.size() , k) ; i++){
    if(s.at(i) != '1'){
      jad = true;
      a = s.at(i);
      break;
    }
  }
  
  if(jad){
    cout << a << endl;
  }
  else{
    cout << 1 << endl;
  }
  
}

Measured memory_bytes: 256
def main():
    x, y = (int(i) for i in input().split())
    ans = 0
    if abs(x) == abs(y):
        if x*y < 0:
            ans += 1
    elif abs(x) < abs(y):
        if x == 0 and y > 0:
            ans += y
        elif x == 0 and y < 0:
            ans += abs(y) + 1
        elif x < 0 and y > 0:
            # -10 20
            ans += 1
            x = -x
            ans += y - x
        elif x > 0 and y < 0:
            # 3 -5
            ans += abs(y) - x + 1
        elif x < 0 and y < 0:
            # -10 -20
            ans += abs(y - x) + 2
        else:
            # 10 20
            ans += y - x
    elif abs(x) > abs(y):
        if x < 0 and y == 0:
            ans += abs(x)
        elif x > 0 and y == 0:
            ans += x + 1
        elif x < 0 and y > 0:
            # -20 10
            ans += abs(x) - y + 1
        elif x > 0 and y < 0:
            # 5 -3
            ans += 1
            y = -y
            ans += x - y
        elif x < 0 and y < 0:
            # -20 -10
            ans += abs(x - y)
        else:
            # 20 10
            ans += x - y + 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int w,n;
pair<int,int> takara[1002];
int dp[1002][10002];
int saidai=0,banti=0;
char ch;
int now=1;
main(){
  while(1){
    cin>>w;
    if(w==0){
      break;
    }
    cin>>n;
    for(int i=1;i<=n;i++){
      cin>>takara[i].first>>ch>>takara[i].second;
    }
    saidai=0;
    banti=0;
    for(int i=0;i<=n;i++){
      for(int j=0;j<=w;j++){
	if(i==0){
	  dp[i][j]=0;
	}
	else if(j-takara[i].second<0){
	  dp[i][j]=dp[i-1][j];
	}
	else{
	  dp[i][j]=max(dp[i-1][j],dp[i-1][j-takara[i].second]+takara[i].first);
	}
	if(i==n&&saidai<dp[i][j]){
	  saidai=dp[i][j];
	  banti=j;
	}
      }
    }
    cout<<"Case "<<now<<":"<<endl<<saidai<<endl<<banti<<endl;
    now++;
  }
}

Measured memory_bytes: 38492
n,c,k=map(int,input().split())
t = [int(input()) for _ in range(n)]
t.sort()
count = 1
num = 0
time=t[0]
for i in range(n):
    if num < c and t[i] <= time+k:
        num+=1
    else:
        count+=1
        time=t[i]
        num=1
print(count)



Measured memory_bytes: 7384
while True:
    arr = input().split()
    a = int(arr[0])
    op = arr[1]
    b = int(arr[2])
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break

Measured memory_bytes: 7664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(void){
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind road(N), rail(N);
  int p, q, r, s;
  REP(i, K){
    scanf("%d %d", &p, &q);
    road.unionSet(p-1, q-1);
  }
  REP(i, L){
    scanf("%d %d", &r, &s);
    rail.unionSet(r-1, s-1);
  }

  int cnt[N];
  map<pair<int, int>, int> mp;
  map<pair<int, int>, vector<int> > index;
  pair<int, int> pa;
  for(int i=0;i<N;i++){
    cnt[i] = 0;
    pa = make_pair(road.root(i), rail.root(i));
    index[pa].PB(i);
    if(mp.count(pa) == 0) mp[pa] = 1;
    else mp[pa]++;
  }

  map<pair<int, int>, int>::iterator it;
  for(it = mp.begin(); it!=mp.end(); it++ ) {
    pair<int, int> thisp = it->first;
    int count = it->second;
    for(int i=0;i<index[thisp].size();++i){
      cnt[index[thisp][i]] = count;
    }
  }

  for(int i=0;i<N;i++){
    printf("%d", cnt[i]);
    if(i != N-1) printf(" ");
    else printf("\n");
  }

  return 0;
}


Measured memory_bytes: 34432
#include <iostream>
#include <algorithm>
using namespace std;
    int DP[101][101];
    int *p;
int rec(int r,int c){
    int Min =100000001;
    
    for(int i=0;i<c-r;i++){
        Min =min(Min,DP[r][r+i] + DP[r+i+1][c]+p[r-1]*p[r+i]*p[c]);
    }
    return Min;
}
int main(void){
    int n,bb;
    cin>>n;
    p =new int[n+1];
    cin>> p[0];
    cin>>p[1];
    for(int i=1;i<=n ;i++) DP[i][i]=0;;
    for(int i=2;i<=n;i++){
        cin>>bb;
        cin>>p[i];
    }
    for(int i=1;i<n;i++){
        DP[i][i+1]=p[i-1]*p[i]*p[i+1];
    }
    for(int j=0;j<=n-3;j++){
        for(int i=3+j;i<=n;i++){
            DP[i-2-j][i] =rec(i-2-j,i);
        }
    }
    cout <<DP[1][n]<<endl;
}



Measured memory_bytes: 3080
n = int(input())
s = input()

a = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
y = [0]*len(s)
x = ""

for i in range(len(s)):
    for j in range(26):
        if s[i] == a[j]:
            d = (j+n)%26
            y[i] = a[d]

for k in range(len(s)):
    x = x + y[k]

print(x)


Measured memory_bytes: 3188
import java.util.*;
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Integer> hashmap = new HashMap<String, Integer>();
    for(int i = 0; i < n; i++){
      String check = sc.next();
      if(!hashmap.containsKey(check)){
        hashmap.put(check, 0);
      }
    }
    System.out.println(hashmap.size());
    sc.close();
  }
}

Measured memory_bytes: 78588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    int ans = 0;
    rep(i,N){
        while(a[i]%2 == 0){
            ans++;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
}

    



Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto d = readln.chomp.split.to!(long[]);
  auto b = readln.chomp.split.to!(long[]);
  foreach (i; 0..n) {
    d[i] -= b[i];
  }
  d = sort(d).array;

  if (d.sum < 0) {
    writeln("-1");
    return;
  }
  

  auto l = 0;
  auto r = d.length - 1;
  auto tmp = 0;
  int cnt;
  while (d[l] < 0) {
    tmp += d[l];
    while (tmp < 0) {
      tmp += d[r];
      cnt++;
      r--;
    }
    cnt++;
    l++;
  }
  cnt.writeln;
}


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

bool col[4]={};
char color[204];
int N;

int main(){
  int i;
  scanf("%d",&N);
  scanf("%c% ",&color[0]);
  for(i=1;i<2*N+1;i++)scanf("%c",&color[i]);

  for(i=1;i<2*N+1;i++){
    if(color[i]=='P'&&col[0]==0)col[0]++;
    if(color[i]=='W'&&col[1]==0)col[1]++;
    if(color[i]=='G'&&col[2]==0)col[2]++;
    if(color[i]=='Y'&&col[3]==0)col[3]++;
  }
  if(col[0]==1&&col[1]==1&&col[2]==1&&col[3]==1)printf("Four\n");
  else printf("Three\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

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

const ll mod = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int main(){
  int N, T;
  cin >> N >> T;
  vector<int> D(N);
  REP(i, N) cin >> D[i];
  sort(ALL(D), greater<int>());

  ll ans = 1;
  int p  = -1;
  
  REP(i, N){
    while(D[i] + T < D[p+1]) p++;
    ans = (ans * (i - p)) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A+C+B>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() { 
  ll n;
  cin >> n;
  vector<ll> a(n),p(n),q(n);
  REP(i, n) { cin >> p[i]; }
  REP(i, n) { cin >> q[i]; }
  REP(i, n) { a[i] = i + 1; }
  ll cp = 1, cq = 1;
  ll ansp=0, ansq=0;
  do {
    if (ansp * ansq != 0) break;
    if (a == p) ansp = cp;
    if (a == q) ansq = cq;
    cp++;
    cq++;
    // DEBUGS(a);
  } while (next_permutation(ALL(a)));
  cout << abs(ansp - ansq) << endl;
  
  return 0;
}


Measured memory_bytes: 3604