akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    lli H, W;
    cin >> H >> W;
    lli num = H * W;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else if (num % 2 == 0) {
        cout << num / 2 << endl;
    } else {
        cout << num / 2 + 1<< endl;
    }
}


Measured memory_bytes: 256
# C - Tsundoku
from bisect import bisect
from itertools import accumulate


def main():
    N, M, K, *AB = map(int, open(0).read().split())
    cum_A, cum_B = tuple(accumulate([0] + AB[:N])), tuple(accumulate(AB[N:]))
    candidates = []
    for i, a_time in enumerate(cum_A):
        if a_time > K:
            candidates.append(0)
            break
        b_time = K - a_time
        candidates.append(i + bisect(cum_B, b_time))
    print(max(candidates))


if __name__ == "__main__":
    main()


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

int main() {
    string s, t; cin >> s >> t;
    set<string> ans;
    for (int i = 0; i + t.size() <= s.size(); i++) {
        bool flag = true;
        for (int j = 0; j < t.size(); j++) {
            if (s[i+j] != t[j] && s[i+j] != '?') flag = false;
        }
        if (flag) {
            string ss = s;
            for (int j = 0; j < t.size(); j++) ss[i+j] = t[j];
            for (int j = 0; j < s.size(); j++) {
                if (ss[j] == '?') ss[j] = 'a';
            } 
            ans.insert(ss);
        }
    }
    if (ans.size() == 0) cout << "UNRESTORABLE" << endl;
    else cout << *ans.begin() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,nw,cw;
string s; 
int main(){
	int ans=1e6;
	cin>>n>>s;s="*"+s;s+="d";
	vector<int>v;
	for(int i=1;i<=n;i++)if(s[i]=='W')nw++,v.push_back(i);
	ans=min(ans,min(nw,n-nw));
	for(int i=0;i<=n;i++){
		if(s[i]=='W')cw++;
		int ok=(upper_bound(v.begin(),v.end(),i)-v.begin())-(lower_bound(v.begin(),v.end(),i-cw+1)-v.begin());
		ans=min(ans,cw-ok+(n-i-(nw-cw)));
		ok=(upper_bound(v.begin(),v.end(),n)-v.begin())-(lower_bound(v.begin(),v.end(),n-(nw-cw)+1)-v.begin());
		ans=min(ans,(nw-cw)-ok+cw);
	}
	cout<<ans;
}

Measured memory_bytes: 4580
import Control.Monad
import Text.Printf

getLines :: Int -> IO [String]
getLines n = replicateM n getLine

getLinesInt :: Int -> IO [Int]
getLinesInt n = fmap read <$> getLines n

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

getDoubles :: IO [Double]
getDoubles = map (read :: String -> Double) . words <$> getLine

main :: IO ()
main = do
    [b] <- getLine
    putChar $ case b of 'A' -> 'T'
                        'T' -> 'A'
                        'C' -> 'G'
                        'G' -> 'C'




Measured memory_bytes: 380
#include <stdio.h>

void printReverseStr(char *str) {
  char *ptr = str;

  for (; *ptr != '\0'; ptr++);

  while (ptr-- != str)
    printf("%c", *ptr);
  printf("\n");
}

int main(void) {
  char str[21];

  scanf("%20s", str);

  printReverseStr(str);

  return 0;
}

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

const int maxn = 100000 + 10;

int gcd(int a, int b)
{
    return b == 0? a: gcd(b, a%b);
}

int main()
{
    int n, k, x;
    int GCD = 0, mx = 0;
    scanf("%d%d%d", &n, &k, &x);
    GCD = mx = x;
    while(--n)
    {
        scanf("%d", &x);
        mx = max(mx, x);
        GCD = gcd(GCD, x);
    }
    if(k<=mx && k%GCD==0) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n, k = map(int, input().split())
al = [int(i) for i in input().split()]

# dictionary で種類と数値をとっておく
d = defaultdict(int)
for a in al:
  d[a] += 1

# 種類が少ないものから色を変えていくと最小の変えなければいけないボールの数がわかる
ans = 0
if len(d.keys()) > k:
  # 色を塗り替えないといけないので数えなければ…
  v = list(d.values())
  v.sort()
  ans = sum(v[:len(d.keys()) - k])
print(ans)

Measured memory_bytes: 32540
bingo = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
l = [int(input()) for _ in range(n)]
for i in range(3):
    if bingo[i][0] in l and bingo[i][1] in l and bingo[i][2] in l:
        print("Yes")
        exit()
for i in range(3):
    if bingo[0][i] in l and bingo[1][i] in l and bingo[2][i] in l:
        print("Yes")
        exit()
if bingo[0][0] in l and bingo[1][1] in l and bingo[2][2] in l:
    print("Yes")
    exit()
if bingo[0][2] in l and bingo[1][1] in l and bingo[2][0] in l:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
bool check(vector<int> &v, size_t i, int x) {
  if (x == 0)
    return true;
  if (i >= v.size())
    return false;
  return check(v, i + 1, x) || check(v, i + 1, x - v[i]);
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &e : v)
    cin >> e;
  sort(v.begin(), v.end());
  int q;
  cin >> q;
  while (q--) {

    int x;
    cin >> x;
    if (check(v, 0, x))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int flg=0;
	string s;cin>>s;
	int a[26]={0};
	for(auto x:s){
		a[x-'a']++;
	}
	REP(i,0,25){
		if(a[i]%2!=0){
			flg=1;break;
		}
	}
	if(flg==0)cout<<"Yes";
	else cout<<"No";
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  long long H, A;
  cin >> H >> A;
  if(H%A == 0) cout << H/A << endl;
  else cout << H/A + 1 << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,t,a,s,r=1e9,z;
  scanf("%d%d%d",&n,&t,&a);
  for(int i=0;i<n;i++){
    scanf("%d",&s);
    if(abs(1000*t-s*6-1000*a)<r){
      r=abs(1000*t-s*6-1000*a);
      z=i;
    }
  }
  printf("%d",z+1);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;

char a[60][60];
int vis[60][60];
int S, T;
int n, m;
int head[3000], nxt[600000], to[600000], w[600000], f[600000], TOT;
queue <int> q;
int dist[3000], edge[3000], lst[3000], inq[3000];

void add_edge(int x, int y, int W, int F) {
	w[TOT] = W, f[TOT] = F, to[TOT] = y, nxt[TOT] = head[x], head[x] = TOT++;
	w[TOT] = 0, f[TOT] = -F, to[TOT] = x, nxt[TOT] = head[y], head[y] = TOT++;
}

void dfs(int x, int y, int id) {
	vis[x][y] = 1, add_edge(id, x * m + y, 1, 0);
	if (x + 1 < n && a[x + 1][y] != '#' && !vis[x + 1][y]) dfs(x + 1, y, id);
	if (y + 1 < m && a[x][y + 1] != '#' && !vis[x][y + 1]) dfs(x, y + 1, id);
}

bool spfa() {
	for (int i = 0; i <= T; i++) {
		dist[i] = 0x3f3f3f3f;
	}
	q.push(S), inq[S] = 1, dist[S] = 0;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		inq[x] = 0;
		for (int i = head[x]; ~i; i = nxt[i]) {
			if (!w[i]) continue;
			int v = to[i];
			if (dist[v] > dist[x] + f[i]) {
				dist[v] = dist[x] + f[i];
				edge[v] = i, lst[v] = x;
				if (!inq[v]) q.push(v), inq[v] = 1;
			}
		}
	}
	return dist[T] != 0x3f3f3f3f;
}

int min_cost() {
	int cost = 0;
	while (spfa()) {
		int now = T;
		while (now != S) {
			int tmp = edge[now];
			w[tmp]--, w[tmp ^ 1]++;
			cost += f[tmp];
			now = lst[now];
		}
	}
	return cost;
}

int main () {
	memset(head, -1, sizeof(head));
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%s", a[i]);
	}
	int tot = n * m, ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] == 'o') {
				memset(vis, 0, sizeof(vis));
				dfs(i, j, tot);
				tot++, ans -= i + j;
			}
		}
	}
	S = tot++, T = tot++;
	for (int i = n * m; i < tot - 2; i++) {
		add_edge(S, i, 1, 0);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			add_edge(i * m + j, T, 1, -i - j);
		}
	}
	ans -= min_cost();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5864
#include<stdio.h>

int main(){

	unsigned long a, b, c, d, r, temp;

	while (scanf ("%ld %ld", &a, &b) != EOF){

		//a>b????????????????????\??????????????????
		if(a<b){
			temp=a;
			a=b;
			b=temp;
		}

		c = a*b;
	
		//????????????????????????????????¨?????????????????????d????????§??¬?´???°??????????????????

		while((r=a%b) != 0){
			a=b;
			b=r;
		}

	//????°???¬?????°???2?????????/?????§??¬?´???°??§?±???????????????????

	printf("%ld %ld\n",b,c/b);
	}
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef unsigned long long ll;

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


void solve(void){
	int N;
	cin >> N;
	vector <ll> as(N);
	rep(N, i) cin >> as[i];
	if (as[0] != 0LL) {
		cout << -1 << endl;
		return;
	}
	reverse(all(as));
	if (N == 1) {
		cout << 0 << endl;
		return;
	}
	ll ans = 0LL;
	rep(N, i) {
		if (as[i] == 0LL) continue;
		if (as[i] == as[i+1]+1LL) {
			ans++;
			continue;
		}
		if (as[i] >= as[i+1] + 2LL) {
			cout << -1 << endl;
			return;
		}
		ans += as[i];
	}
	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < n - 2; i++){
        if(s[i] == 'A') {
            if(s[i+1] == 'B') {
                if(s[i+2] == 'C'){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 1000
void initialize();
int isEmpty();
void push(int);
int pop();
int S[MAX],top;
int main() {
	int x,a,b;
	char s[MAX];
	initialize();
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			b = pop();
			a = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			b = pop();
			a = pop();
			push(a*b);
		}
		else {
			x = atoi(s);
			push(x);
		}
	}
	printf("%d", pop());
	printf("\n");

	return 0;
}
void initialize() {
	top = 0;
}
int isEmpty() {
	if (top == 0) {
		return 1;
	}
	else {
		return 0;
	}
 }
int isFull() {
	if (top >= MAX - 1) {
		return 1; 
	}
	else
	{
		return 0;
	}
}
void push(int x) {
	if (isFull()) {
		fprintf(stderr, "入れれません");
	}
	else
	{
		top++;
		S[top] = x;
	}
}
int pop() {
	if (isEmpty()) {
		fprintf(stderr, "アンダーフロー");
		exit(0);
	}
	else {
		top--;
		return S[top + 1];
	}
}


Measured memory_bytes: 2108
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
 
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
 
#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  
 
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
 
int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
 
int main() {
	int M, K;
	scanf("%d %d", &M, &K);
	
	if (M == 0) {
		if (K == 0) return !printf("0 0\n");
		return !printf("-1\n");
	}
	if (M == 1) {
		if (K == 0) return !printf("0 1 1 0\n"); 
		return !printf("-1\n");
	}
	if (K == 0) {
		for (int i = 0; i < (1 << M); i++) printf("%d %d ", i, i);
		return !printf("\n");
	}
 
	if (K >= (1 << M)) return !printf("-1\n");
 
	printf("0 ");
	for (int i = 1; i < (1 << M); i++) if (i != K) printf("%d ", i);
	printf("0 %d ", K);
	for (int i = (1 << M) - 1; i >= 1; i--) if (i != K) printf("%d ", i);
	return !printf("%d\n", K);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll x,y,a,b,c,i,j;
    cin>>x>>y>>a>>b>>c;
    ll ar1[a];
    priority_queue<pair<ll,ll> >pq;
    for(i=0;i<a;i++)
        cin>>ar1[i];
    ll ar2[b];
    for(i=0;i<b;i++)
        cin>>ar2[i];
    ll ar3[c];
    for(i=0;i<c;i++)
        cin>>ar3[i];
    sort(ar1,ar1+a);
    sort(ar2,ar2+b);
    sort(ar3,ar3+c);
    multiset<ll> s1,s2;
    for(i=a-x;i<a;i++)
        s1.insert(ar1[i]);
    for(i=b-y;i<b;i++)
        s2.insert(ar2[i]);
    ll sum=0;
    for(auto xx:s1)
        sum+=xx;
    for(auto xx:s2)
        sum+=xx;
    for(i=0;i<c;i++)
    {
        if(*s1.begin() < *s2.begin())
        {
            // replace in s1
            if(ar3[i] > *s1.begin())
            {
                sum-=*s1.begin();
                sum+=ar3[i];
                s1.erase(s1.find(*s1.begin()));
                s1.insert(ar3[i]);
            }
        }
        else
        {
            if(ar3[i] > *s2.begin())
            {
                sum-=*s2.begin();
                sum+=ar3[i];
                s2.erase(s2.find(*s2.begin()));
                s2.insert(ar3[i]);
            }
        }
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 11008
#include<cstdio>

int main() {
	int a, b,c,A,B;

	while (scanf("%d %d", &a, &b) != EOF) {
		A = a;
		B = b;
		while (b != 0) {
			c = a%b;
			a = b;
			b = c;
		}
		printf("%d %d\n", a, A / a*B);
	}
	return 0;
}


Measured memory_bytes: 2592
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
    int N; cin >> N;
    vector<long> L(N + 1);
    L[0] = 2; 
    L[1] = 1;

    for (int i = 2; i <= N; i++){
        L[i] = L[i - 2] + L[i - 1];
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 256
def main():
    import itertools
    n,x,y = map(int,input().split())
    stat = [i for i in range(n)]
    ans = [0 for i in range(n-1)]
    for s in itertools.combinations(stat,2):
        d = min(s[1]-s[0],abs(x-1-s[0])+1+abs(y-1-s[1]))
        ans[d-1] += 1
    for i in range(len(ans)):
        print(ans[i])

if __name__ == "__main__":
    main()


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

typedef struct {
    int number;
    int jyuni;
}student;

int cmp( const void *p, const void *q ) {
    return ((student*)p)->jyuni - ((student*)q)->jyuni;
}

int main(void){
    int N;
    int i;

    scanf("%d",&N);

    student person[N];
    
    for(i=0;i<N;i++){
        person[i].number=i+1;
        scanf("%d",&person[i].jyuni);
    }

    qsort(person,N,sizeof(student),cmp);

    for(i=0;i<N;i++){
        printf("%d ",person[i].number);
    }

    return 0;

}

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;
    int n = s.size();

    ll a = 0, ans = 0;
    for (int i = 0; i < n-1; i++) {
        if (s[i] == 'A') {
            a++;
        } else if (s[i] == 'B' && s[i+1] == 'C') {
            ans += a;
            i++;
        } else {
            a = 0;
        }
    }

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

Measured memory_bytes: 832
N = int(input())
node = [list(map(int, input().split())) for i in range(N)]
dp = [[0,0,0] for i in range(N+1)]
for i in range(N):
    dp[i+1][0] = node[i][0] + max(dp[i][1],dp[i][2])
    dp[i+1][1] = node[i][1] + max(dp[i][0],dp[i][2])
    dp[i+1][2] = node[i][2] + max(dp[i][0],dp[i][1])
print(max(dp[-1]))

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll a,b;
    ll c,d;
    cin >> a >> b >> c >> d;
    a--;
    ll cd = lcm(c,d);
    ll wa,wb;
    wa = a/c+a/d-a/cd;
    wb = b/c+b/d-b/cd;
    ll ans = (b-a)-(wb-wa);
    cout << ans << endl;
    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    int n, ans = 0;
    cin >> n;
    vector <int> l(n);
    for (int i = 0; i < n; i++) cin >> l[i];

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

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ans += lower_bound(all(l), l[i]+l[j])-l.begin() - j - 1;
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    ll ac = 0;
    ll wa = 0;
    map<ll, ll> cnt;
    set<ll> used;
    rep(i, M) {
        ll p;
        string S;
        cin >> p >> S;
        if (S == "AC" && used.count(p) == 0) {
            ac++;
            wa += cnt[p];
            used.insert(p);
        } else {
            cnt[p]++;
        }
    }
    cout << ac << " " << wa << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 11264
from collections import deque
n = int(input())
A = list(map(int, input().split()))
X = deque([str(A[0])])
append_ = True if n % 2 != 0 else False
for a in A[1:]:
    if append_:
        X.append(str(a))
    else:
        X.appendleft(str(a))
    append_ = not append_
print(" ".join(X))


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

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

    int ans = 0;  
    if(n == 100000){
        ans = 90909;
    }
    else if(100000 > n && n >= 10000){
        ans = 909 + (n - 10000 + 1);
    }
    else if(10000 > n && n >= 1000){
        ans = 909;
    }
    else if(1000 > n && n >= 100){
        ans = 9 + (n - 100 + 1);
    }
    else if(100 > n && n >= 10){
        ans = 9;
    }
    else{
        ans = n;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int nxtpos(VE<P<ll>>& a, ll d, ll now) {
	int l = 0, r = a.size();
	while (r - l > 1) {
		int mid = (l + r) / 2;
		if (a[mid].first <= now + d) l = mid;
		else r = mid;
	}
	l++;
	return l;
}
int main() {
	ll n, d, e;
	cin >> n >> d >> e;
	d = 2 * d; // 2*d+1だと区間を1余計に含むからダメでは？
	VE<P<ll>> a(n);
	rep(i, n) {
		ll x;
		cin >> a[i].first >> x;
		a[i].second = (x + e - 1) / e;
	}
	VL imos(n + 1, 0); // 区間iの爆弾が使われた回数をimos法で効率よく処理
	ll ans = 0;
	sort(all(a));
	rep(i, n) {
		if (i != 0) imos[i] += imos[i - 1];
		a[i].second -= imos[i];
		ll use = max((ll)0, a[i].second);
		ans += use;
		imos[i] += use;
		int index = nxtpos(a, d, a[i].first);
		imos[index] -= use;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7996
n = int(input())
dat = list(map(int,input().split()))

def gcd(x,y):
    if(y==0):
        return x
    return gcd(y,x%y)
pre = [dat[0]]
for d in dat[1:]:
    pre.append(gcd(pre[-1],d))
pre = [-1]+pre[:-1]
pos = [dat[-1]]
for d in dat[:-1][::-1]:
    pos.append(gcd(pos[-1],d))
pos = pos[::-1]
pos = pos[1:]+[-1]
res = 1
for i in range(n):
    if pre[i]==-1:
        res = max(res,pos[i])
    elif pos[i]==-1:
        res = max(res,pre[i])
    else:
        res = max(res,gcd(pre[i],pos[i]))
print(res)




Measured memory_bytes: 14584
n,m=map(int,input().split())
S=[]
for _ in range(m):
  s=list(map(int,input().split()))
  S.append(s[1:])
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  for k in range(m):
    sw=0
    for j in range(n):
      if (i>>j)&1 and j+1 in S[k]:
        sw+=1
    if sw % 2 != p[k]:
      break
  else:
    ans+=1
print(ans)



Measured memory_bytes: 71244
#include <stdio.h>
#include <string.h>
int main(void){
	int N;
	scanf("%d",&N);
	double YEN=0;
	double BIT=0;
	double Y=0;
	double X=0;
	char s[4];
	int i;
	
	for(i=0; i<N; i++){
		scanf("%lf",&X);
		scanf("%s",&s);
		if(!strcmp(s,"JPY")){
			YEN+=X;
		}else if(!strcmp(s,"BTC")){
			BIT+=X;
		}
	}
	Y = YEN + (BIT*380000);
	printf("%lf\n",Y);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;

int main(){
    int N; cin >> N;
    vector <ll> A(N);
    rep(i,N) cin >> A[i];
    
    sort(A.begin(),A.end());
    for (int i=0; i<N-1; i++){
        if (A[i]==A[i+1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,k;
std::vector<int> d={0,1,2,3,4,5,6,7,8,9};
int INF=1e9;
int dfs(int now,int depth=1){
  if(now>=n) return now;
  if(depth==7) return INF;
  std::vector<int> tmp;
  for(auto &e: d) {
    tmp.push_back(dfs(now*10+e,depth+1));
  }
  return *min_element(tmp.begin(),tmp.end());
}


int main()
{
  cin>>n>>k;
  for(int i=0;i<k;i++){
    int tmp;
    cin>>tmp;
    d[tmp]=-1;
  }
  sort(d.begin(),d.end(),greater<int>());
  for (int i = 0; i < k; ++i)
  {
    d.pop_back();
  }
  cout<<dfs(0);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    uint64_t N;
    cin >> N;
    string result;
    result.reserve(64);
    while(true) {
        N -= 1;
        auto n = N % 26;
        result += 'a' + n;
        if(N < 26) break;
        N /= 26;
    }
    reverse(result.begin(), result.end());
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct vec{
  ll x,y,z;
};
ll peg[11][11][11];
vec dir[13] = {{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{-1,1,0},{-1,0,1},{0,-1,1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
bool check(ll x,ll y,ll z,ll muki,ll col,ll m){
  ll cnt = 1;
  while(true){
    x += dir[muki].x;
    y += dir[muki].y;
    z += dir[muki].z;
    if(peg[x][y][z] != col)break;
    cnt++;
  }
  return cnt >= m;
}
void solve(ll n,ll m,ll p){
  bool fl = true;
  for(int i=0;i<p;i++){
    ll x,y;cin>>x>>y;
    ll now = i%2+1;
    for(int j=1;j<=n;j++){
      if(peg[x][y][j] == 0){
	peg[x][y][j] = now;
	break;
      }
    }

    for(int ii=1;ii<=n;ii++){
      for(int j=1;j<=n;j++){
	for(int k=1;k<=n;k++){
	  if(peg[ii][j][k] == now && fl){
	    for(int l=0;l<13;l++){
	      if(check(ii,j,k,l,now,m)){
		fl = false;
		cout<<((now==1)?"Black":"White")<<" "<<i+1<<endl;
		break;
	      }
	    }
	  }
	}
      }
    }
  }
  if(fl)
    cout<<"Draw"<<endl;
  return;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,p;
  while(cin>>n>>m>>p,n+m+p){
    for(int i=0;i<11;i++)
      for(int j=0;j<11;j++)
	for(int k=0;k<11;k++)
	  peg[i][j][k] = 0;
    solve(n,m,p);
  }
  return 0;
}



Measured memory_bytes: 3148
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int main() {
	ll n, l, r, ans = 0;
	cin >> n;
	repi(i, 0, n) {
		cin >> l >> r;
		ans += (r - l + 1);
	}
	wrln(ans);
	return 0;
}

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



int main(){
	int n,s;
	while(cin>>n>>s&&(n||s)){
		int dp[11][11][101]={};
		dp[0][0][0] = 1;
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=10;j++){
				rep(k,s+1){
					for(int l=1;l<=j;l++){
						if(k-(j-1)>=0) dp[i][j][k]+=dp[i-1][j-l][k-(j-1)];
					}
				}
			}
		}
		int ans = 0;
		rep(i,11) ans += dp[n][i][s];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z <<" "<< x <<" "<< y;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n; 
    cin>>n;
    for(int i=0;i<=n;i++)
        if(pow(2,i)<=n&&pow(2,i+1)>n)
        {
            cout<<pow(2,i)<<endl;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int n;
char s[30010];
int dp[4][1010];
int main(){
	scanf("%d %s",&n,s);
	dp[0][0]=1;
	rep(i,0,n){
		int c=s[i]-'0';
		rep(i,0,100)dp[3][i*10+c]|=dp[2][i];		
		rep(i,0,10)dp[2][i*10+c]|=dp[1][i];
		rep(i,0,1)dp[1][i*10+c]|=dp[0][i];
	}
	int ans=0;
	rep(i,0,1000)ans+=dp[3][i];
	printf("%d",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#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 ll long long int

int main(){
    string s;
    cin>>s;
    s='a'+s;
    int cnt=0,ans=0;
    for(int i=1;i<4;i++){
        debug(s);
        if(s[i]=='R'){
            if(s[i]==s[i-1])cnt++;
            else cnt=1;
        }
        else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<"\n";
}


Measured memory_bytes: 3628
import math

if __name__ == '__main__':
    
    while True:
        d,w,h = map(int,input().split())
        if d == 0 and w == 0 and h == 0:
            break
    
        a1 = math.sqrt(d*d + h*h)
        a2 = math.sqrt(d*d + w*w)
        a3 = math.sqrt(h*h + w*w)
        n = int(input())

        for _ in range(n):
            c = int(input())
            if c*2 <= a1 and c*2 <= a2 and c*2 <= a3:
                print("NA")
            else:
                print("OK")



Measured memory_bytes: 5660
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef
import Data.IORef

main :: IO ()
main = do
  s <- getLine :: IO String
  let len = length s
  if any (\i -> take i s ++ drop (len+i-7) s == "keyence") $ [0..7]
    then putStrLn "YES"
    else putStrLn "NO"


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int H, W, i, j, k, l, x, y, bomb=0;
  cin >> H >> W;
  vector<vector<char>> find(H, vector<char>(W));
  for(i=0;i<H;i++)
  {
    for(j=0;j<W;j++)
    {
      cin >> find.at(i).at(j);
    }
  }

  for(i=0;i<H;i++)
  {
    for(j=0;j<W;j++)
    {
      if(find[i][j]!='#')
      {
        bomb=0;
        for(k=0;k<3;k++)
        {
          for(l=0;l<3;l++)
          {
            x=i+k-1,y=j+l-1;
            if(x>=0&&x<H&&y>=0&&y<W&&find[x][y]=='#')
             bomb++;
          }
        }
        find[i][j]='0' + bomb;
      }
      cout << find.at(i).at(j);
      if(j==W-1)
        cout << endl;
    }
  }
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = []
for _ in range(0,n):
    hh = int(input())
    h.append(hh)
h.sort()
ans = float("inf")
for i in range(0,n-k+1):
    ans = min(ans,h[i+k-1]-h[i])
print(ans)


Measured memory_bytes: 7384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    if (i * j == N)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
using namespace std;
const int mo=1e9+7,sz=1e5;
main()
{
    long long a,b;
    scanf("%lld%lld",&a,&b);
    long long x[sz],y[sz];
    long long xl=0,yl=0;

    for(int i=0;i<a;i++)
    {
        scanf("%lld",x+i);
        if(i!=0)
        {
            xl+=(x[i]-x[i-1])*(a-i)*i;
            xl%=mo;
        }
        cerr<<xl<<endl;
    }
    
    for(int i=0;i<b;i++)
    {
        scanf("%lld",y+i);
        // cerr<<i<<": "<<x[i]<<' '<<y[i}endl;
        if(i!=0)
        {
            yl+=(y[i]-y[i-1])*(b-i)*i;
            yl%=mo;
        }
        cerr<<yl<<endl;
    }
    long long res=xl*yl%mo;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main()
{
	int n;
	int i;
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		
		int ans[16]={0};
		
		for(i=0;i<n;i++)
		{
			int a;
			cin >> a ;
			ans[a]++;
		}
		
		for(i=0;i<10;i++)
		{
			if(ans[i]==0)
			{
				cout << "-" << endl;
			}
			else
			{
				for(int j=0;j<ans[i];j++)
				{
					cout << "*" ;
				}
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
    int H , V , K;
    string s;
    cin >> H >> V >> K;
    int a[6] = {0};

    for (int i = 0; i < H; i ++){
        cin >> s;
        int code = 0;
        for (int j = 0; j < V; j ++){
            if (s[j] == '#'){
                code |= 1 << j;
            }
        }
        a[i] = code;
    }

    int ans = 0;
    for (int i = 0; i < (1 << H); i ++){
        int b[6] = {0};
        for (int j = 0; j < H; j ++){
            if ((1 << j) & i){
                b[j] = 0;
            }
            else{
                b[j] = a[j];
            }
        }

        for (int k = 0; k < (1 << V); k ++){
            int c[6] = {0};
            memcpy(c, b, sizeof(b));
            int t = ((1 << V) - 1) ^ k;

            for (int j = 0; j < H; j ++){
                c[j] &= t;
            }
            int cnt = 0;
            for (int j = 0; j < H; j ++){
                while (c[j] > 0){
                    if (c[j] & 1 > 0){
                        cnt ++;
                    }
                    c[j] >>= 1;
                }
            }
            if (cnt == K){
                ans ++;
            }
        }
    }
    cout << ans;
    system("pause");
    return 0;
}

Measured memory_bytes: 3608
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s1: String,
        s2: String,
    }
    // annotate for rust-analyzer
    let s1: Vec<char> = s1.chars().collect_vec();
    let s2: Vec<char> = s2.chars().collect_vec();

    let mut i = 0;
    let mut ans = 0;
    while i < s1.len() {
        if s1[i] != s2[i] {
            ans += 1;
        }
        i += 1;
    }

    println!("{}", ans);
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};




int main()
{
    ll n,k,c;
    string s;
    cin>>n>>k>>c>>s;
    vector<ll> mae, ato, ans;
    for (int i = 0; i < n; i++)
    {
        if(s[i]=='x') continue;
        mae.push_back(i);
        if(mae.size()>=k) break;
        i+=c;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if(s[i]=='x') continue;
        ato.push_back(i);
        if(ato.size()>=k) break;
        i-=c;
    }
    reverse(all(ato));
    
    
    for (int i = 0; i < k; i++)
    {
        if(mae[i]==ato[i]) ans.push_back(mae[i]);
        //cout<<mae[i]<<"\t"<<ato[i]<<endl;
    }
    for (int i = 0; i < ans.size(); i++)
    {
        cout<<ans[i]+1<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 6644
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
char s[maxn];
int ans[maxn];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	int f=0;
	FOR(i,1,n){
		if(s[i]=='L'){
			if(s[i-1]=='R')f=i-1;
			if((i-f)%2==0)ans[f]++;
			else ans[f+1]++;
		}
	}
	FORD(i,n,1){
		if(s[i]=='R'){
			if(s[i+1]=='L')f=i+1;
			if((f-i)%2==0)ans[f]++;
			else ans[f-1]++;
		}
	}
	FOR(i,1,n)printf("%d ",ans[i]);
}

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

int main(){
        int h,w;
        while(1){
                scanf("%d %d",&h,&w);
                if(!h) break;
                for(int i=0;i<h;i++){
                        for(int j=0;j<w;j++){
                                if((i%2==0 && j%2==0) || (i%2==1 && j%2==1)){
                                        printf("#");
                                }else{
                                        printf(".");
                                }
                        }
                        printf("\n");
                }
                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string s;
    cin >> s;
    int year = stoi(s.substr(0, 4));
    int month = stoi(s.substr(5, 2));
    int day = stoi(s.substr(8, 2));
    if (year <= 2018 || (year == 2019 && month <= 4)) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" <<endl;
    }

    return 0;
}




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

int main()
{
    string s;
    cin>>s;
    long long n=0;
    int l=s.length();
    for(int i=0;i<l/2;i++)
        if(s[i]!=s[l-i-1]) n++;
    cout<<n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  char a;
  cin >> a;
  if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') dump("vowel");
  else dump("consonant");
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        String s = fs.next();
        long r=0, b=0, g=0;
        for(char c : s.toCharArray()){
            if(c == 'R') r++;
            else if(c == 'B') b++;
            else g++;
        }
        long total = r*b*g;
        int rgb = (int) 'R' + (int) 'B' + (int) 'G';
        for(int i=0; i<n; ++i){
            char si = s.charAt(i);
            for(int j=i+1; j<n; ++j){
                char sj = s.charAt(j);
                int k = j + (j-i);
                if(k < n){
                    if(((int) si + (int) sj + (int) s.charAt(k)) == rgb)
                        total--;
                }
            }
        }
        System.out.println(total);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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


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


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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int x=0;
    int ans=0;
    rep(i,N){
        if(S[i]=='I') x++;
        else x--;
        ans=max(ans,x);

    }
    cout << ans << endl;
}


Measured memory_bytes: 256