akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x) (x.begin(),x.end()) 
#define sz(v) ((int)(v.size()))
#define endl '\n'
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 
 
int32_t main(){
  fast; /*
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif */
	
  int T=1; //cin>>T; 
  while(T--){

  	int n,k; cin>>n>>k; 
  	vi a(n); 

  	for(int i=0;i<n;i++) cin>>a[i]; 

  	vector< bool > dp(k+1,false); 

  	for(int i=0;i<=k;i++){
  		for(int x:a){
  			if(!dp[i] && i+x<=k){
  				dp[i+x]=true; 
  			}
  		}
  	}

  	if(dp[k]) cout<<"First"<<endl; 
  	else cout<<"Second"<<endl; 

  






  }
    


  return 0; 
} 


Measured memory_bytes: 256
n = int(input())
v = map(int, input().split())

d1, d2 = {}, {}

for i, a in enumerate(v):
    if i % 2 == 0:
        d1[a] = d1.get(a, 0) + 1
    else:
        d2[a] = d2.get(a, 0) + 1

d1[-1] = 0
d2[-1] = 0

s = (sorted(d1.items(), key=lambda x: -x[1]))
t = (sorted(d2.items(), key=lambda x: -x[1]))

if (s[0][0] != t[0][0]):
    print (n-s[0][1]-t[0][1])
else:
    print( min( n-s[0][1]-t[1][1], n-s[1][1]-t[0][1]) )


Measured memory_bytes: 20916
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007
inf = 10**12
#+++++

def main():
	#a = int(input())
	n, max_w = IN()
	#s = input()
	dp_v = [inf] * (10**5 + 100)
	dp_v[0] = 0
	for _ in range(n):
		add_v = []
		w, v = IN()
		for i, cv in enumerate(dp_v):
			if dp_v[i] == inf:
				continue
			if dp_v[i] + w < dp_v[i+v]:
				add_v.append((i+v, dp_v[i] + w))
		for i, nv in add_v:
			dp_v[i] = nv
			
	for i, min_w in enumerate(dp_v[::-1]):
		if min_w <= max_w:
			v=len(dp_v)-i-1
			return v
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 55644
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var qu=new Queue<long>();
		for(int i = 1;i<10;i++) {qu.Enqueue(i);}
		int g=0;
		long ans=0;
		while(g<n){
			g++;
			ans=qu.Dequeue();
			long p=ans%10;
			for(int i = (int)Max(0,p-1);i<=9&&i<=p+1;i++) {qu.Enqueue(ans*10+i);}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
const int N = 305, T = 2e5 + 5;
int L[N], ava[N], need[N][N], has[N][N], a[T], b[T];
bool done[N];
int got[N];
int main() {
	int p, r, t;
	scanf("%d%d%d", &p, &r, &t);
	for (int i = 1; i <= r; ++ i) scanf("%d", &L[i]);
	for (int i = 1; i <= p; ++ i) {
		for (int j = 1; j <= r; ++ j) scanf("%d", &need[i][j]);
	}
	for (int i = 1; i <= t; ++ i) scanf("%d%d", &a[i], &b[i]);
	int l = 1, R = t, ans = -1;
	while (l <= R) {
		int mid = (l + R) / 2;
		memset(has, 0, sizeof(has));
		memset(ava, 0, sizeof(ava));
		memset(got, 0, sizeof(got));
		memset(done, 0, sizeof(done));
		for (int i = 1; i <= r; ++ i) ava[i] = L[i];
		int dones = 0;
		for (int i = 1; i <= p; ++ i) {
			for (int j = 1; j <= r; ++ j) if (need[i][j] == 0) {
				got[i] ++;
				if (got[i] == r) {
					done[i] = 1;
					dones ++;
				}
			}
		}
		for (int i = 1; i <= mid; ++ i) {
			has[a[i]][b[i]] ++;
			ava[b[i]] --;
			if (has[a[i]][b[i]] == need[a[i]][b[i]]) {
				got[a[i]] ++;
				if (got[a[i]] == r) {
					done[a[i]] = 1;
					dones ++;
					for (int j = 1; j <= r; ++ j) ava[j] += need[a[i]][j];
				}
			}
		}
		bool flag = 1;
		while (flag) {
			flag = 0;
			for (int i = 1; i <= p; ++ i) {
				if (done[i]) continue;
				bool can = 1;
				for (int j = 1; j <= r; ++ j) if (ava[j] + has[i][j] < need[i][j]) {
					can = 0;
					break;
				}
				if (can) {
					done[i] = 1;
					dones ++;
					flag = 1;
					for (int j = 1; j <= r; ++ j) ava[j] += has[i][j];
				}
			}
		}
		if (dones == p) {
			l = mid + 1;
		}
		else {
			R = mid - 1;
			ans = mid;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 5476
#include "bits/stdc++.h"

using namespace std;

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  auto ans1 = min(c, b);
  c -= ans1;
  b -= ans1;
  auto ans2 = 0ll;
  if (c) {
    ans2 = min(c, a);
    c -= ans2;
    a -= ans2;
    if (c) ans2++;
  } else if (b) {
    ans2 = b;
  }
  cout << ans1 * 2 + ans2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int y,m,d;
    string X,Y,M;
    char s1,s2;
    cin >> X;
    if(X.at(0) == '0')
        Y = X.substr(1,3);
    else
        Y = X.substr(0,4);
    
    if(X.at(5) == '0')
        M = X.substr(6,1);
    else
        M = X.substr(5,2);

    y = stoi(Y);
    m = stoi(M);

    if(y < 2019)
        cout << "Heisei" << endl;
    else if(y == 2019){
        if(m <= 4)
            cout << "Heisei" << endl;
        else if(m > 4)
            cout << "TBD" << endl;
    }else
        cout << "TBD" << endl;

    return 0;    

}

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

typedef long long int int64;

int64 *tmp=NULL;
int64 calc(int64 *a,int n){
  if(n<=1) return 0;
  int m=n/2;
  int64 res=calc(a,m)+calc(a+m,n-m);
  int i=0;
  int j=m;
  int k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      tmp[k++]=a[i++];
    } else {
      res+=i;
      tmp[k++]=a[j++];
    }
  }
  while(i<m) tmp[k++]=a[i++];
  while(j<n){
    res+=i;
    tmp[k++]=a[j++];
  }
  for(i=0;i<n;i++) a[i]=tmp[i];
  return res;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int64 *a=(int64 *)malloc(sizeof(int64)*(n+1));
  a[0]=0;
  int i;
  for(i=1;i<=n;i++){
    int x;
    scanf("%d",&x);
    a[i]=a[i-1]+x-k;
  }
  tmp=(int64 *)malloc(sizeof(int64)*(n+1));
  int64 ans=calc(a,n+1);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 3328
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let n = s.trim().parse::<i64>().unwrap();
    let mut shu = Vec::new();
    s.clear();
    stdin().read_line(&mut s).ok();
    let v: Vec<i64> = s.split_whitespace().map(|e| e.parse().unwrap()).collect();

    let mut t = vec![0; 1000000];
    for &i in v.iter() {
        if t[i as usize] == 0 {
            shu.push(i as usize);
        }
        t[i as usize] += 1;
    }

    let mut total = 0;
    let mut table: Vec<i64> = Vec::new();
    for i in shu {
        let tmp = comb(t[i]);
        table.push(tmp);
        total += tmp;
    }

    for i in v {
        let i = i as usize;
        let subnum = t[i] - 1;
        println!("{}", total - subnum);
    }
}

fn comb(n: i64) -> i64 {
    n * (n - 1) / 2
}


Measured memory_bytes: 22004
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define FOR(i, m, n) for(int i = (int)m; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;

int main() {
    ll t1, t2;
    cin >> t1 >> t2;
    ll a1, a2, b1, b2;
    cin >> a1 >> a2 >> b1 >> b2;
    if(a1 < b1) {
        swap(a1, b1);
        swap(a2, b2);
    }
    if(a1 * t1 + a2 * t2 > b1 * t1 + b2 * t2) {
        cout << 0 << endl;
        return 0;
    }
    if(a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2) {
        cout << "infinity" << endl;
        return 0;
    }
    ll ans = 1;
    ll diff1 = (a1 - b1) * t1;
    ll diff2 = b1 * t1 + b2 * t2 - a1 * t1 - a2 * t2;
    //cout << diff1 << " " << diff2 << endl;
    if(diff1 % diff2 == 0) {
        ans += 2 * ((diff1 - 1) / diff2) + 1;
    } else ans += 2 * (diff1 / diff2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans[110][110];
int main(){
	ll h,w,n;
	cin>>h>>w>>n;
	vector<ll>v;

	for(int i=1;i<=n;i++){
		ll x;
		cin>>x;
		while(x--)v.push_back(i);
	}
	ll now=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i%2)ans[i][w-1-j]=v[now];
			else ans[i][j]=v[now];
			now++;
		}
		for(int j=0;j<w;j++)cout<<ans[i][j]<<' ';
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3808
import java.util.Scanner;

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

        double x1=scan.nextDouble();
        double y1=scan.nextDouble();
        double x2=scan.nextDouble();
        double y2=scan.nextDouble();

        double S=(y2-y1)*(y2-y1)+(x2-x1)*(x2-x1);

        System.out.println(Math.sqrt(S));
    }
}



Measured memory_bytes: 27960
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	int a,b;
	scanf("%d %d", &a,&b);
	if (a > b) {
		printf("a > b\n");
	}
	if (a < b) {
		printf("a < b\n");
	}
	if (a == b) {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int a[100][100];


int main(){
  int N, D;
  cin >> N >> D;
  rep(i,N){
    rep(j,D){
      cin >> a[i][j];
    }
  }
  int ans = 0;
  bool flag = false;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      int r = 0;
      flag = false;
      rep(l,D){
	int diff = abs(a[i][l]-a[j][l]);
	r += diff * diff;
      }
      for(int k = 0; k <= r; k++){
	if(k*k == r) flag = true;
      }
      if(flag) ans++;
    }
  }
  cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

using ull = unsigned long long;
#define B1 100000007
#define B2 1000000007

bool rolling_hash(string const &S, int t_start, int m){
    int s_start = t_start + m;

    // B^mを用意する
    ull pow_B_m_1 = 1, pow_B_m_2 = 1;
    for(int k = 0; k < m; k++){
        pow_B_m_1 *= B1, pow_B_m_2 *= B2;
    }

    // sとtの先頭m文字のハッシュ値sh,thを計算
    ull sh1 = 0, sh2 = 0, th1 = 0, th2 = 0;
    for(int k = 0; k < m; k++){
        th1 = th1 * B1 + S[t_start + k], th2 = th2 * B2 + S[t_start + k];
        sh1 = sh1 * B1 + S[s_start + k], sh2 = sh2 * B2 + S[s_start + k];
    }

    // sをずらしてハッシュ値を更新
    for(int k = 0; s_start + m + k <= S.length(); k++){
        if(sh1 == th1 && sh2 == th2) return true;
        sh1 = sh1 * B1 + S[s_start + m + k] - S[s_start + k] * pow_B_m_1;
        sh2 = sh2 * B2 + S[s_start + m + k] - S[s_start + k] * pow_B_m_2;
    }
    return false;
}

int main(){
    int n; string S;
    cin >> n >> S;

    // 一致する最大文字数を２分探索
    int ng = n+1, ok = 0, mid;
    while(ng - ok > 1){
        mid = (ng + ok) / 2;
        bool mached = false;
        // Sのi文字目をtの先頭として,t = S[i:i+mid], s = S[i+mid:n]
        for(int i = 0; i <= n - mid*2; i++){
            if(rolling_hash(S, i, mid)){
                mached = true;
                break;
            }
        }
        if(mached) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  
  int number = 1;
  int i;
  for( i=0; i < N; i++){
    if(	number * 2 < number + K)	number *= 2;
    else	number += K;
  }
  
  cout << number << endl;
}

Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	map<string, int> words;
	while(n--)
	{
		string word;
		cin >> word;
		--words[word];
	}
	vector<pair<int, string>> ordered;
	for(auto &word : words) ordered.emplace_back(word.second, word.first);
	FSRT(ordered);
	for(auto &word : ordered) if(word.first == ordered[0].ff) cout << word.second << '\n';
}

Measured memory_bytes: 29332
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
bus = 0
count = 0
j = 0
for i in range(N-1):
  count += 1
  if count >= C or T[i+1] > T[j]+K:
    bus += 1
    j += count
    count = 0
  if i == N-2:
    count += 1
    if count%C == 0:
      bus += count//C
    else:
      bus += count//C+1
print(bus)

Measured memory_bytes: 7512
N = int(input())

# 約数の全列挙
def divisors(n):
    divisors = []
    R = int(n**(0.5)) + 1
    for i in range(1, R):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort(reverse=True)  # ソート
    return divisors

ans = 10**18
for d in divisors(N):
    k = N // d

    ans = min(ans, d + k - 2)
print(ans)


Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
#define testcases ll t; cin>>t; while(t--)

using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,W;
    cin>>n>>W;
    vector<ll> v(n+1),w(n+1);
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(w[i]>j) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
        }
    }
    cout<<dp[n][W];
    return 0;
}



Measured memory_bytes: 80256
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var d = new long[N+1];
        for (int i = 0; i < N; i++)
        {
            d[i + 1] = d[i] + a[i];
        }
        long ans = long.MaxValue;
        for (int i = 1; i < N; i++)
        {
            ans = Math.Min(ans, Math.Abs(d[i] - (d[N]-d[i])));
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 45048
#include <iostream>

using namespace std;

int main()
{
    int A, B, ans;

    cin >> A >> B;

    if (A <= 5) {
        ans = 0;
    } else if (6 <= A && A <= 12) {
        ans = B / 2;
    } else {
        ans = B;
    }

    cout << ans << endl;

    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void solve() {
    ll N; cin >> N;
    auto dv = divisor(N);
    ll res = 0;
    for(auto d: dv){
        if((d+1) < N/d) res += (N-d)/d;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


string s;

int main(){
  int n;cin>>n;
  int tmp = 0;
  int ans = 0;
  cin>>s;
  for(int i=0;i<n;i++){
    if(s[i] == 'I'){
      tmp++;
    } else{
      tmp--;
    }
    ans = max(ans,tmp);
  }
  cout<<ans<<endl;

}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	vector<bool> ok(n, true);
	rep(i, n)cin >> h[i];
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		if (h[a] <= h[b])ok[a] = false;
		if (h[b] <= h[a])ok[b] = false;
	}
	int ans = 0;
	rep(i, n)if (ok[i])ans++;
	cout << ans << endl;
	return 0;
}






Measured memory_bytes: 3776
S, T = input(), input()
cnt1, cnt2, r1, r2 =[], [], [], []
for c in S:
    if not c in r1:
        cnt1.append(S.count(c))
        r1.append(c)
for c in T:
    if not c in r2:
        cnt2.append(T.count(c))
        r2.append(c)
cnt1.sort()
cnt2.sort()
if cnt1 == cnt2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 41584
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int[] balls = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int ans = 0;
            int a,b;
            for(int i = 0 ; i < N ; i++)
            {
                a = balls[i] * 2;
                b = Math.Abs(balls[i]-K)*2;
                ans += Math.Min(a,b);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] h = new int[N];
        int[] dp = new int[N];
        for(int i = 0; i < N; i++) {
            h[i] = scanner.nextInt();
        }

        dp[1] = Math.abs(h[0] - h[1]);
        for(int i = 2; i < N; i++) {
            dp[i] = Math.min(Math.abs(h[i] - h[i-1]) + dp[i-1], Math.abs(h[i] - h[i-2]) + dp[i-2]);
        }
        System.out.println(dp[N-1]);
    }
}


Measured memory_bytes: 52872
#include<bits/stdc++.h>
using namespace std;
typedef long long giant;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
template<class T> inline T read() {
	T x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
const int maxn=1e5+1;
const int q=1e9+7;
const giant inf=2e18;
inline int Plus(int x,int y) {return (x+=y)>=q?x-q:x;}
inline void Pe(int &x,int y) {x=Plus(x,y);}
int n,f[maxn][2];
giant lim[2],a[maxn];
namespace sgt {
	const int maxp=8e6;
	struct node {
		int l,r,s;
	} t[maxp];
	int tot=0;
	inline void newnode(int &x) {
		int y=x;
		t[x=++tot]=t[y];
	}
	void modify(int &x,int l,int r,int p,int d) {
		newnode(x);
		if (l==r) {t[x].s=d;return;}
		int mid=l+r>>1;
		p<=mid?modify(t[x].l,l,mid,p,d):modify(t[x].r,mid+1,r,p,d);
		t[x].s=Plus(t[t[x].l].s,t[t[x].r].s);
	}
	inline void modify(int &x,int p,int d) {
		modify(x,0,n,p,d);
	}
	int sum(int x,int L,int R,int l,int r) {
		if (!x) return 0;
		if (L==l && R==r) return t[x].s;
		int mid=L+R>>1;
		if (r<=mid) return sum(t[x].l,L,mid,l,r);
		if (l>mid) return sum(t[x].r,mid+1,R,l,r);
		return Plus(sum(t[x].l,L,mid,l,mid),sum(t[x].r,mid+1,R,mid+1,r));
	}
	inline int sum(int x,int l,int r) {
		return sum(x,0,n,l,r);
	}
}
int main() {
	n=read<int>(),lim[0]=read<giant>(),lim[1]=read<giant>();
	a[0]=-inf,generate(a+1,a+n+1,read<giant>);
	for (int i=0;i<2;++i) sgt::modify(f[1][i],0,1);
	for (int x=2;x<=n;++x) for (int c=0;c<2;++c) {
		if (a[x]-a[x-1]>=lim[c]) f[x][c]=f[x-1][c];
		int j=upper_bound(a,a+x,a[x]-lim[c])-a-1;
		sgt::modify(f[x][c],x-1,sgt::sum(f[x-1][c^1],0,j));
	}
	int ans=Plus(sgt::sum(f[n][0],0,n-1),sgt::sum(f[n][1],0,n-1));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 47488
N, M = map(int, input().split())

isSafe = [True] * (N+1)
for _ in range(M):
    a = int(input())
    isSafe[a] = False

dp = [0] * (N +1)

dp[0] = 1
dp[1] = 1
for i in range(2, N+1):
    if isSafe[i-1]:
        dp[i] += dp[i-1]
    if isSafe[i-2]:
        dp[i] += dp[i-2]

print(dp[N]%(10**9+7))

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int H, W;
  cin >> H >> W;
  ll INF = 1ll * 1e10 + 100;
  // パターン1
  ll ans1 = INF;
  if (3 <= H)
    ans1 = H % 3 == 0 ? 0ll : 1ll * W;
  // パターン2
  ll ans2 = INF;
  if (3 <= W)
    ans2 = W % 3 == 0 ? 0ll : 1ll * H;
  // パターン3
  ll ans3 = INF;
  for (int h = 0; h <= H; ++h)
  {
    ll s1 = 1ll * h * W;
    ll s2 = 1ll * (H - h) * (W / 2);
    ll s3 = (1ll * (H - h) * W) - s2;
    ans3 = min(ans3, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
  }
  // パターン4
  ll ans4 = INF;
  for (int w = 0; w <= W; ++w)
  {
    ll s1 = 1ll * H * w;
    ll s2 = 1ll * (H / 2) * (W - w);
    ll s3 = (1ll * H * (W - w)) - s2;
    ans4 = min(ans4, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
  }
  cout << min(min(ans1, ans2), min(ans3, ans4)) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC101A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int i = 0;
            for (int a = 0;a <4;a++)
            {
                int y = 0;
                y = y + a;
                if (s.Substring(y, 1) == "+")
                {
                    i = i + 1;
                }
                else
                {
                    i = i - 1;
                }
            }
            Console.WriteLine(i);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>
 
int main(){
  int s,i,n;
   
  while(1){
    char b[1005]={};
 
    s=0;
    scanf("%s",b);
    if(b[0]=='0')
      break;
 
    n=strlen(b);
    for(i=0;i<n;i++)
      s+=b[i]-'0';
 
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

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

	string s; cin >> s;
	int64_t v = 0;
	FOR_LT(i, 0, s.size()) {
		v += s[i] - '0';
	}
	if (v % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3740
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      
      int[][] edges = new int[m][2];
      for(int i = 0; i < m; i++) {
        edges[i][0] = sc.nextInt();
        edges[i][1] = sc.nextInt();
      }

      int cnt = 0;
      for(int i = 0; i < m; i++) {
          int[] root = new int[n+1];
          for(int k = 1; k < root.length; k++)
              root[k] = k;
          int[] size = new int[n+1];
          Arrays.fill(size, 1);

          for(int j = 0; j < m; j++) {
             if(j == i) continue;
             union(edges[j][0], edges[j][1], root, size);
          }
          int rootCnt = 0;
          for(int k = 1; k < root.length; k++)
              if(root[k] == k) rootCnt++;
          if(rootCnt > 1) cnt++;
      }
      System.out.println(cnt);
  }

  private static void union(int a, int b, int[] root, int[] size) {
      int rootA = find(a, root);
      int rootB = find(b, root);

      if(rootA == rootB) return;

      if(size[rootA] > size[rootB]) {
          root[rootB] = rootA;
          size[rootA] += size[rootB];
      } else {
          root[rootA] = rootB;
          size[rootB] += size[rootA];
      }
  }

  private static int find(int a, int[] root) {
      if(a != root[a]) {
          root[a] = find(root[a], root);
      }
      return root[a];
  }
}


Measured memory_bytes: 23380
import heapq
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for a,b,c in src:
    es[a-1].append((b-1,c))
    es[b-1].append((a-1,c))

Q,K = map(int,input().split())
qs = [tuple(map(int,input().split())) for i in range(Q)]
K -= 1

INF = float('inf')
dists = [INF]*N
dists[K] = 0
hq = [(0,K)]
heapq.heapify(hq)

while hq:
    d,v = heapq.heappop(hq)
    for to,c in es[v]:
        if d+c >= dists[to]: continue
        dists[to] = d+c
        heapq.heappush(hq, (d+c, to))

for a,b in qs:
    print(dists[a-1] + dists[b-1])

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

int main(){
  int A[105];
  int n;
  int max=1, min=1000000000;
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> A[i];
  }
  for (int i=0; i<n; i++){
    if (max<A[i]) max = A[i];
    if (min>A[i]) min = A[i];
  }
  int ans = max - min;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] num = line.split(" "); //空白で分けて格納してくれる.split()
        Deque<Integer> stack = new ArrayDeque<Integer>(); //スタックを作成する、中身はIntegerなので文字列は厳しい？
        sc.close();
        for(int i = 0; i < num.length; i++){
            if(num[i].equals("+")){    //Stringはequalsを使わなければ比べられない
                int x = stack.remove(); //popまたはremove()で取り出し
                int y = stack.remove();
                stack.push(y + x);
            }
            else if(num[i].equals("-")){
                int x = stack.remove();
                int y = stack.remove();
                stack.push(y - x);
            }
            else if(num[i].equals("*")){
                int x = stack.remove();
                int y = stack.remove();
                stack.push(y * x);
            }
            else 
                stack.push(Integer.parseInt(num[i]));//スタックに格納する前にIntegerに変換
            
        }
        System.out.println(stack.remove());
    }
}


Measured memory_bytes: 26296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a=0,b=0,c=0,d=0;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        int i=0;
        if(s[i]=='A')
            a++;
        else if(s[i]=='W')
            b++;
        else if(s[i]=='T')
            c++;
        else
            d++;
    }
   cout<<"AC x "<<a<<endl;
     cout<<"WA x "<<b<<endl;
     cout<<"TLE x "<<c<<endl;
     cout<<"RE x "<<d<<endl;

}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    set<int> s;
    rep(i, N) {
        int a;
        cin >> a;
        if(s.find(a) == s.end()) {
            s.insert(a);
        } else {
            s.erase(a);
        }
    }
    cout << s.size() << endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var X = long.Parse(Console.ReadLine());

        long deposit = 100;
        var year = 0;
        while (deposit < X)
        {
            year++;
            deposit = (long)Math.Floor(deposit * (decimal)1.01);
        }

        Console.WriteLine(year);
    }

}


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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n; cin>>n;
    string s = "";
    while(n){
        if(n%26==0){
            s.push_back('z');
            n--;
        }
        else s.push_back(char('a' + (n%26)-1));
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T> void Exit(T first){cout << first << endl;exit(0); };

int main(){
    iosetup;
    string S; cin >> S;
    sort(ALL(S));
    if(S[0] != S[2]) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n;
	
	cin >> n;
	
	int dig = 0;
	int ans = 0;
	
	if (n == 100000) {
		ans =(99999 - 9999) + (999 - 99) + 9;
	} else if ( n > 9999) {
		ans = (n - 9999) + (999 - 99) + 9;
	} else if(n > 999) {
		ans = (999 - 99) + 9;
	} else if (n > 99) {
		ans = (n - 99) + 9;
	} else if ( n > 9) {
		ans = 9;
	} else {
		ans = n;
	}
	
	cout << ans << endl;
	


	return 0;
}


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

int m, n;
int a[111];
vector<int>ans, odd, even, x;

int main() {
	scanf("%d%d", &m, &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		if(a[i]%2) odd.push_back(a[i]);
		else even.push_back(a[i]);
	}
	if(odd.size()>2) {
		printf("Impossible\n");
		return 0;
	}
	if(odd.size()) ans.push_back(odd[0]);
	for(int i=0;i<even.size();i++)
		ans.push_back(even[i]);
	if(odd.size()==2) ans.push_back(odd[1]);
	
	for(int i=0;i<ans.size();i++)
		printf("%d%c", ans[i], i<ans.size()-1 ? ' ' : '\n');
	
	if (ans[0]>1) x.push_back(ans[0]-1);
	for(int i=1;i<ans.size();i++)
		if(ans[i] % 2) {
			x.push_back(2);
			if(ans[i]>1) x.push_back(ans[i]-1);
		} else x.push_back(ans[i]);
	if(odd.size()<=1) x.push_back(1);
	printf("%d\n", x.size());
	for(int i=0;i<x.size();i++)
		printf("%d%c", x[i], i<x.size()-1 ? ' ' : '\n');
	
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const lll mod=1e9+7;



int main(){
      ll n,j;
      cin>>n>>j;
      lll k=j;
      ll a[n];
      rep0(i,n) cin>>a[i];
      lll m[n],u[n];
      fill(m,m+n,0);
      fill(u,u+n,0);
      rep0(i,n){
            for(int j=0;j<i;j++){
                  if(a[j]<a[i]) m[i]++;
            }
            for(int j=i+1;j<n;j++){
                  if(a[i]>a[j]) u[i]++;
            }
      }
      lll ans=0;
      rep0(i,n){
            ans=(ans+u[i]*((k*(k+1))/2))%mod;
            ans=(ans+m[i]*((k*(k-1))/2))%mod;
      }
      cout<<(long long)ans<<endl;
      return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
a.append(0)

lst = []
before = 0
for num in a:
    lst.append(abs(num - before))
    before = num
total = sum(lst)
for i in range(n):
    if i == 0:
        print(total - lst[i] - lst[i + 1] + abs(a[i+1]))
    else:
        print(total - lst[i] - lst[i + 1] + abs(a[i - 1] - a[i + 1]))

Measured memory_bytes: 14040
N = int(input())

for h in range(1, 3501):
	for n in range(1, 3501):
		if 4*h*n-N*n-N*h > 0 and N*h*n % (4*h*n-N*n-N*h) == 0:
			print (h, n, N*h*n // (4*h*n-N*n-N*h))
			exit()


Measured memory_bytes: 3060
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
long long MAX(long long A,long long B){
    return A>B?A:B;
}
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main()
{   int a[5],b=0,c,d,e,x,y,n,m=16,ans=0,i;
    for(i=0;i<5;i++)scanf("%d",&a[i]);
    for(i=0;i<5;i++){
        if(a[i]%10==0){
            ans+=a[i];
        }else{
            ans+=((a[i]/10+1)*10);
            b=1;
        }
        }
        //printf("preans%d",ans);
        if(b==1){
        ans-=10;
        for(i=0;i<5;i++){
            if(m>a[i]%10&&a[i]%10>0){
                m=(a[i]%10);
            //    printf("m=%d",m);
            }
            
        }
        ans+=m;
        }
    printf("%d",ans);
    return 0;
}


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

int divi(int n){
    int c=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            c++;
            if(i!=n/i){c++;}
        }
    }
   // cout<<n<<" "<<c<<endl;
    return (c);
}

int main() {
    ll n;
    cin>>n;
    ll c=0;
    for(int i=3;i<=n;i=i+2){
        if(divi(i)==8){c++;}
     //   cout<<i<<endl;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d; cin>>d;
    if(d==22){
        print("Christmas Eve Eve Eve");
    } else if (d==23){
        print("Christmas Eve Eve");
    } else if (d==24){
        print("Christmas Eve");
    } else if (d==25){
        print("Christmas");
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = 0
B = 0
for _ in range(n):
  a,b = map(int,input().split())
  A = max(A,a)
  B = max(B,b)
  w = max(((A+B)-1)//(a+b)+1 , (A-1)//a+1 , (B-1)//b+1)
  A = w * a
  B = w * b
  #print(A,B)
print(A+B)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define sz 3000000

inline ll add(ll a, ll b)
{
	a = ((a % MOD) + MOD) % MOD;
	b = ((b % MOD) + MOD) % MOD;
	return (a + b) % MOD;
}

ll dp[21][sz];
vector<int>adj[21];

ll f(int x, int y)
{
	if (x == -1)
		return 1;
	ll &ans = dp[x][y];
	if (ans != -1)
		return ans;
	ans = 0;
	for (auto it : adj[x])
	{
		if (!(y & (1 << it)))
			ans = add(ans, f(x - 1, (y | (1 << it))));
	}
	return ans;
}

int main()
{

	memset(dp, -1, sizeof(dp));

	int n, a; scanf("%d", &n);

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			scanf("%d", &a);
			if (a == 1)
				adj[i].push_back(j);
		}
	}

	cout << f(n - 1, 0);

	return 0;
}

Measured memory_bytes: 492416
#include<bits/stdc++.h>
 
using namespace std;
 
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int INF = 1e10;
int a[3];
 
int main(){
	IOS;
	while(cin>>a[0]>>a[1]>>a[2]){
		sort(a,a+3);
		int ans=0;
		for(int i=0;i<2;i++){
			ans+=a[i+1]-a[i];
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    A, B, C, K = read_ints()
    if A >= K:
        return K
    K -= A
    if B >= K:
        return A
    K -= B
    return A-K


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 9176