akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

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

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;

	if (s == u) cout << a - 1 << " " << b << endl;
	else if (t == u) cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

R = min(C, X // 50)
if (X - 50 * R) % 100 != 0 and R > 0:
	R -= 1
Q = min(B, (X - 50 * R) // 100)
while (X - 50 * R - 100 * Q) % 500 != 0:
	if Q > 0:
		Q -= 1
	elif R > 1:
		R -= 2
	else:
		break
P = min(A, (X - 50 * R - 100 * Q) // 500)

if 500 * P + 100 * Q + 50 * R >= X:
	ans = 1
	
	while True:
		while True:
			if 50 * R >= 100 and Q < B:
				R -= 2
				Q += 1
				ans += 1
			else:
				break
	
		if 100 * Q + 50 * R >= 500 and P < A:
			P += 1
			R = min(C, (X - 500 * P) // 50)
			if (X - 50 * R) % 100 != 0 and R > 0:
				R -= 1
			Q = min(B, (X - 500 * P - 50 * R) // 100)
			ans += 1
		else:
			break

else:
	ans = 0

print(ans)

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


int main(){
    string s;
    cin >> s;
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }
    string t = s;
    sort(t.begin(), t.end());
    if ((int) s.size() < 26) {
        for (int i = 0; i < 26; i++) {
            if (i == (int)s.size() || t[i] != 'a' + i) {
                cout << s << (char)('a' + i) << endl;
                return 0;
            }
        }
    }
    
    for (int i = 24; i >= 0; i--) {
        if ((int)s[i] < (int)s[i+1]) {
            string ans = "";
            for (int j = 0; j <= i-1; j++) ans = ans + s[j];
            for (int j = 25; j >= i+1; j--) {
                if ((int)s[j] > (int) s[i]) {
                    ans = ans + s[j];
                    break;
                }
            }
            cout << ans << endl;
            return 0;
        }
    }
}

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

long long n;
vector<long long> a;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if (n == 2 && a[0] >= a[1] && (a[0] + a[1]) % 2 == 0)
    return a[0] - (a[0] + a[1]) / 2;
  long long bit = 0, sum = a[0] + a[1], tmp = 0;
  vector<int> id;
  for (int i = 2; i < n; ++i) bit ^= a[i];
  if ((sum ^ bit) & 1) return -1;
  for (int i = 0; i < 50; ++i)
    if (bit >> i & 1) {
      sum -= 1LL << i;
      id.push_back(i);
    }
  if (sum < 0) return -1;
  for (int i = 1; i < 50; ++i) {
    if ((sum >> i & 1) && (bit >> (i - 1) & 1)) return -1;
    if (sum >> i & 1) tmp += 1LL << (i - 1);
  }
  if (tmp >= a[0]) return -1;

  reverse(id.begin(), id.end());
  for (auto x : id)
    if ((1LL << x) + tmp < a[0]) tmp += 1LL << x;
  if (tmp == 0) return -1;
  return a[0] - tmp;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if ((a * b) % 2 == 0) {
      System.out.println("Even");
    }else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21204
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    m = 10 ** 5
    cnt = [0] * (m + 1)
    for x in a:
        cnt[x] += 1
        if x > 0: cnt[x-1] += 1
        if x < m: cnt[x+1] += 1
    print(max(cnt))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 14044
n = int(input())
t, a = [0] * n, [0] * n
for i in range(n):
    t[i], a[i] = map(int, input().split())
ans = a[0] + t[0]
j_pre = 1
for i in range(1, n):
    j = max(-(-(t[i - 1] * j_pre) // t[i]), -(-(a[i - 1] * j_pre) // a[i]) )
    ans = (t[i] + a[i]) * j
    j_pre = j
    #print(t[i] * j, a[i] * j)
    #print(ans)

print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**7)


def dfs(s, max_ctoi, n):
    global ans
    if len(s) == n:
        ans.append(s)
        return
    else:
        for i in range(max_ctoi+1):
            if i == max_ctoi:
                dfs(s+chr(ord("a")+i), max_ctoi+1, N)
            else:
                dfs(s+chr(ord("a")+i), max_ctoi, N)


ans = []
N = int(input())
dfs("", 0, N)
ans.sort()
for a in ans:
    print(a)


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x; cin >> x;
  int n = x;
  int p = 10;
  vector<vector<int>> fac(n+1,vector<int>(p+1));
  rep(i,n+1)
    rep(j,p+1) fac[i][j] = 1;
    
  for(int i = 1;i<=x;i++){
    for(int j = 1;j<=p;j++){
      fac[i][j] = fac[i][j-1]*i;
    }
  }

  int ans = -1;
  for(int i = 1;i<=x;i++){
    for(int j = 2;j<=p;j++){
      if(fac[i][j]<=x) ans = max(ans,fac[i][j]);
    }
  }

  cout << ans << endl;
  
  return 0;
}


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

int main() {
  string s;cin>>s;
  if (s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
  else cout << "No";
}


Measured memory_bytes: 256
from math import ceil
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    mx = [0] * (N+1)
    mn = [0] * (N+1)

    mx[-1] = A[-1]
    mn[-1] = A[-1]

    for i in range(N-1,-1,-1):
        mx[i] = mx[i+1] + A[i]      
        mn[i] = ceil(mn[i+1]/2) + A[i]
    
    if not mn[0] <= 1 <= mx[0]:
        print(-1)
        return

    ans = 1
    now = 1
    piyo = [1]
    for i in range(1,N+1):
        nxt = (now-A[i-1]) * 2
        piyo.append(nxt)
        ans += min(mx[i],nxt)
        now = nxt

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

Measured memory_bytes: 700508
program j01;
var a,b,n,l,r:int64;
begin
  readln(n,a,b);
  if(n=1)and(a=b)then begin writeln(1);halt; end; 
  if(n=1)or(a>b)then begin writeln(0);halt; end;
  r:=a+(n-1)*b;
  l:=b+(n-1)*a;
  writeln(r-l+1);
end.


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long


int main(){
  int q=998244353;
  int N;
  cin >> N;
  vector<int> D(N);
  vector<int> d(N,0);
  for(int i=0; i<N; i++){
    cin >> D[i];
    d[D[i]]++;
  }
  if(D[0] != 0){
    cout << 0 << endl;
    return 0;
  }
  if(d[0] != 1){
    cout << 0 << endl;
    return 0;
  }
  ll ans=1;
  for(int i=1; i<N; i++){
    for(int j=0; j<d[i]; j++){
      ans = (ans*(ll)d[i-1])%q;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import bisect

def main():
    n = int(input())
    a = list(map(int, input().split()))

    a.sort()
    i = bisect.bisect_left(a, a[n - 1] / 2)

    r = 0
    if a[i] * 2 == a[n - 1]:
        r = a[i]
    elif i == 0:
        r = a[0]
    elif i == n - 1:
        r = a[i - 1]
    elif a[n - 1] - a[i - 1] * 2 < a[i] * 2 - a[n - 1]:
        r = a[i - 1]
    else:
        r = a[i]

    print('{} {}'.format(a[n - 1], r))


if __name__ == '__main__':
    main()



Measured memory_bytes: 15208
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            if(i != n-1){
                System.out.print(a[i] + " ");
            }else{
                System.out.println(a[i]);
            }
        }
        int v, j;
        for(int i = 1; i < n; i++){
            v = a[i];
            j = i-1;
            while(j >= 0 && a[j] > v){
                a[j+1] = a[j];
                j--;
                a[j+1] = v;
            }
            for(int k = 0; k < n; k++){
                if(k != n-1){
                System.out.print(a[k] + " ");
                }else{
                    System.out.println(a[k]);
                }
            }
        }
    }
}



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


typedef long long ll;
int N, W, w[101], v[101];
//-----------------------------------------------------------------------------------
vector<vector<vector<vector<ll>>>> dp[2];
int N0, N1, N2, N3;
void pre() {
    rep(i, 0, N) {
        if (w[i] == w[0]) N0++;
        else if (w[i] == w[0] + 1) N1++;
        else if (w[i] == w[0] + 2) N2++;
        else if (w[i] == w[0] + 3) N3++;
    }

    N0++; N1++; N2++; N3++;

    dp[0] = vector<vector<vector<vector<ll>>>>(N0, vector<vector<vector<ll>>>(N1, vector<vector<ll>>(N2, vector<ll>(N3, -1))));
    dp[1] = vector<vector<vector<vector<ll>>>>(N0, vector<vector<vector<ll>>>(N1, vector<vector<ll>>(N2, vector<ll>(N3, -1))));
}
//-----------------------------------------------------------------------------------
int main() {
    cin >> N >> W;
    rep(i, 0, N) scanf("%d%d", &w[i], &v[i]);

    pre();

    rep(w0, 0, N0) rep(w1, 0, N1) rep(w2, 0, N2) rep(w3, 0, N3) dp[0][w0][w1][w2][w3] = -1;
    dp[0][0][0][0][0] = 0;
    rep(i, 0, N) {
        int ii = (i + 1) % 2;
        rep(w0, 0, N0) rep(w1, 0, N1) rep(w2, 0, N2) rep(w3, 0, N3) dp[ii][w0][w1][w2][w3] = -1;
        rep(w0, 0, N0) rep(w1, 0, N1) rep(w2, 0, N2) rep(w3, 0, N3) if (0 <= dp[i % 2][w0][w1][w2][w3]) {
            dp[(i + 1) % 2][w0][w1][w2][w3] = max(dp[(i + 1) % 2][w0][w1][w2][w3], dp[i % 2][w0][w1][w2][w3]);

            int ii = (i + 1) % 2;
            int ww0 = w0;
            int ww1 = w1;
            int ww2 = w2;
            int ww3 = w3;

            if (w[i] == w[0]) ww0++;
            else if (w[i] == w[0] + 1) ww1++;
            else if (w[i] == w[0] + 2) ww2++;
            else if (w[i] == w[0] + 3) ww3++;

            ll wei = 1LL * w[0] * ww0;
            wei += 1LL * (w[0] + 1) * ww1;
            wei += 1LL * (w[0] + 2) * ww2;
            wei += 1LL * (w[0] + 3) * ww3;
            if (W < wei) continue;

            dp[ii][ww0][ww1][ww2][ww3] = max(dp[ii][ww0][ww1][ww2][ww3], dp[i % 2][w0][w1][w2][w3] + v[i]);
        }
    }

    ll ans = 0;
    rep(w0, 0, N0) rep(w1, 0, N1) rep(w2, 0, N2) rep(w3, 0, N3) ans = max(ans, dp[N % 2][w0][w1][w2][w3]);
    cout << ans << endl;
}

Measured memory_bytes: 8960
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, k, h[100100];
ll dp[100100];

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];

    for(int i = 0; i < 100100; i++) dp[i] = inf;

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

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
def main():
    A, B, C = map(int, input().split())
    ans = 0
    seen = set()
    while True:
        if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
            break
        if (A, B, C) in seen:
            print(-1)
            return
        seen.add((A, B, C))
        x = A//2
        y = B//2
        z = C//2
        A = y + z
        B = z + x
        C = x + y
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int top3 = N / 10;
  int bottom3 = N % 1000;
  
  if (top3 % 111 == 0 || bottom3 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl; 
  }
    
}

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

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n;
ll a[MAX];
map<ll, ll> mp1, mp2;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        read(a[i]);
        if(i > 1) mp2[(ll)i-a[i]]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i > 1) mp2[(ll)i-a[i]]--;
        ans += mp2[a[i]+i]+mp1[a[i]-i];
        mp1[-a[i]-i]++;
    }
    cout << ans/2 << endl;

    return 0;
}


Measured memory_bytes: 50580
W,H,N = gets.split.map &:to_i
ps = (0...N).map{ gets.split.map &:to_i }

x1 = ps.select{ |x,y,a| a == 1 }.map{ |x,_,_| x }.max || 0
x2 = ps.select{ |x,y,a| a == 2 }.map{ |x,_,_| x }.min || W
y1 = ps.select{ |x,y,a| a == 3 }.map{ |_,y,_| y }.max || 0
y2 = ps.select{ |x,y,a| a == 4 }.map{ |_,y,_| y }.min || H
p [x2-x1,0].max * [y2-y1,0].max


Measured memory_bytes: 1788
import sys

def main():
    H, W = map(int, raw_input().split(" "))
    matrix = []
    for _ in range(H):
        matrix.append(list(raw_input()))

    for i in range(H):
        for j in range(W):
            if matrix[i][j] == "#":
                continue

            num_bombs = 0
            if i - 1 >= 0 and j - 1 >= 0 and matrix[i - 1][j - 1] == "#":
                num_bombs += 1
            if j - 1 >= 0 and matrix[i][j - 1] == "#":
                num_bombs += 1
            if i - 1 >= 0 and matrix[i - 1][j] == "#":
                num_bombs += 1
            if i + 1 < H and j + 1 < W and matrix[i + 1][j + 1] == "#":
                num_bombs += 1
            if j + 1 < W and matrix[i][j + 1] == "#":
                num_bombs += 1
            if i + 1 < H and matrix[i + 1][j] == "#":
                num_bombs += 1
            if i - 1 >= 0 and j + 1 < W and matrix[i - 1][j + 1] == "#":
                num_bombs += 1
            if i + 1 < H and j - 1 >= 0 and matrix[i + 1][j - 1] == "#":
                num_bombs += 1

            matrix[i][j] = str(num_bombs)

    for i in range(H):
        for j in range(W):
            sys.stdout.write(matrix[i][j])
        print ""

if __name__ == '__main__':
    main()


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

int n, b; long double d, p[100], h[100], ret = 1000000000;

long double solve(long double vspeed, int bounce) {
	long double sec = vspeed*2.0L*(bounce + 1);
	long double gspeed = d / sec;
	return sqrtl(vspeed*vspeed + gspeed*gspeed);
}

int main() {
	cin >> d >> n >> b;
	for (int i = 1; i <= n; i++)cin >> p[i] >> h[i];
	for (int i = 0; i <= b; i++) {
		bool flag = false;
		long double maxn = 0, dist = d / (1.0L*(i + 1));
		for (int j = 1; j <= n; j++) {
			long double E = p[j];
			while (E >= dist)E -= dist;
			if (fabs(E) < 1e-9) { flag = true; break; }
			long double T = (E / dist)*((dist - E) / dist); T *= 4.0L;
			maxn = max(maxn, h[j] / T);
		}
		if (flag == true) continue;
		long double L = sqrtl(maxn * 2), R = 10000.0L, c1, c2, res = 1000000000;
		for (int j = 0; j < 100; j++) {
			c1 = (L + L + R) / 3;
			c2 = (L + R + R) / 3;
			long double a1 = solve(c1, i);
			long double a2 = solve(c2, i);
			if (a1 < a2)R = c2;
			if (a1 >= a2)L = c1;
			res = min(res, min(a1, a2));
		}
		ret = min(ret, res);
	}
	printf("%.12Lf\n", ret);
	return 0;
}


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

int main() {
    int r,g,b;
    cin >> r >> g >> b;

    int sum = r * 100 + g * 10 + b;

    if (sum % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

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

int main() {
 int N,M;
  cin >> N >> M;
  int x;
  if (N <= 1 && M <=1) {
    x = 0;
  }
  else if(N <=1){
   x = M * (M -1) / 2; 
  }
  else if ( M <=1) {
    x = N * (N - 1 ) / 2;
  } 
  else {
	x = (N * (N - 1) / 2 )+ (M * (M - 1) / 2);
  }
  cout << x << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n, t;
P p[3005];
int dp[3005][6005];
signed main() {
	cin >> n >> t;
	rep(i, n) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + n);
	rep(i, n + 1)rep(j, 6005)dp[i][j] = -inf;
	dp[0][0] = 0;
	int ans = 0;
	rep(i, n) {
		rep(j, 3001) {
			if (dp[i][j] == -inf)continue;
			chmax(dp[i + 1][j + p[i].first], dp[i][j] + p[i].second);
		}
		rep(j, t + p[i].first)chmax(ans, dp[i + 1][j]);
		rep(j, 3001) {
			chmax(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 141056
left = "qwertasdfgzxcvb"
while true
    str = gets.chomp
    break if str == "#"
    hand = left.include?(str[0])
    prev = hand
    count = 0
    str[1..-1].each_char{|c|
        hand = left.include?(c)
        if prev != hand
            count += 1
            prev = hand
        end
    }
    puts count
end


Measured memory_bytes: 6860
import time

t1 = time.time()

N, M, P = map(int, input().split())
ABC = [tuple(map(int, input().split())) for _ in range(M)]

to_w = [set() for _ in range(N)]
for a, b, c in ABC:
    to_w[a - 1].add((b - 1, P - c))
reachable_from_start = {0}
q = {0}
while q:
    u = q.pop()
    for v, _ in to_w[u]:
        if v not in reachable_from_start:
            reachable_from_start.add(v)
            q.add(v)


from_w = [set() for _ in range(N)]
for a, b, c in ABC:
    from_w[b - 1].add((a - 1, P - c))
reachable_to_goal = {N - 1}
q = {N - 1}
while q:
    u = q.pop()
    for v, _ in from_w[u]:
        if v not in reachable_to_goal:
            reachable_to_goal.add(v)
            q.add(v)


reachable = reachable_from_start & reachable_to_goal


to_w = [set() for _ in range(N)]
for a, b, c in ABC:
    if a - 1 in reachable and b - 1 in reachable:
        to_w[a - 1].add((b - 1, P - c))
d = [float("inf")] * N
d[0] = 0
q = {0}
while q:
    u = q.pop()

    for v, w in to_w[u]:
        tmp = d[u] + w
        if tmp < d[v]:
            d[v] = tmp
            if v not in q:
                q.add(v)

        if time.time() > 1.9 + t1:
            d[-1] = -float("inf")
            break
    else:
        continue
    break

if d[-1] == -float("inf"):
    print(-1)
else:
    print(max(0, -d[-1]))


Measured memory_bytes: 9184
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
		String T = sc.next();
      
      	String[] Sarray = S.split("");
      	String[] Tarray = T.split("");
      
      	int count = 0;
      	for (int i=0; i<Sarray.length; i++){
          	if (!Sarray[i].equals(Tarray[i])){
              	count += 1;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 68640
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<LL,LL>
int N, M;
int L;
std::vector<int> v1,v2,v3;

int main(){
    std::cin >> L;
    int top = 0;
    while((1<<(top + 1)) <= L)top++;
    for(int i = 1; i <= top; i++){
        v1.push_back(i);
        v2.push_back(i+1);
        v3.push_back((1<<(i-1)));
        v1.push_back(i);
        v2.push_back(i+1);
        v3.push_back(0);
        M += 2;
    }
    int d = (1 << top) - 1;
    L -= (1 << top);
    for(int i = 0;i<=20;i++){
        if((L >> i) & 1){
            v1.push_back(i+1);
            v2.push_back(20);
            v3.push_back(d+1);
            d += (1 << i);
            M++;
        }
    }
    if(top!=19){
        v1.push_back(top+1);
        v2.push_back(20);
        v3.push_back(0);
        M++;
    }
    std::cout<<20 <<" " << M <<std::endl;
    for(int i = 0;i <M;i++){
        std::cout <<v1[i] <<" "<<v2[i] <<" "<<v3[i]<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%MOD;
        a=a*a%MOD;
        x>>=1;
    }
    return res;
}
string s;
int g(int i){
    if(i<0) return 0;
    if(i==0) return 1;
    if(i==1&&s[1]==s[0]) return 1;

}
int main(){
    int x;
    for(int i=0;i<5;i++){
        cin>>x;
        if(x==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    string v = "Vacant";
    
    vector<string> s(n);
    int l = 0;
    int r = n-1;
    cout << l << endl;
    cin >> s[l];
    if(s[l] == v) return 0;
    cout << r << endl;
    cin >> s[r];
    if(s[r] == v) return 0;

    while(r-l > 0){
        int mid = (l+r) / 2;
        cout << mid << endl;
        cin >> s[mid];
        if(s[mid] == v) return 0;

        if(s[mid] == s[l]){
            if((mid-l)%2 == 0) l = mid;
            else r = mid;
        }
        else{
            if((mid-l)%2 == 0) r = mid;
            else l = mid;
        }
    }

    return 0;

}

Measured memory_bytes: 6436
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	int n;
	cin >> n;

	if (n > 999) cout << "ABD"<< endl;
	else cout << "ABC"<< endl;

	return 0;
}


Measured memory_bytes: 256
import math


# def burger_generator(n):
#     if n == 0:
#         return int("101", 2)
#     else:
#         lt = burger_generator(n-1)
#         x1 = 1 + (lt << 1)
#         length = int(math.log2(x1)) + 1
#         x1 = x1 + (lt << length + 1)
#         length = int(math.log2(x1)) + 1
#         return x1 + (1 << length)


def f(N, X):
    if X == 1:
        # print(1)
        return 0 if not N == 0 else 1
    elif X <= 1 + size[N - 1]:
        # print(2)
        return f(N - 1, X - 1)
    elif X == 2 + size[N - 1]:
        # print(3)
        return patty[N - 1] + 1
    elif X <= 2 + 2 * size[N - 1]:
        # print(4)
        return patty[N - 1] + 1 + f(N - 1, X - 2 - size[N - 1])
    elif X == 3 + 2 * size[N - 1]:
        # print(5)
        return 2 * patty[N - 1] + 1


N, X = map(int, input().split())
# burger = format(burger_generator(N), "b")
# print(burger[-K:].count("0"))
size, patty = [1], [1]
for i in range(N):
    size.append(size[i] * 2 + 3)
    patty.append(patty[i] * 2 + 1)
# for i in range(N):
#     print(size)
# for i in range(N):
#     print(patty)
print(f(N, X))


Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int even = 0;
        int odd = 0;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (tmp % 2 == 0) {
                even++;
            } else {
                odd++;
            }
        }
        if (odd % 2 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}


Measured memory_bytes: 48836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 2007
#define SDOI2020 RP++ 
using namespace std;
char a,b,c; 
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}


int main()
{
	cin>>a>>b>>c;
	if(a != b || b != c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
} 

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

string a, b;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> a >> b;
	string s = a + b;
	int c = stoi(s);
	for(int i=0; i<1000; ++i)
		if(i * i == c){
			cout << "Yes\n";
			return 0;
		}
	cout << "No\n";
}

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

int main() {
	int N;
	cin >> N;
	ll h = 0;
	ll c = 0;
	for (int i = 0; i < N; i++) {
		ll A;
		cin >> A;
		if (h < A) {
			h = A;
		}
		else {
			c += h - A;
		}
	}
	cout << c << endl;
	return(0);
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
ll dp[51][51][2501];
int main()
{
    int n,a;cin >> n >> a;
    vector<int> x(n);rep(i,n)cin >> x[i];
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <=i ; j++)
        {
            for (int k = 0; k  < 2500; k  ++)
            {
                if(k+x[i]<=2500)
                {
                    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                }
                dp[i + 1][j][k] += dp[i][j][k];
            }
            
        }   
    }
    ll ans = 0;
    for (int i = 1; i <=n; i++)
    {
        ans+= dp[n][i][i*a];
    }
    
    cout << ans << endl;
}

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

;int main()
{
  ;int A, B;
  ;cin >> A >> B;
  ;if (A == 1) {
    A = 14;
  }
  ;if (B == 1) {
    B = 14;
  }
  ;if (A == B) {
    ;cout << "Draw" << endl;
  }
  else if (A > B) {
    ;cout << "Alice" << endl;
  }
  else {
    ;cout << "Bob" << endl;
  }
  ;return 0;
}


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

int main() {
    vector<int> o;
    int tmp, tcost = 0;
    for (int i = 0; i < 5; ++i) {
        cin >> tmp;
        o.push_back(tmp);
        tcost += ((tmp+9) / 10) * 10;
    }
    tmp = 644; 
    for (int i: o) {
        tmp = min(tmp, tcost - ((i+9) / 10) * 10 + i);
    }
    tcost = tmp;
    cout << tcost << endl;
    return 0;
}


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

mod=10**9+7
a.sort()

if n%2==0:
  b=[]
  for i in range(n//2):
    b.append((i*2+1))
    b.append((i*2+1))
  if a==b:
    ans=1
    for _ in range(n//2):
      ans=ans*2
      ans=ans%mod
      
    print(ans)
    
  else:
    print(0)
    
else:
  b=[0]
  for i in range((n-1)//2):
    b.append(((i+1)*2))
    b.append(((i+1)*2))
    
  if a==b:
    ans=1
    for i in range((n-1)//2):
      ans=ans*2
      ans=ans%mod
      
    print(ans)
      
  else:
    print(0)

Measured memory_bytes: 90616
x = int(input())
for a in range(1000 + 1):
    for b in range(1000 + 1):
        A = pow(a, 5)
        B = pow(b, 5)
        if A - B == x:
            print(a, b)
            exit()
        if A + B == x:
            print(a, -b)
            exit()
print("wrong")


Measured memory_bytes: 64480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt[26] = {};
    rep(i, 0, n) {
        cnt[s[i] - 'a']++;
    }

    ll ans = 1;
    rep(i, 0, 26) {
        if (cnt[i] != 0) {
            ans *= (cnt[i] + 1);
            ans = ans % mod;
        }
    }

    ans--;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int UF[5100];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
char in[20];
int b[5100];
int d[5100];
map<string,int>m;
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<a;i++){
		scanf("%s%d",in,b+i);
		string tmp=in;
		m[tmp]=i;
	}
	int c;scanf("%d",&c);
	for(int i=0;i<c;i++){
		scanf("%s",in);
		string p=in;
		scanf("%s",in);
		string q=in;
		UNION(m[p],m[q]);
	}
	for(int i=0;i<a;i++)d[i]=999999;
	for(int i=0;i<a;i++){
		d[FIND(i)]=min(d[FIND(i)],b[i]);
	}
	int ret=0;
	for(int i=0;i<a;i++){
		ret+=d[FIND(i)];
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1684
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> s = nextCharArray();
		HashSet<String> set = new HashSet<String>();
		for(int i = 0; i < s.size(); i++){
			set.add(s.get(i));
		}
		if(s.size() == set.size()){
			myout("yes");
		}else{
			myout("no");
		}
	}
	//Method addition frame start



	//Method addition frame end
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

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

    bool check = true;
    while(1){
        check = false;
        for(int i = 2; i * i < x; i++){
            if(x%i == 0){
                check = true;
                break;
            }
        }
        if(!check) break;
        x++;
    }
    cout << x << endl;
    


    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	a := nextFloat64()
	b := nextFloat64()

	fmt.Printf("%.10f", float64(a/b))
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

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

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
N,K = map(int,input().split())
D = []
A = []
for k in range(1,K+1):
    d = int(input())
    D.append(d)
    a = list(map(int, input().split()))
    for n in a:
        A.append(n)

for i in range(1,N+1):
    x = A.count(i)
    if x >= 2:
        for n in range(1,x):
            A.remove(i)

print(N - len(A))

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+7, LINF = 1e18;


int main()
{
    ll k,n;
    cin>>k>>n;
    ll a[n];
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    cout<<max(0LL,a[n-1]*2-k-1)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
vector<int> l;
int n, in[3];
vector<int> v[4];
int ans = 1<<30;

void dfs(int pos){
    if(pos == n){
        int tmp = 0, make[3] = {};
        for(int i = 0; i < 3; i++){
            tmp += max(0, (int)(v[i].size())-1)*10;
            for(int j : v[i])   make[i] += l[j];
            if(make[i] == 0)    return;
        }
        sort(in, in+3);
        do{
            ans = min(ans, tmp+abs(in[0]-make[0])+abs(in[1]-make[1])+abs(in[2]-make[2]));
        }while(next_permutation(in, in+3));
        return;
    }

    for(int i = 0; i < 4; i++){
        v[i].push_back(pos);
        dfs(pos+1);
        v[i].pop_back();
    }
}

int main(){
    cin >> n >> in[0] >> in[1] >> in[2];
    l.resize(n);
    for(int i = 0; i < n; i++)  cin >> l[i];
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int d[100010];
int main()
{

    int n;
    cin >> n;
    REP(i, n)
        cin >> d[i];

    sort(d, d + n);
    cout << d[n / 2] - d[n / 2 - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
function main(input) {
  var a = input[0].split(" ")[0]-0;
  var b = input[0].split(" ")[1]-0;
  if(b%a == 0) console.log(a+b);
  else console.log(b-a);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 21064
#include<iostream>

using namespace std;
typedef long long ll;

int main(){
    int K, S;
    int tmp, ans=0;

    cin >> K >> S;

    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            int k = S - i - j;
            if(k>=0 && k<=K){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define ll int
#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+500;
ll a[maxn];
ll b[maxn];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n;
	cin>>n;
	vector<ll> vec;
	multiset<ll> sta;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(i&1){
			sta.insert(a[i]);
		}
		b[i]=a[i];
	}
	sort(b,b+n);
	for(ll i=0;i<n;i++){
		if(i&1){
			multiset<ll> :: iterator it;
			it=sta.find(b[i]);
			if(it!=sta.end()){
				sta.erase(it);
			}
		}
	}
	cout<<sta.size();
}








Measured memory_bytes: 3328
def abc055_d():
    n = int(input())
    s = str(input())
    ss = s[-1] + s + s[0]

    def solve(ini1, ini0):
        res = [None] * (n+2)
        res[1] = ini1
        res[0] = ini0
        for i in range(1, n+1):
            if ss[i] == 'o':
                if res[i] == 'S' and res[i-1] == 'S': res[i+1] = 'S'
                if res[i] == 'S' and res[i-1] == 'W': res[i+1] = 'W'
                if res[i] == 'W' and res[i-1] == 'S': res[i+1] = 'W'
                if res[i] == 'W' and res[i-1] == 'W': res[i+1] = 'S'
            else:
                if res[i] == 'S' and res[i-1] == 'S': res[i+1] = 'W'
                if res[i] == 'S' and res[i-1] == 'W': res[i+1] = 'S'
                if res[i] == 'W' and res[i-1] == 'S': res[i+1] = 'S'
                if res[i] == 'W' and res[i-1] == 'W': res[i+1] = 'W'
        return res

    ans = '-1'
    ini = [('S','S'), ('S','W'), ('W','S'), ('W','W')]
    for ini1, ini0 in ini:
        res = solve(ini1, ini0)
        if res[0] == res[n] and res[1] == res[n+1]:
            ans = ''.join(res[1:n+1])
            break
    print(ans)

if __name__ == '__main__':
    abc055_d()

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
  int N; cin >> N;
  ll MOD = pow(10, 9) + 7;
  map<int64_t, int> m;
  for(int P = 1; P <= N; ++P) {
    for(auto x: prime_factor(P)) {
      while(x.second--) {
        m[x.first]++;
      }
    }
  }

  ll ans = 1;
  for(auto x: m) {
    ans *= (x.second + 1);
    ans = ans % MOD;
  }
  cout << ans << endl;
}


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

namespace A.AtCoder_Crackers
{
    class Program
    {
        static void Main(string[] args)
        {
            var N_K = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = N_K[0];
            int K = N_K[1];
            var ans = int.MaxValue;

            if (N % K == 0) ans = 0;
            else ans = 1;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define N 100000
const int MOD = 1000000007;

int main(void)
{
	char a[50] = { "\0" }, b[50] = { "\0" };
	char c[50] = { "\0" };
	int a1 = 0, b1 = 0;
	scanf("%s %s", a, b);
	scanf("%d %d", &a1, &b1);
	scanf("%s", c);
	if (!strcmp(a, c))
	{
		a1--;
	}
	else
	{
		b1--;
	}
	printf("%d %d", a1, b1);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
typedef std::pair<int,int> ipair;
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 = 1001001001;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    vector<int> sum(n, INF);
    rep(i,n) {
        if (i==0) {
            sum[0] = 0;
        } else {
            for (int j=1;j<=k;j++) {
                if (i>=j) chmin(sum[i], sum[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    
    cout << sum[n-1] << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll x;
  if (B > N) {
    x = N;
  } else {
    x = B - 1;
  }
  ll ans = (ll)(double(A) * double(x) / double(B)) - (ll)(A * (ll)(double(x) / double(B)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	static int n,m;
	static int[] v,t;
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		int l = a.length();
		for(int i = 0; i < l; i++){
			char c = a.charAt(i);
			if(c=='0'){
				sb.append(0);
			}else if(c=='1'){
				sb.append(1);
			}else{
				int len = sb.length();
				if(len!=0){
					sb.delete(len-1,len);
				}
			}
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 7892