akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  int n;cin >> n;
  while(n--){
    int a,b;cin >> a >> b;
    if(d.left()==a) d.roll('E');
    if(d.right()==a) d.roll('W');
    while(d.top()!=a) d.roll('N');
    while(d.front()!=b) d.roll('R');
    cout << d.right() << endl;
  }
  return 0;
}



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

int main() {
    vector<long> x(11);
    long r,d; cin >> r >> d >> x[0];
    for(int i = 1; i < 11; i ++) {
        x[i] = x[i-1]*r - d;
        cout << x[i] << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long A = sc.nextLong();
		Long B = sc.nextLong();

		Long na1 = 0L;
		Long na2 = 0L;
		
		if ((N % (A+B)) <= A){
			na1 = (N / (A+B)) * A;
			na2 = N % (A+B);
		}else {
			na1 = (N / (A+B)) * A;
			na2 = A;
		}
		
		System.out.println(na1 + na2);
		sc.close();
	}
}

Measured memory_bytes: 21844
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N =  int(sys.stdin.readline())
print(24 + (24 - N))

Measured memory_bytes: 64492
// https://atcoder.jp/contests/abc145/tasks/abc145_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

int X[1000], Y[1000];
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    // vector<int> X(N), Y(N);
    REP(i, N) { cin >> X[i] >> Y[i]; }
    double sum = 0;
    REP(i, N) {
        FOR(j, i + 1, N) { sum += hypot(X[i] - X[j], Y[i] - Y[j]); }
    }
    cout << setprecision(10) << 2.0 * sum / N << endl;

    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int n;
	int tmp1=0, tmp2=0, tmp3=0, tmp4=0;
	int roomInfo[4][3][10] = {};

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> tmp1; cin >> tmp2; cin >> tmp3; cin >> tmp4;
		roomInfo[tmp1-1][tmp2-1][tmp3-1] += tmp4;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << roomInfo[i][j][k];
			}
			cout << endl;
		}
		if (i != 3) cout << "####################" << endl;
	}
	return 0;
}


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

int main() {
	// your code goes here
	ll a,b,n;
	cin>>a>>b>>n;
  	n=min(b-1ll,n);
  	cout<<(((a*n)/b)-(a*(n/b)))<<endl;
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long[] a = new long[5];
        long n = sc.nextLong();
        a[0] = sc.nextLong();
        long min = a[0];
        for(int i=1;i<5;i++){
            a[i] = sc.nextLong();
            if(min>a[i])min=a[i];
        }
        if(min>n){
            System.out.println(5);
            return;
        }
        if(n%min==0){
            System.out.println(n/min + 4);
            return;
        }
        System.out.println(n/min + 5);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int compare_long(const void *a, const void *b) {
	return *(long*)a - *(long*)b;
}

int main() {
	long N, M;
	long a[300001];
	long i, j;
	long ans = 0;
	
	sl(N); sl(M);
	
	if(2*N <= M) {
		ans += N;
		M -= 2*N;
		ans += M/4;
	} else {
		ans = M/2;
	}
	
	pl(ans);
	
	return 0;
}

Measured memory_bytes: 128
'use strict'
function main(inp) {
  inp = inp.trim().split(' ').map(x => x * 1);
  let ans = -1;
  for(let i = 10000; i >= 1; i--){
  	if(Math.floor(i*0.08) ==inp[0] && Math.floor(i*0.1) ==inp[1]){
    	ans = i;
    };
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if (a<b){
        cout << a << ' ';
    }else{
        cout << b << ' ';
    }
    if (a+b>=n){
        cout << a+b-n;
    }else{
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @author takahiro 問題文 √a+√b<√c ですか？<br>
 *     制約 1 ≤ a,b,c ≤ 10^9 入力は全て整数である。
 */
public class Main {

  public static void main(final String[] args) throws IOException {
    try (final Scanner scanner = new Scanner(System.in)) {
      final Input input = new Input(scanner);
      execute(input);
    }
  }

  private static void execute(final Input input) {
    Result.toResult(calculate(input)).answer();
  }

  private static final BigDecimal FOUR = new BigDecimal("4");
  /**
   * √a+√b < √c <br>
   * = a + 2√ab + b < c <br>
   * = 2√ab < c - a - b <br>
   * = 2√ab < minused <br>
   * = 4 * a * b < minused^2
   */
  private static boolean calculate(final Input input) {
    final long a = input.getA();
    final long b = input.getB();
    final long c = input.getC();
    final long minused = c - a - b;
    if (minused < 0) {
      return false;
    }
    return 4 * a * b < minused * minused;
  }

  private static class Input {

    private Input(final Scanner scanner) {
      a = scanner.nextInt();
      b = scanner.nextInt();
      c = scanner.nextInt();
    }

    public int getA() {
      return a;
    }

    public int getB() {
      return b;
    }

    public int getC() {
      return c;
    }

    private final int a, b, c;
  }

  private enum Result {
    Yes,
    No;

    private static Result toResult(final boolean calculate) {
      return calculate ? Yes : No;
    }

    private void answer() {
      System.out.println(this.toString());
    }
  }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main(){
  int cnt=0,ans=0;
  string s;
  cin >> s;
  for(size_t i=0;i<s.size();i++){
    if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'){
      cnt++;
    }else{
      cnt=0;
    }
    ans=max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


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

N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
    exit()

diffX = [X[i + 1] - X[i] for i in range(len(X) - 1)]
diffX.sort()

ans = X[-1] - X[0]
for i in range(N - 1):
    ans -= diffX[-(i + 1)]

print(ans)


Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
int main()
{
        string SA, SB, SC;
        cin >> SA >> SB >> SC;
        int p = 0;
        int ap = 0; int al = SA.length();
        int bp = 0; int bl = SB.length();
        int cp = 0; int cl = SC.length();
        while (1) {
                if (p == 0) {
                        if (ap == al) {
                                cout << "A" << endl;
                                break;
                        }
                        char tmp = SA[ap];
                        ap++;
                        if (tmp == 'a') {
                                continue;
                        }
                        else if (tmp == 'b') {
                                p = 1;
                        }
                        else {
                                p = 2;
                        }
                }
                else if (p == 1) {
                        if (bp == bl) {
                                cout << "B" << endl;
                                break;
                        }
                        char tmp = SB[bp];
                        bp++;
                        if (tmp == 'a') {
                                p = 0;
                        }
                        else if (tmp == 'b') {
                                continue;
                        }
                        else {
                                p = 2;
                        }
                }
                else {
                        if (cp == cl) {
                                cout << "C" << endl;
                                break;
                        }
                        char tmp = SC[cp];
                        cp++;
                        if (tmp == 'a') {
                                p = 0;
                        }
                        else if (tmp == 'b') {
                                p = 1;
                        }
                        else {
                                continue;
                        }
                }
        }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,n;
	n=0;
	scanf("%d %d", &a,&b);
	if(a>1) n=n+(a*(a-1)/2);
	if(b>1) n=n+(b*(b-1)/2);
	printf("%d", n);
	return 0;
}

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

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> a(n);
        int sum = 0;
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
            sum += a[i];
        }
        int ave = sum / n, ans = 0;
        for(int i = 0 ; i < n ; i++){
            if(a[i] <= ave){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
local n, a, b = io.read("*n", "*n", "*n")
local bmax = n + 1 - a
local bmin = math.ceil(n / a)
if n < a or b < bmin or bmax < b then
  print(-1)
else
  local t = {}
  for i = 1, a do
    t[i] = n - a + i
  end
  local curmax = n - a
  local rem = n + 1 - a - b
  while 0 < rem do
    if a - 1 <= rem then
      for i = 1, a do
        table.insert(t, curmax - a + i)
      end
      curmax = curmax - a
      rem = rem - a + 1
    else
      for i = 1, rem + 1 do
        table.insert(t, curmax - rem - 1 + i)
      end
      curmax = curmax - rem - 1
      rem = 0
    end
  end
  for i = curmax, 1, -1 do
    table.insert(t, i)
  end
  print(table.concat(t, " "))
end


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

int main(){
	int a,b;
  cin>>a>>b;
  while(a!=0 && b!=0){
    rep(i,a){
      rep(j,b){
        if(i==0 || i==a-1){
        cout << "#";
        }
        else{
          if (j==0 || j==b-1){
            cout << "#";
          }
          else {cout << ".";}
        }
      }
      cout << endl;
    }
    cout << endl;
    cin>>a>>b;
  }
	
}


Measured memory_bytes: 3096
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b>=c*2:
    ans = c*2*min(x,y)
    if x>y:
        if a<c*2:
            ans+=(x-y)*a
        else:
            ans+=c*2*(x-y)
    else:
        if b<c*2:
            ans+=(y-x)*b
        else:
            ans+=c*2*(y-x)
    print(ans)
else:
    print(a*x+b*y)

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long all = 1;
        for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextLong();
          if(a[i]== 0){
            System.out.println(0);
            return;
          } 

		}
      


		for(int i = 0 ; i < n ; i++) {
          if(1000000000000000000L / all < a[i]) {
            System.out.println(-1);
			return;
          }
			all *= a[i];
          if(all > 1000000000000000000L) {
			System.out.println(-1);
			return;
		}
		}

			System.out.println(all);


	}

}




Measured memory_bytes: 61252
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  int n, i;
  char units[3][4] = {"bon", "pon", "hon"};
  scanf("%d", &n);

  switch (n % 10)
  {
  case 3:
    i = 0;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    i = 1;
    break;
  default:
    i = 2;
    break;
  }

  printf("%s\n", units[i]);
  return 0;
}

Measured memory_bytes: 1656
N = int(input())
x = list(map(int, input().split()))
flag = True
count = 0

while flag:
    for i in range(N):
        if x[i] % 2 == 0:
            x[i] = x[i] / 2
        else:
            flag = False
            break
    else:
        count += 1

print(count)

    

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

int  main()
{
    unsigned long long  n,x,t ; 
    cin>>n>>x>>t; 

    long long int ratio = n/x; 

    if(n%x !=0)
    {
     ratio += 1 ; 
    }

    cout<<t*(ratio);


}

Measured memory_bytes: 3580
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

const inf = 10000

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 10000)

	H, W := getInt(), getInt()
	dist := make([][]int, H)
	a := make([]string, H)
	for i := 0; i < H; i++ {
		a[i] = getString()
		dist[i] = make([]int, W)
	}

	for y := 0; y < H; y++ {
		t := inf
		for x := 0; x < W; x++ {
			if a[y][x] == '#' {
				t = 0
			}
			dist[y][x] = t
			t++
		}
		t = dist[y][W-1]
		for x := W - 1; x >= 0; x-- {
			if a[y][x] == '#' {
				t = 0
			}
			dist[y][x] = min(dist[y][x], t)
			t++
		}
	}

	// for y := 0; y < H; y++ {
	// 	out(dist[y])
	// }
	// out("----")

	for x := 0; x < W; x++ {
		t := dist[0][x]
		for y := 0; y < H; y++ {
			if a[y][x] == '#' {
				t = 0
			}
			t = min(dist[y][x], t)
			dist[y][x] = t
			t++
		}
		t = dist[H-1][x]
		for y := H - 1; y >= 0; y-- {
			if a[y][x] == '#' {
				t = 0
			}
			t = min(dist[y][x], t)
			dist[y][x] = t
			t++
		}
	}

	// for y := 0; y < H; y++ {
	// 	out(dist[y])
	// }
	ans := 0
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			ans = max(ans, dist[y][x])
		}
	}
	out(ans)
}


Measured memory_bytes: 10112
/**
 * Author: Behradm
 * Created: 09-05-2020 17:33:41
 * In the Name of God
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout.tie(0);
	cout.precision(6);
	int r;
	cin >> r;
	cout << 3 * r * r << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main()
{
    int i,j;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}

Measured memory_bytes: 924
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] capacityBox = new int[n];
        int[] amountEach = new int[n];
        boolean isPossible = true;
        Arrays.fill(amountEach,0);
        for (int i=0; i<n; i++){
            capacityBox[i] = scanner.nextInt();
        }
        int numberInstructions = scanner.nextInt();
        for (int i=0 ; i< numberInstructions; i++){
           int t = scanner.nextInt();
           int x = scanner.nextInt();
           int d = scanner.nextInt();

           if (t == 1){
               amountEach[x-1] += d;
           }else {
               amountEach[x-1] -= d;
           }
           if (amountEach[x-1] > capacityBox[x-1] || amountEach[x-1] <0){
               isPossible = false;
               System.out.println(x);
               break;
           }

        }
        if(isPossible){
            System.out.println(0);
        }
    }
}



Measured memory_bytes: 99512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll n;
    cin >> n;
    string ans = "";
    while(n) {
        ans += 'a' + (n - 1) % 26;
        n = (n - 1) / 26;
    }
    reverse(all(ans));
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3588
package main
import "fmt"
func main() {
  var n,r,b int
  var s string
  fmt.Scan(&n)
  fmt.Scan(&s)
  for i:=0;i<n;i++ {
    if s[i:i+1] == "R" {
      r++
    } else {
      b++
    }
  }
  if r > b {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

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

using namespace std;

using ll = long long;

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

int main()
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(k >= e - a)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
string s,t;
cin>>s>>t;
int ns=size(s);
int nt=size(t);
int ans=INT_MAX;
for(int i=0;i<ns-nt+1;i++)
{
	string chk=s.substr(i,nt);
	int cnt=0;
	for(int i=0;i<nt;i++)
	{
		if(t[i]==chk[i])
		cnt++;
	}
	ans=min(ans,nt-cnt);
}
cout<<ans;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3648
def relu(a, b):
    if(a <= b):
        return 0
    else:
        return a - b

def main():
    args = input().rstrip().split(' ')
    A, B, C, K = int(args[0]),int(args[1]),int(args[2]),int(args[3])
    
    if(A >= K):
        print(K)
    else:
        print(A - relu(K, A+B))
    
if __name__ == "__main__":
    main()

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

int main () {
  int N;
  cin >> N;
  
  if (N % 1110 <= 9) {
    cout << "Yes" << endl;
  }
  
  else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
#define pii pair<int , int>
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000;
const int mod = 998244353;
const int MAX = 1000 * 1000 + 47;
using namespace std;
vector<pair<int , int> > g[200005];
int izol = 0;
int sz[200005];
int p[200005];
int ans[200005];
int color[200005];
int find(int u)
{
	return p[u] = u == p[u] ? u : find(p[u]);
}
void unite(int u , int v)
{
	u = find(u) , v = find(v);
	if(u == v)
		return;
	izol -= sz[u] == 1;
	izol -= sz[v] == 1;
	sz[u] += sz[v];
	p[v] = u;
}
map<int , vector<int> > byD;
int main()
{
	memset(color , -1 , sizeof color);
	ios_base::sync_with_stdio(0);
	int n ,m;
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		sz[i] = 1 , p[i] = i;
	for(int i = 0; i < n; i++)
	{
		int d;
		cin >> d;
		byD[d].pb(i);
	}
	for(int i = 0; i < m; i++)
	{
		int u , v;
		cin >> u >> v;
		u--;v--;
		g[u].pb({v , i});
		g[v].pb({u , i});
	}
	for(auto x : byD)
	{
		for(auto y : x.y)
		{
			izol++;
			bool allBlack = true;
			for(auto w : g[y])
			{
				allBlack &= color[w.x] != 0;
				if(color[w.x] != -1)
				{
					ans[w.y] = x.x;
					unite(y , w.x);
				}
			}
			color[y] = !allBlack;
		}
		if(izol)
		{
			cout << -1;
			return 0;
		}
	}
	for(int i = 0; i < n; i++)
		cout << (color[i] == 0 ? 'B' : 'W');
	cout << endl;
	for(int i = 0; i < m; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 25856
import math

N = int(input())
P = input().split()
Q = input().split()
P = list(map(int, P))
Q = list(map(int, Q))

a = 0

for i, p in enumerate(P, start=1):
  for j in range(1, p):
    if not j in P[:i-1]:
    	a += math.factorial(N-i)
    
b = 0

for i, q in enumerate(Q, start=1):
  for j in range(1, q):
    if not j in Q[:i-1]:
      b	+= math.factorial(N-i)

sum = a - b
if sum < 0:
  sum *= -1

print(sum)

Measured memory_bytes: 3064
import Control.Monad
import Data.List

solve l' r' [] = [l',r']
solve l' r' ((l:r:s):lrss) = solve l'' r'' lrss
    where
        l'' = if l' <= l then l else l'
        r'' = if r' >= r then r else r'

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    lr <- replicateM m (map read . words <$> getLine) :: IO [[Int]]
    let [l,r] = solve 1 n lr
    print $ if (r-l) >= 0 then r-l+1 else 0



Measured memory_bytes: 127576
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
	int key;
	struct Node* parent;
	int degree;
	int depth;
	int height;
	char type[15];
	
	int * child_list;
};
typedef struct Node * NodePointer;


void serach_depth (NodePointer ,int  ,NodePointer[]);

int main (){
	int n;
	scanf("%d\n",&n);
	
	//setting part
	NodePointer array [n];
	for (int i = 0; i < n;i++)
	{
		array[i] = (NodePointer) malloc (sizeof(struct Node));
		array[i]->parent = NULL;
		array[i]->degree = 0;
		strcpy(array[i]->type,"internal node");
	}
	
	//input part
	for (int i = 0; i < n;i++)
	{
		int id;
		scanf("%d ",&id);
		array[id]->key = id;
		int child_num;
		scanf("%d" ,&child_num);
		array[id]->child_list = (int *) malloc (child_num * sizeof(int));
		
		if ( child_num == 0){
			strcpy(array[id]->type ,"leaf");
		}else {
			for (int j = 0; j < child_num; j++){
				int child_id;
				scanf(" %d" ,&child_id);
				array[id]->child_list[j] = child_id;
				array[child_id]->parent = array[id];
				array[id]->degree++;
			}
		}

	}
	
	//search part
		for (int i = 0; i < n;i++)
	{
		if(array[i]->parent == NULL) {
			strcpy(array[i]->type ,"root");
			serach_depth(array[i],0 ,array); break;
		}
	}
	
	//print part
	for (int i = 0; i < n ;i++){
		printf("node %d: ",i);
		if (array[i] -> parent != NULL){
		printf("parent = %d, ",array[i]->parent->key);
		}else {
			printf("parent = -1, ");
		}
		printf("depth = %d, %s, [",array[i]->depth,array[i]->type );
		for ( int j = 0; j < array[i]->degree; j++){
			printf("%d" ,array[i]->child_list[j]);
			if ( j + 1 != array[i]->degree){printf(", ");}
		}
		printf("]\n");
	}
	
	//printf("%d" ,array[6]->child_list[3]);
	
	return 0;
}

void serach_depth (NodePointer tag,int dep , NodePointer array[]){
	tag->depth = dep;
	if ( tag->degree == 0 ){tag->height = 0; return;}
	for ( int j = 0; j < tag->degree ; j++){
		serach_depth(array [ (tag->child_list[j]) ] , dep + 1 ,array);
	}
}



Measured memory_bytes: 12256
package main

import (
	"fmt"
)

func main() {
	var A, B, ans int
	fmt.Scan(&A, &B)

	if B == 1 {
		fmt.Println(0)
		return
	}
	sum := 1
	for {
		ans++
		sum = sum - 1 + A
		if sum >= B {
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

typedef long long int ll;

std::vector<ll> enum_div(ll n);
long long comb(int n, int r);
bool IsPrime(int num);
bool dp[110][10010];
class UnionFind;
using Graph = vector<vector<int>>;

//自作関数一覧---------------------------
ll gcd(ll a, ll b); //最小公倍数の導出
ll lcm(ll x, ll y); //最大公約数の導出
ll bur(ll N, ll X); //??
//---------------------------------------

//UF木
class UnionFind {
public:
	//親
	vector<int> Parent;

	//初期状態
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//サイズ確認
	int size(int A) {
		return -Parent[root(A)];
	}

	int connect(int A, int B) {
		//root同氏をくっつける
		A = root(A);
		B = root(B);

		//結合済み
		if (A == B) {
			return false;
		}
		//大きいほうに小さいほうをくっつける
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズ更新
		Parent[A] += Parent[B];
		//Bの親をAに
		Parent[B] = A;

		return true;
	}

};

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;


	string S, T;
	char fi[50], fv[50];
	char board[4][4];
	bool start = false;
	ll left = 0, right = 0;
	ll all = 0;
	
	cin >> N;
	vector < ll > bow(N);
	rep(i, 0, N) {
		cin >> bow[i];
	}

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

	rep(k, 0, N - 2) {
		rep(j, k+1, N-1) {
			rep(i, j+1, N) {

				if (bow[k] + bow[j] > bow[i]) {
					all++;
				}
				else {
					break;
				}

				//cout << k << j << i << endl;
			}
		}
	}

	cout << all << endl;

	return 0;
}


std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	vector<ll> res;
	for (int i = 1; i*i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}








bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}



//combination
long long comb(int n, int r) {
	std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v[n][r];
}


ll gcd(ll a, ll b) {

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y / b*x;
}

// 最大公約数を求める関数
ll lcm(ll x, ll y)
{
	if (x == 0 || y == 0)  // 引数チェック
	{
		//fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	return (x * y / gcd(x, y));
}

ll bur(ll N, ll X) {
	ll pan = 1;
	ll pat = 1;
	ll burg = 0;



	if (X > burg) {
		if (N == 0)
			return pat;


		burg += pan;
		burg += bur(N - 1, X);
		burg += pat;
		burg += bur(N - 1, X);
		burg += pan;


	}

	return burg;

}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main(){
int N,K; cin >> N >> K;
set<int> s;
vector<int> A(N);
vector<int> B(N,0);
rep(i,N) cin >> A[i];
rep(i,N) {
	B[A[i]-1]++;
	s.insert(A[i]-1);
}
vector<pair<int, int>> c(N);//配列の宣言
for(int i = 0; i < N ; i++){
  int a,b;
  a = i;
  b = B[i];
  c[i] = make_pair(b,a);//配列型のpairに代入
}
  sort(c.begin(),c.end());//pair.firstを小さい順にsort




if (s.size() <= K){
	cout << 0 << endl;
}
else {
	int sum = 0;
	int i = 0;
	while(s.size() != K){
		if(s.count(c[i].second)){
			sum += c[i].first;
			s.erase(c[i].second);
		}
		i++;
	}
	cout << sum << endl;
}
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
set<int> blok[100010];
struct UnionFind {
    vector < int > par;
    vector < int > siz;
    
    UnionFind(int n): par(n), siz(n, 1) {
	for(int i = 0; i < n; i++) par[i] = i;
    }
    int root(int x){
	if(par[x] == x) return x;
	else return par[x] = root(par[x]);
    }
    int size(int x){ return siz[root(x)];}
    bool same(int x, int y){ return root(x) == root(y); }//判定
    bool unite(int x, int y){//連結
	if((x=root(x))==(y=root(y))) return false;
	if( siz[y] > siz[x] ) swap(x,y);
	siz[x] += siz[y];
	par[y] = x;
	return true;
    }
};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k;
    cin >>n>>m>>k;
    UnionFind uf(n+1);
    int ans[100010]={};
    for(int i=0;i<m;i++){
	int a,b;
	cin >>a>>b;
	uf.unite(a,b);
	blok[a].insert(b);
	blok[b].insert(a);
    }
    for(int i=0;i<k;i++){
	int c,d;
	cin >>c>>d;
	if(!uf.same(c,d)) ans[c]++,ans[d]++;
	blok[c].insert(d);
	blok[d].insert(c);
    }
    for(int i=1;i<=n;i++){
	ans[i]+=uf.size(i)-blok[i].size()-1;
    }
    cout <<ans[1];
    for(int i=2;i<=n;i++)cout <<' '<<ans[i];
    cout <<'\n';
    return (0);
}


Measured memory_bytes: 25472
#include<stdio.h>
main(){
  int h,w,i,j;
  while(1){
    scanf("%d%d",&h,&w);
    if(h==0 && w==0)
      break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++)
	printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

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

using vertex =int;
using weight = int;

struct edge{
    vertex u; // leaving vertex
    vertex v; // entering vertex
};

struct undigraph{ // adjacency-list representation
    int n;
    vector<vector< vertex >> Adj;
    void add_edge(edge Edge){
        Adj.at(Edge.u).push_back(Edge.v);
        Adj.at(Edge.v).push_back(Edge.u);
    };
    undigraph(int _n){
        this->Adj.resize(_n);
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    vector<long> h(n);
    for(auto &e:h) {
        cin >> e;
    }

    edge E;
    undigraph G(n);
    for(auto i=0;i<m;i++){
        cin >> E.u >> E.v;
        E.u--;
        E.v--;
        G.add_edge(E);
    }
    
    int ans = 0;
    for(auto i=0;i<n;i++){
        bool flag = 1;
        auto itr = G.Adj[i].begin();
        auto end = G.Adj[i].end();
        for(;itr!=end;itr++){
            if(h.at(i) <= h.at(*itr)){
                flag = 0;
            }
        }
        ans += flag;
    }
    cout << ans << endl;
}

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

long long gcd(long long a, long long b) {return b ? gcd(b, a % b) : abs(a);}
long long lcm(long long a, long long b) {return abs(a / gcd(a, b) * b);}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int res = a[0];
  for (int i = 1; i < n; i++) res = gcd(res, a[i]);
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 640
use proconio::input;
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

fn main() {
    input! {
        l: usize,
        r: usize,
        d: usize  
    }

    let mut ans = r/d - l/d;
    if l%d == 0 {
        ans += 1;
    }

    println!("{}",ans)
}


Measured memory_bytes: 2080
N = int(input())
A = []
B = []
Sa = 0
Sb = 0
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,i])
    B.append([b,i])
    Sa += a
    Sb += b
C = sorted(A+B)
ind = []
ans = 0
for i in range(N):
    ind.append(C[i][1])
    ans += C[i][0]
ind = set(ind)
if len(ind) == N:
    if C[N-1][1] != C[N][1]:
        ans += C[N][0]-C[N-1][0]
    else:
        ans += min(C[N][0]-C[N-2][0],C[N+1][0]-C[N-1][0])
ans = min(Sa,Sb,ans)
print(ans)

Measured memory_bytes: 42220
n = int(input())
s = list(map(str, input()))

alphabet = [
    "A", "B", "C", "D", "E", "F", "G", "H",
    "I", "J", "K", "L", "M", "N", "O", "P",
    "Q", "R", "S", "T", "U", "V", "W", "X",
    "Y", "Z"
]

for i in range(len(s)):
    x = alphabet.index(s[i])
    s[i] = alphabet[
        (x + n) % 26
    ]

print("".join(s))



Measured memory_bytes: 3064
# from math import gcd # ダメ
def gcd(a,b): 
    while b!=0:
        a,b=b,a%b
    return a

n, X = map(int, input().split())
x = list(map(int, input().split()))

ans = abs(x[0]-X)
for xi in x:
    ans = gcd(ans, abs(xi-X))
    
print(ans)

Measured memory_bytes: 14252
//スキャナークラスをインポート
import java.util.Scanner;


/**
 * 割り算の結果と余りと小数点を出力
 */
 
 
class Main{
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
			
		System.out.print( a / b +" " );
		System.out.print( a % b + " ");
		//intからdoubleにキャスト
		//String.formatで
		System.out.println(String.format("%.5f", (double)a/(double)b));

	}
}


Measured memory_bytes: 26480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
 
        String[] inputList = br.readLine().split(" ");
        int r = Integer.parseInt(inputList[0]);
        int c = Integer.parseInt(inputList[1]);
        int[][] list = new int[r + 1][c + 1];
        int i, j, num, sum;
        for (i = 0; i < r; i++) {
            sum = 0;
            String[] hoge = br.readLine().split(" ");
            for (j = 0; j < c; j++) {
                num = Integer.parseInt(hoge[j]);
                list[i][j] = Integer.parseInt(hoge[j]);
                sum = sum + num;
            }
            list[i][c] = sum;
        }
 
        for (i = 0; i < c + 1; i++) {
            sum = 0;
            for (j = 0; j < r + 1; j++) {
                sum = sum + list[j][i];
            }
            list[r][i] = sum;
        }
 
        String output;
        for (i = 0; i < r + 1; i++) {
            output = "";
            for (j = 0; j < c + 1; j++) {
                output = output + list[i][j] + " ";
            }
            System.out.println(output.substring(0, output.length() - 1));
        }
    }
}

Measured memory_bytes: 41296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_KW_LEN 16
#define CMND_LEN 8

#define TRUE 1
#define FALSE 0

typedef struct _node {
  int endFlg;
  struct _node *A;
  struct _node *C;
  struct _node *G;
  struct _node *T;
} node_t;

node_t *root = NULL;

node_t* createNewNode() {
  node_t *new;

  new = (node_t*)malloc(sizeof(node_t));
  if (new == NULL)
    exit(EXIT_FAILURE);
  new->A = NULL;
  new->C = NULL;
  new->G = NULL;
  new->T = NULL;
  new->endFlg = FALSE;
  return new;
}

void insertTree(node_t *node, char key[]) {
  int i;
  char c, tail[MAX_KW_LEN];

  // first time
  if (node == NULL) {
    root = createNewNode();
    if (key[0] == '\0')
      root->endFlg = TRUE;
  }

  c = key[0];
  for (i = 0; i < strlen(key); i++)
    tail[i] = key[i + 1];
  switch (c) {
  case 'A':
    if (node->A == NULL)
      node->A = createNewNode();
    if (tail[0] == '\0'){
      node->A->endFlg = TRUE;
      break;
    }
    insertTree(node->A, tail);
    break;
  case 'C':
    if (node->C == NULL)
      node->C = createNewNode();
    if (tail[0] == '\0'){
      node->C->endFlg = TRUE;
      break;
    }
    insertTree(node->C, tail);
    break;
  case 'G':
    if (node->G == NULL)
      node->G = createNewNode();
    if (tail[0] == '\0'){
      node->G->endFlg = TRUE;
      break;
    }
    insertTree(node->G, tail);
    break;
  case 'T':
    if (node->T == NULL)
      node->T = createNewNode();
    if (tail[0] == '\0'){
      node->T->endFlg = TRUE;
      break;
    }
    insertTree(node->T, tail);
    break;
  default:
    printf("Not defining character!");
    break;
  }
}

int findTree(node_t *node, char key[]) {
  int i;
  char c, tail[MAX_KW_LEN];
  node_t *child;

  if (!strcmp(key, "") && node->endFlg == TRUE)
    return TRUE;
  else if (!strcmp(key, "") && node->endFlg == FALSE)
    return FALSE;
  else {
    c = key[0];
    for (i = 0; i < strlen(key); i++)
      tail[i] = key[i + 1];
    switch (c) {
    case 'A':
      child = node->A;
      break;
    case 'C':
      child = node->C;
      break;
    case 'G':
      child = node->G;
      break;
    case 'T':
      child = node->T;
      break;
    default:
      printf("Not defining character!");
      break;
    }
    if (child == NULL)
      return FALSE;
    else
      return findTree(child, tail);
  }
}

void freeTree(node_t *node) {
  if (node == NULL)
    return;
  freeTree(node->A);
  freeTree(node->C);
  freeTree(node->G);
  freeTree(node->T);
  free(node);
}

int main(void) {
  int i, n;
  char word[MAX_KW_LEN], command[CMND_LEN];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %s", command, word);
    if (!strcmp(command, "insert")) {
      insertTree(&root, word);
    }
    else if (!strcmp(command, "find")) {
      if ((findTree(&root, word)) == TRUE)
  	printf("yes\n");
      else
  	printf("no\n");
    }
    else
      printf("Not available command!");
  }
  freeTree(root);

  return 0;
}

Measured memory_bytes: 16892
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  if (N % 10 == 9 or N / 10 == 9) puts("Yes"); else puts("No");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N,K;cin>>N>>K;
    vector<int>A(N,0);
    REP(i,N)cin>>A[i];
    sort(A.begin(),A.end());
    int ans=INF;
    for(int i=0;i<=N-K;i++){
        ans=min(ans,A[i+K-1]-A[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <float.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j, k, l, m, n;
	long int x;
	
	scanf("%ld", &x);
	/*
	if(x >= 20000) {
		printf("1\n");
		return 0;
	}
	*/
	for(i = 0; i <= (x / 100); i++) {
		if( (i * 100) > x) {
			break;
		}
		for(j = 0; j <= (x / 101); j++) {
			if( (i * 100 + j * 101) > x) {
				break;
			}
			for(k = 0; k <= (x / 102); k++) {
				if( (i * 100 + j * 101 + k * 102) > x) {
					break;
				}
				for(l = 0; l <= (x / 103); l++) {
					if( (i * 100 + j * 101 + k * 102 + l * 103) > x) {
						break;
					}
					for(m = 0; m <= (x / 104); m++) {
						if( (i * 100 + j * 101 + k * 102 + l * 103 + m * 104) > x) {
							break;
						}
						if( (x - i * 100 - j * 101 - k * 102 - l * 103 - m * 104) % 105 == 0) {
							printf("1\n");
							//printf("%ld %ld %ld %ld %ld %ld\n", x, i, j, k, l, m);
							return 0;
						}
					}
				}
			}
		}
	}
	
	printf("0\n");
	
	return 0;
}


Measured memory_bytes: 128
using System;

class Practice
{
    public static void Main()
    {
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int h = int.Parse(str[0]);
            int w = int.Parse(str[1]);
            if (h == 0 && w == 0) break;
            for (int i = 0; i < h; ++i)
            {
                for (int j = 0; j < w; ++j)
                {
                    Console.Write('#');
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        int n = 0;
        long t = 0;
        long[] ts = null;
        try (BufferedReader br =
                     new BufferedReader(new InputStreamReader(System.in))) {
            String[] elems = br.readLine().split(" ");
            n = Integer.parseInt(elems[0]);
            t = Long.parseLong(elems[1]);
            ts = new long[n];
            elems = br.readLine().split(" ");
            for (int i = 0; i < n; i++) {
                ts[i] = Long.parseLong(elems[i]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        long sum = 0;
        long next = 0;
        long current = 0;
        for (int i = 1; i < n; i++) {
            if (current + t < ts[i]) {
                sum += (current + t) - ts[i];
                current = ts[i];
            }
            else {
                current = ts[i];
            }
        }
        System.out.println(sum + (t + ts[ts.length-1]));
    }
}


Measured memory_bytes: 46036
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){
int n, m,a,b,ans=0;
vector<int> l,r;
cin>>n>>m;
if(n<=10)ans=m+100*(10-n);
  else ans=m;
cout<<ans<<endl;
return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		int in[500][500];
		rep(i,500)rep(j,500)in[i][j]=inf;
		in[250][250]=0;
		rep(k,n-1){
			int a,b;
			cin>>a>>b;
			bool h=false;
			rep(i,500){
				rep(j,500)if(in[i][j]==a){
					if(b==0)in[i][j-1]=k+1;
					if(b==1)in[i+1][j]=k+1;
					if(b==2)in[i][j+1]=k+1;
					if(b==3)in[i-1][j]=k+1;
					h=true;
					break;
				}
				if(h)break;
			}
		}	
		int a,b;
		rep(j,500){
			bool h=false;
			rep(i,500)if(in[i][j]!=inf){a=j;h=true;break;}
			if(h)break;
		}
		for(int j=499;j>=0;j--){
			bool h=false;
			rep(i,500)if(in[i][j]!=inf){b=j;h=true;break;}
			if(h)break;
		}
		cout<<b-a+1<<" ";
		rep(i,500){
			bool h=false;
			rep(j,500)if(in[i][j]!=inf){a=i;h=true;break;}
			if(h)break;
		}
		for(int i=499;i>=0;i--){
			bool h=false;
			rep(j,500)if(in[i][j]!=inf){b=i;h=true;break;}
			if(h)break;
		}
		cout<<b-a+1<<endl;
		
	}
}

Measured memory_bytes: 2132
#include<stdio.h>
int main()
{

int x,n,c;
double sum,ave;
sum=0;c=0;ave=0;
while(scanf("%d,%d",&x,&n)!=EOF)
{
sum=sum+(x*n);
ave+=n;
c++;
}

ave=ave/c;
ave+=0.5;
printf("%.0lf\n%.0lf\n",sum,ave);
return 0;
}

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

const int MAX_N = 200005;
int64_t as[MAX_N];

int main() {
  int64_t x = 0;
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int64_t val;
    scanf("%lld", &val);
    x ^= val;
    as[i] = val;
  }
  for (int i = 0; i < N; ++i) {
    printf("%lld ", x ^ as[i]);
  }
  printf("\n");
}


Measured memory_bytes: 5376
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
l1 = []
l2 = []
l3 = []
for e in P:
    if e <= A:
        l1.append(e)
    elif A + 1 <= e <= B:
        l2.append(e)
    elif B + 1 <= e:
        l3.append(e)
ans = min(len(l1),len(l2),len(l3))
print(ans)

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

tree_list = [[] for _ in range(N) ]
LRC = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: (x[0], x[1]))
inf = float('inf')
dp = [inf] * N
dp[0] = 0
flag = False
if LRC[0][0] != 1:
    print(-1) 
else:
    for l, r, c in LRC:
        l = l -1
        r = r -1
        '''
        if dp[l] == 1000000000000:
            flag = True
            break
        '''
        if dp[r] > dp[l] + c:
            for i in reversed(range(l+1,r+1)):
                if dp[i] > dp[l] + c:
                    dp[i] = dp[l] + c
                else:
                    break 
    if dp[N-1] < inf:
        print(dp[N-1])
    else:
        print(-1)
        

Measured memory_bytes: 116512
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	rep (i, 0, n) {
		cin >> a[i];
	}
	sort(all(a));
	ll s = 0;
	rep (i, 0, n) {
		s += a[i];
		if (s > x) {
			cout << i;
			return 0;
		}
	}
	if (s == x) {
		cout << n;
	} else {
		cout << n - 1;
	}
}


Measured memory_bytes: 256