akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define BUF (1000)
#define ll long long 
#define MOD (1000000007)
#define MAX (210000)

long long fac[MAX], finv[MAX], inv[MAX];
ll n, k;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(void){
	COMinit();
	cin >> n >> k;
	ll ans = 0;
	for (int i = 0; i <= k; i++)
	{
		if(n==i) break;
		ll tmp = 1;
		tmp = COM(n,i);
		tmp %= MOD;
		tmp *= COM(n-1,i);
		tmp %= MOD;
		ans += tmp;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5120
#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; cin >> N;
    vector<ll> C(N-1), S(N-1), F(N-1);
    rep(i, N-1){cin >> C.at(i) >> S.at(i) >> F.at(i);}

    rep(i, N){
        ll t = 0;
        rep2(j, i, N - 1){
            if (t < S.at(j)){
                t = S.at(j);
            } else if (t % F.at(j) == 0){
            } else {
                t = t + F.at(j) - t % F.at(j);
            }
            t += C.at(j);
        }
        cout << t << endl;
    }
}

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] weights = new int[n+1];
        int[] values = new int[n+1];
        int valSum = 0;
        for(int i =1 ; i<=n ; ++i){
            weights[i] = scanner.nextInt();
            values[i] = scanner.nextInt();
            valSum+=values[i];
        }
        int sol=0;
        long[][] dp = new long[n+1][valSum+1];
        for(long[] arr :dp)
            Arrays.fill(arr,Integer.MAX_VALUE);
        dp[0][0]=0;
        for(int i = 1 ; i<=n ; ++i){
            for(int j = 0 ; j<=valSum ; ++j){
                if(values[i]<=j ){
                    dp[i][j] = Math.min(weights[i]+dp[i-1][j-values[i]],dp[i-1][j]);
                }else{
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
        for(int i = valSum ; i>=0 ; --i){
            if(dp[n][i]<=w){
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 141036
import math

a=list(map(int, input().split()))

#a[0]=long,a[1]=short,a[2]=hour,a[3]=min

w=abs(360*(a[2]*60+a[3])/720 - 360*a[3]/60) #w=angle
cosw=math.cos(math.radians(w))

l=math.sqrt(a[0]**2 + a[1]**2 - 2*a[0]*a[1]*cosw)

print(l)



Measured memory_bytes: 9500
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



print(I() ** 2)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans = 0;
  int frag = 1;
  int now = 0;
  while(frag) {
    frag = 0;
    if(S.size() == 0 || S.size() == 1) {
      break;
    }
    for(int i = now; i < S.size() - 1; i++) {
      if(S[i] != S[i + 1]) {
        S.erase(S.begin() + i);
        S.erase(S.begin() + i);
        ans++;
        frag = true;
        // cout << "S: " << S << " ans: " << ans << " now: " << now << " i: " << i<< endl;
        if(i == 0) {
          now = 0;
          break;
        } else {
          now = i - 1;
          break;
        }
      }
      if(S.size() == 0 || S.size() == 1) {
        break;
      }
    }
  }
  cout << ans * 2 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main() {
    int A, B, C, X, Y;
    while (~scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y)) {
          int ans = 0;
          if (2 * C <= A + B) {
             int tmp = min(X, Y);
             ans += tmp * 2 * C;
             X -= tmp;
             Y -= tmp;
          }
          if (2 * C <= A) ans += X * 2 * C;
          else ans += X * A;
          if (2 * C <= B) ans += Y * 2 * C;
          else ans += Y * B;
          printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.HashMap

object Main extends App {
  val h = new HashMap[Int,Int]
  val r = new ArrayBuffer[String]
  val q = readLine.split(" ").map(_.toInt)
  var max = (-1,-1)
  for(i<-1 to q(1)) {
    val n = readLine.split(" ").map(_.toInt)
    if(h.contains(n(0)))
      h.update(n(0),h(n(0)) + n(1))
    else
      h += (n(0)->n(1))

    if(max._1 == n(0) && max._2 > h(n(0))) {
      val a =  h.toArray.sortWith{ (x,y) =>
        if(x._2>y._2) true else if(x._2==y._2 && x._1 < y._1) true else false
      }
      max = (a(0)._1,a(0)._2)
    } else if(max._2 < h(n(0))) {
      max = (n(0),h(n(0)))
    } else if(max._2==h(n(0)) && max._1 > n(0)) {
      max = (n(0),h(n(0)))
    }

    r += max._1 + " " + max._2
  }
  println(r.mkString("\n"))
}

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

int main() {
   string S;
  cin >> S;
  int n = S.size() -1;
  
  string A = "";
  A += S.at(0);
  for (int i=1; i<(S.size()); i++){
    A += ' ';
    A += S.at(i);
  }
  for (int i=0; i< (1 << n); i++) {
     int ans = S.at(0) - '0';
     for (int j=0; j<n; j++) {
       if (i&(1<<j)){
       ans += S.at(j+1) - '0';
       A.at(2*(j+1)-1) = '+' ;
       }
       else{
       ans -= S.at(j+1) - '0';
       A.at(2*(j+1)-1) = '-';
       }
     }
       if (ans == 7) {
         cout << A << "=7" << endl;
         break;
       } 
  }
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():




    s = S()
    if s[-1] == "s":
        print(s+"es")
    else:
        print(s+"s")


main()


Measured memory_bytes: 74480
#include <bits/stdc++.h>
using namespace std;
long long n;
int a[20];
int vis[30];
int main(){
	cin>>n;
	long long l=n,cnt=0;
	while (n){
		if (n%26!=0){
			a[++cnt]=n%26;
			n/=26;	
		}else {
			a[++cnt]=26;
			n/=26;
			n--;
		}
	}
	for (int i=cnt;i>=1;i--){
		cout<<(char)(a[i]+'a'-1);
	}
	cout<<endl;
	return 0;
}



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

namespace _175.C
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToList();
            var x = Math.Abs(input[0]);
            var k = input[1];
            var d = input[2];

            var a = Math.Min(k, x / d);

            k -= a;
            x -= d * a;

            if (k % 2 == 0)
            {
                Console.WriteLine(x.ToString());
            }
            else
            {
                Console.WriteLine((d - x).ToString());
            }
        }
    }
}

Measured memory_bytes: 18952
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a[200];
  cin >> n;
  int count = 0;
  
  for(int j = 0; j<n; j++){
      cin >> a[j];
  }
  
  for (int i = 0; i<30; i++){
    for(int j = 0; j<n; j++){
      if(a[j]%2 == 0)
        a[j] /= 2;
      else
        goto out;
    }
    count++;
  }
  out:
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
void solve(int);
int main(){
  int n;
  while(cin >> n){
    if(n==-1)break;
    solve(n);
    cout << endl;
  }
}
void solve(int n){
  if(n/4==0){
    cout<<n%4;
    return;
  }
  solve(n/4);
  cout <<n%4;
}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int maxN = 1e16;
const int oo = 1e18;
const int mod  = 1e9 + 7;

int n;
int color_cnt[N], color[N], total[N], sz[N], tmp_count[N];
vector<int> vi[N], group[N];

void prepare(int u, int pu) {
    sz[u] = 1;
    for(auto v: vi[u]) if(v != pu) {
        prepare(v, u);
        sz[u] += sz[v];
    }
}

void dfs(int u, int pu) {
    int base = tmp_count[ color[u] ];
    int cur_count = tmp_count[ color[u] ];
    for(auto v: vi[u]) if(v != pu) {
        dfs(v, u);
        int inc = tmp_count[ color[u] ] - cur_count;
        group[ color[u] ].pb(sz[v] - inc);
        total[ color[u] ] += (sz[v] - inc);
        cur_count = tmp_count[ color[u] ];
    }
    tmp_count[ color[u] ] = base + sz[u];
}

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("spm.out", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) cin >> color[i], color_cnt[ color[i] ] ++;
    FOR(i, 1, n - 1) {
        int u, v; cin >> u >> v;
        vi[u].pb(v); vi[v].pb(u);
    }
    prepare(1, 1);
    dfs(1, 1);
    FOR(i, 1, n) if(total[i] + color_cnt[i] < n)
        group[i].pb(n - total[i] - color_cnt[i]);

    FOR(i, 1, n) {
        int ans = n * (n - 1) / 2 + n;
        for(auto num: group[i]) {
            ans -= (num * (num - 1) / 2);
            ans -= num;
            //cout << i << ' ' << num << '\n';
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 56056
import sys

n = int(input())
a = [int(input()) for i in range(n)]

ans = 0
for i in range(n):
    if i == 0:
        if a[i] != 0:
            ans = -1
            break
    elif a[i] > i:
        ans = -1
        break

    else:
        if a[i] == a[i-1] + 1:
            continue
        else:
            if a[i] >= a[i-1] + 2:
                ans = -1
                break
            ans += a[i-1]

if ans == -1:
    print(-1)
    sys.exit()

ans += a[n-1]

print(ans)


Measured memory_bytes: 11052
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

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

bool visited[1000][1000];
char A[1000][1000];
int dist[1000][1000];
int H, W,K;
int bfs(int X, int Y, int n) {
	queue<P>que;
	REP(i, 1000) {
		REP(j, 1000) {
			dist[i][j] = INF;
		}
	}
	int res= min({ X,H - X - 1,Y,W - Y - 1 });
	que.push({ X,Y });
	dist[X][Y] = 0;
	visited[X][Y] = true;
	int cnt = 0;
	while (!que.empty()) {
		int x = que.front().first, y = que.front().second;
		que.pop();
		visited[x][y] = true;
		REP(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx >= 0 && nx < H && ny >= 0 && ny < W) {
				if (visited[nx][ny])continue;
				if (A[nx][ny] != '#') {
					dist[nx][ny] = min(dist[nx][ny], dist[x][y] + 1);
					visited[nx][ny] = true;
					if (dist[nx][ny] <= n) {
						res = min(res, min({ nx,H - nx - 1,ny,W - ny - 1 }));
						que.push({ nx,ny });
					}
				}
			}
		}
	}
	return res;
}
int dfs(int x,int y,int n) {
	visited[x][y] = true;
	if (n == 0) {
		return min({ x,H - x - 1,y,W - y- 1 });
	}
	int res = min({ x,H - x - 1,y,W - y-1 });
	REP(i, 4) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx >= 0 && nx < H && ny >= 0 && ny < W) {
			if (visited[nx][ny])continue;
			if (A[nx][ny] != '#') {
				res=min(res,dfs(nx, ny, n - 1));
			}
		}
	}
	return res;
}

void solve() {
	cin >> H >> W>>K;
	int sx=0, sy=0;
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
			if (A[i][j] == 'S') {
				sx = i, sy = j;
			}
		}
	}
	int rem = bfs(sx, sy, K);
	/*REP(i, H) {
		REP(j, W) {
			pe(dist[i][j]);
		}cout << endl;
	}*/
	int ans = 1;
	ans += (rem + K - 1) / K;
	print(ans);
}


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


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

int main(){
  int N = 87;
  vector<int64_t> L(87);
  L.at(0)=2LL;
  L.at(1)=1LL;
  for(int i=2; i<N; i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  int M;
  cin >> M;
  cout << L.at(M) << endl;
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)

for _ in range(M):
    tmp_min = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmp_min//2))
print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  ll count = 0;
  vector<char> c(n);
  vector<ll> pos_r;

  rep(i,n) {
    cin >> c.at(i);
    if(c.at(i) == 'R') pos_r.push_back(i);
  }

  if(pos_r.size() == 0) {
    cout << 0 << endl;
    return 0;
  }

  reverse(pos_r.begin(), pos_r.end());

  ll current_pos = 0;

  rep(i,n) {
    if(c.at(i) == 'W') {
      if(i > pos_r.at(current_pos)) {
        cout << count << endl;
        return 0;
      }
      else if(i < pos_r.at(current_pos)) {
        current_pos++;
        count++;
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 5416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int n,h,w;
cin >> n >> h >> w;
cout << (n-w+1)*(n-h+1)<<endl;
 }


Measured memory_bytes: 256
require 'numo/narray'
include Numo

h, w, k = gets.split.map(&:to_i)
rows = Array.new(h){gets.chomp.bytes.map{|c| (c == '#'.ord) ? 1 : 0}}
cnt = 0
[0, 1].repeated_permutation(h) do |x|
  m = Int32[*rows.dup]
  m = []
  x.each_with_index do |y, i|
    if y == 0
      m << rows[i].dup
    else
      m << [0] * w
    end
  end
  [0, 1].repeated_permutation(w) do |u|
    mc = Int32[*m]
    u.each_with_index do |v, l|
      mc[true, l] = 0 if v == 1
    end
    cnt += 1 if mc.to_a.flatten.sum == k
  end
end
puts cnt

Measured memory_bytes: 16300
#include <functional>
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;
# define maxn 500
# define maxm 50

int main() {
  int n,C[maxn],S[maxn],F[maxn];
  cin>>n;
  for (int i(0);i<n-1;i++) cin>>C[i]>>S[i]>>F[i];
  for (int i(0);i<n;i++){ // start from i station
    int t(0); // time
    for (int j(i);j<n-1;j++){
      if (t < S[j]) t = S[j];
      else if (t%F[j]==0);
      else t = t+F[j] - t%F[j];
      t += C[j];
    }
    cout << t<< endl;
  }
}

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


public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader br = null;
        PrintWriter writer = null;
        
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            writer = new PrintWriter(System.out);
            
            int N = Integer.parseInt(br.readLine());
            int A = Integer.parseInt(br.readLine());
            
            if(N%500 <= A) writer.println("Yes");
            else writer.print("No");
            
        }finally{
            if(br != null){
                br.close();
            }
            if(writer != null){
                writer.close();
            }
        }

    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstring>
using namespace std;
int n;
char c[202][12];
bool ok,b;
int main()
{ cin>>n;
  cin.get();
  c[0][0]=' ';
  for(int i=1;i<=n;i++)
  { cin.getline(c[i],11);
    if(!b)
    { for(int j=1;j<i;j++)
      { ok=0;
        for(int k=0;k<=10 && !ok;k++)
          if(c[i][k]!=c[j][k])
             ok=1;
        if(!ok)
           b=1;
      }
      if(c[i-1][strlen(c[i-1])-1]!=c[i][0] && i>1)
         b=1;
    }
  }
  if(!b)
     cout<<"Yes";
  else
     cout<<"No";
  return 0;
}


Measured memory_bytes: 256
open System

let n = Console.ReadLine() |> int

let ss =
    [ for i in 1 .. n -> Console.ReadLine() ]

let ans =
    let choose2 n = n * (n - 1L) / 2L

    ss
    |> List.map (fun s ->
        [0 .. s.Length - 1]
        |> List.map (fun i -> s.[i])
        |> List.fold (
            fun (m: Map<_, _>) c ->
                if m.ContainsKey c then
                    m |> Map.add c (m.[c] + 1L)
                else
                    m |> Map.add c 1L
            ) (Map []))
    |> List.countBy id
    |> List.map (fun (m, n) -> (m, int64 n))
    |> List.fold (fun acc (_, n) -> acc + (choose2 n)) 0L

ans |> Console.WriteLine

Measured memory_bytes: 92548
package main

import (
	"fmt"
	"sort"
)

var m map[int]int

func main() {
	var N int
	fmt.Scan(&N)
	var arr []int
	for i := 1; i*i <= N; i++ {
		arr = append(arr, i*i)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(arr)))
	for i := 0; i < len(arr); i++ {
		if N >= arr[i] {
			fmt.Println(arr[i])
			return
		}
	}
}

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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N)
    cin >> L[i];
  sort(L.begin(), L.end());

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        if (L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]) {
          if(L[i]+L[j] > L[k])
            cnt++;
        }
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dfs(int i,int sum){
	if(i==n) return sum;
	return min(dfs(i+1,sum*2),dfs(i+1,sum+k));
}
int main(){
	scanf("%d %d",&n,&k);
	printf("%d\n",dfs(0,1));
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3


def solve(N, Q, a, b, p, x):
    parent = [0] * (N+1)
    for ai, bi in zip(a, b):
        parent[bi] = ai
    plus = [0] * (N+1)
    for pi, xi in zip(p, x):
        plus[pi] += xi
    ans = [0] * (N+1)
    for i in range(1, N+1):
        ans[i] = ans[parent[i]] + plus[i]
    return ans[1:]


if __name__ == '__main__':
    N, Q = map(int, input().split())
    a = [0] * (N-1)
    b = [0] * (N-1)
    for idx in range(N-1):
        a[idx], b[idx] = map(int, input().split())
    p = [0] * Q
    x = [0] * Q
    for idx in range(Q):
        p[idx], x[idx] = map(int, input().split())

    ans = solve(N, Q, a, b, p, x)

    print(' '.join(map(str, ans)))


Measured memory_bytes: 58560
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9+5

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,k,ans;    cin>>n>>k;
    vector<int> a(n),dp(n,inf);
    dp[0]=0;


    for(auto &i:a)  cin>>i;

    for(int i=0 ; i<n ; i++)
    {
        for(int j=i+1 ; j<=i+k ; j++)
            if(j<n)
            dp[j]=min(dp[j],abs(a[i]-a[j])+dp[i]);

       // for(auto i:dp)            cout<<i<<" "; cout<<endl;
    }

    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>

#define LEN 1046527
#define NIL (-1)
#define L 14

using namespace std;

char H[LEN][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  if(ch == 'C') return 2;
  if(ch == 'G') return 3;
  if(ch == 'T') return 4;
  return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for(i = 0; i< strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

long long h1(long long key){
  return key % LEN;
}

long long h2(long long key){
  return 1 + (key % (LEN -1));
}

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % LEN;
    if(strcmp(H[h], str) == 0) return 1;
    if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % LEN;
    if(strcmp(H[h], str) == 0) return 1;
    if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(int argc, const char * argv[]) {
  int i, n;
  char str[L], com[9];
  
  for(i = 0; i < LEN; i++){
    H[i][0] = '\0';
  }
  cin >> n;
  
  for(i = 0; i < n; i++){
    cin >> com >> str;
    
    if(com[0] == 'i'){
      insert(str);
    }else{
      if(find(str)){
        cout << "yes" << endl;
      }else{
        cout << "no" << endl;
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 17448
#include <stdio.h>

int main() {
  int money, number_of_coin_500, number_of_coin_100, number_of_coin_50, i, j, k, count = 0;
  scanf("%d", &number_of_coin_500);
  scanf("%d", &number_of_coin_100);
  scanf("%d", &number_of_coin_50);
  scanf("%d", &money);
  for(i = 0; i <= number_of_coin_500; i++) {
    for(j = 0; j <= number_of_coin_100; j++) {
      for(k = 0; k <= number_of_coin_50; k++) {
        if(500 * i + 100 * j + 50 * k == money) {
          count++;
        }
      }
    }
  }
  printf("%d\n", count);
  return 0;
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) {
    cin >> a[i];
  }
  REP(i, N-1) {
    a[N - 1] |= a[i];
  }
  a[N - 1] &= 1;
  if(a[N - 1] == 1) {
    cout << "first" << endl;
  } else {
    cout << "second" << endl;
  }
  return 0;
}


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

string reverse(string s){
	int n = s.length();
	for (int i=0 ; i<n/2; i++){
		char temp = s[i];
		s[i] = s[n-1-i];
		s[n-1-i] = temp;
	}
	return s;
}

int main(){
	string s;
	cin >> s;
	if (s.length()==2)
		cout << s;
	else cout << reverse(s);
}

Measured memory_bytes: 256
//
//  count_ball.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <math.h>
typedef long long ll;
int main(int argc, const char* argv[]) {
  ll n, a, b;
  std::cin >> n >> a >> b;

  ll total = 0;
  if (a!=0 || b!=0) {
    ll blue_time = n/(a+b);
    total = blue_time * a;
    if (n%(a+b) < a) {
      total += n%(a+b);
    }
    else {
      total += a;
    }
  }

  std::cout << total << std::endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
char X[1001], Y[1001];
int  c[1001][1001];
int m, n;
int LCSLength(void)
{
  int i, j;
  m = strlen(X);
  n = strlen(Y);
  
  for( i=1 ; i<=m ; i++ )
    c[i][0] = 0;
  for( j=0 ; j<n ; j++ )
    c[0][j] = 0;
  for( i=1 ; i<=m ; i++ ){
    for( j=1 ; j<=n ; j++ ){
      if(X[i-1]==Y[j-1])
    c[i][j] = c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])
    c[i][j] = c[i-1][j];
      else
    c[i][j] = c[i][j-1];
    }
  }
  return c[i-1][j-1];
} 
int main()
{
  int a[150];
  int i, j, k, q;
  scanf("%d",&q);
  for( i=0 ; i<q ; i++ ){
    scanf("%s",X);
    scanf("%s",Y);
    LCSLength();
    a[i] = LCSLength();
  }
  for( i=0 ; i<q ; i++ ){
    printf("%d\n",a[i]);
  }
  
  return 0;
}





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

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int N = Integer.parseInt(br.readLine());
			String[] strArr = br.readLine().split("\\s");
			int[] intArr = new int[N];
			for (int i = 0; i < N; i++) {
				intArr[i] = Integer.parseInt(strArr[i]);
			}
			
			int tmp = 0;
			int j = 0;
			for (int i = 0; i < N ; i++) {
				for (int k = 0; k < N; k++) {
					System.out.print(intArr[k]);
					if (k != N-1) {
						System.out.print(" ");
					}
				}
				System.out.println();
				if (i == N -1) {
					break;
				}
				tmp = intArr[i+1];
				j = i;
				while (j >= 0 && intArr[j] > tmp) {
					intArr[j+1] = intArr[j];
					j--;
				}
				intArr[j+1] = tmp;
			}
			
		} catch (NumberFormatException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
		
	}

}



Measured memory_bytes: 33056
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] stack = new int[n + 1];
			int top = 0;
			int color = scanner.nextInt();
			for (int i = 1; i < n; i++) {
				int cur = scanner.nextInt();
				if (color == cur)
					continue;
				color = cur;
				if (i % 2 == 0)
					stack[top++] = i;
				else if (top > 0)
					top--;
			}
			stack[top++] = n;
			int ans = 0;
			int cur = 0;
			for (int i = 0; i < top; i++) {
				if (i % 2 == 0)
					ans += stack[i] - cur;
				cur = stack[i];

			}
			if (color == 0 ^ top % 2 != 0)
				ans = n - ans;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 64012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; string s; cin >> n >> s;
    int ans=0;
    rep(i, 1000){
        int a[3];
        if(i<100) a[0] = 0;
        else a[0] = i/100;
        if(i<10) a[1] = 0;
        else a[1] = (i%100)/10;
        a[2] = i%10;
        int ai = 0;
        // printf("%d%d%d\n", a[0], a[1], a[2]);
        rep(j, n){
            if(a[ai] == s[j]-'0'){
                ai++;
                if(ai==3) break;
            }
        }
        if(ai==3) {
            // pr(i);
            ans++;
        }
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3644
def root(x, parent_list):
    if parent_list[x] == x:
        return parent_list[x]
    else:
        parent_list[x] = root(parent_list[x], parent_list)
        return parent_list[x]


def same(x, y, parent_list):
    return root(x, parent_list) == root(y, parent_list)


def unite(x, y, parent_list):
    x = root(x, parent_list)
    y = root(y, parent_list)
    if x == y:
        return

    parent_list[x] = y

N, M = [int(elem) for elem in input().split(' ')]
p_list = [int(elem) - 1 for elem in input().split(' ')]

swap_list = [[int(elem) - 1 for elem in input().split(' ')]\
            for _ in range(M)]

parent_list = list(range(N))
for swap in swap_list:
    unite(swap[0], swap[1], parent_list)

count = 0
for i in range(N):
    if root(p_list[i], parent_list) == root(i, parent_list):
        count += 1

print(count)


Measured memory_bytes: 29028
#include<stdio.h>
#include<algorithm>
#include<string.h>

int n[1000] = { 0 };
char a[1001] = { 0 };
char b[1001] = { 0 };
int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	scanf("%s", &a);
	scanf("%s", &b);
	
	int len,cnt = 0;
	
	len = strlen(a);
	for (int i = 0; i < len; i++) {
		int j = 0;
		int z = i;
		while (cnt != len - 1) {
			if (j == len) {//문자열 b 끝까지 왔을때
				j = 0;
			}
			if (z == len) {//문자열 a 끝까지 왔을때
				z = 0;
			}
			if (a[z] != b[j]) {
				break;
			}
			else {
				cnt++;
				j++;
				z++;
			}
		}
		if (cnt == len-1) {
			printf("Yes");
			break;
		}
		else {
			cnt = 0;
		}
	}
	if (cnt != len-1) {
		printf("No");
	}
}

Measured memory_bytes: 128
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n, r; cin >> n >> r;
    if(n>=10) {
        cout << r << endl;
    } else {
        cout << r + 100*(10-n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
 
main = do
  xs <- readInts
  let xs_mul | product(xs) `mod` 2 == 0 = "Even"
             | otherwise = "Odd"
  putStrLn xs_mul

Measured memory_bytes: 380
object Main {

  def dis(a:List[Int],b:List[Int]) ={
    if(b(0)<b(1)){
      List(a(0),a(1)+b.sum)
    }else if(b(0)>b(1)){
      List(a(0)+b.sum,a(1))
    }else{
      List(a(0)+b(0),a(1)+b(1))
    }
  }

  def calc(sc:java.util.Scanner):Unit ={
    sc.nextInt match{
      case 0 =>
        Unit
      case n =>
        var ans = List.fill(n,2)(sc.nextInt).fold(List(0,0))(dis)
        printf("%d %d\n",ans(0),ans(1))
        calc(sc)
    }
  }

  def main(args:Array[String]) = {
    calc(new java.util.Scanner(System.in))
  }
}

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

main(){

  ll h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h)cin>>s[i];

  vector<vector<ll>> yoko (h,vector<ll>(w));
  vector<vector<ll>> tate (h,vector<ll>(w));
  rep(i,h)rep(j,w){
    if(s[i][j]=='.'){
      yoko[i][j]++;
      tate[i][j]++;
    }
  }
  for(ll i=0;i<h;++i){
    for(ll j=1;j<w;++j){
      if(yoko[i][j]>0 && yoko[i][j-1]>0)yoko[i][j]+=yoko[i][j-1];
    }
  }
  for(ll i=0;i<h;++i){
    for(ll j=w-2;j>=0;--j){
      if(yoko[i][j]>0 && yoko[i][j+1]>0)yoko[i][j]=yoko[i][j+1];
    }
  }
  for(ll j=0;j<w;++j){
    for(ll i=1;i<h;++i){
      if(tate[i][j]>0 && tate[i-1][j]>0)tate[i][j]+=tate[i-1][j];
    }
  }
  for(ll j=0;j<w;++j){
    for(ll i=h-2;i>=0;--i){
      if(tate[i][j]>0 && tate[i+1][j]>0)tate[i][j]=tate[i+1][j];
    }
  }

  ll ans=0;
  rep(i,h)rep(j,w){
    ans=max(ans,yoko[i][j]+tate[i][j]-1);
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 67072
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  char S[5];
  int i, res=700;
  rd(S);
  for(i=0;i<(3);i++){
    if(S[i]=='o'){
      res += 100;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// {
//   char S[5];
//   int res = 700;
//   rd(S);
//   rep(i,3) if(S[i]=='o') res += 100;
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    vector<int> ans;
    vector<int> cnt(n + 1, 0);
    for (int i = n; i >= 1; i--)
    {
        int tmp = 0;
        for (int j = 1; i * j <= n; j++)
        {
            tmp += cnt[i * j];
        }
        if (tmp % 2 != a[i])
        {
            cnt[i]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (cnt[i] >= 1)
        {
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for (auto r : ans)
    {
        cout << r << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;

int main( void ){
	int A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if (V <= W){
		cout << "NO\n";
		return 0;
	}
	ll d = abs( A - B ), v = V - W;
	if (d <= v*T){
		cout << "YES\n";
		return 0;
	}
	cout << "NO\n";
	return 0;

}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
	ll x;
	cin>>x;
	if(x>=400&&x<=599)
	{
		cout<<8<<endl;
	}
	if(x>=600&&x<=799)
	{
		cout<<7<<endl;
	}
	if(x>=800&&x<=999)
	{
		cout<<6<<endl;
	}
	if(x>=1000&&x<=1199)
		cout<<5<<endl;
	{
	}
	if(x>=1200&&x<=1399)
	{
		cout<<4<<endl;
	}
	if(x>=1400&&x<=1599)
	{
		cout<<3<<endl;
	}
	if(x>=1600&&x<=1799)
	{
		cout<<2<<endl;
	}
	if(x>=1800&&x<=1999)
	{
		cout<<1<<endl;
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3800
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    d = set(map(str, D))
    while set(str(N))&d:
        N += 1

    print(N)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
  int A, B;
  cin >> A >> B;
  if(A >= 13)
    cout << B;
  else if((6 <= A) && (A <= 12))
    cout << B / 2;
  else
    cout << 0;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
if K == 1 or N == 0 or N % K == 0:
    print(0)
elif N*2 < K:
    print(N)
elif N < K < 2*N:
    print(K-N)
else:
    tmp = abs(N%K-K)
    print(min(N%K,tmp))



Measured memory_bytes: 2940
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: f64,
        xys: [(i64,i64);n]
    }
    let mut cnt = 0;
    for (x,y) in xys {
        let b = ((x.pow(2) + y.pow(2)) as f64).sqrt();
        if b <= d {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 7848
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		int[] a = new int[3];
		a[0] = 1;
		a[1] = a[2] = 0;
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			String[] str = stdIn.next().split(",");
			char from = str[0].charAt(0);
			char to = str[1].charAt(0);
			if(from == 'A')
			{
				if(to == 'B')
				{
					int temp = a[0];
					a[0] = a[1];
					a[1] = temp;
				}
				else if(to == 'C')
				{
					int temp = a[0];
					a[0] = a[2];
					a[2] = temp;
				}
			}
			else if(from == 'B')
			{
				if(to == 'A')
				{
					int temp = a[0];
					a[0] = a[1];
					a[1] = temp;
				}
				else if(to == 'C')
				{
					int temp = a[1];
					a[1] = a[2];
					a[2] = temp;
				}
			}
			if(from == 'C')
			{
				if(to == 'A')
				{
					int temp = a[0];
					a[0] = a[2];
					a[2] = temp;
				}
				else if(to == 'B')
				{
					int temp = a[1];
					a[1] = a[2];
					a[2] = temp;
				}
			}
		}
		if(a[0] == 1)
		{
			System.out.println("A");
		}
		else if(a[1] == 1)
		{
			System.out.println("B");
		}
		else
		{
			System.out.println("C");
		}
	}
}

Measured memory_bytes: 12000
/*
	Name:
	Author:
	Date:
	Website:
	Description:
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ac=0,wa=0,tle=0,re=0;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s[0]=='A')
		{
			ac++;
		}
		if(s[0]=='W')
		{
			wa++;
		}
		if(s[0]=='T')
		{
			tle++;
		}
		if(s[0]=='R')
		{
			re++;
		}
	}
	cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re;
	return 0;
}


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

int main()
{
  string sa,t,S;
  cin>>sa>>t;
  vector<string> ac;
  int ss=sa.size();
  int ts=t.size();
  for(int i=0;i<=ss-ts;i++)
  {
    bool jd=false;
    S=sa;
    for(int j=0;j<ts;j++)
	{
      if(sa[i+j]!=t[j] && sa[i+j]!='?')
	  {
        jd=true;
        break;
      }
    }
    if(jd) continue;
    for(int j=0;j<ts;j++)
	{
      S[i+j]=t[j];
    }
    for(int j=0;j<ss;j++)
	{
      if(S[j]=='?')
        S[j]='a';
    }
    ac.push_back(S);
  }
  
  if(ac.empty())
  {
    cout<<"UNRESTORABLE"<<endl;
  }
  else
  {
    sort(ac.begin(),ac.end());
    cout<<ac[0]<<endl;
  }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int count = 0;
  for(int i = 0; i < n; i++) cin >> p.at(i);
  for(int i = 1; i < n-1; i++){
    if((p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)) || (p.at(i+1) < p.at(i) && p.at(i) < p.at(i-1))) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll 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 / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++){
    cin>>a[i];
}
sort(a,a+n);
cout<<a[n/2]-a[n/2-1]<<endl;


return 0;
}










Measured memory_bytes: 1024