akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N= 1e5 + 10;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}


int main()
{
    int n, k, d, a, ans;
    cin >> n >> k;
    int victim[10000];
    ans = n;
    for (int i = 0; i < k;i++)
    {
        cin >> d;
        while(cin>>a)
        {
            if(victim[a]==0)
            {
                ans--;
                victim[a] = 1;
            }
            char ch = getchar();
            if(ch=='\n')
                break;
        }
    }
    cout << ans;
    return 0;
}



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

int main(){
  int D, N;
  cin >> D >> N;
  if (D == 0){
    if (N == 100){
      cout << 101 << endl;
    } else {
    cout << N << endl;
    }
  }
  int tmp = 0;
  if (D == 1){
    if (N == 100){
      cout << 10100 << endl;
    } else {
    tmp = 100;
    cout << tmp * N << endl;
    }
  }
  if (D == 2){
    if (N == 100){
      cout << 1010000 << endl;
    } else {
    tmp = 10000;
    cout << tmp * N << endl;
    }
  }

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline


def dfs(v, par):
    for nv in tree[v]:
        if nv != par:
            adds[nv] += adds[v]
            dfs(nv, v)


n,q = map(int, input().split())
tree = [[]for _ in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

adds = [0] * n
for i in range(q):
    p,x = map(int, input().split())
    p -= 1
    adds[p] += x
dfs(0, -1)
print(*adds)


Measured memory_bytes: 230960
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        int i, n=0, count=0;
        for(i=a; i<=b; i++){
        	n = c%i;
        	if(n==0){
        		count++;
        	}
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 17304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
ll A[100000];

bool isbad(int x){

    bool flag = true;
    ll b = A[x];
    rep(i, N){
        if(i == x) continue;
        if(A[i] > b * 2) {
            flag = false;
            break;
        }
        else{
            b += A[i];
        }
    }

    return !flag;
}

// good most left = bad most right + 1
int binarySearch(){
    int left = 0;
    int right = N;

    if(!isbad(0)) return 0;
    if(isbad(N-1)) return N;

    while (left + 1 < right){
        int mid = (left + right) / 2;
        if(isbad(mid)) {
            left = mid;
        }
        else{
            right = mid;
        }
    }
    return right;
}

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];

    sort(&A[0], &A[N]);

    int first = binarySearch();

    cout << N - first << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

string s[1010];
signed main(void)
{
	while(true) {
		int n;
		cin >> n;
		if(!n) break;
		REP(i, n) cin >> s[i];

		REP(i, n) {
			REP(j, s[i].size()) {
				if(s[i][j] == '.') {
					if(s[i][j+1] == '.') s[i][j] = ' ';
					else s[i][j] = '+';
				} else {
					break;
				}
			}
		}

		for(int i=n-1; i>0; --i) {
			int idx = 0;
			REP(j, s[i].size()) {
				if(s[i][j] == '+') {idx = j; break;}
			}
			//??????????????£?????????
			for(int j=i-1; j>=0; --j) {
				if(s[j][idx] == ' ') s[j][idx] = '|';
				else break;
			}
		}

		REP(i, n) cout << s[i] << endl;
	}
	return 0;
}

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

int main(){
  long D, N;
  cin >> D >> N;
  if(D==0){
    if(N!=100){
      cout << N << endl;
    }else{
      cout << "101" << endl;
    }
    return 0;
  }
  if(D==1){
    if(N!=100){
      cout << N*100 << endl;
    }else{
      cout << 10100 << endl;
    }
    return 0;
  }
  if(N!=100){
    cout << N*10000 << endl;
  }else{
    cout << 1010000 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
import math

a = int(input())
b = int(input())
c = int(input())
x = int(input())

counter = 0

a_min = min( math.floor(x/500) ,a)
for ai in range(a_min+1):
    rem_a = x - (ai * 500)
    # print("500円玉 * {} のパターン".format(ai))
    # print("残り {}".format(rem_a))

    if rem_a == 0:
        counter+=1
        break

    b_min = min( math.floor(rem_a/100) ,b)
    for bi in range(b_min+1):
        rem_b = rem_a - (bi * 100)
        # print("----100円玉 * {} のパターン".format(bi))
        # print("    残り {}".format(rem_b))

        if rem_b == 0:
            counter+=1
            break

        c_min = min( math.floor(rem_b/50) ,c)
        for ci in range(c_min+1):
            rem_c = rem_b - (ci * 50)
            # print("--------50円玉 * {} のパターン".format(ci))
            # print("        残り {}".format(rem_c))

            if rem_c == 0:
                counter+=1
                break

print(counter)






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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, b, c) = [int(e) for e in lines[0].split(" ")]
    k = int(lines[1])

    return (a, b, c, k)


def solve(a, b, c, k):

    a2 = a
    b2 = b
    c2 = c
    tmp = k
    while tmp > 0 and b2 <= a2:
        tmp = tmp - 1
        b2 = 2 * b2

    while tmp > 0 and c2 <= b2:
        tmp = tmp - 1
        c2 = 2 * c2

    if c2 > b2 and b2 > a2:
        result = 'Yes'
    else:
        result = 'No'
    
    return result    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62288
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
//#define fastio; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;

int main()
{
    int s,w;
    cin>>s>>w;

    if(w>=s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

void dec(vector<int>& ans, int keta, int k){
	if(ans[keta] == 0){
		dec(ans, keta-1, k);
		if(ans[keta-1] != 0){
			ans[keta] = k;
		}
	}else{
		ans[keta]--;
	}
}

int main(void){
	ll k,n;
	cin>>k>>n;
	if(k==1){
		rep(i, (n+1)/2){
			cout<<1<<" ";
		}
		cout<<endl;
		return 0;
	}
	if(k%2 == 0){
		cout<<k/2;
		rep(i,n-1){
			cout<<" "<<k;
		}
		cout<<endl;
	}else{
		vector<int> ans;
		rep(i,n){
			ans.push_back(k/2+1);
		}
		rep(i,n/2){
			dec(ans, n-1, k);
		}
		rep(i,n){
			if(ans[i] == 0) break;
			cout<<ans[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#define MOD 1000000007

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    long long dp[k + 1]; for (int i = 0; i <= k; i++) dp[i] = 0;
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        long long tot = 0;
        for (int j = k; j >= max(0, k - a); j--) {
            tot += dp[j];
            tot %= MOD;
        }
        for (int j = k; j >= 0; j--) {
            long long tmp = dp[j];
            dp[j] = tot; dp[j] %= MOD;
            tot -= tmp; tot += MOD; tot %= MOD;
            if (j - a - 1 >= 0) {
                tot += dp[j - a - 1];
                tot %= MOD;
            }
        }
    }
    cout << dp[k];
    return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSnack solver = new CSnack();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSnack {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            long a = s.nextLong();
            long b = s.nextLong();
            long gcd = CSnack.Maths.gcd(a, b);
            out.println((a * b) / gcd);

        }

        private static class Maths {
            private static long gcd(long a, long b) {
                if (b == 0) {
                    return a;
                }

                return gcd(b, a % b);
            }

        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

// ll modexp(ll x, ll y, ll p)
// {
// 	ll res = 1;
// 	x = x % p;
// 	while (y > 0)
// 	{
// 		if (y & 1)
// 			res = (res * x) % p;
// 		y = y >> 1;
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll mulmod(ll a, ll b)
// {
// 	return ((a % mod) * (b % mod)) % mod;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b) 
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

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

// ll modInv(ll a) 
// { 
//     ll g = gcd(a, mod); 
//     if (g != 1) 
//         return -1; 
//     else
//         return modexp(a, mod-2, mod); 
// } 


int main()
{
	fastio;
//#ifndef ONLINE_JUDGE   
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	ll n = 0;
	cin >> n;
	if (n % 2 == 0)
		cout << n;
	else
		cout << 2 * n;

	
}



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

using namespace std;

int main()
{
    int n; cin >> n;
    int a = 100000;

    for (int i = 0; i < n; ++i) {
        a += (double)a * (5 / 100.0);
        a += (1000 - a % 1000) % 1000;
    }

    cout << a << endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a+b==15)
        printf("+");
    else if(a*b==15)
        printf("*");
    else if(a+b!=15 || a*b!=15)
        printf("x");
    return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std;

int n,t;
long long dp[60][2];
int a[60];

int main()
{
	scanf("%d %d",&n,&t);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]+=dp[i-1][0];
		dp[i][1]+=dp[i-1][1];
		if(a[i]%2)
		{
			dp[i][0]+=dp[i-1][1];
			dp[i][1]+=dp[i-1][0];
		}
		else
		{
			dp[i][0]+=dp[i-1][0];
			dp[i][1]+=dp[i-1][1];
		}
	}
	cout<<dp[n][t];
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>

const int MaxN = 200000;
const int INF = 0x7F7F7F7F;

struct data {
  int w, l, r;
  data(int _w = 0, int _l = 0, int _r = 0) { w = _w, l = _l, r = _r; }
  inline friend bool operator < (const data &x, const data &y) { return x.w > y.w; }
};

int N;
int A[MaxN + 5];
int B[MaxN + 5];
std::priority_queue<data> Pq;

template <const int Size>
class sparse_table {
private:
  int value[Size + 5];
  int arr[20][Size + 5];
  int log2[Size + 5];
public:
  void init(int *a, int n) {
    for (int i = 2; i <= n; ++i)
      log2[i] = log2[i >> 1] + 1;
    for (int i = 1; i <= n; ++i) {
      value[i] = a[i];
      arr[0][i] = i;
    }
    for (int i = 1; (1 << i) <= n; ++i)
      for (int j = 1; j + (1 << i) - 1 <= n; ++j) {
        int vl = arr[i - 1][j], vr = arr[i - 1][j + (1 << (i - 1))];
        if (value[vl] < value[vr]) arr[i][j] = vl;
        else arr[i][j] = vr;
      }
  }

  inline int query(int l, int r) {
    int k = log2[r - l + 1];
    int vl = arr[k][l], vr = arr[k][r - (1 << k) + 1];
    if (value[vl] < value[vr]) return vl;
    else return vr;
  }
};
sparse_table<MaxN> St[2];

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
}

void solve() {
  static int tmp[MaxN + 5];
  for (int i = 1; i <= N; ++i)
    if (i & 1) tmp[i] = A[i];
    else tmp[i] = INF;
  St[1].init(tmp, N);
  for (int i = 1; i <= N; ++i)
    if (i & 1) tmp[i] = INF;
    else tmp[i] = A[i];
  St[0].init(tmp, N);
  Pq.push(data(A[St[1].query(1, N)], 1, N));
  int cnt = 0;
  while (!Pq.empty()) {
    data d = Pq.top();
    // printf("d = (%d, %d, %d)\n", d.w, d.l, d.r);
    Pq.pop();
    int m1 = St[d.l & 1].query(d.l, d.r);
    int m2 = St[(m1 + 1) & 1].query(m1 + 1, d.r);
    B[++cnt] = A[m1];
    B[++cnt] = A[m2];
    if (d.l <= m1 - 1) Pq.push(data(A[St[d.l & 1].query(d.l, m1 - 1)], d.l, m1 - 1));
    if (m1 + 1 <= m2 - 1) Pq.push(data(A[St[(m1 + 1) & 1].query(m1 + 1, m2 - 1)], m1 + 1, m2 - 1));
    if (m2 + 1 <= d.r) Pq.push(data(A[St[(m2 + 1) & 1].query(m2 + 1, d.r)], m2 + 1, d.r));
  }
  for (int i = 1; i <= N; ++i)
    printf("%d%c", B[i], " \n"[i == N]);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 38776
#include<iostream>
using namespace std;
int main ()
{
      int n,k,i,j,sum=0;
      cin>>n;
      cin>>k;
      int arr[n];

       for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(arr[j]>arr[j+1])
            {

                int temp=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=temp;
            }
        }
    }
    for(i=0;i<k;i++)
  //  cout<<arr[i]<<" ";
    {
        sum=sum+arr[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3156
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
INF = 10**12
N, M, L = map(int, input().split())

A = []; B = []; C = []
for i in range(M):
    a, b, c = map(int, input().split())
    A.append(a - 1); B.append(b - 1); C.append(c)
A = np.array(A); B = np.array(B); C = np.array(C)

graph = csr_matrix((C, (A, B)), (N, N))
d = floyd_warshall(graph, directed=False)

d[d <= L] = 1
d[d > L] = INF

d = floyd_warshall(d, directed=False)

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    if d[s - 1][t - 1] != INF:
        print(int(d[s - 1][t - 1]) - 1)
    else:
        print(- 1)

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

typedef long long ll;

bool isPrime(int n) {
    if (n < 2) return false;
    for (int i = 2; i * 1LL * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    for (int i = x; ; ++i) {
        if (isPrime(i)) {
            cout << i << endl;
            return 0;
        }
    }
    assert(false);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 401;
int dp[maxn][maxn];
int pref[maxn];
signed main() {
	int n;
	cin >> n;
	vector<int>a(n + 1);
	for (int i = 1; i <= n; i++)cin >> a[i];
	pref[0] = 0;
	for (int i = 1; i <= n; i++)pref[i] = pref[i - 1] + a[i];
	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < maxn; j++)dp[i][j] = LLONG_MAX;
	}
	for (int i = 0; i < maxn; i++)dp[i][i] = 0;
	for (int i = 1; i <= n - 1; i++) {
		for (int l = 1; l <= n; l++) {
			if (l + i >= maxn)continue;
			int r = l + i;
			for (int m = l; m < r; m++) {
				dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r] + pref[r] - pref[l - 1]);
			}
		}
	}
	cout << dp[1][n];
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin>>N;
vector<int>d(N);
rep(i,N)cin>>d[i];
sort(d.begin(),d.end());
int num_k=d[N/2]-d[N/2-1];
cout<<num_k<<endl;
//system("pause");
return 0;
}

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

const int INF = 1<<30;
vector<int> num, dp, ans;
vector<vector<int>> G;

void dfs(int u){
    int i = lower_bound(all(dp), num[u]) - dp.begin();
    int save = dp[i]; dp[i] = num[u];
    ans[u] = lower_bound(all(dp), INF) - dp.begin();
    for(auto next : G[u]) if(ans[next] == 0) dfs(next);
    dp[i] = save;
}

int main(){
    int n; cin >> n;
    num.assign(n, 0); rep(i,n) cin >> num[i];
    dp.assign(n, INF);
    ans.assign(n, 0);
    G.assign(n, vector<int>());
    rep(i,n-1){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0);

    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 25080
N, K = map(int, input().split())

ans = [0] * (N)
for i in range(K):
    d = int(input())
    l = list(map(int, input().split()))
    for j in l:
        ans[j-1] += 1

a = 0
for i in ans:
    if i == 0:
        a += 1

print(a)


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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  int S = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    S += a[i];
  }
  bitset<4000001> bs;
  bs[0] = 1;
  for (int i = 0; i < n; i++) {
    bs |= (bs << a[i]);
  }
  int ans = 0;
  for (int i = 0; i <= 4000000; i++) {
    if (i * 2 >= S && bs[i]) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
A = int(input())
if A <=111:
  print(111)
elif A<= 222:
  print(222)
elif A <= 333:
  print(333)
elif A <= 444:
  print(444)
elif A <= 555:
  print(555)
elif A <=666:
  print(666)
elif A <= 777:
  print(777)
elif A <= 888:
  print(888)
elif A <=999:
  print(999)

Measured memory_bytes: 3060
#include<stdio.h>
int main ()
{
	int a,b,c,d,i,j;
	int x[11],y[11];
	for(i=0;i<10;i++)
	{
		scanf("%d",&x[i]);
	}
	for(i=0;i<10;i++)
	{
		for(j=i+1;j<10;j++)
		{
			if(x[i]<x[j])
			{
				a=x[i];
				x[i]=x[j];
				x[j]=a;
			}
		}
	}
	for(i=0;i<10;i++)
	{
		scanf("%d",&y[i]);
	}
	for(i=0;i<10;i++)
	{
		for(j=i+1;j<10;j++)
		{
			if(y[i]<y[j])
			{
				a=y[i];
				y[i]=y[j];
				y[j]=a;
			}
		}
	}
	b=x[0]+x[1]+x[2];
	c=y[0]+y[1]+y[2];
	printf("%d %d\n",b,c);
	return 0;
}


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

const int MAX = 200;
const int INF = 1e5;

int N, M;
int cost[MAX][MAX];

int main() {
  cin >> N >> M;
  // 前処理
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cost[i][j] = (i == j ? 0 : INF);
    }
  }
  // 入力
  int a[M], b[M], c[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i], --b[i];
    cost[a[i]][b[i]] = cost[b[i]][a[i]] = c[i];
  }
  
  // ワーシャルフロイド法
  for (int k = 0; k < N; k++) { // 経由頂点
    for (int i = 0; i < N; i++) { // 出発頂点
      for (int j = 0; j < N; j++) { // 終了頂点
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (cost[a[i]][b[i]] != c[i]) ++ans;
  }

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


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

    signed main() {
        int n,m,a,b;
        cin>>n>>m;
        bool ans[n]={};
        for(int i=0;i<m;i++){
            cin>>a>>b;
            ans[a-1]=!ans[a-1];
            ans[b-1]= !ans[b-1];
        }
        for(int i=0;i<n;i++){
            if(ans[i]){
                cout<<"NO"<<endl;
                return 0;
            }
        }
        cout<<"YES"<<endl;
    }


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    string a, s, c;
    cin >> a >> s >> c;
    cout << 'A' << s[0] << 'C' << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int sum, input, numbers[3];

    for(int i = 0; i < 3; i++) {
        cin >> input;
        numbers[i] = input;
        sum += numbers[i];
    }

    if(sum <= 21) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }

    return 0;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	ll a;
  cin >> a;
  vector<ll> b(a);
  froop1(0,a){
    cin >> b.at(i);
  }
  ll max = 0,sum = 0;
  froop1(0,a){
    if(max < b.at(i))max = b.at(i);
    else sum += max - b.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 4764
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

#include<queue>

using namespace std;

int main() {

	int N, M;
	cin >> N >> M;

	priority_queue< pair<int, int> > cards;
	for (int i = 0; i < N; i++)
	{
		int tmp = 0;
		cin >> tmp;
		cards.push(make_pair(tmp,1));
	}
	for (int i = 0; i < M; i++)
	{
		int B, C;
		cin >> B >> C;

		cards.push(make_pair(C, B));
	}

	long long result = 0;
	for (int i = 0; i < N; i++)
	{
		auto tmp = cards.top();
		cards.pop();
		result += tmp.first;
		--tmp.second;
		if (tmp.second != 0)
		{
			cards.push(tmp);
		}
	}

	cout << result << endl;


	return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
}

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    while(A>0 or C>0){
        C -= B;
        if(C <= 0) break;
        A -= D;
        if(A <= 0) break;
    }
    if(C<=0) cout << "Yes" << endl;
    if(A<=0) cout << "No" << endl;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <queue>

using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
#define F first
#define S second
#define mkp make_pair
#define PB push_back
#define ALL(v) v.begin(),v.end()
#define maxs(a,b) (a=max(a,b))
#define mins(a,b) (a=min(a,b))
const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef pair<int,int> pii;

int dp[40][40][4];
int dd[]={-1,0,1,0,-1};
typedef pair<pii,pii> P;
int w,h;

bool inside(pii a){
	return 0<=a.F&&a.F<h&&0<=a.S&&a.S<w;
}


int main(){
	while(cin>>w>>h,h||w){
		vvint vv(h,vint(w));
		rep(i,h){
			rep(j,w) cin>>vv[i][j];
		}
		vint co(4);
		rep(i,4) cin>>co[i];
		// rep(i,4) cout<<co[i]<<" ";cout<<endl;
		rep(i,40) rep(j,40) rep(k,4) dp[i][j][k]=INF;
		dp[0][0][1]=0;
		priority_queue<P> pq;
		pq.push(mkp(pii(0,1),pii(0,0)));
		while(pq.size()){
			P top=pq.top();
			pii pos = top.S;
			int cost = -top.F.F;
			int di = top.F.S;
			pq.pop();
			if(dp[pos.F][pos.S][di]<cost) continue;
			// cout<<pos.F<<" "<<pos.S<<" "<<di<<" "<<cost<<endl;
			if(vv[pos.F][pos.S]!=4){
				int nd = (di+vv[pos.F][pos.S])%4;
				pii npos(pos.F+dd[nd],pos.S+dd[nd+1]);
				if(inside(npos)){
					if(dp[npos.F][npos.S][nd]>cost){
						dp[npos.F][npos.S][nd]=cost;
						pq.push(mkp(pii(-cost,nd),npos));
					}
				}
			}
			rep(i,4){
				int nd = (di+i)%4;
				pii npos(pos.F+dd[nd],pos.S+dd[nd+1]);
				if(inside(npos)){
					if(dp[npos.F][npos.S][nd]>cost+co[i]){
						dp[npos.F][npos.S][nd]=cost+co[i];
						pq.push(mkp(pii(-cost-co[i],nd),npos));
					}
				}	
			}
		}
		int ans = INF;
		rep(i,4){
			mins(ans,dp[h-1][w-1][i]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes";
			break;
		}
		a-=d;
		if(a<=0){
			cout<<"No";
			break;
		}
	} 
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;

int main(void){
	cin >> str;
	int ans=str.size();
	ans--;
	for(int i=0;i<26;i++){
		string nex=str;
		for(int j=0;j<=ans;j++){
			bool flag=true;
			for(int k=0;k<nex.size();k++){
				if(nex[k]!=('a'+i))flag=false;
			}
			if(flag){
				ans=(j);
				break;
			}
			string tmp="";
			for(int k=1;k<nex.size();k++){
				if(nex[k]==('a'+i) || nex[k-1]==('a'+i)){
					tmp+=('a'+i);
				}else{
					tmp+=nex[k];
				}
			}
			nex=tmp;
			
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<pair<long long int, long long int>>num(N + 1);
	num[0].second = N;
	for (int i = 1; i <= N; i++) {
		cin >> num[i].first;
		num[i].second = N - i;
	}
	sort(num.begin(), num.end());
	R = N;
	M = num[N].second;
	long long int sum = num[N].first;
	vector<long long int>ans(N + 1);
	for (int i = N - 1; i >= 0; i--) {
		if (M > num[i].second) {
			sum += num[i].first;
			continue;
		}
		ans[N-M] = sum - num[i].first*(N - i);
		R = i;
		sum = (N - i + 1)*num[i].first;
		M = num[i].second;
	}
	for (int i = 1; i <= N; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

signed main() {
  int N; cin >> N;
  
  set<int> S;
  rep(i,0,N) {
    int val; cin >> val;
    if(!S.count(val)) {
      S.insert(val);
    }
    else {
      S.erase(val);
    }
  }
  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct infant {
    int id;
    ll score;

    bool operator<(const infant& other) const {
        if (score < other.score) return true;
        else return false;
    }
};

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<infant> infants(N);
    REP(i, N) {
        infants[i].id = i;
        infants[i].score = A[i];
    }

    sort(ALL(infants));
    reverse(ALL(infants));

    vector< vector<ll> > dp(N+1, vector<ll>(N+1));
    dp[0][N] = 0; // dp[l][r]: 1~l、r~Nまで入ってる

    REP(i, N) {
        infant c = infants[i];
        REP(l, i+1) {
            int r = N + l - i;
            // if(dp[l+1][r] > dp[l][r] + c.score * abs(l - c.id)) {
            //     cerr << "l = " << l << " r = " << r << endl;
            // }
            // if(dp[l][r-1] > dp[l][r] + c.score * abs(r - 1 - c.id)) {
            //     cerr << "l = " << l << " r = " << r << " dp[l][r-1] = " << dp[l][r-1] << endl;
            // }
            // cerr << "i = " << i << " l = " << l << " r = " << r << " dp[l+1][r] = " << dp[l+1][r] << " dp[l][r-1] = " << dp[l][r-1] << endl;
            dp[l+1][r] = dp[l][r] + c.score * abs(l - c.id);
            dp[l][r-1] = max(dp[l][r-1], dp[l][r] + c.score * abs(r - 1 - c.id));
        }
    }

    ll ans = 0;
    REP(i, N) if(ans < dp[i][i]) ans = dp[i][i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 34616
n = int(input())

ab = [list(map(int, input().split())) for _ in range(n)]

res = 0

for i in  range(n):
    a = ab[i][0]
    b = ab[i][1]
    
    if a==b:
        res +=1
    else:
        res =0
    
    if res ==3:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //bit全探索を用いる
  string S;
  cin >> S;
  long long int ans = 0;
  for (int bit = 0; bit < (1<<(S.size()-1)); bit++) { //　Sの部分集合の全探索 (数と数の間について+が入るかどうかを全列挙)
      int s = 0; //考えている現在地
      for (int i=0; i<S.size()-1; i++) {
          if (bit & (1 << i)) { //iがbitに入るかどうか
              ans += stoll(S.substr(s, i - s + 1)); //+が入る部分までを加える
              s = i + 1; //+が入る位置の右隣まで現在地を進める
          }
      }
      ans += stoll(S.substr(s, S.size() - s));//最後に+が入った位置から最後の数字までを加える
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
length = gets.to_i
arr = gets.split.map(&:to_i)

def insertion_sort(arr, length)
  for i in 1..(length-1) do
    v = arr[i]
    sub = 0
    while i - 1 - sub >=0 && arr[i - sub -1] > v do
      arr[i - sub] = arr[i - sub - 1]
      sub += 1
    end
    arr[i - sub] = v
    puts arr.join(' ')
  end
end

puts arr.join(' ')
insertion_sort(arr, length)


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

int main() {
  int N,count,mini,x;
  cin >>N;
  vector<int>p(N);
  for(int i;i<N;i++){
  	cin >>p.at(i);
  }
  mini=1+N;
 for(int i;i<N;i++){
 	x=p.at(i);
   mini=min(mini,x);
   if(mini==x){count++;}
 }
  cout <<count <<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

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

	string a, b;
	cin >> a >> b;

	rep(i, a.size()){
		cout << a[i];
		if(i < b.size())
		cout << b[i];
	}


	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define inf 1e8

using namespace std;

int main(){
    int n,m;
    cin >>n >> m;
    int a[1000],b[1000],c[1000],dis[1000][1000];
    
    for (int i=1;i<=m;i++){
        cin >> a[i] >> b[i]>> c[i];
    }
    //初期化
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            if(i==j) dis[i][j]=0;
            else dis[i][j]=inf;
        }
    }
    //数値入れ
    for (int i=1;i<=m;i++){
        dis[a[i]][b[i]]=min(dis[a[i]][b[i]],c[i]);
        dis[b[i]][a[i]]=min(dis[b[i]][a[i]],c[i]);
    }
    
    //ワーシャルフロイド
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    
    //検査
    int ans=m;
    for (int i=1;i<=m;i++){
        bool use=0;
        for(int j=1;j<=n;j++){
            if(dis[j][a[i]]==dis[j][b[i]]+c[i]) use=1;
        }
        if(use) ans--;
    }
    cout << ans << endl;
    
    
}



Measured memory_bytes: 2688
import bisect
N, K = map(int, input().split())
x = list(map(int, input().split()))
if 0 not in x:
    bisect.insort(x, 0)
    N += 1
    K += 1
ans = 10 ** 9
for i in range(N-K+1):
    lo, hi = x[i], x[i+K-1]
    if lo <= 0 <= hi:
        ans = min(ans, abs(lo) + hi + min(abs(lo), hi))
print(ans)

Measured memory_bytes: 62576
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    while(true) {
        int N, M;
        cin >> N >> M;
        if(N == 0 && M == 0) break;
        vector<ll> C(M), x(N+1);
        REP(i, M) cin >> C[i];
        REP(i, N) cin >> x[i+1];
        vector< vector<ll> > dp(N+1, vector<ll>(256, 1e18));

        dp[0][128] = 0;

        FOR(i, 1, N) {
            REP(j, M) {
                REP(k, 256) {
                    int y_next = min(max(0ll, k + C[j]), 255ll);
                    if(dp[i][y_next] > dp[i-1][k] + (y_next - x[i]) * (y_next - x[i])) {
                        dp[i][y_next] = dp[i-1][k] + (y_next - x[i]) * (y_next - x[i]);
                    }
                }
            }
        }

        ll ans = 1e9;
        REP(i, 256) if(ans > dp[N][i]) ans = dp[N][i];

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


Measured memory_bytes: 43756
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll ans = min(A, B);
  ans += min(C, D);
  ANS;
  return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

int VMAX = 1000;
ll MAX = 10000000000000;

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

    int N, M;
    cin >> N >> M;

    vvi outadj(N);
    vi indeg(N, 0);

    for(int i=0;i<M;i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        outadj[x].push_back(y);
        indeg[y]++;
    }

    vi order;
    queue<int> bfs;
    for(int i=0;i<N;i++) {
        if (indeg[i] == 0) bfs.push(i);
    }

    while (!bfs.empty()) {
        int cur = bfs.front(); bfs.pop();

        order.push_back(cur);

        for (int nbr : outadj[cur]) {
            indeg[nbr]--;
            if(indeg[nbr] == 0) bfs.push(nbr);
        }
    }

    vi lp(N, 0);
    for (int v : order) {
        for (int w : outadj[v]) {
            lp[w] = max(lp[w], 1 + lp[v]);
        }
    }

    int ans = 0;
    for (int i=0;i<N;i++) ans = max(ans, lp[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7032
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	int num, ber = 1;
	cin >> num;
	while (true)
	{
		ber *= 2;
		if (ber > num)
		{
			ber /= 2;
			break;
		}
	}

	cout << ber << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;

  int k = 0;
  string before = "";
  string tmp = "";
  for (int i = 0; i < s.size(); i++) {
    tmp += s[i];
    if (tmp != before) {
      k++;
      before = tmp;
      tmp = "";
    }
  }
  cout << k << endl;


}

Measured memory_bytes: 640
count = int(input())

a = list(map(int,input().split()))
    
c =0
bool = True
while (bool):
    for i in range(count):
        if a[i]%2 == 0:
            a[i]/=2
        else:
            bool = False
            break
    else:
        c+=1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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 main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    double T, X;

    cin >> T >> X;

    cout << T / X << endl;


    return 0;
}


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

using namespace std;

int main() {

	string S;
	cin >> S;

	if((S[2] == S[3]) && (S[4] == S[5])) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

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

class Program
{
  static void Main()
  {
    var s = Console.ReadLine();
    int n = s.Length;
    
    int j = (n-1)/2 + 1;
    int jfoot = n - 1;
    int ifoot = (n-1)/2 - 1;
    for (int i = 0; i < (n-1) / 2; i++, j++)
    {
      if (s[i] != s[ifoot - i] || s[j] != s[jfoot - i] || 
          s[i] != s[jfoot - i] || s[j] != s[ifoot - i])
      {
        Console.WriteLine("No");
        return;
      }
    }
    Console.WriteLine("Yes");
  }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
  using namespace std;
  #define       M                        1000000007
  #define       ll                       long long
  #define       FIO                      ios_base::sync_with_stdio(false);cin.tie(NULL)
  #define       ifor(st,lim)             for(int i=st;i<lim;i++)
  #define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
  #define       eifor(st,lim)            for(int i=st;i<=lim;i++)
  #define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
  #define       blank                    cout<<'\n' 


void solve()
{ 
   int n; cin>>n;
   int a[n];
   ifor(0,n) cin>>a[i];
   sort(a,a+n);
   int ans = 0;
   for(int i=0;i<n;i++) {
    for(int j=0;j<i;j++) {
      for(int k=0;k<j;k++) {
        if(a[i] != a[j] and a[j] != a[k] and a[k]+a[j] > a[i]) ans++;
      }
    }
   }
   cout<<ans;  
}
 
  int main()
  {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
  int t=1;
  while(t--){
      solve();
     } 
  }

Measured memory_bytes: 3608
n = gets.to_i

divisor = 1000000007

dp = Array.new(n+1) { Array.new(4, 0) }
dp[1] = [0, 1, 1, 8]

1.upto(n-1) do |i|

  dp[i+1][0] = (dp[i][0]*10 + dp[i][1] + dp[i][2]) % divisor
  dp[i+1][1] = (dp[i][1]*9 + dp[i][3]) % divisor
  dp[i+1][2] = (dp[i][2]*9 + dp[i][3]) % divisor
  dp[i+1][3] = (dp[i][3]*8) % divisor

end

# dp.each do |a|
#   p a
# end

puts dp.last.first


Measured memory_bytes: 114676
import numpy as np
N,M,C = map(int,input().split())
B = [int(k) for k in input().split()]
A = [[int(j) for j in input().split()] for i in range(N)] 
b = np.array(B)
cnt = 0
for i in range(N):
    if (np.dot(np.array(A[i]),b) + C >0):
        cnt += 1
    else:
        cnt = cnt
        
print(cnt)




Measured memory_bytes: 12448