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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

vector<ll> v;
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll com[51][51]={0};
    for(int i=0; i<51; ++i){
        com[i][0]=1;
        com[i][i]=1;
    }
    
    for(int i=1; i<51; ++i){
        for(int j=1; j<51; ++j){
            com[i][j] = com[i-1][j] + com[i-1][j-1];
        }
    }
    int N,A,B; cin >> N >> A >> B;
    map<ll,int> mp;
    REP(i, N){
        ll a;cin >> a;
        mp[a]++;
        v.push_back(a);
    }
    
    sort(all(v), greater<ll>());
    
    ll sum = 0;
    for(int i=0; i<A; ++i) sum += v[i];
    double ave = (double)sum / A;
    
    ll res = 0;
    int num = 0;
    for(int i=0; i<N; ++i) if(v[i] == v[A-1]) ++num;
    if(v[0] == v[A-1]){
        for(int j=A; j<=B; ++j){
            res += com[num][j];
        }
    }else{
        int a = 0;
        for(int i=0; i<A; ++i) if(v[i] == v[A-1]) ++a;
        res += com[num][a];
    }
    
    cout << ave << "\n" << res << endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int a[100001]={};
	int n,t,ans;
	scanf("%d", &n);
    ans=n;
	for (int i = 0; i < n; i++)
	{
      scanf("%d", &t);
      if(t <= n)
      {
        a[t]++;
        if(a[t] == t)
        {
          ans -= t;
        }
      }
	}
	printf("%d", ans);
	return 0;
}


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

int main() {
  int K;
  string S;
  cin>>K>>S;
  if(S.size()<=K){
    cout<<S<<endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	vector<string> v = {
		"SUN", 
		"MON",
		"TUE", 
		"WED", 
		"THU", 
		"FRI", 
		"SAT",
	};
	string s;
	cin >> s;
	int pos = find(v.begin(), v.end(), s) - v.begin();
	cout << (7 - pos) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[128], p[128], *i;
	char ss[256];
	if (fgets(s, sizeof(s), stdin) == NULL) return 1;
	if (fgets(p, sizeof(p), stdin) == NULL) return 1;
	if ((i = strchr(s, '\n')) != NULL) *i = '\0';
	if ((i = strchr(p, '\n')) != NULL) *i = '\0';
	strcpy(ss, s);
	strcat(ss, s);
	puts(strstr(ss, p) != NULL ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int H,W,h,w; cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;

    return 0;
}

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

int bkt[100010]={0};
int A[100010];
int ans;

int solve(int x,int count){
  bkt[x]++;
  if(A[x] == 2)  return count;
  if(bkt[x]>=2)  return -1; 
  count++;
  solve(A[x],count);
  }

int main() {
  int N; cin >> N;
   for(int i=1;i<=N;i++) cin >> A[i];
  cout << solve(1,1) << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int a,b,c,d=0;
  while(scanf("%d %d",&a,&b)){
    if(a==0 && b==0) break;
    if(d!=0)printf("\n");
    c=0;
    for(;a<=b;a++){
      if((a%4==0)-(a%100==0)+(a%400==0)){
        printf("%d\n",a);
        c=1;
      }
    }
    if(c==0)printf("NA\n");
    d=1;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X,Y,Z;
    cin >> X >> Y >> Z;
    ll lv = 0, rv = 1e5;
    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        if(mid * (Y + Z) + Z <= X){
            lv = mid;
        }else{
            rv = mid;
        }
    }
    print(lv);


}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <set>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
set<int> list;
int main() {
  rep(i,28){
    cin >> n;
    list.insert(n);
  }
  REP(i,1,31)
    if(list.count(i)==0)
      cout << i << endl;
  return 0;
}

Measured memory_bytes: 1192
from bisect import bisect_left


A,B,Q = map(int, input().split())
INF = float("inf")
S = [int(input()) for _ in range(A)]
S = [-INF] + S + [INF]
T = [int(input()) for _ in range(B)]
T = [-INF] + T + [INF]
X = [int(input()) for _ in range(Q)]

ans = []
for x in X:
    idx_s = bisect_left(S, x)
    idx_t = bisect_left(T, x)
    candidate = [max(abs(x - T[idx_t - 1]), abs(x - S[idx_s-1])),
                max(abs(x - S[idx_s]), abs(x - T[idx_t])),
                2*abs(x - S[idx_s-1]) + abs(x - T[idx_t]),
                2*abs(x - T[idx_t]) + abs(x - S[idx_s-1]),
                2*abs(x - T[idx_t-1]) + abs(x - S[idx_s]),
                2*abs(x - S[idx_s]) + abs(x - T[idx_t-1])
                ]
    ans.append(min(candidate))

print(*ans, sep="\n")

Measured memory_bytes: 103000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

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

map<int, int> mp;

rep(i,N) {
    mp[A[i]]++;
}
int ans = SZ(mp);
int cnt = 0;
for(auto x : mp) {
    cnt += x.second - 1;
}
if(cnt % 2 != 0) ans--;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 5376
import java.io.IOException;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		while (true) {
			int N = nextInt();
			if (N == 0) {
				break;
			}
			int M = nextInt();

			int[] codebook = new int[M];
			for (int i = 0; i < codebook.length; i++) {
				codebook[i] = nextInt();
			}

			int[][] dp = new int[N + 1][256];// i個目の音でy=jになった時の最小値
			for (int i = 0; i < dp.length; i++) {
				Arrays.fill(dp[i], Integer.MAX_VALUE);// 全部最大で埋めておく
			}
			dp[0][128] = 0;

			for (int i = 0; i < N; i++) {
				int x = nextInt();
				for (int j = 0; j < dp[i].length; j++) {
					if (dp[i][j] < Integer.MAX_VALUE) {
						int y = j;
						for (int k = 0; k < codebook.length; k++) {
							int nextY = y + codebook[k];
							if (nextY < 0) {
								nextY = 0;
							} else if (nextY > 255) {
								nextY = 255;
							}
							dp[i + 1][nextY] = Math.min(
									dp[i][j] + (int) Math.pow(x - nextY, 2),
									dp[i + 1][nextY]);
						}
					}
				}
			}
			int ans = Integer.MAX_VALUE;
			for (int i = 0; i < dp[N].length; i++) {
				ans = Math.min(ans, dp[N][i]);
			}

			System.out.println(ans);
		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

Measured memory_bytes: 72332
using System;

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            if(c >= a && c <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,h[maxn],tot,ans[maxn];
set<int>comp[maxn];
struct node
{
    int to,nxt,com;
}e[maxn<<2];
void add(int x,int y,int z)
{
    tot++;
    e[tot].to=y;
    e[tot].com=z;
    e[tot].nxt=h[x];
    h[x]=tot;
}
priority_queue<pair<int,int> >p;
int main()
{
    int i,j;
    memset(ans,inf,sizeof ans);
    scanf("%d%d",&n,&m);
    while(m--)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        add(a,b,c);
        add(b,a,c);
    }
    p.push({0,1});ans[1]=0;
    while(!p.empty())
    {
        int now=p.top().se,ca=-p.top().fi;
        p.pop();
        if(ans[now]<ca)continue;
        for(i=h[now];i;i=e[i].nxt)
        {
            int to=e[i].to,to_com=e[i].com;
            int to_ca=ca+(!comp[now].count(to_com));
            if(ans[to]>to_ca)
            {
                ans[to]=to_ca;
                p.push({-to_ca,to});
                comp[to].clear();
                comp[to].insert(to_com);
            }
            else if(ans[to]==to_ca)
            {
                comp[to].insert(to_com);
            }
        }
    }
    printf("%d\n",ans[n]==inf?-1:ans[n]);
    //system("Pause");
    return 0;
}


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

int main() {
    int n, sum = 0, ans = 0;
    cin >> n;
    vector<int> d(n);
    rep(i, n) {
        cin >> d.at(i);
        sum+= d.at(i);
    }
    rep(i, n) ans += d.at(i) * (sum - d.at(i));
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處
LL a[200005];
LL prefix[200005];
LL postfix[200005];
int n;

LL count(int i1, int i2, int i3) {
    LL s[] = {prefix[i1-1], prefix[i2-1] - prefix[i1-1], prefix[i3-1] - prefix[i2-1], prefix[n-1]-prefix[i3-1]};
    sort(s, s + 4);
    return s[3] - s[0];
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    LL pre = 0;
    LL post = 0;
    for (int i = 0; i < n; i++) {
        pre += a[i];
        prefix[i] = pre;
        post += a[n - 1 - i];
        postfix[n - 1 - i] = post;
    }
    vector<vector<int>> possibles;
    LL ans = 999999999999999999LL;
    for (int mid = 2; mid < n - 1; mid++) {
        // 0 ~ mid - 1, mid ~ n - 1
        LL target = prefix[mid - 1] / 2;
        LL *t = upper_bound(prefix, prefix + mid, target);
        int ind = t - prefix;

        target = prefix[mid-1] + (prefix[n - 1] - prefix[mid - 1]) / 2;
        t = upper_bound(prefix + mid, prefix + n, target);
        int ind3 = t - prefix;
        // printf("mid = %d, ind = %d , ind3 = %d\n", mid, ind, ind3);
        ans = min(ans, count(ind + 1, mid, ind3 + 1));
        ans = min(ans, count(ind + 1, mid, ind3));
        ans = min(ans, count(ind, mid, ind3 + 1));
        ans = min(ans, count(ind, mid, ind3));
    }

    printf("%lld\n", ans);
}


Measured memory_bytes: 4864
ii = lambda : int(input())

n = ii()

cnt=0
for i in range(1, 10):
    if n%i==0:
        a = n//i
        for j in range(1, 10):
            if a%j==0 and a//j==1:
                cnt+=1

if cnt==0:
    print('No')
else:
    print('Yes')

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

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

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 (a>b) { a=b; return 1; } return 0; }

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

void solve(std::string S){
  string ans;
  if(S=="AAA" or S=="BBB")ans=NO;
  else{ans=YES;}
  cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
      cout << fixed << setprecision(6);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();
    rep(i,N) if (S[i]=='?') S[i] = 'D';

    cout << S << ln;
}

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

#define PI 3.1415926535897932

//typedef long long ll;


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

/**
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int r,g,b,n,ans=0;
    scanf("%d %d %d %d",&r,&g,&b,&n);
    for (int i=0;i<n+1;i++) {
        for (int j=0;j<n+1;j++) {
            if ((i*r+j*g)>n) break;
            if ((n-(i*r+j*g))%b==0) ans+=1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
# A happy new year, AtCoder !
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

myinf = 10 ** 9 + 7
tab_graph = [[myinf] * (H * W) for _ in range(H * W)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            if i + di < 0: continue
            if i + di >= H: continue
            if j + dj < 0: continue
            if j + dj >= W: continue
            # print("#", i, j, '->', i + di, j + dj)
            if S[i + di][j + dj] == '#': continue
            #
            src = i * W + j
            dst = (i + di) * W + (j + dj)
            tab_graph[src][dst] = 1

from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

G = csgraph_from_dense(tab_graph, null_value=myinf)
d = floyd_warshall(G)

# print("#", d)
ans = 0
for i in range(H * W):
    for j in range(H * W):
        if i == j: continue
        # print("##", i, j, d[i][j])
        if d[i][j] < myinf: ans = max(ans, int(d[i][j]))

print(ans)

Measured memory_bytes: 20980
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;

int cnt[3][33] ;
int C , N , tr[33][33] ;

int calc( int u , int v , int w ){
	int rt = 0 ;
	for( int i = 1 ; i <= C ; i ++ )
		rt += cnt[0][i] * tr[i][u] + cnt[1][i] * tr[i][v] + cnt[2][i] * tr[i][w] ;
	return rt ;
}

void solve(){
	int ans = 0x3f3f3f3f ;
	for( int i = 1 ; i <= C ; i ++ )
		for( int j = 1 ; j <= C ; j ++ ) if( i != j )
			for( int k = 1 ; k <= C ; k ++ ) if( j != k && i != k )
				ans = min( ans , calc( i , j , k ) ) ;
	printf( "%d" , ans ) ;
}

int main(){
	scanf( "%d%d" , &N , &C ) ;
	for( int i = 1 ; i <= C ; i ++ )
		for( int j = 1 ; j <= C ; j ++ )
			scanf( "%d" , &tr[i][j] ) ;
	for( int i = 1 ; i <= N ; i ++ )
		for( int j = 1 , t ; j <= N ; j ++ )
			scanf( "%d" , &t ) , cnt[ (i+j)%3 ][t] ++ ;
	solve() ;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);

	int n,m,x,sum=0;
	cin>>n>>m;

	for(int i=0;i<m;i++)
	{
		cin>>x;
		sum+=x;
	}

	if(sum<=n)
		cout<<n-sum;
	else
		cout<<"-1";

	return 0;

}

Measured memory_bytes: 3644
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define case_for(n) for(int i = 1 ; i <= n ; i ++) { cout<<"Case "<<i<<": "<<endl; solve();}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll power(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a * a % p, b /= 2; }return ans; }
int hw_check(string a, int l, int r) { int ans = r - l + 1; for (l, r; l < r; l++, r--)if (a[l] != a[r]) return 0; return ans; }
string movesubstr(string a, int l, int r) { string s = "";	for (int i = l; i <= r; i++) s.push_back(a[i]);	return s; }


void solve()
{
	int n, l, r; cin >> n >> l >> r;
	if (n == 1) cout << "OK";
	else if (l / n < r / n || l % n == 0 || r % n == 0) cout << "OK" << endl;
	else  cout << "NG" << endl;
}
	
/*
3 3
3 3 3
4 1 3
4 1 3
*/
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(0);

	/*int t; cin >> t;
	while (t--) 
	{
		solve();
	}*/
	solve();
	return 0;
}
/*

*/

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

int main() {
  int N,M,i,j,k,l=0,ten=1;
  cin>>N;
  vector<string> s(N);
  for(i=0;i<N;i++){
    cin>>s.at(i);
  }
  cin>>M;
  vector<string> t(M);
  for(i=0;i<M;i++){
    cin>>t.at(i);
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if(s.at(i)==s.at(j)){
        ten++;
      }
    }
    for(k=0;k<M;k++){
      if(s.at(i)==t.at(k)){
        ten--;
      }
    }
    if(ten>l){
      l=ten;
    }
    ten=1;
  }
  cout<<l<<endl;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    vector<int> rui(n + 1, 0);
    for (int i = 1; i <=n; i++)
    {
        rui[i] = rui[i - 1] + a[i - 1];
    }
    show(rui);
    int r = 1e6,l=-1;
    int ans = 0;
    while (l + 1 < r)
    {
        int mid = (l + r) / 2;
        bool ok;
        int cnt = 0;
        int c = 0;
        for (int i = 0; i < n; i++)
        {
            int x = lower_bound(ALL(a), mid - a[i]) - a.begin();
            cnt += a[i]*(n-x)+(rui[n] - rui[x]);
            c += n - x;
            
        }
       // cerr << l << " " << r << endl;
        cerr << c << " " << cnt <<" "<<mid<< endl;
        ok = (c >= m ? 1 : 0);
        if(c==m){
            chmax(ans, cnt);
        }
        if (ok)
        {
            l = mid;
            ans =cnt - (c - m) * mid;
        }
        else{
            r = mid;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
N=int(input())

S = 'abcdefghij'

def num(x):
    ans = 0
    for i in range(len(S)):
        count = 0
        for j in range(0,len(x)):
            if x[j] == S[i]:
                count = count +1
        if count != 0:
            ans = ans + 1
        else:
            ans = ans
    return ans

def base(x):
    List=[]
    for j in range(len(x)):
        for i in range(num(x[j])+1):
            List.append(x[j]+S[i])
    return List

K = 'a'

cou = 1
while cou < N:
    K = base(K)
    cou = cou+1

for i in range(len(K)):
    print(K[i])

Measured memory_bytes: 12984
#include <iostream>

using namespace std;

int main()
{
   int a, b;     
   cin >> a >> b;
   if (a == b)
      cout << "a == b" <<endl;
   else if(a > b)
      cout << "a" << " > " << "b" <<endl;
   else
      cout << "a" << " < " << "b" <<endl;
   return 0;
}


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

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

    int sw = 0;
    bool flag = 1;
    for(int i = 0; flag; i++){
        flag = 0;
        rem(j,n-1,i+1){
            if(a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                sw++;
                flag = 1;
            }
        }
    }

    rep(i,0,n){
        if(i) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<sw<<endl;

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int d2 = j / 10;
            int d1 = j % 10;
            if(d1 >= 2 && d2 >= 2 && d1 * d2 == i){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int N;
vector<pair<int,int>> R;

int main(){
  cin >> N;
  if(N == 3){
    R.push_back(make_pair(1, 3));
    R.push_back(make_pair(2, 3));
  }
  else{
    if(N%2){
      for(int i=1; i<N; i++){
        R.push_back(make_pair(i, N));
      }
      N--;
    }
    for(int i=1; i<=N; i++){
      for(int j=i+1; j<=N; j++){
        if(j+i != N+1)
          R.push_back(make_pair(i, j));
      }
    }
  }

  cout << R.size() << endl;
  for(auto x : R){
    cout << x.first << " " << x.second << endl;
  }

  return 0;
}


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

int main() {
    ll n;
    cin >> n;

    vector<ll> divisor;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            divisor.push_back(i);
            if (i * i != n) divisor.push_back(n / i);
        }
    }

    ll ans = 0;
    for (auto i : divisor) {
        ll m = i - 1;
        if (m == 0) continue;
        if (n / m == n % m) ans += m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
int main(){
    int a, b, c;
 
    cin >> a;
    cin >> b;
    cin >> c;
 
    int count = 0;
 
    for ( int i = a; i <= b; i++ ) {
        if ( c % i == 0 ) {
            count++;
 
        }
    }
 
    cout << count << endl;
 
}

Measured memory_bytes: 1160
n = int(input())
*p, = map(int, input().split())
q = [True if p[i] != i+1 else False for i in range(n)] + [True]
ans = 0
for i in range(n):
    if not q[i]:
        ans += 1
        q[i] = q[i+1] = True
print(ans)


Measured memory_bytes: 20596
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846264338327950L
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
	//return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow
	//return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数

//素数判定
template<typename T>
bool IsPrime(T num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));
//vector<vector<Type>> vv(n);
//cout << fixed << setprecision(20) << endl;

int main() {
	ll N, M;cin>>N>>M;
	vector<ll>k(M + 1), p(M + 1);
	vector<vector<ll>> data(M+1);
	ll a = 0;
	for (ll i = 1;i <= M;i++) {
		cin >> k[i];
		data[i].resize(k[i]+1);
		for (ll j = 1;j <= k[i];j++) {
			cin >> a;
			a--;
			data[i][j] = a;
		}
	}
	ll bulb;
	ll ans = 0;
	bool ok = true;
	for (ll i = 1;i <= M;i++)cin >> p[i];
	for (ll bit = 0;bit < (1 << N);bit++) {
		ok = true;
		for (ll i = 1;i <= M;i++) {
			bulb = 0;
			for (ll j = 1;j <= k[i];j++) {
				if (bit & (1 << data[i][j])) {
					bulb++;
				}
			}
			if (bulb % 2 != p[i]) {
				ok = false;
				break;
			}
		}
		if (ok) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter, deque

N = int(input())
A = list(map(int, input().split()))

cntA = Counter(A)
valA = list(set(A))
valA.sort(reverse=True)

pathLeng = [0] * (N + 1)

if cntA[valA[0]] < 2 or cntA[valA[-1]] > 2:
    print('Impossible')
    exit()

pathLeng[1] = valA[0]
pathLeng[2] = valA[0]
cntA[valA[0]] -= 2
maxNode = 2

pr = [[] for _ in range(N + 1)]
ch = [[] for _ in range(N + 1)]

for i, a in enumerate(valA[1:], start=2):
    if a == valA[-1] and cntA[valA[-1]] == 1:
        prevLeft = maxNode
        prevRight = maxNode - 1
        maxNode += 1
        ch[prevLeft].append(maxNode)
        ch[prevRight].append(maxNode)
        pr[maxNode].append(prevLeft)
        pr[maxNode].append(prevRight)
        pathLeng[maxNode] = valA[-1]
        cntA[valA[-1]] -= 1
        break

    prevLeft = (i - 1) * 2 - 1
    prevRight = (i - 1) * 2
    nowLeft = i * 2 - 1
    nowRight = i * 2

    maxNode = max(maxNode, nowRight)
    if maxNode > N:
        print('Impossible')
        exit()

    pathLeng[nowLeft] = a
    pathLeng[nowRight] = a

    cntA[a] -= 2

    ch[prevLeft].append(nowLeft)
    ch[prevRight].append(nowRight)
    pr[nowLeft].append(prevLeft)
    pr[nowRight].append(prevRight)
else:
    ch[maxNode].append(maxNode - 1)
    pr[maxNode - 1].append(maxNode)

for a, c in cntA.items():
    for _ in range(c):
        maxNode += 1
        i = pathLeng.index(a)
        ch[maxNode].append(ch[i][0])
        pr[ch[i][0]].append(maxNode)
        pathLeng[maxNode] = a
        cntA[a] -= 1

def search(index):
    visited = [False] * (N + 1)
    visited[index] = True
    st = deque([(index, 0)])
    ret = 0

    while st:
        now, d = st.pop()
        ret = max(ret, d)

        for to in pr[now]:
            if not visited[to]:
                st.append((to, d + 1))
                visited[to] = True
        for to in ch[now]:
            if not visited[to]:
                st.append((to, d + 1))
                visited[to] = True
    return ret

for i, d in enumerate(pathLeng[1:], start=1):
    if search(i) != d:
        print('Impossible')
        exit()

for v in cntA.values():
    if v != 0:
        print('Impossible')
        exit()

A.sort()
pathLeng.sort()

if A == pathLeng[1:]:
    print('Possible')
else:
    print('Impossible')

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

int main()
{
    int N;
    float T, A;
    cin >> N;
    cin >> T >> A;

    float m = 1000;
    int ans = 0;
    float h;
    for (int i = 0; i < N; i++)
    {
        cin >> h;

        if (abs(A - T + h * 0.006) < m)
        {
            m = abs(A - T + h * 0.006);
            ans = i + 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }


VV g;
vector<P> len;

int dfs(int now) {
	int a = g[now][0] >= 0 ? dfs(g[now][0]) : 1;
	int b = g[now][1] >= 0 ? dfs(g[now][1]) : 1;
	int p, q;
	tie(p, q) = len[now];
	int gcd = __gcd(a*p, b*q);
	int x = b*q / gcd;
	int y = a*p / gcd;
	return a*x + b*y;
}

signed main() {
	int n;
	while (cin >> n&&n) {
		g.clear();
		g.resize(n);
		len.clear();
		len.resize(n);
		V root(n, true);
		rep(i, n) {
			int p, q, r, b;
			cin >> p >> q >> r >> b;
			r--; b--;
			int gcd = __gcd(p, q);
			p = p / gcd;
			q = q / gcd;
			if (~r) root[r] = false;
			if (~b) root[b] = false;
			g[i].push_back(r);
			g[i].push_back(b);
			len[i] = P(p, q);
		}
		int idx = find(all(root), true) - root.begin();
		cout << dfs(idx) << endl;
	}

	//system("pause");
}

Measured memory_bytes: 3144
require 'set'

x = gets.split(" ").map(&:to_i)
a = {}
x.each_with_index { |x, i| a[x] = [0, i] }

x = gets.split(" ").map(&:to_i)
x.each_with_index { |x, i| a[x] = [1, i] }

x = gets.split(" ").map(&:to_i)
x.each_with_index { |x, i| a[x] = [2, i] }

n = gets.to_i

res = []
n.times do |i|
  res << a[gets.to_i]
end


bingo_set = [
  [[0, 0], [0, 1], [0, 2]],
  [[1, 0], [1, 1], [1, 2]],
  [[2, 0], [2, 1], [2, 2]],
  [[0, 0], [1, 0], [2, 0]],
  [[0, 1], [1, 1], [2, 1]],
  [[0, 2], [1, 2], [2, 2]],
  [[0, 0], [1, 1], [2, 2]],
  [[0, 2], [1, 1], [2, 0]],
]

ans = false
bingo_set.each do |bingo|
  if Set.new(bingo).subset?(Set.new(res)) then
    ans = true
  end
end

puts ans ? "Yes" : "No"


Measured memory_bytes: 2044
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
A = [a-1 for a in LIST()]

MAX = 64
nxt = list2d(MAX, N, -1)
for i, a in enumerate(A):
    nxt[0][i] = a

for k in range(1, MAX):
    for i in range(N):
        nxt[k][i] = nxt[k-1][nxt[k-1][i]]

ans = 0
for k in range(MAX-1, -1, -1):
    if K >> k & 1:
        ans = nxt[k][ans]
print(ans+1)


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long

int main() {
  int n , k ;
  cin >> n >> k ;
  vector<int> l(n);
  int ans = 0 ;
  
  rep(i,n)
    cin >> l.at(i);
  
  sort(all(l));
  reverse(all(l));
  
  rep(i,k)
    ans += l.at(i);
  
  cout << ans;
}


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

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


def CalculateExpectedValu(n):
    bunbo = 1 / n
    ans = 0

    for i in range(1,n+1):
        ans = ans + (i*bunbo)

    return ans

number = 0
CumulativeSum = [0]

for i in P:
    number = number + CalculateExpectedValu(i)
    CumulativeSum.append(number)

ans = 0



for i in range(0 , (len(CumulativeSum)-K)):
    tmpans = CumulativeSum[i+K] - CumulativeSum[i]
    ans = max(ans, tmpans)

print(ans)


Measured memory_bytes: 99100
#include<bits/stdc++.h>
using namespace std;
int h,n,a,s;
int main(){
	cin >> h >> n;
	for(int i = 1;i <= n;i++){
		cin >> a;
		s = s + a;
	}
	if (s >= h)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
  double a,b,b1,s;
  cin >> a >> b;
  b1 = b * 10.0;
  for(int i = 0; i < 10; i++){
    s = b1+i;
    int a1;
    a1 = s* 0.08;
    if(a==a1){
      cout << s << endl;
      break;
    }
    else if(i == 9){cout << -1 << endl;}
  }

}

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> as, bs;
    for (int k = 1; k < 8; ++k) {
        for (int a = 1 << k; a < n; a += 1 << k + 1) {
            for (int b = a + 1; b < min(n, a + (1 << k)); ++b) {
                as.push_back(a);
                bs.push_back(b);
            }
        }
    }
    int m = as.size();
    cout << m << endl;
    for (int i = 0; i < m; ++i) {
        cout << as[i] + 1 << ' ' << bs[i] + 1 << endl;
    }
    auto query = [&](int x) -> int {
        if (x >= n) return 0;
        cout << x + 1 << endl;
        string s; cin >> s;
        if (s == "Yes") return -1;
        if (s == "Near") return 1;
        assert(s == "No");
        return 0;
    };
    auto solve = [&]() -> void {
        int l = 0, u = 256;
        while (true) {
            int mid = u + l >> 1;
            int r = query(mid);
            if (r == -1) return;
            (r ? l : u) = mid;
        }
        // return l;
    };
    while (k--) {
        solve();
    }
}


Measured memory_bytes: 3308
from collections import deque

n = int(input())
p = list(map(int,input().split()))
z = list(map(int,input().split()))
p_n = 0
q_n = 0
for i in range(len(p)):
    if i == 0:
        p_n = p[i]
        q_n = z[i]
    else:
        p_n = p[i]+(p_n*10)
        q_n = z[i]+(q_n*10)


q = deque()
ans_list = []
n_list = [0 for i in range(n)]


for i in range(n):
    n_list[i] = 1
    tmp = []
    for j in n_list:
        tmp.append(j)
    q.append([i+1,tmp])
    n_list[i] = 0

while len(q) != 0:
    tmp = q.popleft()
    s = str(tmp[0])
    if len(s) == n:
        ans_list.append(tmp[0])
        continue
    for i in range(n):
        tmp_n = tmp[0]
        if tmp[1][i] == 0:
            tmp_l = []
            for j in range(n):
                tmp_l.append(tmp[1][j])
            tmp_l[i] = 1
            q.append([(i+1)+tmp_n*10,tmp_l])

ans_list = sorted(ans_list)

p_i = 0
q_i = 0

for i in range(len(ans_list)):
    if ans_list[i] == p_n:
        p_i = i
    if ans_list[i] == q_n:
        q_i = i

print(abs(p_i-q_i))


Measured memory_bytes: 19896
N,K=map(int,input().split())
A=list(map(int,input().split()))

buckets = {}
for i in A:
  if i in buckets:
    buckets[i] += 1
  else:
    buckets[i] = 1

kinds = sorted(buckets.values(), reverse=True)
if K < len(kinds):
  mini = N-sum([kinds[i] for i in range(K)])
  print(mini)
else:
  print(0)


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      int y = X - 500*a - 100*b;
      if(y < 0 || y > C*50) continue;
      if(y % 50 == 0) ++res; 
//      for (int c = 0; c <= C; ++c) {
//        int total = 500*a + 100*b + 50*c; // 合計金額
//        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
//      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n--){
    int mas[6][6] = {{}};
    for(int i = 1; i <= 5; i++){
      for(int j = 1; j <= 5; j++){
        int c;
        cin >> c;
        mas[i][j] = mas[i - 1][j] + mas[i][j - 1] - mas[i - 1][j - 1] + c;
      }
    }
    int ret = -1;
    for(int i = 1; i <= 5; i++){
      for(int j = 1; j <= 5; j++){
        for(int k = 0; k < 5; k++){
          if(i + k > 5) break;
          for(int l = 0; l < 5; l++){
            if(j + l > 5) break;
            int sum = mas[i + k][j + l] + mas[i - 1][j - 1] - mas[i - 1][j + l] - mas[i + k][j - 1] ;
            ret = max( ret, (k + 1) * (l + 1) * (sum == (k + 1) * (l + 1)));
          }
        }
      }
    }
    cout << ret << endl;
  }
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N;
    cin>>N;
    multiset<ll> m;
    rep(i,N){
        ll x;
        cin>>x;
        m.insert(x);
    }
    ll ans = 0LL;
    while(!m.empty()){
        auto ite = m.end();
        ite--;
        ll t = *ite;
        m.erase(ite);
        ll s = t;
        ll c = 1LL;
        while(s>0){
            s>>=1LL;
            c<<=1LL;
        }
        if(m.find(c-t)!=m.end()){
            ans++;
            m.erase(m.find(c-t));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12968
#include <stdio.h>
#include <math.h>

#define sq(x) ((x) * (x))
int color[8][3] ={ {0,0,0},
		   {0,0,255},
		   {0,255,0},
		   {0,255,255},
		   {255,0,0},
		   {255,0,255},
		   {255,255,0},
		   {255,255,255} };

int convert(char a, char b){
  int x, y;
  if(a >= 'a' && a <= 'f') x = (a - 'a' + 10) * 16;
  else x = (a - '0') * 16;
  if(b >= 'a' && a <= 'f') y = b - 'a' + 10;
  else y = b - '0';
  return x + y;
}

int main(){
  int n, i, j, c[3], dmin, dk;
  char rgb[16], s;

  while(scanf("%c", &s) && s != '0'){
    scanf("%s", rgb);
    getchar();
    c[0] = c[1] = c[2] = 0;
    for(i = 0, j = 0; i < 6; i += 2, j++)
      c[j] = convert(rgb[i], rgb[i + 1]);
    
    dmin = -1;
    int res;
    for(i = 0; i < 8; ++i){
      dk = sq(c[0] - color[i][0]) + sq(c[1] - color[i][1]) + sq(c[2] - color[i][2]);
      if(dmin > dk || dmin == -1){
	dmin = dk;
	res = i;
      }
    }

    switch(res){
    case 0: puts("black"); break;
    case 1: puts("blue"); break;
    case 2: puts("lime"); break;
    case 3: puts("aqua"); break;
    case 4: puts("red"); break;
    case 5: puts("fuchsia"); break;
    case 6: puts("yellow"); break;
    case 7: puts("white"); break;
    }
  }
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	string s;
	cin >> s;
	if(s.size()>3)
	{
		if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

#define Nfor(N) for(int i=0;i<N;i++) 

int main(){
  	int N, K;
  	cin >> N >> K;
  	vector<int> bA(N, 0);
  	Nfor(N){
      	int A_tmp;
      	cin >> A_tmp;
      	bA[A_tmp - 1]++;
    }
  	sort(bA.rbegin(), bA.rend());
  	int count = accumulate(bA.begin()+K, bA.end(), 0);
  	cout << count << endl;
}

Measured memory_bytes: 4028
#include	<iostream>
#include	<cstdio>
#include	<cmath>

using namespace std;

int main(void) {
	int tyou = 0, hisi = 0;
	while(1) {
		int a, b, c;
		if( scanf("%d,%d,%d", &a, &b, &c) == EOF )	{ break; }
		if(a == b) {
			hisi++;
		} else if( b * b + a * a == c * c ) {
			tyou++;
		}
	}
	cout << tyou << endl << hisi << endl;
	return 0;
}

Measured memory_bytes: 1204