akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int n; cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(!(i%3==0||i%5==0)) ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}


template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  string s;
  cin >> s;
  int N = s.size();
  vector<int> to_inv(N, 0);// to_inv[i]: s[i]から逆の文字似た取り付くまでの距離
  // char prev='L';// s[0]は必ずRなので Lを入れとく
  int cnt = 0;
  for(int i=0; i<N; i++){// s[i]がRのときだけ考える
    if(s[i] == 'L') cnt = 0;
    else{
      if(cnt) to_inv[i] = to_inv[i-1]-1;
      else{
        int j = i;
        while(s[j] == 'R'){cnt++; j++;}
        to_inv[i] = cnt;
      }
    }
  }

  // cout << " to_inv: " ;  print_vec(to_inv);
  cnt = 0;
  for(int i=N-1; i>=0; i--){// s[i]がLの時だけ考える
    if(s[i] == 'R') cnt = 0;
    else{
      if(cnt) to_inv[i] = to_inv[i+1] - 1;
      else{
        int j=i;
        while(s[j] == 'L'){cnt++; j--;}
        to_inv[i] = cnt;
      }
    }
  }

  // cout << " to_inv: " ;  print_vec(to_inv);
  vector<int> ans(N, 0);
  for(int i=0; i<N; i++){
    if(s[i] == 'R'){
      if(to_inv[i]%2 == 0) ans[i+to_inv[i]]++;
      else ans[i+to_inv[i]-1]++;
    }
    else{
      if(to_inv[i]%2 == 0) ans[i-to_inv[i]]++;
      else ans[i-to_inv[i]+1]++;
    }
    // cout << " i: "<< i << " s[i]: " << s[i] << " to_inv[i]: " << to_inv[i] << endl;
  }

  for(int i=0; i<N; i++) cout << ans[i] << " ";
  cout << endl;
	return 0;
}



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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int a = A;
  bool can = true;
  while(true){
    if(a%B==C){
      break;
    }
    if(a!=A && a%B==A%B){
      can = false;
      break;
    }
    a += A;
  }
  if(can){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 0; i < 10; ++i)
	{
		c = c * a - b;
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	string s;
	cin >> s;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		if(s[i]=='U'){
			continue;
		}
		if(s[i]=='D'){
			continue;
		}
		if((s[i]=='L')^(i%2)){
			cout << "No" << endl;
			return 0; 
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string S, T; cin >> S >> T;
	T.erase(T.end()-1);
	if(S == T){
		cout << "Yes"<< endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	map<int, int> values;
	long long sum = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		++values[a];
		sum += a;
	}

	int Q;
	cin >> Q;

	vector<long long> ans;
	for (int i = 0; i < Q; ++i) {
		int b, c;
		cin >> b >> c;
		long long diff = c - b;
		long long count = values[b];

		sum += diff * count;
		values[c] += count;
		values[b] = 0;

		ans.push_back(sum);
	}

	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;
	}



	return 0;
}




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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  int n = s.size();
  int count = 0;
  rep(i,n-1){
    if(s[i] == s[i+1]){
      ++count;
    }
    else{
      if(count%2 == 0){
        puts("No");
        return 0;
      }
      else count = 0;
    }
  }
  if(count%2 == 0){
    puts("No");
  }
  else puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 1000000007
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
#define N 100005
char s[N];
int nxt[N][3],a[N],f[N];
signed main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'a';
	bool ok=0; for(int i=2;i<=n;i++) if(s[i]==s[i-1]) ok=1;
	if(!ok) {cout<<1<<endl; return 0;}
	nxt[n+1][0]=nxt[n+1][1]=nxt[n+2][0]=nxt[n+2][1]=n+2;
	int sum=0;
	f[n+1]=1;
	for(int i=n;i>=1;i--)
	{
		sum=(sum+a[i]+1)%3;
		if(a[i]==0) nxt[i][0]=i+1;
		else if(a[i+1]==1) nxt[i][0]=i+2;
		else nxt[i][0]=nxt[i+2][0];
		if(a[i]==1) nxt[i][1]=i+1;
		else if(a[i+1]==0) nxt[i][1]=i+2;
		else nxt[i][1]=nxt[i+2][1];
		f[i]=add(f[nxt[i][0]],f[nxt[i][1]],sum==0);
	}
	if(sum==0) f[1]=sub(f[1],1);
	cout<<f[1]<<endl;
	return 0;
}

Measured memory_bytes: 5780
#include <stdio.h>

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    int a[M], b[M], i, c[N];
    for(i=0; i<N; i++) {
        c[i] = 0;
    }
    for(i=0; i<M; i++) {
        scanf("%d %d", &a[i], &b[i]);
        c[a[i]-1] += 1;
        c[b[i]-1] += 1;
    }

    for(i=0; i<N; i++) {
        printf("%d\n", c[i]);
    }

    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)  
#define mod(x) (x%1000000007)
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='R') ans++;
    }
    int res=0;
    for(int i=0;i<ans;i++){
        if(s[i]=='W') res++;
    }
    cout<<res<<endl;
    
    
    
    
    
    
}

Measured memory_bytes: 3384
fn main() {
    let (n,x) = {
        let mut inputline = String::new();
        std::io::stdin().read_line(&mut inputline).ok();
        let mut inpuline  = inputline.split_whitespace();
        (inpuline.next().unwrap().parse::<i32>().unwrap(),
        inpuline.next().unwrap().parse::<i32>().unwrap(),)
    };
    let l:Vec<i32> = {
        let mut inputline = String::new();
        std::io::stdin().read_line(&mut inputline).ok();
        inputline.split_whitespace()
            .map(|x|x.parse::<i32>().unwrap())
            .collect::<Vec<i32>>()
    };
    let sum = {
        let mut temp = 0;
        let mut result = 0;
        for (i,v) in l.into_iter().enumerate(){
            temp += v;
            if temp > x {
                result = i + 1 ;
                break;
            }else if i as i32 == n - 1{
                result = i + 2 ;
            }
        }
        result
    };
    println!("{}",sum);
}


Measured memory_bytes: 4352
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
 
a,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
cnt = 0
while li[2] != li[1]:
    li[0] += 1
    li[1] += 1
    cnt+=1
cnt += (li[1]-li[0])//2
if (li[1]-li[0])%2 != 0:
    cnt += 2
print(cnt)

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

int main(void){
    int i, j;
    int N, M, Q;
    cin >> N >> M >> Q;

    int array[N+1][N+1];
    int sum[N+1][N+1];

    for(i=0; i<=N; i++){
        for(j=0; j<=N; j++){
           array[i][j] = 0;
           sum[i][j] = 0;
        }
    }

    int l,r;
    for(i=0; i<M; i++){
        cin >> l >> r;
        array[l][r]++;
    }
    

    for(i=1; i<=N; i++){
        for(j=i; j<=N; j++){
            sum[i][j] = sum[i][j-1] + array[i][j];
        }
    }

    

    int p, q;
    int ans[Q];
    for(i=0; i<Q; i++){
        ans[i] = 0;
        cin >> p >> q;
        for(j=p; j<=q; j++){
            ans[i] += sum[j][q] - sum[j][j-1];
        }
    }

    for(i=0; i<Q; i++){
        cout << ans[i] << endl;
    }


    return 0;

}

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

inline int read(){
	int res=0,f=1;char ch=' ';
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){res=res*10+ch-'0';ch=getchar();}
	return res*f;
}
const int N=1e5+5;
const int mod=998244353;
int n,S,T;
int d[N],flag[N];
int head[N*20],to[N*20],w[N*20],nxt[N*20],cnt;
inline void qxx(int x,int y,int z){
	cnt++;nxt[cnt]=head[x];head[x]=cnt;to[cnt]=y;w[cnt]=z;
}
inline void SPFA(){
	memset(d,63,sizeof(d));
	queue<int>q;q.push(S);d[S]=0;flag[S]=1;
	while(!q.empty()){
		int k=q.front();q.pop();flag[k]=0;
		for(register int i=head[k];i;i=nxt[i]){
			int kk=to[i];
			if(d[kk]>d[k]+w[i]){
				d[kk]=d[k]+w[i];
				if(!flag[kk]){
					flag[kk]=1;q.push(kk);
				}
			}
		}
	}
}
int main(){
	n=read();
	S=0;T=1;
	for(register int i=1;i<=n;i++)
		for(register int j=0;j<=9;j++)
			qxx(i,((i-1)*10+j)%n+1,j);
	for(register int i=1;i<=9;i++) qxx(0,i+1,i);
	SPFA();
	printf("%d\n",d[1]);
	return 0;
}

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

using namespace std;

using Weight=long long;

struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

template<typename T>
class UnionFind{
private:
    vector<T>data;
public:
    UnionFind(T n):data(n,-1){}
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

pair<Weight,Edges>kruskal(const Graph &g){
    int n=g.size();
    UnionFind<int> uf(n);
    priority_queue<Edge>q;
    for(int i=0;i<n;++i){
        for(auto e:g[i]){
            if(i<e.dst)q.push(e);
        }
    }
    Weight total=0;
    Edges forest;
    while(forest.size()<n-1 && !q.empty()){
        Edge e=q.top();q.pop();
        if(uf.unite(e.src,e.dst)){
            forest.push_back(e);
            total+=e.weight;
        }
    }
    return {total,forest};
}

int main(){
    int v,e;cin>>v>>e;
    Graph g(v);
    for(int i=0;i<e;++i){
        int s,t,w;cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
        g[t].emplace_back(t,s,w);
    }
    cout<<kruskal(g).first<<endl;
    return 0;
}
// be checked by AOJ(GRL-2-A).

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

using namespace std;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x = -x;
    long long temp = 0;
  	long long xx = x;
  	while (xx > 0) {
      	xx -= d;
      	temp++;
    }
    if (x % d == 0) temp = x / d;
    else temp = x / d + 1;
    if (k < temp) {
        printf("%lld\n", x - k * d);
        return 0;
    }
    k -= temp;
    x -= (temp * d);
    if (k % 2 == 0) printf("%lld\n", abs(x));
    else {
        printf("%lld\n", abs(x + d));
    }
    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n,ans=0;
  cin >> n;
  for(int i=1; i<=n; i++) {
    if(to_string(i).size()%2==1) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = input()

if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or  N[-1] == "7" or  N[-1] == "9":
    print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or  N[-1] == "8":
    print("pon")
else:
    print("bon")

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


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

int main() {
	int N,Q;
	string S;
	vector<set<int>> m(26);

	cin >> N >> S >> Q;
	rep(i,N)
		m.at(S.at(i)-'a').insert(i+1);

	rep(q,Q) {
		int t,i;
		cin >> t >> i;

		if(t == 1) {
			char c;
			cin >> c;
			
			m[S.at(i-1)-'a'].erase(i);
			m[c-'a'].insert(i);
			S.at(i-1) = c;
		} else {
			int r,c=0;
			cin >> r;

			rep(j,26) {
				auto itr_l = m.at(j).lower_bound(i);
				if(itr_l != m.at(j).end()) {
					auto itr_r = m.at(j).upper_bound(r);
					c += (itr_l != itr_r);
				}
			}
			cout << c << endl;
		}
	}
}

Measured memory_bytes: 27236
a = list(input())
b = list(input())
c = list(input())
num = 0
dic = {0:a,1:b,2:c}
while 1:
    if len(dic[num]) == 0:
        print(tmp.upper())
        break
    tmp = dic[num].pop(0)
    if tmp == "a":
        num = 0
    elif tmp == "b":
        num = 1
    else:
        num = 2

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l;
	char a[110];
	cin>>a;
	l=strlen(a);
	cout<<a[0];
	int cnt=0;
	for(int i=1;i<l-1;i++)
	{
		cnt++;
	}
	cout<<cnt<<a[l-1];
	return 0;
}

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

sunuke = [i for i in range(1, n + 1)]

for i in range(k):
    d = input()
    a = list(map(int, input().split()))
    for j in a:
        if j in sunuke:
            sunuke.remove(j)
print(len(sunuke))


Measured memory_bytes: 9176
s = input()

ans = True
for i in range(len(s)):
    if (i + 1) % 2 == 0:
        if s[i] == 'R':
            ans = False
    else:
        if s[i] == 'L':
            ans = False

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38612
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int search_sequence(vector<int> &a,int n){
	int cnt=0;
	for(int i=0;i<a.size();++i){
		if(a[i]==-1)++cnt;
		else cnt=0;
		if(cnt>=n)return i-cnt+1;
	}
	return -1;
}

int main(void){
    vector<int> seat(17,-1);
    int time[100],finish[100];
    queue<pair<int,int> > q;
    int x=0,y=0;
    for(int t=0;y<100;++t){
      if(t%5==0&&x<100) q.push(make_pair(x++,(x%5==1)?5:2));
      for(int i=0;i<17;++i){
        if(seat[i]!=-1&&finish[seat[i]]==t){
        	fill(&seat[i],&seat[i+((seat[i]%5==1)?5:2)],-1);
        	//cerr<<t<<":";for(int i=0;i<17;++i)cerr<<seat[i]<<((i!=16)?" ":"\n");
      	}
      }
      while(!q.empty()){
      	pair <int,int> p=q.front();
      	if(search_sequence(seat,p.second)==-1)break;
        fill(&seat[search_sequence(seat,p.second)],&seat[search_sequence(seat,p.second)+p.second],p.first);
        //cerr<<t<<":";for(int i=0;i<17;++i)cerr<<seat[i]<<((i!=16)?" ":"\n");
        finish[p.first]=t+17*(p.first%2)+3*(p.first%3)+19;
        time[p.first]=t-5*p.first;
        q.pop();++y;
      }
    }
  int n;
  while(cin>>n){
  	cout<<time[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
    int n,k,_1,ans=INT_MAX;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==1)
			_1=i;
	}
	for(int i=1;i<=k;i++)
        if(_1>=i&&n-_1>=k-i)
            ans=min(ans,(int)(ceil((float)(_1-i)/(float)(k-1))+ceil((float)(n-(_1+k-i))/(float)(k-1))));
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 640
N, M= map(int, input().split())

L_list = []
R_list = []

for _ in range(M):
    L, R = map(int, input().split())
    L_list.append(L)
    R_list.append(R)

ans = min(R_list) - max(L_list) + 1

if ans < 0:
    ans = 0

print(ans)

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

int main(){

  int a=0,b=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++){

    if(s.at(i)=='A') a++;
    if(s.at(i)=='B') b++;

  }

  if(a>0&&b>0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;



  return 0;
}

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

WA = [0] * (10 ** 5 + 1)
AC = [False] * (10 ** 5 + 1)
for i in range(M):
    _no , re = input().split()
    no = int(_no)
    if re == 'AC':
        AC[no] = True
    if not AC[no]:
        if re == 'WA':
            WA[no] += 1
pena = 0
for i in range(10 ** 5 + 1):
    if AC[i]:
        pena += WA[i]

print(AC.count(True), pena)


Measured memory_bytes: 4596
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))



struct max_flow{
	struct edge{
		int to,co,p;
	};
	vector<edge> vs[100005];
	
	void adde(int fr,int to,int co){
		vs[fr].push_back((edge){to,co,vs[to].size()});
		vs[to].push_back((edge){fr,0,vs[fr].size()-1});
	}
	
	int gone[100005];
	int fold_dfs(int no,int gl,int f){
		if(no==gl)return f;
		gone[no]=1;
		rep(i,vs[no].size()){
			edge& e = vs[no][i];
			if(e.co==0 || gone[e.to])continue;
			int tf=fold_dfs(e.to,gl,min(f,e.co));
			if(tf<=0)continue;
			e.co -= tf;
			vs[e.to][e.p].co += tf;
			return tf;
		}
		return 0;
	}
	
	int inf;
	max_flow(){ inf = IINF; }
	int fold(int st,int gl){
		int res=0;
		for(;;){
			memset(gone,0,sizeof(gone));
			int f=fold_dfs(st,gl,inf);
			if(f<=0)break;
			res+=f;
		}
		return res;
	}
} flow;



/*
int main(void){
	int n,g,e;
	scanf("%d%d%d",&n,&g,&e);
	rep(i,g){
		int a;
		scanf("%d",&a);
		flow.adde(a,n+5,1);
	}
	rep(i,e){
		int a,b;
		scanf("%d%d",&a,&b);
		flow.adde(a,b,1);
		flow.adde(b,a,1);
	}
	printf("%d\n",flow.fold(0,n+5));
	return 0;
}
*/

int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		flow.adde(a,b,c);
	}
	printf("%d\n",flow.fold(0,n-1));
	return 0;
}

Measured memory_bytes: 6044
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];
    int cnt=0;
    for(int i=1;i<n-1;i++){
        if(((a[i-1]-a[i])>0&&(a[i+1]-a[i]<0))||((a[i-1]-a[i])<0&&(a[i+1]-a[i]>0)))cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <utility>
#include <string>

using namespace std;

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};

bool check(RollingHash &rh, int n, int d) {
    map<pair<long long, long long>, int> ma;
    for (int i = 0; i + d <= n; ++i) {
        auto p = rh.get(i, i+d);
        if (ma.count(p)) {
            if (i - ma[p] >= d) return true;
        }
        else ma[p] = i;
    }
    return false;
};

int main() {
    int n;
    string s;
    cin >> n >> s;
    RollingHash rh(s);

    for (int length = (n >> 1); length > 0; --length) {
        if (check(rh, n, length)) {
            cout << length << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;

const D EPS = 1e-8;
const D PI = acos(-1);
//for vector
inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
inline P rotate(P v, D s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

inline D seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

inline D seg_seg_dis(L a,L b){
  D res = 1e10;
  res = min(res,seg_p_dis(a,b.fs));
  res = min(res,seg_p_dis(a,b.sc));
  res = min(res,seg_p_dis(b,a.fs));
  res = min(res,seg_p_dis(b,a.sc));
  return res;
}

D g[111][111];
L stars[111][5];
P v[5],c,p;
int n,m,l,x,y,a,r;

int main(){
  while(scanf("%d%d%d",&n,&m,&l), n){
    for(int i=0;i<n;i++){
      scanf("%d%d%d%d",&x,&y,&a,&r);
      c = P(x,y), p = P(0,r);
      for(int j=0;j<5;j++)v[j] = c+rotate(p,PI*(a+j*72)/180);
      for(int j=0;j<5;j++)stars[i][j] = L(v[j],v[(j+2)%5]);
    }

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	D dis = 1e9;
	for(L a : stars[i]){
	  for(L b : stars[j]){
	    if(is_cp(a,b)){
	      dis = 0;
	      break;
	    }else dis = min(dis, seg_seg_dis(a,b));
	  }
	}
	g[i][j] = g[j][i] = dis;
      }
      g[i][i] = 0;
    }

    for(int k=0;k<n;k++){
      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	  g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	}
      }
    }

    printf("%.9lf\n",g[m-1][l-1]);
  }
}	

Measured memory_bytes: 1344
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)
#define mem0(a) memset(a,0,sizeof(a))
#define mem_1(a) memset(a,-1,sizeof(a))
#define mem0x(a) memset(a,0x3f,sizeof(a))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN(a,b) (a)<(b)?(a):(b)
#define INF 0x7f7f7f7f
using namespace std;


typedef long long ll;
//typedef __int64_t i64;
typedef long long unsigned llu;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const int N = 50001;



int main(){
    
    int n,m,q;
    int a,b;//c,tmp,cur;

    //string opt;
    cin>>n>>m;
    
    if(m>=n) cout<<1<<endl;
    else{
        cout<< n/m + (n%m>0?1:0)<<endl;
    }
    
    
    return 0;
}


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

int main(int argc, const char * argv[]) {
    int N,M;
    cin>>N>>M;
    
    unordered_set<stack<int>*> stcGrp;
    
    stack<int> **grps=new stack<int>*[N];
    for(int i=0;i<N;++i){
        grps[i]=NULL;
    }
    int max=1;
    for(int i=0;i<M;++i){
        int a1,b1;
        cin>>a1>>b1;
        --a1;
        --b1;
        if(grps[a1]==NULL){
            if(grps[b1]==NULL){
                stack<int> *nGrp=new stack<int>();
                stcGrp.insert(nGrp);
                nGrp->push(a1);
                nGrp->push(b1);
                grps[a1]=nGrp;
                grps[b1]=nGrp;
                if(max<nGrp->size()){
                    max=(int)nGrp->size();
                }
            }else{
                grps[a1]=grps[b1];
                grps[b1]->push(a1);
                if(max<grps[b1]->size()){
                    max=(int)grps[b1]->size();
                }
            }
        }else{
            if(grps[b1]==NULL){
                grps[b1]=grps[a1];
                grps[a1]->push(b1);
                if(max<grps[a1]->size()){
                    max=(int)grps[a1]->size();
                }
            }else if(grps[b1]!=grps[a1]){
                stack<int> *delGrp,*tGrp;
                if(grps[b1]->size()<grps[a1]->size()){
                    delGrp=grps[b1];
                    tGrp=grps[a1];
                }else{
                    delGrp=grps[a1];
                    tGrp=grps[b1];
                }
                while(!delGrp->empty()){
                    int idx=delGrp->top();
                    delGrp->pop();
                    tGrp->push(idx);
                    grps[idx]=tGrp;
                }
                stcGrp.erase(delGrp);
                delete delGrp;
                if(max<tGrp->size()){
                    max=(int)tGrp->size();
                }
            }
        }
    }
    cout<<max<<endl;
    for(unordered_set<stack<int>*>::iterator itr=stcGrp.begin(),end=stcGrp.end();itr!=end;++itr){
        delete *itr;
    }
    delete[] grps;
    return 0;
}


Measured memory_bytes: 164320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		long zeroCount = 0;
		long oneCount = 0;

		long count = 0;
		for (char c : s.toCharArray()) {
			if(c=='0') {
				zeroCount++;
			} else {
				oneCount++;
			}

			if(zeroCount > 0 && oneCount > 0) {
				count++;
				zeroCount--;
				oneCount--;
			}
		}

		System.out.println(count*2);
	}

}


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

int main(){
	int n, m, l;
	int i, j, k;
	int A[100][100], B[100][100];
	long C[100][100] = {0};
	
	cin >> n >> m >> l;
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	
	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			for(k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){		
			cout<<C[i][j];
			if(j != l - 1){
				cout << " ";
			}
		}
		cout << endl;
		
	}
				

 	return 0;
}

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

using namespace std;

bool pf[55700];
int main() {
	vector<int> p;
	
	pf[0] = pf[1] = true;
	for(int i = 2; i < 55555; i++) {
		if(pf[i] == false) {
			p.push_back(i);
			//cout << i << endl;
			for(int j = 2; i * j <= 55555; j++) {
				pf[i * j] = true;
			}
		}
	}
	
	int N;
	cin >> N;

	int cnt = 0;
	for(int i = 0, SIZE = p.size(); i < SIZE; i++) {
		if(p[i] % 5 == 1) {
			cout << p[i] << flush;
			cnt++;
			if(cnt == N) {
				cout << endl;
				break;
			} else {
				cout << ' ' << flush;
			}
		}
	}

	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <vector>
using namespace std;
void query1(const int &p, const char &c, vector<set<int>> &a) {
	for (int i = 0; i < 26; i++) {
		auto itr = a[i].find(p);
		if (itr != a[i].end()) {
			a[i].erase(itr);
			break;
		}
	}
	a[c - 'a'].insert(p);
}
void query2(const int &l, const int &r, const vector<set<int>> &a) {
	int cnt = 0;
	for (int i = 0; i < 26; i++) {
		auto itr = a[i].lower_bound(l);
		if (itr != a[i].end()) {
			if (itr != a[i].end()) {
				if (*itr <= r) cnt++;
			}
		}
	}
	printf("%d\n", cnt);
}
int main() {
	int n;
	scanf("%d", &n);
	char s[n];
	scanf("%s", s);
	vector<set<int>> a(26);
	for (int i = 0; i < n; i++) a[s[i] - 'a'].insert(i);
	int q;
	scanf("%d", &q);
	while (q--) {
		int p;
		scanf("%d", &p);
		if (p == 1) {
			int i;
			char c;
			scanf("%d %c", &i, &c);
			query1(i - 1, c, a);
		} else {
			int l, r;
			scanf("%d%d", &l, &r);
			query2(l - 1, r - 1, a);
		}
	}
	return 0;
}

Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    ll cnt=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='I')
        {
            cnt++;
        }
        else{
            cnt--;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
/*
 * Author : Sadi
 * Mon 06/07/2020
 * 16:30:21.13
 */
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;

bool nein(vector<int>& v1, vector<int>& v2) {
	double dis = 0;
	for(int i = 0; i < (int) v1.size(); ++i) {
		dis += pow(abs(v1[i] - v2[i]), 2);
	}
	double result = sqrt(dis);
	if(result - floor(result) == 0) {
		return true;
	}
	else {
		return false;
	}
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

	int n, d;
	cin >> n >> d;
	vector<vector<int>> v(n, vector<int>(d));
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < d; ++j) {
			int point;
			cin >> point;
			v[i].push_back(point);
		}
	}  
	// assert(false);  
	int ans = 0;
	for(int i = 0; i < n - 1; ++i) {
		for(int j = i + 1; j < n; ++j) {
			// assert(false);
			if(nein(v[i], v[j])) {
				ans++;
			}
		}
	}
	cout << ans << endl;
    return 0;
}




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

using namespace std;

vector<long long > baga,pate;

long long dfs(int size,long long num){
    long long ans=0;
    if(num<=0){
        return ans;
    }

    if(baga[size]<=num){
        return pate[size];
    }

    ans +=dfs(size -1,min(num,baga[size]/2+1)-1);
    if(num>baga[size]/2){
        ans+=1;
        ans+=dfs(size-1,num-(baga[size]/2)-1);
    }

    return ans;

}


int main(){
    long long  N,X;
    cin>>N>>X;

    baga.assign(N+1, 0), pate.assign(N+1, 0);
    baga[0] = 1;
    pate[0] = 1;

    for(int i=0;i<N;++i){
        baga[i+1]=baga[i]*2+3;
        pate[i+1]=pate[i]*2+1;
    }

    cout<<dfs(N,X)<<endl;

}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a>b:
	if c>d:
		print(b+d)
	else:
		print(b+c)
elif a<=b:
	if c>d:
		print(a+d)
	else:
		print(a+c)


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

using namespace std;

int h,w;
int main() {
  cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) cin >> s[i];
  bool ok = false;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++){
      ok = false;
      if(s[i][j] == '#') {
        if((i > 0 && s[i-1][j] == '#') or
          (i < h-1 && s[i+1][j] == '#') or
          (j > 0 && s[i][j-1] == '#') or
          (j < w-1 && s[i][j+1] == '#'))
          ok = true;
        if (!ok) {cout << "No"; exit(0);}
      }
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const ll MAX_N = 300010;
vi ctmp(MAX_N, 0);
vi c;
// >= val の要素数
int CountUpperE(const vll &vec, ll val){
    return distance(lower_bound(ALL(vec), val), vec.end());
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(ALL(a));
    rep(i, n){
        ctmp[a[i]-1]++;
    }
    c.resize(*max_element(ALL(ctmp)));
    ll nc = SZ(c);
    rep(i, n){
        repr(j, 1, ctmp[i]+1){
            c[j-1]++;
        }
    }
    repr(i, 1, nc){
        c[i] += c[i-1];
    }
    vll c2(n);
    repr(k, 1, n+1){
        c2[k-1] = c[min(k, nc)-1]/k;
    }
    reverse(ALL(c2));
    dump(c2);
    repr(k, 1, n+1){
        cout << CountUpperE(c2, k) << "\n";
    }
    return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int main()
{
	int R=read(),G=read(),B=read(),n=read();
	int ans=0;
	for(int r=0;r*R<=n;++r)	
		for(int g=0;g*G+r*R<=n;++g)
			if((n-g*G-r*R)%B==0)
				++ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N, a, b = map(int, input().split(" "))

ok_list = []
for i in range(N):
    N_now = i+1
    sum_tmp = 0
    for j in range(len(str(N_now))):
        sum_tmp += int(str(N_now)[j])
    
    if sum_tmp >= a and sum_tmp <= b:
        ok_list.append(N_now)
print(sum(ok_list))

Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
bool custom(pii a, pii b) {
  return (a.first + a.second < b.first + b.second);
}

int main() {
  int n;
  cin >> n;
  vector<pii> x(n);
  for(int i=0;i<n;i++) {
    cin >> x[i].first >> x[i].second;
  }

  sort(x.begin(), x.end(), custom);
  int lim = INT_MIN;
  int ans = 0;
  for(int i=0;i<n;i++) {
    if(x[i].first - x[i].second < lim) continue;
    else {
      ans++;
      lim = x[i].first + x[i].second;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W;
char A[110][110];

int main()
{
	int cnt[26];
	for (int i = 0; i < 26; ++i) cnt[i] = 0;

	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		scanf("%s", A[i]);
		for (int j = 0; j < W; ++j) {
			cnt[A[i][j] - 'a'] += 1;
		}
	}

	vector<int> reqs;

	for (int i = 0; i < (H + 1) / 2; ++i) {
		for (int j = 0; j < (W + 1) / 2; ++j) {
			int i2 = H - 1 - i, j2 = W - 1 - j;

			int req = (i == i2 ? 1 : 2) * (j == j2 ? 1 : 2);
			reqs.push_back(req);
		}
	}
	sort(reqs.begin(), reqs.end());
	reverse(reqs.begin(), reqs.end());

	for (int i = 0; i < reqs.size(); ++i) {
		bool flg = false;
		for (int j = 0; j < 26; ++j) {
			if (reqs[i] <= cnt[j]) {
				cnt[j] -= reqs[i];
				flg = true;
				break;
			}
		}
		if (!flg) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <cmath>
#define INF 500000+500
#define Max 0x3f3f3f3f
#define Mod 1000000007
typedef long long int ll;
using namespace std;
ll arr[INF],brr[INF];
ll sum1[INF];
int main() 
{
	ll n;
	cin >> n;
	ll t = n+1;
	for(int i=1; i<=t; i++) {
		cin >> arr[i];
	}
	ll cnt=0;
	for(int i=1; i<=n; i++) {
		cin >> brr[i];
		if(brr[i]<=arr[i])	cnt+=brr[i];
		else if(brr[i]<=arr[i]+arr[i+1]) {
			cnt += brr[i];
			arr[i+1] -= brr[i]-arr[i];
		}else{
			cnt += arr[i]+arr[i+1];
			arr[i+1] = 0;
		}
	}
	cout << cnt << endl;
	
	
	
	
    return 0;
}

Measured memory_bytes: 8448
N = int(input())
ans = [0]*(N)

if N <= 3:
  for i in range(N):
    print(0)
  exit()

M = int((N-2)**0.5)
 
for x in range(1, M+1):
  for y in range(1, M+1):
    for z in range(1, M+1):
      a = (x+y+z)**2 - (x*y + y*z + z*x)
      if a <= N:
      	ans[a-1] += 1
 
for i in range(N):
  print(ans[i])

Measured memory_bytes: 9556
#include <iostream>
using namespace std;
int main(){
	int a[4];
	cin >> a[1] >> a[2] >> a[3];
	while(a[1] != -1 || a[2] != -1 || a[3] != -1){
		if (a[1] == -1 || a[2] == -1 || a[1]+a[2]<30)
			cout<<"F"<<endl;
		else if (a[1]+a[2] > 79)
			cout << "A"<<endl;
		else if (a[1]+a[2]>64)
			cout<<"B"<<endl;
		else if (a[1]+a[2]>49)
			cout<<"C"<<endl;
		else if (a[1]+a[2]>29){
			if (a[3] > 49)
				cout<<"C"<<endl;
			else cout<<"D"<<endl;
		}
		cin >> a[1] >> a[2] >> a[3];
	}
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 10

int maxProductSubarrayOfSizeK(int A[], int n, int k) 
{ 
    // sorting given input array 
    sort(A, A + n); 
  
    // variable to store final product of all element 
    // of sub-sequence of size k 
    int product = 1; 
  
    // CASE I 
    // If max element is 0 and 
    // k is odd then max product will be 0 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
  
    // CASE II 
    // If all elements are negative and 
    // k is odd then max product will be 
    // product of rightmost-subarray of size k 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
            product = (product*((A[i]+hell)%hell) + hell)%hell;
        return product; 
    } 
  
    // else 
    // i is current left pointer index 
    int i = 0; 
  
    // j is current right pointer index 
    int j = n - 1; 
  
    // CASE III 
    // if k is odd and rightmost element in 
    // sorted array is positive then it 
    // must come in subsequence 
    // Multiplying A[j] with product and 
    // correspondingly changing j 
    if (k & 1) { 
        product  =  (product*((A[j]+hell)%hell) + hell)%hell;
        j--; 
        k--; 
    } 
  
    // CASE IV 
    // Now k is even 
    // Now we deal with pairs 
    // Each time a pair is multiplied to product 
    // ie.. two elements are added to subsequence each time 
    // Effectively k becomes half 
    // Hence, k >>= 1 means k /= 2 
    k >>= 1; 
  
    // Now finding k corresponding pairs 
    // to get maximum possible value of product 
    for (int itr = 0; itr < k; itr++) { 
  
        // product from left pointers 
        int left_product = A[i] * A[i + 1]; 
  
        // product from right pointers 
        int right_product = A[j] * A[j - 1]; 
  
        // Taking the max product from two choices 
        // Correspondingly changing the pointer's position 
        if (left_product > right_product) { 
            product = (product*((left_product+hell)%hell) + hell)%hell;
            i += 2; 
        } 
        else { 
            product = (product*((right_product+hell)%hell) + hell)%hell;; 
            j -= 2; 
        } 
    } 
  
    // Finally return product 
    return product; 
} 


void solve(){
	
	int n,k;
	cin>>n>>k;
	int arr[n];
	rep(i,0,n){
		cin>>arr[i];
	} 
	cout<<maxProductSubarrayOfSizeK(arr,n,k)<<endl;;
	

}

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5164
N, M = map(int, input().split())

like = {}

for i in range(N):
    foods = list(map(int, input().split()))

    K = foods.pop(0)

    for food in foods:
        if food in like:
            like[food] += 1
        else:
            like[food] = 1

count = 0;

for numOfLike in like.values():

    if numOfLike == N:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int n;
    cin >> n;
    vi h(n);
    garr(h);
    int ans = 0;
    map<int, int> cnt;
    rlt(i, 0, n)
    {
        ans += cnt[i - h[i]];
        cnt[i + h[i]]++;
    }
    cnl(ans);
}

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

Measured memory_bytes: 27320