akhauriyash/Code-Regression huggingface dataset:
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int a, b, target[105], score[105], mon;
int main() {
	cin >> a >> b;
	for (int i = 0; i < b; ++i) {
		cin >> target[i];
	}
	for (int i = 0; i < b; ++i) {
		for (int j = 0; j < a; ++j) {
			cin >> mon;
			if (mon == target[i]) ++score[j];
			else ++score[target[i] - 1];
		}
	}
	for (int i = 0; i < a; ++i) {
		cout << score[i] << endl;
	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);


inline LL in() { LL in; scanf("%lld", &in); return in; }
inline void outLL(LL out, bool endl = 1) { printf("%lld%c", out, " \n"[endl]); }

int main() {
	int N = in(), M = in();
	VI deg(N);
	VVI G(N); {
		FOR(i, 0, N - 1 + M) {
			int a = in() - 1, b = in() - 1;
			G[a].push_back(b);
			deg[b]++;
		}
	}
	VI par(N); // +1しとく
	int p = 0;
	FOR(i, 0, N) {
		if (deg[i] == 0)par[i] = 0, p = i;
	}
	queue<int>q;
	q.push(p);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int nx : G[v]) {
			deg[nx]--;
			if (deg[nx] == 0) {
				q.push(nx);
				par[nx] = v+1;
			}
		}
	}
	FOR(i, 0, N) {
		outLL(par[i]);
	}

}

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

int main(){
  string s[] = {"BD","ACE","BF","AEG","BDFH"
		,"CEI","DH","EGI","FH"};

  for(int i = 0 ; i < 1000 ; i++){
    string str;
    bool possible = true;

    cin >> str;
    int size = str.size();
    for(int j = 1 ; j < size ; j++){
      int k;
      for(k = 0 ; k < s[str[j-1]-'A'].size() ; k++){
	if(str[j] == s[str[j-1]-'A'][k]){
	  break;
	}
      }
      if(k == s[str[j-1]-'A'].size()){
	possible = false;
	break;
      }   
    }
    if(possible){
      cout << str << endl;
    }
  }

  return 0;
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
//	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	string s;
	getline(cin, s);
	int kol = 0;
	for (int i = sz(s) / 2; i < sz(s); ++i) {
		if (i != sz(s) / 2 && s[i] != s[i - 1])
			break;
		if (s[i] == s[sz(s) - 1 - i]) {
			debug(all(s));
			debug(mt(i, sz(s) - 1 - i));
			kol++;     	
		} else {
		 	break;
		}
	}
	debug(mt(sz(s), kol));
	cout << sz(s) / 2 + kol << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int a,b;

    scanf("%d %d", &a, &b);
    printf("%d\n", a*b);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3828
fun main(args: Array<String>) {

    val input = readLine()?.split(" ")
    val inputInt = arrayListOf<Int>()
    input?.forEach { inputInt.add(it.toInt()) }
    
    var count = 0
    for (i in inputInt[0]..inputInt[1]) {
        if (inputInt[2] % i == 0) count++
    }

    println("$count")
}



Measured memory_bytes: 32416
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	const m = 2019
	var exgcd func(a, b int) (x, y int)
	exgcd = func(a, b int) (x, y int) {
		if b == 0 {
			return 1, 0
		}
		y, x = exgcd(b, a%b)
		y -= a / b * x
		return
	}
	invM := func(a int) int { x, _ := exgcd(a, m); return (x%m + m) % m }

	var s []byte
	Fscan(bufio.NewReader(_r), &s)
	cnts := [m]int{0: 1}
	ans, v, ten := 0, 0, 1
	for _, b := range s {
		v = (v*10 + int(b-'0')) % m
		w := v * invM(ten) % m
		ans += cnts[w]
		cnts[w]++
		ten = ten * 10 % m
	}
	Fprint(_w, ans)
}

func main() { run(os.Stdin, os.Stdout) }


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

int main()
{
  int E,Y;
  cin>>E>>Y;

  switch(E){
    case 0:
      if(1868<=Y&Y<=1911){
        cout<<'M'<<Y-1867<<endl;
      }
      else if(1912<=Y&Y<=1925){
        cout<<'T'<<Y-1911<<endl;
      }
      else if(1926<=Y&Y<=1988){
        cout<<'S'<<Y-1925<<endl;
      }
      else if(1989<=Y&Y<=2016){
        cout<<'H'<<Y-1988<<endl;
      }
      break;

    case 1:
      cout<<Y+1867<<endl;
      break;
    case 2:
      cout<<Y+1911<<endl;
      break;
    case 3:
      cout<<Y+1925<<endl;
      break;
    case 4:
      cout<<Y+1988<<endl;
      break;
  }
  return 0;
}

Measured memory_bytes: 3080
// Problem : C - Snuke Festival
// Contest : AtCoder - AtCoder Beginner Contest 077
// URL : https://atcoder.jp/contests/abc077/tasks/arc084_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int n;cin>>n;
	vi a(n),b(n),c(n);cin>>a>>b>>c;
	sort(all(a));
	sort(all(b));
	sort(all(c));
	int ans=0;
	int suff[n];
	for(int i=n-1;i>=0;i--)
	{
		int ind=upper_bound(all(c),b[i])-c.begin();
		if(i==n-1)
		{
			suff[n-1]=n-ind;
		}
		else
		{
			suff[i]=n-ind;
			suff[i]+=suff[i+1];
		}
	}
	for(int i=0;i<n;i++)
	{
		int ind=upper_bound(all(b),a[i])-b.begin();	
		if(ind<n)	
		ans+=suff[ind];
	}
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int flag=0;
    for (int i=0;i<3;i++) {
        if (s.at(i)==s.at(i+1)) {
            cout<<"Bad"<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<"Good"<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}





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

two_beki = [1]*20
for i in range(1,20):
    two_beki[i] = 2**i
#[1,2,4,8,16,32,64,128,256,512,1024,2048,8192,16384]
n = N+1
list_index = list()
for I in range(1,n):
    for J in range(20):
        if(I*two_beki[J]>=K):
            list_index.append(J) 
            # print(J,I*two_beki[J])
            break
#print(list_index)
sum_harf = 0.0
for I in list_index:
    sum_harf += 1/two_beki[I]/N
print(sum_harf)


Measured memory_bytes: 3864
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;



int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	long long res = 0;
	for (int i = 0; i < n - 1; i++)
		for (int j = i + 1; j < n; j++)
			res += a[i] * a[j];
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, K;
void func()
{
    cin >> N >> K;
    int ans(1);
    rep(i, 0, N)
    {
        if (ans < K)
            ans *= 2;
        else
            ans += K;
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>

using namespace std;


int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    if (a == 0)
    {
        cout << (b / x + 1) - 0 << endl;
    }
    else
    {
        cout << (b / x + 1) - ((a - 1) / x + 1) << endl;
    }
    

    return 0;
}


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

int main()
{
	int a, b, c, res = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c % i == 0)
			res++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;

	string s = "";
	for (int i = 0; i < n; i++) {
		if (s1[i] == s2[i]) {
			s += "X";
		} else {
			s += "Y";
			i++;
		}
	}

	long long ans = (s[0] == 'X') ? 3 : 6;
	int mod = 1000000007;
	for (int i = 1; i < s.length(); i++) {
		if (s[i - 1] == 'X') {
			if (s[i] == 'X') {
				ans *= 2;
			} else {
				ans *= 2;
			}
		} else {
			if (s[i] != 'X') {
				ans *= 3;
			}
		}
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long LL;
const int MAXN = 510;
const int INF = 0x3f3f3f3f;
const int MAXE = MAXN * MAXN * 10;
const LL NINF = 0xcfcfcfcfcfcfcfcf;
int head[MAXN], nxt[MAXE], to[MAXE], val[MAXE], tot = 1;
LL cost[MAXE];
void addedge(int b, int e, int v, LL c) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e; val[tot] = v; cost[tot] = c;
	nxt[++tot] = head[e]; to[head[e] = tot] = b; val[tot] = 0; cost[tot] = -c;
}
LL dis[MAXN]; bool inq[MAXN];
std::queue<int> q;
int S, T, idx;
bool bellmanford() {
	memset(dis, 0xcf, idx + 1 << 3);
	dis[S] = 0; inq[S] = true; q.push(S);
	while (!q.empty()) {
		int t = q.front(); q.pop(); inq[t] = false;
		for (int i = head[t]; i; i = nxt[i])
			if (val[i] && dis[to[i]] < dis[t] + cost[i]) {
				dis[to[i]] = dis[t] + cost[i];
				if (!inq[to[i]]) {
					inq[to[i]] = true;
					q.push(to[i]);
				}
			}
	}
	return dis[T] != NINF;
}
int dinic(int u, int minv) {
	if (u == T || !minv) return minv;
	int res = 0, t;
	inq[u] = true;
	for (int & i = head[u]; i; i = nxt[i])
		if (val[i] && !inq[to[i]] && dis[to[i]] == dis[u] + cost[i] && (t = dinic(to[i], std::min(minv, val[i])))) {
			minv -= t;
			res += t;
			val[i] -= t;
			val[i ^ 1] += t;
			if (!minv) break;
		}
	inq[u] = false;
	if (!res) dis[u] = NINF;
	return res;
}
LL flow(int & fl) {
	static int th[MAXN];
	memcpy(th, head, idx + 1 << 2);
	LL res = 0; int t;
	while (bellmanford()) {
		t = dinic(S, INF);
		fl -= t, res += t * dis[T];
		memcpy(head, th, idx + 1 << 2);
	}
	return res;
}
int n, m;
int xs[MAXN], ys[MAXN];
int ts[MAXN], as[MAXN], bs[MAXN];
LL vs[MAXN];
int xl[MAXN], xr[MAXN], yl[MAXN], yr[MAXN];
void getmax(int & x, int y) { x < y ? x = y : 0; }
void getmin(int & x, int y) { x > y ? x = y : 0; }
const int R = 100;
LL solve(int K) {
	memset(head, 0, idx + 1 << 2); tot = 1, idx = R << 1 | 1;
	for (int i = 1; i <= n; ++i)
		addedge(xs[i], ys[i] + R, 1, vs[i]);
	for (int i = 0; i <= K + 1; ++i)
		xl[i] = yl[i] = 1, xr[i] = yr[i] = R;
	for (int i = 1; i <= m; ++i) if (bs[i] <= K)
		switch (ts[i]) {
			case 'L': getmax(xl[bs[i] + 1], as[i] + 1); break;
			case 'R': getmin(xr[K - bs[i]], as[i] - 1); break;
			case 'D': getmax(yl[bs[i] + 1], as[i] + 1); break;
			case 'U': getmin(yr[K - bs[i]], as[i] - 1); break;
		}
	for (int i = 1; i <= K; ++i)
		getmax(xl[i], xl[i - 1]), getmax(yl[i], yl[i - 1]);
	for (int i = K; i; --i)
		getmin(xr[i], xr[i + 1]), getmin(yr[i], yr[i + 1]);
	for (int i = 1; i <= K; ++i) {
		addedge(S, ++idx, 1, 0);
		for (int j = xl[i]; j <= xr[i]; ++j)
			addedge(idx, j, 1, 0);
		addedge(++idx, T, 1, 0);
		for (int j = yl[i]; j <= yr[i]; ++j)
			addedge(j + R, idx, 1, 0);
	}
	LL res = flow(K);
	return K ? NINF : res;
}

int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i)
		std::cin >> xs[i] >> ys[i] >> vs[i];
	std::cin >> m;
	static char buf[10];
	for (int i = 1; i <= m; ++i)
		std::cin >> buf >> as[i] >> bs[i], ts[i] = *buf;
	LL ans = 0;
	S = 0, T = idx = R << 1 | 1;
	for (int i = 1; i <= n; ++i)
		ans = std::max(ans, solve(i));
	std::cout << ans << std::endl;
	return 0;
}


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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll fac(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

int main() {
	ll n,m,v,p; cin>>n>>m>>v>>p;
	ll a[n]; for(int i=0; i<n; i++) cin>>a[i];
	sort(a,a+n,greater<>());
	
	ll last;
	for(last=n-1; last>p-1; last--) {
		if(a[last]+m>=a[p-1]) break;
	}
	
	for( ; last>p-1; last--) {
      if(v<=n-last+p-1 || (accumulate(a+p-1,a+last,0LL)+(v-(n-last+p-1))*m <= (last-p+1)*(a[last]+m)) ) break;
		
    }
	cout << last+1 << endl;
	
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool ok(int x)
{
	for(int i = 2; i * i <= x; ++i) if (x % i == 0) return 0;
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	LL a, b;
	cin >> a >> b;
	cout << a * b / __gcd(a, b);
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
N, T = map(int, input().split())
c_min = 1001
for i in range(N):
    c,t = map(int, input().split())
    if t <= T:
        c_min = min(c, c_min)
if c_min == 1001:
    print("TLE")
else:
    print(c_min)

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    
    int ans=0;
    if(s=="SUN") ans=7;
    if(s=="MON") ans=6;
    if(s=="TUE") ans=5;
    if(s=="WED") ans=4;
    if(s=="THU") ans=3;
    if(s=="FRI") ans=2;
    if(s=="SAT") ans=1;

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
A = np.array([lr() for _ in range(H)])
B = np.array([lr() for _ in range(H)])
diff = np.abs(A - B).tolist()

X = (H+W) * 80
L = X + X + 1 #真ん中を0とする、最後に-X
dp = [[np.zeros(L, np.bool) for _ in range(W)] for _ in range(H)]
di = diff[0][0]
dp[0][0][X+di] = 1; dp[0][0][X-di] = 1
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue
        di = diff[i][j]
        if i > 0:
            prev = dp[i-1][j]
            dp[i][j][di:] |= prev[:L-di]
            dp[i][j][:L-di] |= prev[di:]
        if j > 0:
            prev = dp[i][j-1]
            dp[i][j][di:] |= prev[:L-di]
            dp[i][j][:L-di] |= prev[di:]

dp = dp[-1][-1][X:]
possible = np.nonzero(dp)[0]
answer = possible.min()
print(answer)


Measured memory_bytes: 173484
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    string S;
    cin >> S;
    if(S == "SUN") cout << 7 << endl;
    else if(S == "MON") cout << 6 << endl;
    else if(S == "TUE") cout << 5 << endl;
    else if(S == "WED") cout << 4 << endl;
    else if(S == "THU") cout << 3 << endl;
    else if(S == "FRI") cout << 2 << endl;
    else if(S == "SAT") cout << 1 << endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	int a[n], x[n][n], y[n][n];
	for(int i=0; i<n; i++){
		cin >> a[i];
		for(int j=0; j<a[i]; j++){
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}

	int ans=0;
	for(int p=0; p<(1<<n); p++){
		bool flg=true;
		for(int i=0; i<n; i++){
			if(!((p>>i)&1)) continue;
			for(int j=0; j<a[i]; j++){
				if(y[i][j]^((p>>x[i][j])&1)) flg=false;
			}
		}
		if(flg){
			int t=0;
			for(int i=0; i<n; i++){
				if(p&(1<<i)) t++;
			}
			ans=max(ans, t);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   string n;
 
   cin >> n;
  
   if(n=="AAA"||n=="BBB"){
     cout << "No" << endl;
   }else{
     cout << "Yes" << endl;
   }
   
   
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static class Dice {
		private int[] sides;

		private static int[][] eastTable = {
			{6, 2, 4, 1, 3, 6},
			{3, 6, 0, 5, 6, 2},
			{1, 5, 6, 6, 0, 4},
			{4, 0, 6, 6, 5, 1},
			{2, 6, 5, 0, 6, 3},
			{6, 3, 1, 4, 2, 6}
		};

		private static Dice getDice(String line) {
			Dice dice = new Dice();
			String[] sides = line.split(" ");
			dice.sides = new int[sides.length];
			for (int i = 0; i < sides.length; i++) {
				dice.sides[i] = Integer.parseInt(sides[i]);
			}
			return dice;
		}

		public static int getEast(Dice dice, int tnum, int snum) {
			boolean tflag = false;
			boolean sflag = false;
			int top = 0;
			int south = 0;
			int[] sides = dice.sides;
			for (int i = 0; i < sides.length; i++) {
				if (tnum == sides[i]) {
					top = i;
					tflag = true;
					if (sflag) {
						break;
					}
				} else if (snum == sides[i]) {
					south = i;
					sflag = true;
					if (tflag) {
						break;
					}
				}
			}

			int eastSide = eastTable[top][south];
			int east;
			if (eastSide == 6) {
				east = -1;
			} else {
				east = sides[eastSide];
			}

			return east;
		}
	}

	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			Dice dice1 = Dice.getDice(input.readLine());
			Dice dice2 = Dice.getDice(input.readLine());
			boolean equal = false;

			for (int i = 0; i < 6; i++) {
				if (equal) {
					break;
				}

				if (dice1.sides[0] == dice2.sides[i] && dice1.sides[5] == dice2.sides[5-i]) {
					for (int j = 0; j < 6; j++) {
						if (equal) {
							break;
						} else if (j == i) {
							continue;
						}

						if (dice1.sides[1] == dice2.sides[j] && dice1.sides[4] == dice2.sides[5-j]) {
							for (int k = 0; k < 6; k++) {
								if (equal) {
									break;
								} else if (k == i || k == j) {
									continue;
								}

								if (dice1.sides[2] == dice2.sides[k] && dice1.sides[3] == dice2.sides[5-k]) {
									if (dice1.sides[2] == Dice.getEast(dice2, dice2.sides[i], dice2.sides[j])) {
										equal = true;
									} else if (dice2.sides[k] == dice2.sides[5-k]) {
										equal = true;
									}
								}
							}
						}
					}
				}
			}

			System.out.println(equal ? "Yes" : "No");
			input.close();
		} catch (Exception e) {
			e.printStackTrace();
		}		
	}
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, M; cin >> N >> M;
  priority_queue<int> pq;
  rep(i, N) {
    int A; cin >> A;
    pq.push(A);
  }
  while (M > 0) {
    auto t = pq.top(); pq.pop();
    pq.push(t / 2);
    M--;
  }
  ll ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int n,sum;
int main()
{
	cin>>n;
	while(n!=0)
	{
		sum=n%10;
		if(sum==7)
		{
			cout<<"Yes";
			return 0;
		}
		n=n/10;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3616
# Aizu Problem ITP_1_1_C: Rectangle
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

a, b = [int(_) for _ in input().split()]
print(a * b, 2 * (a + b))

Measured memory_bytes: 7684
#include <bits/stdc++.h>
#define int long long
#define double long double
#define F first
#define S second
using namespace std;

int mod=1e9+7;


int32_t main() {
    int T;
    T=1;
    //cin>>T;
    while(T--){
        int n;
        cin>>n;
        double a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        double dp[n+1][n+1];
        memset(dp,0,sizeof(dp));
        // dp[i][j]-> prob of having j heads when i coin tossed up
        dp[0][0]=1;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=i;j++){
                if(j>0)
                    dp[i][j]=a[i-1]*dp[i-1][j-1];
                dp[i][j]+=(1-a[i-1])*dp[i-1][j];
            }
        }
        double ans=0;
        for(int i=0;i<=n;i++){
            int tail=n-i;
            if(i>tail){
                ans+=dp[n][i];
            }
        }
        cout<<fixed<<setprecision(10);
        cout<<ans;
        
        cout<<'\n';
    }
	return 0;
}

Measured memory_bytes: 140928
import java.util.*;
import java.util.HashSet;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String a=sc.next();
        String b=sc.next();
        String c=sc.next();
        char[]aa=a.toCharArray();
        char[]bb=b.toCharArray();
        char[]cc=c.toCharArray();
        char aaa=Character.toUpperCase(aa[0]);
        char bbb=Character.toUpperCase(bb[0]);
        char ccc=Character.toUpperCase(cc[0]);
        System.out.print(aaa);
        System.out.print(bbb);
        System.out.println(ccc);

        
        }
       
        
    }

Measured memory_bytes: 21844
N, M = map(int, input().split())
dic = {i :0 for i in range(1, M+1)}

for j in range(N):
    lis = list(map(int, input().split()))
    count = lis[0]
    answer = lis[1:]
    for k in answer:
        dic[k] += 1

num = [x for x in dic.values() if x == N]
print(len(num))



Measured memory_bytes: 9188
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a,b = MI()

if a % 2 == 0:
    if b % 2 == 0:
        if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
    else:
        if (b-a) % 4 == 1:
            print(1)
        else:
            print(0)
else:
    if b % 2 == 0:
        if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
            for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
            print(aa - 1)
    else:
        if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a)

Measured memory_bytes: 14304
#include <iostream>
using namespace std;
typedef struct Card{
	char suit;
	int value;
}Card;
void bubblesort(Card c[], int n)
{
	int flag = 1;
	while(flag)
	{
		flag = 0;
		for (int i = n-1; i >= 1; --i)
		{
			if(c[i].value < c[i-1].value)
			{
				Card temp = c[i];
				c[i] = c[i-1];
				c[i-1] = temp;
				flag =1;
			}

		}
	}
}

void selectionsort(Card c[], int n)
{
	for (int i = 0; i < n; ++i)
	{
		int minj = i;
		for (int j = i; j < n; ++j)
		{
			if(c[j].value < c[minj].value) minj = j;
		}
		if(minj != i)
		{
			Card temp = c[i];
			c[i] = c[minj];
			c[minj] = temp;
		}
	}

}

bool isstable(Card c1[], Card c2[], int n)
{
	for (int i = 0; i < n; ++i)
	{
		if(c1[i].value==c2[i].value && c1[i].suit!=c2[i].suit) return false;
	}
	return true;
}

void print(Card c[], int n)
{
	for (int i = 0; i < n-1; ++i)
	{
		cout<<c[i].suit<<c[i].value<<" ";
	}
	cout<<c[n-1].suit<<c[n-1].value<<endl;
}
int main()
{
	int n;
	cin>>n;
	Card c1[36], c2[36];
	for (int i = 0; i < n; ++i)
	{
		cin>>c1[i].suit>>c1[i].value;
	}
	for (int i = 0; i < n; ++i)
	{
		c2[i] = c1[i];
	}

	bubblesort(c1, n);
	selectionsort(c2, n);

	print(c1,n);
	cout<<"Stable"<<endl;

	
	print(c2,n);
	if(isstable(c1,c2,n)) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;

	return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll n, y,sum=0;
	cin >> n >> y;
	for (ll i = 0; i <= n; i++) {
		for (ll j = 0; j <= n; j++) {
			if ((n-i-j)>=0&&(n-i-j)<=n&&10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
				cout << i <<" "<< j <<" "<< n - i - j << endl;
				exit(0);
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main{
	public static void main (String[] args){
		Scanner in = new Scanner(System.in);
		
		int w = in.nextInt();
		int h = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int r = in.nextInt();
		
		if(x >= r && x <= w - r && y >= r && y <= h - r){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 26332
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {

	int K;

	queue<long long> Q;

	cin >> K;

	FOR(i, 1, 10) {
		Q.push(i);
	}

	REP(i, K-1) {
		long long x;

		x = Q.front();
		Q.pop();

		if (x % 10 != 0) {
			Q.push(10 * x + (x % 10) - 1);
		}

		Q.push(10 * x + (x % 10));

		if (x % 10 != 9) {
			Q.push(10 * x + (x % 10) + 1);
		}

	}

	cout << Q.front()<< endl;

	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define M_PI 3.14159265358979
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

ll md = (ll)1e9 + 7;

int main()
{
	double a, b, x;
	cin >> a >> b >> x;

	double ans;

	if (x > a * a * b / 2) {
		double A = a * a;
		double L = 2 * b - 2 * x / A;
		ans = rad_to_deg(atan(L / a));
	}
	else {
		double L = 2 * x / (a * b);
		ans = rad_to_deg(atan(b / L));
	}

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


Measured memory_bytes: 4032
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)

int main()
{
    int num;

    while (cin >> num, num) {
        if (!(num % 1111)) {
            cout << "NA" << endl;
        }
        else {
            int cnt = 0;
            while (num != 6174){
                int L = 0, S = 0, n[4];
                REP (i, 4) {
                    n[i] = num % 10;
                    num /= 10;
                }
                sort(n, n + 4);
                REP (i, 4) {
                    L = L * 10 + n[3 - i];
                    S = S * 10 + n[i];
                }
                cnt++;
                num = L - S;
            }
            cout << cnt << endl;
        }
    }
    return (0);
}

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

// ll power(ll x,ll y)
// {
//     ll ml=1;
//     while(y>0)
//     {
//         if(y&1)
//         {
//             ml=(ml*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return ml;
// }

// ll inverse(ll x)
// {
//     return power(x,mod-2);
// }
int main() 
{
    ll n;
    ll i,j,x;

    ll sm=0;
    ll smsq=0;
    
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        sm=(sm+x)%mod;
        smsq=(smsq+x*x)%mod;
    }
    sm=(sm*sm)%mod;
    
    sm=(sm-smsq+mod)%mod;
    
    cout<<(sm*500000004)%mod;
    
    
}

Measured memory_bytes: 3616
using System;
 
namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var W = Console.ReadLine();
            var count = 0;
            var line = "";
            while ((line = Console.ReadLine()) != "END_OF_TEXT")
            {
                var words = line.ToLower().Split();
                foreach (var item in words)
                {
                    if (item == W) ++count;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 19864
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int C[100010];
    int n,i,j;
    cin>>n;
    /*unsigned short *A,*B;

    A=malloc(sizeof(short)*n+1);
    B=malloc(sizeof(short)*n+1);*/
    V<unsigned short>A(n+1),B(n+1);

    memset(C,0,sizeof(C));
    for(i=0;i<n;i++){
        cin>>A[i+1];
        C[A[i+1]]++;
    }
    for(i=1;i<=10000;i++)C[i]+=C[i-1];
    for(j=1;j<=n;j++){
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    for(i=1;i<=n;i++){
        if(i>1)cout<<" ";
        cout<<B[i];
    }
    cout<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------















































Measured memory_bytes: 11016
#include<cstdio>

#define MAX_N 3000

using namespace std;

int main(){
  int N,ans=0,x;
  scanf("%d",&N);
  for(int i; i<N;i++)
  {scanf("%d",&x);
   ans+=(x-1);
  }
  printf("%d",ans);
  	
return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
check=[0]*n
ans=0
for i in range (k):
  d=int(input())
  l=list(map(int,input().split()))
  for j in range(d):
    h=l[j]
    check[h-1]+=1
    
for k in range(n):
  if check[k]==0:
    ans+=1

print(ans)

Measured memory_bytes: 9196
X = int(input())

if 400 <= X < 600:
  print(8)
elif 600 <= X < 800:
  print(7)
elif 800 <= X < 1000:
  print(6)
elif 1000 <= X < 1200:
  print(5)
elif 1200 <= X < 1400:
  print(4)
elif 1400 <= X < 1600:
  print(3)
elif 1600 <= X < 1800:
  print(2)
elif 1800 <= X < 2000:
  print(1)

Measured memory_bytes: 9188
#include<iostream>
#define SIZE 100

using namespace std;

int main(void) {

	int n, c, v;
	int G[SIZE][SIZE];
	int A[SIZE][SIZE];

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		cin >> v;
		cin >> c;
		for (int j = 0; j < c; j++) {
			cin >> G[v-1][j];
			int tmp = G[v-1][j];
			if (tmp > 0) {
				A[v-1][tmp - 1] = 1;
			}
		}
	}

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

}




Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin >> n;
	cout << x[n - 1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-6;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int dd[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    vector<string>v;
    v.push_back("Wednesday");
    v.push_back("Thursday");
    v.push_back("Friday");
    v.push_back("Saturday");
    v.push_back("Sunday");
    v.push_back("Monday");
    v.push_back("Tuesday");
    int mo,da;
    while(cin>>mo>>da,mo){
        int d=da;
        for(int i=0;i<mo-1;i++){
            d+=dd[i];
        }
        cout<<v[d%7]<<endl;
    }
}


Measured memory_bytes: 3172
#include"bits/stdc++.h"
using namespace std;
const int N=5e3+100;
typedef long long LL;
struct node{
	LL h,p;
}a[N];
LL dp[N];
bool cmp(node a,node b){
	if(a.h+a.p==b.h+b.p)return a.h<b.h;
	return a.h+a.p<b.h+b.p;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=5050;i++)dp[i]=0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=n;i++)
		scanf("%d %d",&a[i].h,&a[i].p);
	sort(a+1,a+n+1,cmp);
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=i-1;j>=0;j--){
			if(a[i].h>=dp[j]){
				dp[j+1]=min(dp[j+1],dp[j]+a[i].p);
			}
		}
	}
	int ans=1;
	for(int i=2;i<=n;i++)
		if(dp[i]!=0x3f3f3f3f3f3f3f3f)ans=i;
	printf("%d\n",ans);
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		String[] s=new String[200];
		int ans_kari=0;
		int ans=0;

		for(int i=0;i<N;i++) s[i]=sc.next();

		int M=sc.nextInt();
		String[] t=new String[M];

		for(int i=0;i<M;i++) s[i+N]=sc.next();

		for(int i=0;i<N;i++)
		{
			for(int j=0;j<N+M;j++){
				if(s[i].equals(s[j]) && j<N) ans_kari++;
				else if(s[i].equals(s[j]) && j>=N) ans_kari--;
			}
			if(ans<ans_kari) ans=ans_kari;
			ans_kari=0;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
//一点更新区間取得
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	function<T(T,T)>calcfn;
	function<T(T,T)>updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree():n(0){};
	segtree(int n_,T defvalue_=numeric_limits<T>::max(),
		function<T(T,T)>calcfn_=[](T a,T b){return a<b?a:b;},
		function<T(T,T)>updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		init(n_);
	};
	void init(int n_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(vector<T>v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i++)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query_(int a,int b,int i,int l,int r)
	{
		if(r<=a||b<=l)return defvalue;
		else if(a<=l&&r<=b)return dat[i];
		else
		{
			return calcfn(
				query_(a,b,i*2+1,l,(l+r)/2),
				query_(a,b,i*2+2,(l+r)/2,r)
			);
		}
	}
	T query(int a,int b)//[a,b)
	{
		return query_(a,b,0,0,n);
	}
};
main()
{
	int n,q;cin>>n>>q;
	segtree<int>rsq(n,0,[](int a,int b){return a+b;},[](int a,int b){return a+b;});
	for(int i=0;i<q;i++)
	{
		int c,x,y;cin>>c>>x>>y;
		if(c)cout<<rsq.query(x-1,y)<<endl;
		else rsq.update(x-1,y);
	}
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
const int N = 1005, MOD = 1e9 + 7;
int f[N][N], c[N][N];
int mpow(int x, int n) {
	int res = 1;
	while (n) {
		if (n & 1) res = 1LL * res * x % MOD;
		n >>= 1;
		x = 1LL * x * x % MOD;
	}
	return res;
}
int main() {
	c[0][0] = 1;
	for (int i = 1; i < N; ++ i) {
		c[i][0] = 1;
		for (int j = 1; j <= i; ++ j) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
	}
	int n, A, B, C, D;
	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);
	f[0][A - 1] = 1;
	for (int j = A; j <= B; ++ j) {
		for (int i = 0; i <= n; ++ i) {
			f[i][j] = f[i][j - 1];
			int cc = 1, bb = 1;
			for (int k = 1; k <= D && k * j <= i; ++ k) {
				cc = 1LL * cc * c[n - (i - k * j)][j] % MOD;
				bb = 1LL * bb * mpow(k, MOD - 2) % MOD;
				if (k >= C) (f[i][j] += 1LL * cc * f[i - j * k][j - 1] % MOD * bb % MOD) %= MOD;
			}
		}
	}
	printf("%d\n", f[n][B]);
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
	
using namespace std;
int main()
{
	
	std::ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	if(n==0||k==1||n%k==0){
		cout<<0<<endl;
	}
	else{
		if(n<k){
			ll ans = min(n,abs(n-k));
			cout<<ans<<endl;
		}
		else{
			ll rem = n%k;
			rem = min(abs(rem-k),rem);	
			cout<<rem<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256