akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct edge {
    int vertex;
    int len;
};

struct status {
    int vertex;
    int dis;
    bool is_last_cold;
    int ban_time;

    bool operator>(const status &rhs) const {
        if (dis != rhs.dis) return dis > rhs.dis;
        return vertex > rhs.vertex;
    }
};

int n, x;
vector<int> temperature;
vector<vector<edge>> graph;
vector<vector<vector<int>>> dis;

void dijkstra(int s) {
    priority_queue<status, vector<status>, greater<>> que;
    dis = vector<vector<vector<int>>>(n, vector<vector<int>>(2, vector<int>(x + 1, 1145141919)));
    dis[s][true][x] = 0;
    que.push(status{s, 0, true, x});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        int scored_dis = dis[now.vertex][now.is_last_cold][now.ban_time];
        if (scored_dis < now.dis)continue;

        for (auto next:graph[now.vertex]) {
            if (temperature[next.vertex] == 0 && !now.is_last_cold && now.ban_time > next.len)continue;
            if (temperature[next.vertex] == 2 && now.is_last_cold && now.ban_time > next.len)continue;

            bool next_is_cold;
            int next_ban_time;
            if (temperature[next.vertex] == 1) {
                next_is_cold = now.is_last_cold;
                next_ban_time = max(0, now.ban_time - next.len);
            } else {
                next_is_cold = temperature[next.vertex] == 0;
                next_ban_time = x;
            }

            if (dis[next.vertex][next_is_cold][next_ban_time] > now.dis + next.len) {
                for (int i = next_ban_time; i <= x; i++) {
                    if (dis[next.vertex][next_is_cold][i] <= now.dis + next.len)break;
                    dis[next.vertex][next_is_cold][i] = now.dis + next.len;
                }
                que.push({next.vertex, now.dis + next.len, next_is_cold, next_ban_time});
            }
        }
    }
}

int main() {
    int m;
    cin >> n >> m >> x;
    temperature = vector<int>(n);
    for (int i = 0; i < n; i++)cin >> temperature[i];
    graph = vector<vector<edge>>(n);
    for (int i = 0; i < m; i++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        graph[from].push_back({to, cost});
        graph[to].push_back({from, cost});
    }

    dijkstra(0);

    cout << min(dis[n - 1][0][x], dis[n - 1][1][x]) << endl;
    return 0;
}


Measured memory_bytes: 20572
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll p, m, c;
    cin >> p >> m >> c;
    cout << p + m + c << endl;
    return 0;
}



Measured memory_bytes: 3212
loop {
  sum = 0
  m_score,f_score,r_score = gets.split.map(&:to_i)
  break if m_score == -1 && f_score == -1 && r_score == -1
  sum = m_score + f_score

  if m_score == -1 || f_score == -1
    puts "F" 
  else
    if sum >= 80
      puts "A"
    elsif sum < 80 && sum >= 65
      puts "B"
    elsif sum < 65 && sum >= 50
      puts "C"
    elsif sum < 50 && sum >= 30
      if r_score >= 50
        puts "C"
      else
        puts "D"
      end
    else 
      puts "F"
    end
  end
}



Measured memory_bytes: 8888
#include <stdio.h>
#include <math.h>
 
int data[1000];

int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int i,j,sum=0,a;
		for(i=0;i<n;i++)
		{
			scanf("%d",&data[i]);
			if(data[i]%2==0)
			{
				sum++;
			}
		}
		a = pow(3,n)-pow(2,sum);
		printf("%d\n",a);
	}
	
	return 0;
}

Measured memory_bytes: 256
S = {}
S['a'] = input()
S['b'] = input()
S['c'] = input()


next = 'a'
lens = {'a':len(S['a']), 'b':len(S['b']), 'c':len(S['c'])}
counts = {'a':0, 'b':0, 'c':0}

while True:
  now = next
  counts[now]
  if counts[now] == lens[now]:
    print(now.upper())
    exit()
  next = S[now][counts[now]]
  counts[now] += 1


Measured memory_bytes: 3064
int main()
{
    int n, x, max;
    int a, b, c;
    int ans;
 
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
 
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}



Measured memory_bytes: 2112
n, a, b = gets.split.map{|i| i.to_i}
ans = 0
for i in 1..n do
    t = i.to_s.chars
    temp = 0
    t.each do |p|
        temp+=p.to_i
    end
    if a<=temp && temp<=b then
        ans+=i
    end
end
puts ans

Measured memory_bytes: 1788
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void readInto(T...)(ref T ts) {
    auto ss = readln.split;
    foreach(ref t; ts) {
        t = ss.front.to!(typeof(t));
        ss.popFront;
    }
}

// 冪乗をmod取りつつ計算
@nogc @safe pure ulong modPow(ulong a, ulong n, ulong m) {
    ulong r = 1;
    while (n > 0) {
        if(n % 2 != 0) r = r * a % m;
        a = a * a % m;
        n /= 2;
    }
    return r;
}

// フェルマーの小定理から乗法逆元を計算
// 定理の要請により法は素数
@nogc @safe pure ulong modInv(ulong a, ulong m) {
    return modPow(a, m-2, m);
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modPerm(ulong n, ulong k, ulong m) {
    if (n < k) return 0;

    ulong r = 1;
    for (ulong i = n-k+1; i <= n; i++) {
        r *= i;
        r %= m;
    }
    return r;
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modFact(ulong n, ulong m) {
    return modPerm(n, n, m);
}

// mod取りつつ組み合わせを計算
// modInvを使っているので法は素数
@nogc @safe pure ulong modComb(ulong n, ulong r, ulong m) {
    return modPerm(n, r, m)*modInv(modFact(r, m), m) % m;
}

immutable ulong MOD = 1000000007;

void main() {
    ulong n;
    readInto(n);
    ulong[] a;
    ulong max = 0;
    ulong max_idx;
    for (ulong i = 0; i < n; i++) {
        ulong tmp;
        readInto(tmp);
        if (tmp > max) {
            max = tmp;
            max_idx = i;
        }
        a ~= tmp;
    }
    a.sort!("a > b");

    for (ulong i = 0; i < n; i++) {
        ulong w = a[0];
        if (i == max_idx) w = a[1];
        writeln(w);
    }

}


Measured memory_bytes: 6140
from collections import deque

k = int(input())

d = deque()
for i in range(1,10):
    d.append(i)

i = 0
while i < k:
    a = str(d.popleft())

    if a[-1] == "0":
        d.append(a + "0")
        d.append(a + "1")
    elif a[-1] == "9":
        d.append(a + "8")
        d.append(a + "9")
    else:
        d.append(a + str(int(a[-1]) - 1))
        d.append(a + str(int(a[-1])))
        d.append(a + str(int(a[-1]) + 1))
        pass
    i += 1

print(a)

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

int main(){
  double n,t,a,ans=INF;
  double h[1000];
  int p;
  cin>>n>>t>>a;
  for(int i=0;i<n;i++){
    cin>>h[i];
    h[i]=t-(h[i]*0.006);
  }
  for(int i=0;i<n;i++){
    if(ans>abs(h[i]-a)){
      ans=abs(h[i]-a);
      p=i;
    }
  }
  cout<<p+1<<endl;
    
  return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n >> s;
    char now = 'A';
    ans = 0;
    for (char c : s) {
        if (now != c) {
            ans++;
            now = c;
        }
    }
    MSG(ans)
}


Measured memory_bytes: 3712
import sys
import numpy as np


def main():
    n, m = [int(e) for e in input().split()]
    xm = [int(e) for e in input().split()]
    xm.sort()
    dif = [xm[i + 1] - xm[i] for i in range(m - 1)]
    dif.sort()
    print(sum(dif[:max(0, m - n)]))


main()


Measured memory_bytes: 22932
n,a=map(int,input().split())
*x,=map(int,input().split())
dp=[[[0]*(n*50+1) for i in range(n+1)] for _ in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        for k in range(n*50+1):
            if i==0 and j==0 and k==0:
                dp[i][j][k]=1
            elif i and k<x[i-1]:
                dp[i][j][k]=dp[i-1][j][k]
            elif i and j and k>=x[i-1]:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]]
            else:
                dp[i][j][k]=0

print(sum(dp[n][i][i*a] for i in range(1,n+1)))

Measured memory_bytes: 92784
{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = interact $ map (\ch -> if ch == ',' then ' ' else ch)

-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


Measured memory_bytes: 380
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    vector<int> a(26, 0);
    for(auto el : s){
        ++a[el-'a'];
    }
    bool res = true;
    for(int i = 0; i < 26; ++i){
        if(a[i] % 2){res = false;}
    }
 
    cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def main():
    a = [list(map(int, input().split())) for i in range(3)]
    n = int(input())
    result = [[0,0,0],[0,0,0],[0,0,0]]
    for i in range(n):
        b = int(input())
        flag = False
        for i in range(3):
            for j in range(3):
                if a[i][j] == b:
                    flag = True
                    result[i][j] = 1
                    break
            if flag:
                break
    for i in range(3):
        ans = 0
        for j in range(3):
            ans += result[i][j]
        if ans == 3:
            break
    if ans == 3:
        print("Yes")
        return
    for i in range(3):
        ans = 0
        for j in range(3):
            ans += result[j][i]
        if ans == 3:
            break
    if ans == 3:
        print("Yes")
        return
    if result[0][0]+result[1][1]+result[2][2]==3 or result[0][2]+result[1][1]+result[2][0]==3:
        print("Yes")
        return
    print("No")
main()


Measured memory_bytes: 3064
N,M = map(int,input().split())
A = list(map(int,input().split()))
K = 0
L = 0
for i in range(N):
  K = K + int(A[i])
j = 0

while L < M and j < N:
  if int(A[j]) >= (K/(4*M)):
    L = L + 1
  j = j + 1
if L < M:
  print('No')
elif L == M:
  print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll modPower(ll x, ll y,ll p){
    ll res=1;
    x%=p;
    while(y>0){
        if(y&1) res=(res*x)%p;
        y=y>>1; 
        x=(x*x)%p;
    }
    return res;
}
void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
ll GCD(ll a, ll b){
	if(a==0)return b;
	return GCD(b%a,a);
}
/* -------------------------------------- */

/* -------------------------------------- */
int main() {
	boost();
	int n;cin>>n;vector<int> a(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}int m=0;
	vector<int> b(n+1);
	for(ll i=n;i>0;i--){
		if(i>n/2) b[i]=a[i];
		else{
			int c=0;
			for(int j=2;j*i<=n;j++){
				c+=b[j*i];
			}
			if(c%2==a[i])b[i]=0;
		else b[i]=1;
		}
		m+=b[i];
	}
	cout<<m<<endl;
	for(int i=1;i<=n;i++){
		if(b[i]==1) cout<<i<<" ";
	}
	
	
	
}

Measured memory_bytes: 2560
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
#define P pair<ll,ll>
//#define __int64 long long
int n;

int main(){	
	int a=1;
	cin>>n;
	while((a*2)<=n)a*=2;
	cout<<a<<endl;
	return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int dp[210][210];

int main(){
  double sum=1000;
  int N,T,A,H[1100],ans;
  cin>>N>>T>>A;

  for(int i=0;i<N;i++) cin>>H[i];

  for(int i=0;i<N;i++){
    double temp=T-(double)H[i]*0.006;
    temp=abs(A-temp);
    if(temp<sum){
      ans=i;
      sum=temp;
    }
  }
  ans++;
  cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

ll N;

void init()
{
	cin >> N;
}

void solve()
{
	N--;
	ll res = N / 11;
	res *= 2;
	N %= 11;
	if (N < 6) res++;
	else res+=2;
	cout << res << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  int x, y;
  cin >> x >> y;
  long ans = 0;

  if(x == 1 && y == 1) ans += 1000000;
  else {
    if(x <= 3) {
      ans += (4 - x) * 100000;
    }
    if(y <= 3) {
      ans += (4 - y) * 100000;
    }
  }

  cout << ans << endl;
  

  
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
import numpy

def main():
    H, W = LI()
    S = []
    for i in range(H):
        S.append(list(SI()))
    S = (numpy.array(S) == '.')
    L = numpy.zeros((H, W), dtype=int)
    R = numpy.zeros((H, W), dtype=int)
    T = numpy.zeros((H, W), dtype=int)
    B = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        L[i] = (L[i - 1] + 1) * S[i]
        R[-1 - i] = (R[-i] + 1) * S[-1 - i]
    for i in range(W):
        T[:, i] = (T[:, i - 1] + 1) * S[:, i]
        B[:, -1 - i] = (B[:, -i] + 1) * S[:, -1 - i]
    ans = numpy.max(L + R + T + B) - 3
    return ans

print(main())

Measured memory_bytes: 239148
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++)
      A[i] = sc.nextInt();
    sc.close();

    int max = A[0] + K - A[N - 1];
    for (int i = 1; i < N; i++)
      max = Integer.max(max, A[i] - A[i - 1]);

    long ans = K - max;
    System.out.println(ans);
  }
}


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

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    int now = k;
    while(now <= 1000) {
        if(now >= a && now <= b) {
            // cout << now << endl;
            cout << "OK" << endl;
            return 0;
        }
        now += k;
    }
    cout << "NG" << endl;
    return 0;
}

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

int main(int argc, char *argv[]){
	int i, j,p,q,r, n, m,max = -1;
	int *a;
    for(i=0;; i++){
		scanf("%d %d",&n,&m);
		if (n == 0 && m == 0) break;
		a = (int *)malloc(n * sizeof(int));
		for (j = 0; j < n; j++) {
			scanf("%d", &a[j]);
		}
		for (p = 0; p < n - 1; p++) {
			for (q = p + 1; q < n; q++) {
				if (a[p] + a[q] <= m && a[p] + a[q] > max) {
					max = a[p] + a[q];
				}
			}
		}
		if (max == -1) printf("NONE\n");
		else printf("%d\n", max);
		max = -1;
		/*
        fgets(a, 203, stdin);
		//if (i != 0) printf("\n");
        fgets(b, 203, stdin);
		if (a[0] == '0' && a[1] == '0') break;
        cmpr1(a,b);
		printf("\n");*/
		free(a);
    }
}
/*
void cmpr1(char *a, char *b){
	int i = 0, j = 0;
    int q=0, f=0, g=0;
	for (int i = 0; i < 203;) {
        if(a[i] == '\n' || b[j] == '\n') {
			if (a[i] == b[j]){
				if (!f) {
					printf("IDENTICAL");
				}
				else {
					printf("CLOSE");
				}
				return;
			}
			printf("DIFFERENT");
            return;
        }
		if (!f && a[i] == '"' && b[j] == '"') {
			i++;
			j++;
			while (1) {
				if (a[i] == '"') {
					if (a[i] == b[j]) {
						break;
					}
					else {
						while (b[j] != '"') j++;
						f = 1;
						break;
					}
				}
				if (b[j] == '"') {
					while (a[i] != '"') i++;
					f = 1;
					break;
				}
				if (a[i] != b[j]) f = 1;
				i++;
				j++;
			}
		}
        if(a[i] != b[j]) {
            if(q){
                f = 1;
            }
            else{
                printf("DIFFERENT");
                return;
            }
        }
		i++;
		j++;
    }
    printf("ERROR");
}*/


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> target(m), score(n, 0);
	for(int i=0; i<m; i++) cin >> target[i];
	
	for(int i=0; i<m; i++){
		int fail = 0;
		for(int j=0; j<n; j++){
			int a;
			cin >> a;
			if(a == target[i]){
				score[j]++;
			}else{
				fail++;
			}
		}
		score[target[i]-1] += fail;
	}
	
	for(int i=0; i<n; i++){
		cout << score[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
const long long INF=1e18;
struct Node
{
	long long h,p,su;
};
Node N[5005];
bool cmp(Node a,Node b)
{
	if(a.su==b.su)
	{
		return a.h<b.h;
	}
	return a.su<b.su;
}
long long dp[5005];
int ans;
int main() {
	int n;
	scanf("%d", &n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld",&N[i].h,&N[i].p);
		N[i].su=N[i].h+N[i].p;
	}
	sort(N,N+n,cmp);
	for(int i=1;i<=n;i++)
	{
		dp[i]=INF;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i;j>=0;j--)
		{
			if(dp[j]!=INF&&dp[j]<=N[i].h)
			{
				dp[j+1]=min(dp[j+1],dp[j]+N[i].p);
			}
		}
	}
	ans=0;
	for(int i=0;i<=n;i++)
	{
		if(dp[i]!=INF)
		{
			ans=max(ans,i);
		}
		else
		{
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

constexpr int INFI = 1145141919;

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

    int N, M, X;
    std::cin >> N >> M >> X;

    std::vector<int> A;
    for(int i=0; i<M; i++){
        int buf;
        std::cin >> buf;
        A.push_back(buf);
    }

    std::vector<int> atama;
    std::vector<int> osiri;
    for(int i=0; i<M; i++){
        if(A.at(i) < X){
            atama.push_back(A.at(i));
        }else{
            osiri.push_back(A.at(i));
        }
    }

    std::cout << std::min(atama.size(), osiri.size());

    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    W = [int(v) for v in input().split()]

    sum_w = sum(W)
    dp = [0] * (N + 1)

    min_diff = 100000
    for i in range(N):
        dp[i + 1] += dp[i] + W[i]

        v = abs(sum_w - dp[i + 1] * 2)
        min_diff = min(min_diff, v)

    print(min_diff)


main()


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

int main(){
  int A,B;
  cin >> A >> B;
  int64_t ans=0;
  for(int i=A;i<=B;i++){
    string s=to_string(i);
    string t=s;
    reverse(s.begin(),s.end());
    if(s==t){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    if N < 2:
        print(0)
    else:
        MOD = 10 ** 9 + 7
        U = pow(10, N, MOD)
        A = (U - pow(8, N, MOD)) % MOD
        B = (U - pow(9, N, MOD)) % MOD
        ans = (B * 2 - A) % MOD
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61684
#include<stdio.h>

int main(void)
{
        int i,j,n;
        char s[26];

        scanf("%s",s);

        n = 0;
        for(i=0;s[i]!='\0';i++)
                n++;

        for(i=0;i<n;i++){
                for(j=i+1;j<n;j++){
                        if(s[i]==s[j]){
                                printf("no\n");
                                return 0;
                        }
                }
        }

        printf("yes\n");
        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;int sum=0;
    VI ar(a);VI br(b);VI cr(c);VI q;
    for(int i=0;i<a;i++)cin>>ar[i];
    for(int i=0;i<b;i++)cin>>br[i];
    for(int i=0;i<c;i++)cin>>cr[i];
    sort(all(ar),greater<int>());sort(all(br),greater<int>());
    sort(all(cr),greater<int>());
    for(int i=0;i<x&&i<a;i++)q.pb(ar[i]);
    for(int i=0;i<y&&i<b;i++)q.pb(br[i]);
    for(int i=0;i<c;i++)q.pb(cr[i]);
    sort(all(q),greater<int>());
    for(int i=0;i<x+y;i++)sum+=q[i];
    cout<<sum<<endl;
    
    
    
    
}


return 0;
}





Measured memory_bytes: 8816
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

char s[110];
int len, ans;

int main(){

	cin >> s;
	len = strlen(s);
	for(int i = 0; i < len / 2; i++)
		if(s[i] != s[len - i - 1])
			ans++;
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  int m; cin >> m;
  vi b(m); rep(i, m) cin >> b[i];
  vi res;

  set_union(begin(a), end(a), begin(b), end(b), inserter(res, end(res)));

  for_each(begin(res), end(res), [](int x){cout << x << '\n';});

  return 0;
}


Measured memory_bytes: 6540
import sys
x = input()
x = int(x)
pn = []
k = x
while True:
    cnt = 0
    for j in range(int(x/2)):
        j += 1
        if cnt >= 2:
            break
        if k % j == 0:
            cnt += 1
    if cnt < 2:
        ans = k
        break
    k += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll max_n = 1e6+4; 
void solve(){
    ll p = 0;
    ll Prime[n];
    ll isPrime[n+1];
    for(int i=0 ; i<=n ; i++){
        isPrime[i] = true;
    }
    isPrime[0] = isPrime[1] = 0;
    for(int i=2 ; i<=n ; i++){
        if(isPrime[i]){
            p++;
            for(int j=2*i ; j<=n ; j+=i){
                isPrime[j] = false;
            }
        }
    }
    cout << p << endl;
}

int main(){
    while (cin >> n, cin.eof() != true){
        solve();
    }
    return 0;
}



Measured memory_bytes: 10880
import sys
input = sys.stdin.readline

def swap(a):
    return ((a[1],a[0]))


n, m = [ int(v) for v in input().split() ]
num_list = [ (int(v), 1) for v in input().split() ]
change_list = [ swap([ int(v) for v in input().split() ]) for i in range(m) ]
total_list = sorted(num_list + change_list, reverse = True)

k = n
ans = 0

for i in total_list:

    j = min(i[1], k)
    k -= j
    ans += i[0] * j
    if k == 0:
        break
print(ans)  

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

int n,k;
map<int,int> m;
multiset<int> s;

int main()
{
	scanf("%d%d", &n, &k);
	for(int x,i=1; i<=n; ++i){
		scanf("%d", &x);
		m[x]++;
	}
	for(auto it:m) s.insert(it.second);
	int ans=0;
	while(int(s.size())>k){
		int t = *s.begin();
		s.erase(s.begin());
		ans += t;
		t += *--s.end();
		s.erase(--s.end());
		s.insert(t);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 18944
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long val = in.nextLong();
            long _500 = val / 500;
            long _5 = (val % 500) / 5;
            out.print(_500 * 1000 + _5 * 5);
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

// s内に部分列としてtがあるか探す
bool is_substring(string& s, string& t){
  // t's index
  ll now = 0;
  rep(i, SZ(s)){
    if(s[i]==t[now]){
      now++;
      if(now==SZ(t)) return true;
    }
  }
  return false;
}

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

    // input
    ll N; 
    cin >> N;

    string s; cin >> s;

    ll cnt = 0;
    rep(i, 10){
      rep(j, 10){
        rep(k, 10){
          stringstream ss;
          ss << (char)('0'+i);
          ss << (char)('0'+j);
          ss << (char)('0'+k);
          string t = ss.str();
          if(is_substring(s, t)){
            cnt++;
          }
        }
      }
    }
    p(cnt);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(n) for( int i = 0 ; i < n ; i++ )
#define REP(n) for( int i = 1 ; i <= n ; i++ )
#define repll(n) for( ll i = 0 ; i < n ; i++ )
#define REPll(n) for( ll i = 1 ; i <= n ; i++ )
#define rep2(n) for( int j = 0 ; j < n ; j++ )
#define REP2(n) for( int j = 1 ; j <= n ; j++ )
#define repll2(n) for( ll j = 0 ; j < n ; j++ )
#define REPll2(n) for( ll j = 1 ; j <= n ; j++ )

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , k;
  	cin >> n >> k;
	int a[n];
    rep(n) cin >> a[i];
	int c = 1;
	n -= k;
	while( n > 0 ) {
		n -= k - 1;
	    c++;
	}
    cout << c;
}


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

#define MAX 100000
#define INFTY 1200000000

int num(char ch)
{
    if(ch == 'S'){ return 0; }
    else if(ch == 'H'){ return 1; }
    else if(ch == 'C'){ return 2; }
    else if(ch == 'D'){ return 3; }else{}
    return 0;
}

char suit(int i)
{
    if(i == 0){ return 'S'; }
    else if(i == 1){ return 'H'; }
    else if(i == 2){ return 'C'; }
    else if(i == 3){ return 'D'; }else{}
    return 'Z';
}

void Merge(int* A, int* s, int left, int mid, int right)
{
    int R[MAX], L[MAX];
    int ch_R[MAX], ch_L[MAX];
    int i, j, k, n1, n2;
    n1 = mid - left;
    n2 = right - mid;
    for(i = 0; i < n1; i++){ L[i] = A[i + left]; ch_L[i] = s[i + left]; }
    for(j = 0; j < n2; j++){ R[j] = A[j + mid]; ch_R[j] = s[j + mid]; }

    L[n1] = INFTY;
    R[n2] = INFTY;
    i = j = 0;

    for(k = left; k < right; k++){

		if(L[i] <= R[j]){ A[k] = L[i]; s[k] = ch_L[i]; i++; }

		else{ A[k] = R[j]; s[k] = ch_R[j]; j++; }
    }
}

void MergeSort(int* A, int* s, int left, int right)
{
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        MergeSort(A, s, left, mid);
        MergeSort(A, s, mid, right);
        Merge(A, s, left, mid, right);
    }
    return;
}

int partition(int* A, int* s, int p, int r)
{
    int i, j, x;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++){
        if(A[j] <= x){ i++; swap(A[i], A[j]); swap(s[i], s[j]); }
    }
    swap(A[i + 1], A[r]);
    swap(s[i + 1], s[r]);

    return i + 1;
}

void quicksort(int* A, int* s, int p, int r)
{
    if(!(p < r)) return;
    int q;
    q = partition(A, s, p, r);
    quicksort(A, s, p, q - 1);
    quicksort(A, s, q + 1, r);
}

bool is_stable(int* s, int* t, int n)
{
    int i = 0;
    while(i < n){ if(s[i] != t[i]) return false; i++; };
    return true;
}

int main()
{
    int i, n;
    char ch;
    int A[MAX], B[MAX], s[MAX], t[MAX];
    cin >> n;

    for(i = 0; i < n; i++){
        cin >> ch; s[i] = num(ch); t[i] = s[i];
        cin >> A[i]; B[i] = A[i];
    }

    quicksort(A, s, 0, n - 1);
    MergeSort(B, t, 0, n);

    if(is_stable(s, t, n)){ cout << "Stable"; } else{ cout << "Not stable"; }
    cout << endl;

    for(int i = 0; i < n; i++){ cout << suit(s[i]) << " " << A[i] << endl; }

    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    rep(i,S.size()){
        if(S[i] != T[i]){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3632
n=int(input())
if n==1 or n==2:
  print(0)
  exit()
d=0
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    if i!=n//i and i!=n//i-1:
      d=d+n//i-1
print(d)

Measured memory_bytes: 3060
use std::collections::HashMap;

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: u64 = iterator.next().unwrap().parse().unwrap();
    let p: u64 = iterator.next().unwrap().parse().unwrap();

    if n == 1 {
        return p.to_string()
    }

    let mut counts: HashMap<u64, u64> = HashMap::new();

    let mut i = 2;
    while i * i <= p {
        if !is_prime(i) {
            i += 1;
            continue;
        }
        let mut x = p;
        while x % i == 0 {
            x /= i;
            *counts.entry(i).or_insert(0) += 1;
        }
        i += 1;
    }

    let mut g: u64 = 1;
    for (k, v) in counts {
        g *= k.pow((v / n) as u32);
    }
    return g.to_string();
}

fn is_prime(n: u64) -> bool {
    let mut i: u64 = 2;
    while i * i <= n {
        if n % i == 0 {
            return false;
        }
        i += 1;
    }
    return true;
}


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

int H, W, D;
int A[512][512];
int Q;
int L[512 * 512], R[512 * 512];

int pos[512 * 512][2];

int cost(int from, int to) {
	return abs(pos[to][1] - pos[from][1]) + abs(pos[to][0] - pos[from][0]);
}

int ruisekiwa[512 * 512];

int main(void) {
	int i, j;
	int Q;
	if (scanf("%d%d%d", &H, &W, &D) != 3) return 1;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (scanf("%d", &A[i][j]) != 1) return 1;
			pos[A[i][j]][0] = i;
			pos[A[i][j]][1] = j;
		}
	}
	if (scanf("%d", &Q) != 1) return 1;
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d", &L[i], &R[i]) != 2) return 1;
	}
	for (i = D + 1; i <= H * W; i++) {
		ruisekiwa[i] = ruisekiwa[i - D] + cost(i - D, i);
	}
	for (i = 0; i < Q; i++) {
		printf("%d\n", ruisekiwa[R[i]] - ruisekiwa[L[i]]);
	}
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k, q;
	cin>>n>>k>>q;
	vector<int> a(n, k - q);
	for(int i = 0; i < q; i++){
		int x; cin>>x;
		a[x - 1] += 1;
	}
	for(auto x : a){
		if(x <= 0){
			cout<<"No"<<'\n';
		}else{
			cout<<"Yes"<<'\n';
		}
	}


	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<set>
using namespace std;

int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	int cnt=0;
	long long x,y;
	cin>>x>>y;
	while(y>=x)
	{
		cnt++;
		y/=2;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,a[300010],num;
vector <int> v;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		v.pb(a[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	if(v.size()%2==1) cout<<v.size()<<endl;
	else cout<<v.size()-1<<endl;
	rt0;
}

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

int main()
{

    int n,k,d,x;
    cin>>n>>k;
    int a[n+1]={0};
    while(k--)
    {
        cin>>d;
        for(int i=1;i<=d;i++)
        {
           cin>>x;
           a[x]++;
        }
    }
    cout<<count(a,a+n+1,0)-1<<endl;
    return 0;
}


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


int main() {
    int N, x;
    cin >> N >> x;

    int A[N];
    rep(i, N) cin >> A[i];
    sort(A, A+N);

    int ans = N-1;
    rep(i, N) {
        x -= A[i];
        if (x < 0) {
            ans = i;
            break;
        } else if (x == 0) {
            ans = i + 1;
            break;
        } 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3524
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using std::make_pair;
using std::pair;

using std::max;
using std::min;
using std::sort;

using std::cin;
using std::cout;

using std::vector;

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p;
    for (int i = 0; i < N; ++i) {
        int pi;
        cin >> pi;
        p.push_back(pi);
    }
    sort(p.begin(), p.end());

    int ans = 101;
    for (int i = 101; i >= 0; --i) {
        bool f = true;
        for (int j = 0; j < N; ++j) {
            if (i == p[j]) f = false;
        }
        if (!f) continue;
        if (llabs(i - X) <= llabs(ans - X)) ans = i;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3624
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for _ in range(N):
    s = input()
    if s == 'AC':
        ac+=1
    if s == 'WA':
        wa+=1
    if s == 'TLE':
        tle+=1
    if s == 'RE':
        re+=1

print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 9180
import java.io.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] names = br.readLine().split(" ");
    Set<String> nameSet = new HashSet<String>(Arrays.asList(names));
    System.out.println(nameSet.size() == 2 ? "Yes" : "No");
    
  }
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

using coordinate = struct {
    int x;
    int y;
};

int H, W;
char world_map[1000][1000];
int  cost_map[1000][1000];

bool update_map(const coordinate& target, const int& cost) {
    if(0 <= target.x && target.x < W &&
       0 <= target.y && target.y < H ) {
        if(cost_map[target.y][target.x] == -1) {
            cost_map[target.y][target.x] = cost;
            return true;
        }
    }
    return false;
}

int solve(std::queue<coordinate>& queue) {
    coordinate dst;
    coordinate src;
    while(true) {
        src = queue.front();
        queue.pop();

        int cost = cost_map[src.y][src.x] + 1;

        dst = coordinate{src.x + 1, src.y};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x - 1, src.y};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x, src.y + 1};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x, src.y - 1};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        if(queue.size() == 0) {
            break;
        }
    }

    return cost_map[src.y][src.x];
}

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

    std::cin >> H >> W;

    std::queue<coordinate> queue;
    REP(hi, H) {
        REP(wi, W) {
            cost_map[hi][wi] = -1;

            std::cin >> world_map[hi][wi];
            if(world_map[hi][wi] == '#') {
                queue.push(coordinate{wi, hi});
                cost_map[hi][wi] = 0;
            }
        }
    }

    std::cout << solve(queue) << std::endl;

    return 0;
}


Measured memory_bytes: 13328
N = []
while 1:
  x = input()
  if x==0: break
  N.append(x)
n0 = max(N)-2
A = [1,1,2]+[0]*n0
for i in range(0, n0): A[i+3] = sum(A[i:i+3])
for e in N: print A[e]/3650+[0,1][A[e]%3650>0]

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

void print() {
  cout << endl;
}

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
}

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
}

const int LOG = 64;
const int MAX_N = 200005;
vvi to(LOG, vi(MAX_N)); // to[i][j]: jの2^i個先

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

  int N;
  ll K;
  cin >> N >> K;
  vi a(N);
  rep(i, 0, N) {
    cin >> to[0][i];
    to[0][i]--;
  }

  rep(i, 0, LOG-1) {
    rep(j, 0, N) {
      to[i+1][j] = to[i][to[i][j]];
    }
  }

  int v = 0;
  for (int i = LOG-1; i >= 0; --i) {
    if ((K >> i) & 1) {
      v = to[i][v];
    }
  }

  // rep(i, 0, LOG) {
  //   if ((K >> i) & 1) {
  //     v = to[i][v];
  //   }
  // }

  cout << v + 1 << endl;
  return 0;
};


Measured memory_bytes: 54256