akhauriyash/Code-Regression huggingface dataset:
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int N;
    cin >> N;

    unordered_set<string> s;
    rep(i, 0, N)
    {
        string st;
        cin >> st;
        s.insert(st);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 17616
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int w = sc.nextInt();
			int h = sc.nextInt();
			int[][] field = new int[w][h];
			for (int i = 0; i < w; i++)
				for (int j = 0; j < h; j++)
					field[i][j] = 0;
			for (int i = 0; i < n; i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				field[x - 1][y - 1] = 1;
			}
			int s = sc.nextInt();
			int t = sc.nextInt();
			for (int i = 0; i <= w - s; i++)
				for (int j = 0; j <= h - t; j++)
					for (int k = i; k < i + s; k++)
						for (int l = j; l < j + t; l++)
							if (i != k || j != l)
								field[i][j] += field[k][l];
			int max = 0;
			for (int i = 0; i < w; i++)
				for (int j = 0; j < h; j++)
					max = Math.max(max, field[i][j]);
			System.out.println(max);
		}
		sc.close();
	}
}

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

using namespace std;
char s[101],a[101];
int main()
{
    cin>>s;
    int top=0;
    for(int i=0;i<strlen(s);i++)
    {
        switch(s[i])
        {
        case 'C':
            a[top]='C';
            top++;
            break;
        case 'F':
            if(a[top-1]=='C'&&top>0)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

min_sum = 10**9
ans = 1000
for i in range(min(a), max(a)+1):
    sum = 0
    for j in a:
        sum += (j-i)**2
    if sum < min_sum:
        min_sum = sum

print(min_sum)

Measured memory_bytes: 3060
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
void tc(){
    int a, b;
    cin >> a >> b;
    cout << a * b;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int> q;
  rep(i,n){
    int a;
    cin>>a;
    q.push(a);
  }
  
  rep(i,m){
    int b=q.top();
    q.pop();
    q.push(b/2);
  }
  ll ans=0;
  rep(i,n){
    ans+=q.top();
    q.pop();
  }  

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

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main()
{
    string a,b;
    cin >> a >> b;
    if( a.size() > b.size() )cout << "GREATER" << endl;
    else if( a.size() < b.size() )cout << "LESS" << endl;
    else if( a > b ) cout << "GREATER" << endl;
    else if( a < b ) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main () {
int n,d[4];
scanf("%d",&n);
d[0] = n % 10;
d[1] = (n % 100 - d[0])/10;
d[3] = n/1000;
d[2] = n/100 - 10*d[3];
if(d[2] == d[1] && (d[1] == d[0] || d[2] == d[3])){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int n = h[0], k = h[1];
		var a = new int[n].Select(_ => int.Parse(Console.ReadLine())).ToArray();

		var kM = 300000;

		var r = 0L;
		var st = new ST_RangeSet(kM + 1);

		for (int i = 0; i < n; i++)
			st.Set(Math.Max(0, a[i] - k), Math.Min(kM + 1, a[i] + k + 1), st[a[i]] + 1);

		for (int x = 0; x <= kM; x++)
			r = Math.Max(r, st[x]);
		Console.WriteLine(r);
	}
}

class ST
{
	public struct Node
	{
		public int k, i;
		public Node(int _k, int _i) { k = _k; i = _i; }

		public Node Parent => new Node(k - 1, i >> 1);
		public Node Child0 => new Node(k + 1, i << 1);
		public Node Child1 => new Node(k + 1, (i << 1) + 1);
	}

	protected int kMax;
	public List<long[]> vs = new List<long[]> { new long[1] };

	public ST(int n)
	{
		for (int c = 1; c < n; vs.Add(new long[c <<= 1])) ;
		kMax = vs.Count - 1;
	}

	public virtual long this[int i] => vs[kMax][i];
	public long this[Node n]
	{
		get { return vs[n.k][n.i]; }
		set { vs[n.k][n.i] = value; }
	}

	public void InitAllLevels(long v)
	{
		foreach (var a in vs) for (int i = 0; i < a.Length; ++i) a[i] = v;
	}

	public void Clear()
	{
		for (int k = 0; k <= kMax; ++k) Array.Clear(vs[k], 0, vs[k].Length);
	}

	public void ForLevels(int i, Action<Node> action)
	{
		for (int k = kMax; k >= 0; --k, i >>= 1) action(new Node(k, i));
	}

	// インデックスの昇順ではなく、階層の降順です。
	public void ForRange(int minIn, int maxEx, Action<Node> action)
	{
		for (int k = kMax, f = 1; k >= 0 && minIn < maxEx; --k, f <<= 1)
		{
			if ((minIn & f) != 0) action(new Node(k, (minIn += f) / f - 1));
			if ((maxEx & f) != 0) action(new Node(k, (maxEx -= f) / f));
		}
	}
}

class ST_RangeSet : ST
{
	public ST_RangeSet(int n) : base(n) { }

	public void Set(int minIn, int maxEx, long v) => ForRange(minIn, maxEx, n => this[n] = Math.Max(this[n], v));

	public override long this[int i]
	{
		get
		{
			var r = 0L;
			ForLevels(i, n => r = Math.Max(r, this[n]));
			return r;
		}
	}
}


Measured memory_bytes: 47648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int r,g; cin>>r>>g;
   cout<< g*2-r <<endl;
}


Measured memory_bytes: 256
# 2019-11-18 00:38:19(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 

def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    s = sys.stdin.readline().rstrip()

    happy_count = 0
    happy_count += sum(1 for i in range(n-1) if s[i] == s[i+1])
    
    happy_count += 2 * k
    ans = min(happy_count, n - 1)
    print(ans)
    
if __name__ == "__main__":
    main()



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

vector<set<pii>> g;
vi c;
int n;
void dfs(int v, int p, int s) {
    c[v] = s;
    for (auto i : g[v]) {
        if (i.first == p) continue;
        if (i.second%2==0) dfs(i.first, v, s);
        else dfs(i.first, v, 1-s);
    }
}

int main(){
    cin >> n;
    vector<set<pii>> gl(n);
    rep(i, n-1) {
        int u, v, wi;
        cin >> u >> v >> wi;
        --u; --v;
        gl[u].insert({v, wi});
        gl[v].insert({u, wi});
    }
    g = gl;
    vi cl(n);
    c = cl;
    dfs(0, 0, 0);
    rep(i, n) cout << c[i] << endl;
    return 0;
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

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

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int memo[105][100010]; //価値の最大は10^3 * 100 = 100000
int inf = 1e9+7;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,w; cin >> n >> w;
    vector<pair<int,int>> m(n); //first = w,second = v
    rep(i,0,n) cin >> m[i].first >> m[i].second;
    rep(i,0,105)rep(j,0,100010) memo[i][j] = inf;
    rep(i,0,105) memo[i][0] = 0; 
    memo[0][m[0].second] = m[0].first;
    rep(i,1,n){
        rel(j,100005,0){ //価値でループ
            memo[i][j] = memo[i-1][j];
            if(j+m[i].second>100003) continue;
            //if(i == 0) memo[i][j] = min(memo[i][j],memo[i][j+m[i].second] + m[i].first);
            memo[i][j+m[i].second] = min(memo[i-1][j+m[i].second],memo[i-1][j] + m[i].first);
        }
    }
    int ans=0;
    rep(i,0,n){
        rep(j,0,100005){
            if(memo[i][j]>w) continue;
            ans = max(ans,j);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  map<string, int> mp;
  for (int i = 0; i < n; i++) mp[s[i]]++;
  ll v = 0;
  for (auto &it : mp) {
    if (it.second > v) {
      v = it.second;
    }
  }
  vector<string> ans;
  for (auto &it : mp) {
    if (it.second == v) {
      ans.push_back(it.first);
    }
  }
  sort(ans.begin(), ans.end());
  for (auto &it : ans) {
    cout << it << endl;
  }
  return 0;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> a(M);
  vector<int> b(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i)>>b.at(i);
   }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if(b[0]>=a[M-1])
    cout<<b[0]-a[M-1]+1<<endl;
  else
    cout<<0<<endl;
}

      





Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(lcm(a, b))
}

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

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  rep(i,7){
    cin >> a >> b;
    cout << a - b << endl;
  }
  return 0;
}

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

from collections import defaultdict, Counter, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
def inpl(): return list(map(int, input().split()))

N, Q = inpl()
G = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = inpl()
    G[a-1].append(b-1)
    G[b-1].append(a-1)

S = [0]*N
for _ in range(Q):
    x, d = inpl()
    S[x-1] += d

searched = [0]*N
searched[0] = True
Q = deque([0])

while Q:
    p = Q.popleft()
    for q in G[p]:
        if searched[q]:
            continue
        searched[q] = True
        S[q] += S[p]
        Q.append(q)

print(*S)

Measured memory_bytes: 100416
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 1000 + 5;
vector<int> adj[MAX];
int state[MAX];
int n, m;

void dfs(int u, vector<int> &stack, vector<int> &cycle) {
    stack.push_back(u);
    state[u] = 1;

    for (auto &v : adj[u]) {
        if (state[v] == 0) {
            dfs(v, stack, cycle);
        }
        else if (state[v] == 1 && cycle.empty()) {
            for (int i = (int) stack.size() - 1; i >= 0 && stack[i] != v; i--) {
                cycle.push_back(stack[i]); 
            }
            cycle.push_back(v);
            reverse(begin(cycle), end(cycle));
        }
    }

    stack.pop_back();
    state[u] = 2;
}

vector<int> find_cycle() {
    vector<int> cycle, stack;

    for (int i = 1; i <= n && cycle.empty(); i++) {
        if (state[i] == 0) {
            dfs(i, stack, cycle);
        }
    }

    return cycle;
}

vector<int> reduce_cycle(vector<int> cycle) {
    bool reduced;

    do {
        reduced = false;

        vector<int> cycle_pos(n + 1, -1);
        fori (i, 0, cycle.size()) cycle_pos[cycle[i]] = i;
        
        int size = cycle.size();

        for (int i = 0; i < size && !reduced; i++) {
            int nxt = cycle[(i + 1) % size];
            for (auto &each : adj[cycle[i]]) {
                if (cycle_pos[each] != -1 && each != nxt) {
                    vector<int> new_cycle;

                    for (int j = cycle_pos[each]; j != i; j = (j + 1) % size) {
                        new_cycle.push_back(cycle[j]);
                    }
                    new_cycle.push_back(cycle[i]);

                    cycle = new_cycle;

                    reduced = true; 
                    break;
                }
            }
        }
    } while (reduced);

    return cycle;
}

void solve() {
    cin >> n >> m;

    fori (i, 0, m) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
    }

    vector<int> cycle = find_cycle();
    if (cycle.empty()) {
        cout << -1 << "\n";
        return;
    }

    cycle = reduce_cycle(cycle);

    cout << cycle.size() << "\n";
    for (auto &u : cycle) cout << u << "\n";
}

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



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

int main(){
	int n,ans=0;
	cin >> n;
	int x[n+1],l[n+2],r[n+2];
	for(int i = 1 ; i <= n ; i += 1){
		cin >> x[i];
	}
	l[0] = 0 , l[n+1] = 0 , r[0] = 9 , r[n+1] = 0;
	for(int i = 1 ; i <= n+1 ; i += 1){
		l[i] = __gcd(l[i-1],x[i]);
	}
	for(int i = n ; i >= 0 ; i -= 1){
		r[i] = __gcd(r[i+1],x[i]);
	}
	for(int i = 1 ; i <= n ; i += 1){
		ans = max(ans , __gcd(l[i-1],r[i+1]));
	}
	cout << ans;
}

Measured memory_bytes: 1536
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/UOA/PCKWU/1043

#include <bits/stdc++.h>

using namespace std;

struct Team {
    int id;
    int univ;
    int ac;
    int penalty;

    bool operator<(const Team inst) const {
        if (ac != inst.ac) {
            return ac > inst.ac;
        } else if (penalty != inst.penalty) {
            return penalty < inst.penalty;
        } else {
            return id < inst.id;
        }
    }
};

int main() {
    int n;

    while (true) {
        cin >> n;
        if (n == 0) return 0;

        vector<Team> team(n);
        for (int i = 0; i < n; ++i) {
            cin >> team[i].id >> team[i].univ >> team[i].ac >> team[i].penalty;
        }
        sort(team.begin(), team.end());

        int selected = 0;
        int same[1010] = {};
        for (int i = 0; i < n; ++i) {
            if ((selected < 10 and same[team[i].univ] < 3) or
                (selected < 20 and same[team[i].univ] < 2) or
                (selected < 26 and same[team[i].univ] == 0)) {
                cout << team[i].id << endl;
                selected++;
                same[team[i].univ]++;
            }
        }
    }
}

/*
 *
 */


Measured memory_bytes: 3020
#include<cstdio>
using namespace std;
int main(){
    int n,x;
    int i=1;
    scanf("%d",&n);
    while(1){
        x=i;
        if(x%3==0){
            printf(" %d",i);
        }else{
            while(x){
            if(x%10==3){
                printf(" %d",i);
                break;
            }
            x/=10;
            
        }
        }
if(++i>n){
                break;
            }
        
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2716
#include<bits/stdc++.h>
using namespace std;
char x[100005],y;
int g,z;
int main()
{
    while(x[z]=getchar(),x[z]!='\n')
    {

        if(z==0)y=x[z];
        if(x[z]!=y)g++,y=x[z];

        z++;
    }

    cout<<g;

    return 0;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

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

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int n;
  cin >> n;
  int x = 800 * n;
  int y = 200 * (n / 15);
  cout << x - y << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int m;
    cin >> m;
    if (!m) return 0;
    m = 1000 - m;
    int r = 0, c[6] = { 500, 100, 50, 10, 5, 1 };
    for (int i = 0; i < 6; i++) {
      r += m / c[i];
      m %= c[i];
    }
    cout << r << endl;
  }
}

Measured memory_bytes: 0
n,k = gets.chomp.split(' ').map(&:to_i)
sum = 0
list = []
flag = false
ans = nil
n.times do
  list << gets.chomp.split(' ').map(&:to_i)
end
list.sort!
list.each do |pair|
  sum += pair[1]
  if sum >= k && flag == false 
    ans = pair[0]
    flag = true
  end
end
puts ans

Measured memory_bytes: 22000
# ABC 121: B – Can you solve this?
N, M, C = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
A = [[int(s) for s in input().split()] for _ in range(N)]

exacts = 0

for i in range(N):
    value = C
    
    for j in range(M):
        value += A[i][j] * B[j]
    
    if value > 0:
        exacts += 1

print(exacts)

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

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> nums(40);

	for(int i=0; i<n; i++){
		cin >> a[i];
		for(int j=0; j<40; j++) if(a[i] & (1ll << j)) nums[j]++;	
	}

	ll x = 0;
	for(int i=39; i>=0; i--){
		if(nums[i]*2 <= n) x += (1ll << i);
		if(x > k) x -= (1ll << i);
	}

	ll sum = 0;
	for(ll A : a) sum += A^x;
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
string s,t;
int a[100000],cnt;
int main(void){
    cin>>s;
    cnt++;
    for(int i=1;i<s.size();i++){
        if(s[i]=='R'){
            cnt++;
        }
        else{
            a[i]+=cnt/2;
            a[i-1]+=(cnt+1)/2;
            cnt=0;
        }
    }
    cnt=1;
    for(int i=s.size()-2;i>=0;i--){
        if(s[i]=='L'){
            cnt++;
        }
        else{
            a[i]+=cnt/2;
            a[i+1]+=(cnt+1)/2;
            cnt=0;
        }
    }
    for(int i=0;i<s.size();i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}


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

int main() {
  int a[3][3];
  int n;
  int b[130];
  int bingo_card[3][3];
  // for (int i = 0; i < 3; i++) {
  //   cout << bingo_card[i][0] << bingo_card[i][1] << bingo_card[i][2] << endl;
  // }
  for (int i = 0; i < 3; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (a[j][k] == b[i]) {
          bingo_card[j][k] = 1;
        }
      }
    }
  }

  // for (int i = 0; i < 3; i++) {
  //   cout << bingo_card[i][0] << bingo_card[i][1] << bingo_card[i][2] << endl;
  // }

  int bingoNum = 0;
  for (int i = 0; i < 3; i++) {
    int bingoFlag = 0;
    for (int j = 0; j < 3; j++) {
      if(bingo_card[i][j] == 1) {
        bingoFlag++;
      }
    }
    if (bingoFlag == 3) {
      bingoNum++;
    }
  }
  for (int i = 0; i < 3; i++) {
    int bingoFlag = 0;
    for (int j = 0; j < 3; j++) {
      if(bingo_card[j][i] == 1) {
        bingoFlag++;
      }
    }
    if (bingoFlag == 3) {
      bingoNum++;
    }
  }
  int bingoFlag_left = 0;
  int bingoFlag_right = 0;
  for (int i = 0; i < 3; i++) {
    if(bingo_card[i][i] == 1) {
      bingoFlag_left++;
    }
  }
  for (int i = 0; i < 3; i++) {
    if(bingo_card[2-i][i] == 1) {
      bingoFlag_right++;
    }
  }
  // cout << bingoFlag_left << endl;
  // if (bingoFlag_left == 3 || bingoFlag_right == 3)
  if(bingoFlag_left == 3) {
    bingoNum++;
  }
  if (bingoFlag_right == 3) {
    bingoNum++;
  }
  if(bingoNum!=0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  // for (int i = 0; i < 3; i++) {
  //   cout << bingo_card[i][0] << bingo_card[i][1] << bingo_card[i][2] << endl;
  // }
  // cout << bingoNum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];
int X[N][N];


void printBoard(void){
  int i, j;

  for(i = 0; i < N; i++)
    for(j = 0; j < N; j++)
      if(X[i][j] == 1 && row[i] != j) return;
  
  for( i = 0; i < N; i++ )
    {
      for( j = 0; j< N; j++ )
	printf("%c", row[i] == j ? 'Q' : '.' );
      printf("\n");
    }
}

void recursive(int i){
  int j;

  if(i == N){
    printBoard();
    return;
  }
  
  for(j = 0; j < N; j++){
    if( NOT_FREE == col[j]|| NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1])
      continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    //次の行を試す
   recursive(i + 1);
   //(i,j)のクイーンを取り除く
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
  //配置失敗
}


int main(){
  int i, j, k, r, c;

  for(i = 0; i < N; i++) for(j = 0; j < N; j++) X[i][j] = 0;
  for(i = 0; i < N; i++) col[i] = FREE;
  for(i = 0; i < 2 * N; i++) dpos[i] = dneg[i] = FREE;

  scanf("%d", &k);
  for(i = 0; i < k; i++){
    scanf("%d%d", &r, &c);
    X[r][c] = 1;
  }

  recursive(0);
  
  return 0;
}



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

int main(){
  int N,K,i,most = 0;
  cin >> K >> N;
  
  int A[N],B;
  cin >> A[0];
  for( i=1 ; i<N ; i++ ){
    cin >> A[i];
    if(most < (A[i]-A[i-1]))most = A[i]-A[i-1];
  }
  if(most < (K - A[N-1] + A[0]))most = K - A[N-1] + A[0];
  cout << (K-most) << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	string s;
	cin >> s;
	if(s[0] == 'S')cout << "Cloudy";
	else if(s[0] == 'C')cout << "Rainy";
	else cout << "Sunny";
	
	cout << endl;
}

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

int main(){
  string s;

  while( getline( cin,s ) ){
    for( int i=0;i<26;i++ ){
      for( unsigned int j=0;j<s.length();j++ ){
	if( s[j]<'a' || s[j]>'z' ) continue;
	if( ++s[j]>'z' ) s[j] = 'a';
      }
      
      //    cout << "in loop : " << s << endl;
      int s1 = s.find("the");
      int s2 = s.find("this");
      int s3 = s.find("that");
      //    cout << s1 << "," << s2 << "," << s3 << endl;
      
      if( s1>=0 || s2>=0 || s3>=0 )
	break;
    }
    cout << s << endl;
  }

  return 0;
}

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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 10001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

vector<int> g[maxn];
int used[maxn];
int d[maxn];
int cnt[maxn];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n, x, y;
    cin >> n >> x >> y;
    for (int i = 1; i < n; ++i) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    for (int i = 1; i <= n; ++i) {
        for (int i = 1; i <= n; ++i) {
            used[i] = 0;
            d[i] = 0;
        }
        queue<int> q;
        q.push(i);
        used[i] = 1;
        while (!q.empty()) {
            int v = q.front();
            ++cnt[d[v]];
            q.pop();
            for (int to:g[v]) {
                if (!used[to]) {
                    used[to] = 1;
                    d[to] = d[v] + 1;
                    q.push(to);
                }
            }
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << cnt[i] / 2 << "\n";
    }
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD

bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}

int main(){
    int n;
    cin >> n;
    int temp;
    map<ll,ll>m;
    rep0(i,n){
        cin >> temp;
        m[temp-1]++;
        m[temp]++;
        m[temp+1]++;
    }
    ll maxn = 0;
    for(auto& j : m){
        maxn = max(maxn,j.second);
    }
    cout << maxn << endl;
    return 0;
}

Measured memory_bytes: 6144
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int M = sc.nextInt();
        ArrayList<Integer> List= new ArrayList<>();
        for(int a=0;a<M;a++)List.add(sc.nextInt());
        Collections.sort(List,Comparator.reverseOrder());
        ArrayList<Integer> dis_List = new ArrayList<>();
        for(int a=0;a<List.size()-1;a++){
            int dis = List.get(a)-List.get(a+1);
            dis_List.add(dis);
        }
        Collections.sort(dis_List,Comparator.reverseOrder());
        for(int a=0;a<N-1;a++)
        {
            if(dis_List.size()==0)break;
            dis_List.remove(0);
        }

        int sum=0;
        for(int a=0;a<dis_List.size();a++) sum+=dis_List.get(a);
        System.out.println(sum);
    }
}


Measured memory_bytes: 57760
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[100001],n,d[3]={};
int main(){
	cin>>n;
	for(long long i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%4==0)d[2]++;
		else if(a[i]%2==0)d[1]++;
		else d[0]++;
	}
	if(d[2]>=n/2){
		cout<<"Yes\n";
		return 0;
	}
	if(d[2]>=d[0]){
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";



  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;

int main() {
  int d, t, s;
  cin >> d >> t >> s;

  cout << (s * t >= d ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        int ans = N * (1 + N % 2);
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
n = int(input())
if n == 0:
    print(0)
    exit(0)

oddsum = [2, 10, 42, 170, 682, 2730, 10922, 43690, 174762, 699050, 2796202, 11184810, 44739242, 178956970, 715827882, 2863311530]
evensum = [1, 5, 21, 85, 341, 1365, 5461, 21845, 87381, 349525, 1398101, 5592405, 22369621, 89478485, 357913941, 1431655765]
two = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184]
ans = 0
while n != 0:
    if n < 0:
        x = 1
        for i in oddsum:
            if n >= -1 * i:
                break
            x += 2
        n += two[x]
    else:
        x = 0
        for i in evensum:
            if n <= i:
                break
            x += 2
        n -= two[x]
    v = 1 << x
    ans += v
print(bin(ans)[2:])

Measured memory_bytes: 3192
n, m ,l= map(int, input().split())

result_vec=[[0]*l for n in range(n)]

a = []
b = []

for i in range(n):
    a.append(list(map(int,input().split())))
    
for i in range(m):
    b.append(list(map(int,input().split())))
    

for i in range(n):
    for j in range(l):
        t=0
        for k in range (m) :
            t+=a[i][k]*b[k][j]
        result_vec[i][j]=t
for n in range(n):
    print(' '.join(map(str,result_vec[n])))   
    


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

int main() {
    string S;
    cin >> S;
    int siz = S.size();
    bool flag = true;

    for(int i=0; i<S.size()/2; i++){
	if(S[i] != S[siz-1-i])
	    flag=false;
    }

    for(int i=0; i<(siz-1)/2/2; i++){
	if(S[i] != S[(siz-1)/2-1-i])
	    flag=false;
    }

    for(int i=(siz+3)/2-1; i<S.size(); i++){
	if(S[i] != S[siz-1-i])
	    flag=false;
    }

    cout << (flag? "Yes": "No") << endl;

} 



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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    vector<int> dp(n, 0);
    for(int i = 1; i < n; ++i) {
        if(i == 1) 
            dp[i] = abs(a[i] - a[i-1]);
        else {
            dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

int main() {
    ll n, m, s=0;
    cin >> n >> m;
    if(n >= m/2) {
        cout << m/2 << endl;
    } else {
        s += n;
        m -= 2*n;
        s += m/4;
        cout << s << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    private static final long MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] A = new int[N][60];
        for (int i = 0; i < N; i++ ) {
            long a = sc.nextLong();
            int j = 0;
            while (a > 0) {
                A[i][j] = (int)(a%2);
                j++;
                a /= 2;
            }
        }

        long ans = 0;
        long pow = 1;
        for (int j = 0; j < 60; j++) {
            int num = 0;
            for (int i = 0; i < N; i++) {
                if (A[i][j] == 1) {
                    num++;
                }
            }
            ans += (((long)num*(N-num))%MOD)*pow%MOD;
            ans %= MOD;

            pow *= 2;
            pow %= MOD;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 184168
#include <stdio.h>

int main(void) {
  int n,m,x,i,tmp;
  int pay1=0,pay2=0;
  
  scanf("%d",&n);
  scanf("%d",&m);
  scanf("%d",&x);

  if(n<x){
    for(i=0;i<m;i++){
      scanf("%d",&tmp);
      if(tmp<x&&n<tmp)
	pay1++;
    }
    printf("%d",pay1);
  }
  if(n>x){
    for(i=0;i<m;i++){
      scanf("%d",&tmp);
      if(tmp<x)
	pay1++;
      if(tmp>x)
	pay2++;
    }
    if(pay1<pay2)
      printf("%d",pay1);
    if(pay1>pay2)
      printf("%d",pay2);
  }
	
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> A(N), cnt(N, 0);
    for (auto& a : A) {
        cin >> a;
        ++cnt[--a];
    }

    vector<int> cover(N, 0);
    for (int a = 0; a < N; ++a) {
        for (int i = 0; i < cnt[a]; ++i) {
            if (a - i < 0) break;
            ++cover[a - i];
        }
    }

    int ans = 0;
    for (int a = 0; a < N; ++a) {
        if (cover[a] == 0) ++ans;
    }

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

        int a = A[x];
        int l = a - cnt[a] + 1;
        if (l >= 0) {
            --cover[l];
            if (cover[l] == 0) ++ans;
        }
        --cnt[a];

        A[x] = y;
        ++cnt[y];
        int r = y - cnt[y] + 1;
        if (r >= 0) {
            if (cover[r] == 0) --ans;
            ++cover[r];
        }

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


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'

int main() {
    int s = 0;
    for (int i = 0; i < 5; i++) {
        int a;
        cin >> a;
        s += a;
    }
    cout << 15 - s << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;

    unordered_map<ll, ll> mp;
    rep(i, n) {
        mp[a[i]]++;
    }
    ll ans = 0;
    rep(i, n) {
        vl div = divisor(a[i]);
        bool plus = true;
        each(e, div) {
            if (e == a[i] && mp[e] > 1) {
                plus = false;
                break;
            } else if (e != a[i] && mp[e] > 0) {
                plus = false;
                break;
            }
        }
        if (plus) ans++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 33308
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
        	while(true) {
        		int m = sc.nextInt();
        		int n = sc.nextInt();
        		if(m==0 && n==0) break;
        		int w [] = new int[n];
        		int sum = 0;
        		int max = 0;
        		for(int i=0;i<n;i++) {
        			w[i] = sc.nextInt();
        			sum += w[i];
        			max = Math.max(w[i], max);
        		}
        		max = Math.max(max, sum/m);
        		
        		for(int i=max;;i++) {
        			sum = 0;
        			int count = 0;
        			for(int j=0;j<n;j++) {
        				sum += w[j];
        				if(sum>i) {
        					j--;
        					count++;
        					sum = 0;
        				}
        				if(count==m) break;
        			}
        			if(count<m) {
        			System.out.println(i);
        			break;
        			}
        		}
        	}	
        }
    }
}



Measured memory_bytes: 29524
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin h,w,k;
lin md = 1000000007;
lin res[102][9];

int main(void)
{
    cin >> h >> w >> k;

    res[0][0] = 1;

    rep(i, 100)
    {
        lin jMax = 1 << (w-1);
        rep(j, jMax)
        {
            bool b[w-1];
            rep(k, w-1)
            {
                b[k] = (j >> k) % 2 == 1;
            }

            bool isValid = true;
            rep(k, w-2)
            {
                if(b[k] && b[k+1])
                    isValid = false;
            }
            if(!isValid)
                continue;
            
            lin t[w];
            rep(k, w)
            {
                t[k] = k;
            }
            rep(k, w-1)
            {
                if(b[k])
                {
                    t[k] = k+1;
                    t[k+1] = k;
                }
            }

            rep(k, w)
            {
                res[i+1][k] += res[i][t[k]];
                res[i+1][k] %= md;
            }
        }
    }

    cout << res[h][k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;
int dp[100005];
bool rec(int k,int arr[],int mini,int n){
	if(k<mini)return 0;
	if(dp[k]!=-1)return dp[k];
	int aand=0;
	for(int i=1;i<=n;i++){
		if(k-arr[i]>=0){
     aand=((aand) ||(!rec(k-arr[i],arr,mini,n)));
	}
	}
	return dp[k]=aand;
}
int main() {
     int n,k,i,mini;
     mini=INT_MAX;
     cin>>n>>k;
     int arr[n+1];
     for(i=1;i<=n;i++){
     	cin>>arr[i];
     	mini=min(mini,arr[i]);
     }
     for(i=0;i<=k;i++){
     	dp[i]=-1;
     }
    int ans=rec(k,arr,mini,n);
    if(dp[k]){
    	cout<<"First\n";
    }else{
    	cout<<"Second\n";
    }
	return 0;
}

Measured memory_bytes: 5376
module Main where

import Control.Applicative
import Control.Monad
import Data.List

sharp xs = '#' : xs ++ ['#']

main :: IO ()
main = do
    [h, w] <- fmap read . words <$> getLine :: IO [Int]
    ass <- replicateM h getLine

    putStrLn $ replicate (w + 2) '#'
    mapM_ (putStrLn . sharp) ass
    putStrLn $ replicate (w + 2) '#'

Measured memory_bytes: 1404