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


#define int long long 

const int N = 111;

int L[N];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> L[i];
	}

	sort(L + 1, L + n + 1);

	int ans = 0;

	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			for(int k = j + 1; k <= n; k++) {
				if(L[i] < L[j] && L[j] < L[k]) {
					ans += (L[i] + L[j] > L[k]);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
#include"bits/stdc++.h"

using namespace std;

int n;
int y;


int main() {
	cin >> n >> y;
	y /= 1000;
	int a = 10;
	int b = 5;
	int c = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int sum = i + j;
			int rest = n - sum;
			if (rest >= 0) {
				int ans = i*a + b*j + c*rest;
				if (ans == y) {
					cout << i << " " << j << " " << rest << endl;
					return 0;
				}
			}
		}
	}
	puts("-1 -1 -1");
	return 0;
}

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

using namespace std;

const int MAXN = 1e5 + 10;
long long h[MAXN];
long long dp[MAXN];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i];

    dp[n] = 0;
    dp[n-1] = abs(h[n] - h[n-1]);

    for (int i = n-2; i >= 1; i--)
        dp[i] = min(dp[i+2] + abs(h[i] - h[i+2]),
                    dp[i+1] + abs(h[i] - h[i+1]));

    cout << dp[1];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
	int N;
	cin >> N;
  vector<int> P(N);
	rep(i,N) cin >> P[i];
	vector<int> mns(N);
	mns[0] = P[0];
	for(int i=1;i<N;i++){
		mns[i] = min(mns[i-1],P[i]);
	}
	int ans = 0;
	rep(i,N){
		if(mns[i] >= P[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
using Graph = vector< vector<int> >;
signed main() {
    int N, M; cin >> N >> M;
    Graph G(N);

    vector<int> checked(N);
    deque<int> ans;
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
        if(i == 0) {
            ans.push_back(u);
            ans.push_back(v);
            checked[u] = checked[v] = true;
        }
    }

    while(1) {
        bool find_new_v = false;

        // front
        int u1 = ans.front();
        for(auto to : G[u1]) {
            if(checked[to]) continue;
            find_new_v = true;
            checked[to] = true;
            ans.push_front(to);
            break;
        }

        // back
        int u2 = ans.back();
        for(auto to : G[u2]) {
            if(checked[to]) continue;
            find_new_v = true;
            checked[to] = true;
            ans.push_back(to);
            break;
        }

        if(!find_new_v) break;
    }

    cout << ans.size() << endl;
    for(size_t i=0; i<ans.size(); i++) {
        printf("%lld%c", ans[i] + 1, " \n"[i+1==ans.size()]);
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;

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

ll vv[1000000];
int N, M;

void solve(){
  // vector<ll> memo;
  // memo.push_back(1);
  // memo.push_back(1);
  ll a=1, b=1, res = 0;
  int skip=0;
  for(ll i=1; i<N+1; i++){
    if(vv[skip] == i){
      //cout << "skip" << endl;
      res = 0;
      //cout << res << endl;
      a = b;
      b = res % 1000000007;
      if(skip+1 < M) skip++;
      continue;
    }else{
      if(i == 1) continue;
      res = a + b;
      //cout << res << endl;
      a = b;
      b = res % 1000000007;
    }
  }
  //cout << a << endl;
  cout << b % 1000000007 << endl;
}

void dfs(int i, int n, vector<int> data){
  vector<int> v1, v2;
  copy(all(data), back_inserter(v1));
  copy(all(data), back_inserter(v2));

  if(i >= n){
    if(!(i > n)){
      for(int j = 0; j < data.size(); j++){
        cout << data[j] << " ";
      }
     cout << endl;
    }
    return ;
  }
  //cout << i  << " ";
  v1.push_back(i + 1);
  v2.push_back(i + 2);
  dfs(i + 1, n, v1);
  dfs(i + 2, n, v2);
}



int main(){
  cin >> N >> M;
  for(int i=0; i<M; i++){
    // int x;
    // cin >> x;
    cin >> vv[i];
  }
  // vector<int> p;
  // p.push_back(0);
  // dfs(0, 4, p);
  solve();
}

Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

char add(int ch,int diff){
    diff%=26;
    ch+=diff;
    if(ch>'z')ch-=26;
    
    return ch;
}


int main() {
    int n;
    while(cin>>n && n){
        string s;
        cin>>s;
        
        
        
        stack<pii> st;
        rep(i,n){
            int a,b;
            cin>>a>>b;
            a--;b--;
            st.push(pii(a,b));
        }
        
        while(st.size()){
            int a=st.top().first;
            int b=st.top().second;
            swap(s[a],s[b]);
            
            int diff=abs(a-b);
            s[a]=add(s[a],diff);
            s[b]=add(s[b],diff);

            st.pop();
        }
        
        cout<<s<<endl;
    }


    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int N = 1e5+4;
int a[N];
int n;
void trace(int x)
{
	int res = a[x];
	if(x == 0)
	{
		for(int i=1;i<n-1;i++)
		{
			cout<<a[i]<<' '<<a[i+1]<<'\n';
			a[i+1] = a[i] - a[i+1]; 
		}
		cout<<a[n]<<' '<<a[n-1]<<'\n';
		return;
	}

	if(x == n+1)
	{
		for(int i=n-1;i>=1;i--)
		{
			cout<<a[i+1]<<' '<<a[i]<<'\n';
			a[i] = a[i+1] - a[i];
		}
		return;
	}

	for(int i=x+1;i<n;i++)
	{
		cout<<res<<' '<<a[i]<<'\n';
		res -= a[i];
	}
	cout<<a[n]<<' '<<res<<'\n';
	res = a[n] - res;
	for(int i=1;i<x;i++)
	{
		cout<<res<<' '<<a[i]<<'\n';
		res -= a[i];
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	int sum = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum += a[i];
	}
	sort(a+1,a+1+n);
	int pos = n+1;
	for(int i=1;i<=n;i++)
	{
		if(a[i] >= 0)
		{
			pos = i-1;
			break; 
		}
	}

	if(pos == 0)
	{
		cout<<sum - 2*a[1]<<'\n';
		trace(pos);
		return 0;
	}

	if(pos == n+1)
	{
		cout<<2*a[n] - sum<<'\n';
		trace(pos);
		return 0;
	}
	// cout<<pos<<'\n';
	int ans = a[pos];
	for(int i=pos+1;i<n;i++)
	{
		ans -= a[i];
	}
	ans = a[n] - ans;
	for(int i=1;i<pos;i++)
	{	
		ans -= a[i];
	}
	cout<<ans<<'\n';
	trace(pos);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod =  1e9+7;
int main(){__
	int n,k;
	cin >> n >> k;
	lli ans = 0ll;
	int l = 0,r = n;
	lli suml = 0ll, sumr = 0ll;
	while(l <= n){
		suml+=l;
		sumr+=r;
		lli dif = sumr - suml +1ll;
		if(l >= k-1)
			ans = (ans + dif) % mod;
		l++;
		r--;
	}
	cout<< ans << endl;
	return 0;
}


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

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

auto solve(long long x, long long y){
    int gs[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    return gs[x] == gs[y] ?  YES : NO;
}

int main(){
    long long x;
    scanf("%lld",&x);
    long long y;
    scanf("%lld",&y);
    auto result = solve(x, y);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;



void _sol(){
    int h,w,m; cin >> h >> w >> m;
    vector<int> row(h+1,0) , col(w+1,0);
    map<int,map<int,int>> mp;
    forr(i,m){
        int u,v; cin >> u >> v;
        row[u]++;
        col[v]++;
        mp[u][v]++;
    }
    vector<pair<int,int>> v1,v2;
    for(int i=1;i<=h;i++){
        v1.push_back({row[i] , i});
    }
    for(int i=1;i<=w;i++){
        v2.push_back({col[i] , i});
    }
    sort(v1.rbegin(),v1.rend()); sort(v2.rbegin(),v2.rend());
    int ans = INT_MIN;
    for(int i=1;i<=w;i++){
        ans = max(ans , v1[0].first + v2[i-1].first - mp[v1[0].second][v2[i-1].second]);
    }
    for(int i=1;i<=h;i++){
        ans = max(ans , v1[i-1].first + v2[0].first - mp[v1[i-1].second][v2[0].second]);
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


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

int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    int count1=0,count2=0;
    for(int i=0;i<m;i++)
    {
        int u;
        cin>>u;
        if(u>x)
        {
            count2++;
        }
        else
        {
            count1++;
        }
    }
    
    cout<<min(count1,count2)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
N = int(S)
M = sum([int(s) for s in S])

if N % M == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27300
from collections import Counter
n = int(input())
s = [str(sorted(input())) for i in range(n)]
d = dict()
for el in s:
    if d.get(el) == None:
        d[el] = 1
    else:
        d[el] += 1
count = 0
for el in d.values():
    count += el*(el-1)//2
print(count)


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

int main() {
    int a, b, d, r;
    double f;

    cin >> a >> b;

    d = a/b;
    r = a%b;
    f = (double)a/(double)b;

     printf("%d %d %f\n", d, r, f);

	return 0;
}


Measured memory_bytes: 3208
#include <iostream>
using namespace std;
int main  (){
	int c , d , a , b;
	cin >> c >> d ;
	if (c < d){
		cout << "a < b" << endl;
	}
	if(c > d){
		cout << "a > b"  << endl;
	}
	if(c == d){
		cout << "a == b" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if(N == 1 && M == 1){
        cout << 1 << endl;
        return 0;
    }
    if(N > M){
        swap(N, M);
    }
    ans = N * M - N * 2 - min((ll)1, N - 1) * max((ll)0, (M - 2) * 2);

    cout << ans << endl;

} 

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

int main(){
    int s, w;
    std::cin >> s >> w;
    if(w >= s){
        std::cout << "unsafe" << std::endl;
    }else{
        std::cout << "safe" << std::endl; 
    }
    return 0;
}


Measured memory_bytes: 3556
/* 
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_13_C
 * A*
 */
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define N 4
#define N2 16
using namespace std;

vector<int> move_list[N2];
int dist[N2][N2];

class Game{
public:
  char board[N2];
  char w;
  vector<char> root;
  char mnh;

  bool operator < (const Game &other) const{
    return root.size()+mnh > other.root.size()+other.mnh;
  }

};
Game start;

int solve(){
  priority_queue<Game> q;
  q.push(start);
  
  while(!q.empty()){
    Game g=q.top();q.pop();
    if(g.mnh==0) return g.root.size();

    for(int move:move_list[g.w]){
      if(g.root.size()>0 && g.root.back()==-move) continue;
      Game h=g;
      int to=h.w+move;
      h.mnh -= dist[to][h.board[to]-1];
      h.mnh += dist[h.w][h.board[to]-1];
      swap(h.board[h.w],h.board[to]);
      h.w = to;
      h.root.push_back(move);
      q.push(h); 
    }
  }
  return -1;
}

void initialize(){
  for(int i=0;i<N2;i++){
    if(i%N<N-1) move_list[i].push_back(1);
    if(i%N>0  ) move_list[i].push_back(-1);
    if(i/N<N-1) move_list[i].push_back(N);
    if(i/N>0  ) move_list[i].push_back(-N);
  }

  //i=board,j=piece-1
  for(int i=0;i<N2;i++){
    for(int j=0;j<N2;j++){
      dist[i][j] = abs(j%N-i%N) + abs(j/N-i/N);
    }
  }

  start.mnh=0;
  for(int i=0;i<N2;i++){
    if(i==start.w) continue;
    start.mnh += dist[i][start.board[i]-1];
  }
  
}
 
int main(){
  int tmp;
  for(int i=0;i<N2;i++){
    cin>>tmp;
    if(tmp==0){
      start.board[i]=N2;
      start.w=i;
    }else{
      start.board[i]=tmp;
    }
  }
  initialize();
  cout<<solve()<<endl;
}

Measured memory_bytes: 198900
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc2(n,m);
	f1(i,m)sc(x),sum+=x;
	if(sum>=n)prY;
	else prN;
	
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     long n;
     cin>>n;
      long sum=0;
     for(long i=1;i<=n;i++){
     	if(i%3==0||i%5==0){
     		continue;
     	}
     	else{
     		sum+=i;
     	}
     }
     cout<<sum<<endl;
}

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

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

//#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
tree<
       int,
     null_type,
     less<int>,
     rb_tree_tag,
     tree_order_statistics_node_update>t;
*/

int main()
{
    fast_in_out;

     double r;
     cin>>r;
     printf("%.15f\n", 2*PI*r);

    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
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);
}
int main()
{
    int N,a;
    map<int,int> cnt;
    cin>>N;
    rep(i,N)
    {
        cin>>a;
        cnt[a]++;
    }
    int ans=0;
    for(auto i : cnt)
    {
        int x = i.first,xnum=i.second;
        if(xnum>=x)
        {
            ans+=xnum-x;
        }
        else
        {
            ans+=xnum;
        }
        
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int check = 0;
        int num1 = scan.nextInt();

        for(int i = 0; i < num1; i++){
            int num2 = scan.nextInt();

            if(num2 % 2 == 0){
                if(num2 % 3 != 0 && num2 % 5 != 0){
                    check = 1;
                }
            }
        }


        if(check == 0){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint c(N),s(N),f(N);
    REP(i,N-1) cin>>c[i]>>s[i]>>f[i];

    for(int i=0;i<N;i++){
        int t=0;
        for(int j=i;j<N-1;j++){
            t=max(t,s[j]);
            while((t-s[j])%f[j]) t++;
            t+=c[j];
        }
        cout<<t<<endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

type Magic struct {
	damage int
	mp     int
}

func main() {
	var h, n int
	fmt.Scan(&h)
	fmt.Scan(&n)
	var magicArray []Magic
	magicArray = make([]Magic, n)
	for i := 0; i < n; i++ {
		var d, m int
		fmt.Scan(&d)
		fmt.Scan(&m)
		magicArray[i] = Magic{d, m}
	}

	var dp [][]int
	dp = make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, h+1)
	}
	for i := 0; i < h+1; i++ {
		dp[0][i] = -1
	}
	for i := 0; i < n+1; i++ {
		dp[i][0] = 0
	}

	for i := 1; i < n+1; i++ {
		var magic Magic = magicArray[i-1]
		var mDagame int = magic.damage
		for j := 1; j < h+1; j++ {
			// i-1種類を使ってjダメージを出すために使ったMP
			// i種類を使ってj-dダメージを出すために使ったMP+iを使うためのMP
			// どちらが小さいか
			if dp[i-1][j] != -1 {
				if j-mDagame < 0 {
					if magic.mp < dp[i-1][j] {
						dp[i][j] = magic.mp
					} else {
						dp[i][j] = dp[i-1][j]
					}
				} else {
					if dp[i][j-mDagame]+magic.mp < dp[i-1][j] {
						dp[i][j] = dp[i][j-mDagame] + magic.mp
					} else {
						dp[i][j] = dp[i-1][j]
					}
				}
			} else if j-mDagame < 0 {
				dp[i][j] = magic.mp
			} else {
				dp[i][j] = dp[i][j-mDagame] + magic.mp
			}
		}
	}
	fmt.Println(dp[n][h])
}


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

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

    int w[n];
    int sum=0;
    for (int i=0;i<n;i++){
        cin >> w[i];
        sum += w[i];
    }

    int ans = sum;
    int left,right;
    for(int t=0;t<n;t++){
        left += w[t];
        right = sum - left;
        ans = min(ans,abs(left-right));
    }
    cout << ans << endl;

}

Measured memory_bytes: 3576
package main

import (
	"fmt"
	"log"
	"time"
)

func main() {
	var month, day int
	fmt.Scan(&month)
	fmt.Scan(&day)
	start, err := time.Parse("2006-01-02", "2018-01-01")
	if err != nil {
		log.Fatal(err)
	}
	end, err := time.Parse("2006-01-02", fmt.Sprintf("2018-%02d-%02d", month, day))
	if err != nil {
		log.Fatal(err)
	}
	count := 0
	for start.Before(end) || start.Equal(end) {
		_, m, d := start.Date()
		if int(m) == d {
			count++
		}
		start = start.AddDate(0, 0, 1)
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define F(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=2e5+5;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
void solve()
{
	string s;
    ll n,m;
   
   // cin>>n;
    cin>>s;
    if(s[1]=='R')cout<<"ABC";
    else cout<<"ARC";
}
int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3612
#include <cstdio>
const int N = 1e5 + 5;
typedef long long LL;
int n;
int a[N];
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i ++) scanf("%d", &a[i]);
	int ca = 0;
	LL sum = 0;
	for(int i = 0; i < n; i ++){
		sum += (ca + a[i]) >> 1;
		ca = (ca + a[i]) & 1;
		if(a[i] == 0) ca = 0;
	}
	printf("%lld\n", sum);
} 

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;
int dp[NMAX][3];

void solve()
{
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>a>>b>>c;
        dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c + max(dp[i-1][0], dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

double distance(int x1, int x2, int y1, int y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main() {
    int N; cin >>N;
    double sum = 0, count = 0;
    vector<int> x(N), y(N);
    
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    vector<int> v(N);
    for(int i = 0; i < N ;i++) v[i] = i;
    
    do{
        for(int i = 0; i < N-1; i++){
            sum += distance(x[v[i]], x[v[i+1]], y[v[i]], y[v[i+1]]);
        }
        count++;
    }while(next_permutation(v.begin(), v.end()));

    cout << fixed << setprecision(6) << sum/count <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  s[3] = '8';
  print(s);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >>c;
    cout << min(min(a+b,a+c),b+c);
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;

	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());

	if (s.size() == 26) {
		cout << "None" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != 'a' + i) {
				printf("%c\n", 'a' + i);
				return 0;
			}
		}
	}
	printf("%c\n", 'a' + s.size());

	return 0;
}

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

int main() {
  int a,b,c;
  int k;
  string ans="No";

  cin >> a>>b>>c>>k;

  int x=0,y=0;

  while(a>=b) {
    b*=2;
    x++;
  }

  while(b>=c) {
    c*=2;
    y++;
  }

  if(x+y<=k) {
    ans="Yes";
  }

  cout <<ans<< endl;

  return 0;
}


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

const int MAX_N = 2e5+10;
const int MOD = 1e9+7;
int a[MAX_N],b[MAX_N];
ll dp[MAX_N],sum[MAX_N];
int n;

void solve()
{
    n = unique(a+1,a+n+1)-(a+1);
	dp[0] = 1LL; 
	for(int i=1; i<=n; i++){
		dp[i] = dp[i-1];
		(dp[i]+=sum[a[i]])%=MOD;
		(sum[a[i]]+= dp[i-1])%=MOD;
	}
	printf("%lld\n",dp[n]);
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
    solve();
	return 0;
}

Measured memory_bytes: 7652
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int n,m;
int s[15][15];
int p[15];
int brute(int cur, set<int> se){
	if(cur==n+1){
		/*for(int i=1;i<=n;i++){
			if(se.count(i)){
				cout<<"1";
			}
			else {
				cout<<"0";
			}
		}
		cout<<"\n";*/
		for(int i=1;i<=m;i++){
			int t = 0;
			for(int j=1;j<=s[i][0];j++){
				if(se.count(s[i][j])){
					t++;
				}
			}
			if((t%2)!=p[i]){
				return 0;
			}
		}
		return 1;
	}
	else {
		int ans = 0;
		ans += brute(cur+1,se);
		se.insert(cur);
		ans += brute(cur+1,se);
		return ans;
	}
}

int32_t main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>s[i][0];
		for(int j=1;j<=s[i][0];j++){
			cin>>s[i][j];
		}
	}
	for(int i=1;i<=m;i++){
		cin>>p[i];
	}
	set<int> t;
	cout<<brute(1,t);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007


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

	

	int n, k,r,s,p;
	cin>>n>>k>>r>>s>>p;

	string st;
	cin>>st;
	map <char, int> m;
	map <char, char> mp;
	m['r'] = p;
	m['s'] = r;
	m['p'] = s;
	mp['r'] = 'p';
	mp['s'] = 'r';
	mp['p'] = 's';
	int ans= 0 ;
	string res = "";
	bool fr=0,fs=0,ft=0;
	for (int i=0;i<n;++i)
	{
		if (i-k<0)
		{
			ans+=m[st[i]];
			res+=mp[st[i]];
		}
		else
		{
			if (mp[st[i]]==res[i-k])
			{
				if (i+k>n-1)
					res+=st[i];
				else
				{
					char x = mp[st[i+k]];
					char y = res[i-k];
					if (x=='s')
					{
						if (y=='r') res+='p';
						else res+='r';
					}
					else if (x=='r')
					{
						if (y=='s') res+='p';
						else res+='s';
					}
					else
					{
						if (y=='r') res+='s';
						else res+='r';
					}
				}
			}
			else
			{
				ans+=m[st[i]];
				res+=mp[st[i]];
			}
		}
		// debug2(i,ans);
	}
	cout<<ans<<"\n";

	



	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<Int> dp(K + 1,-1);//dp[i]:残りi個で回ってきた人間が勝てるかどうか -1→未定 0→負け 1→勝ち
	for (Int i = 0; i < a[0]; i++) {
		dp[i] = 0;
	}
	for (Int i = 0; i < N; i++) {
		dp[a[i]] = 1;
	}

	Int flag;
	for (Int i = 0; i < K+1; i++) {
		if (-1!=dp[i]) {
			continue;
		}
		else {
			flag = 0;//負け
			for (Int j = 0; j < N; j++) {
				if (i-a[j]<0) {
					continue;
				}
				else if (0==dp[i-a[j]]) {//一回でも負けを相手に押し付けれる場合は自分の勝ち
					flag = 1;
					break;
				}
			}

			if (flag) {
				dp[i] = 1;
			}
			else {
				dp[i] = 0;
			}
		}
	}

	if (dp[K]) cout << "First" << "\n";
	else cout << "Second" << "\n";
}


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

int main()
{
    int n;cin>>n;
    vector<int> s(n);
    int i;
    for(i=0;i<n;i++)cin>>s.at(i);
    int sum=0;
    for(i=0;i<n;i++)sum+=s.at(i);
    if(sum%10!=0)cout<<sum<<endl;
    else
    {
        int t=-1;
        sort(s.begin(),s.end());
        for(i=0;i<n;i++)
        {
            if(s.at(i)%10!=0)
            {
                t=i;
                break;
            }
        }
        if(t==-1)cout<<0<<endl;
        else cout<<sum-s.at(t)<<endl;
    }
    
}


Measured memory_bytes: 256
N = list(map(int, input().split()))
A,B = list(map(int, input().split()))
l = list(map(int, input().split()))

ca = cb = cc = 0

for i in l:
    if i <= A :
        ca += 1
    elif A < i <= B:
        cb += 1
    elif B < i:
        cc += 1

print(min(ca,cb,cc))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define sec second
int main(){
  pair<int,int> x[6];
  for(int i=0;i<6;++i){
    cin>>x[i].fst>>x[i].sec;
    if(x[i].fst>x[i].sec) swap(x[i].fst,x[i].sec);
  }
  sort(x,x+6);
  pair<int,int> y[3];
  for(int i=0;i<6;i+=2){
    if(x[i]==x[i+1]) y[i/2]=x[i];
    else{ cout<<"no\n"; return 0; }
  }
  if(y[0].fst==y[1].fst && y[1].sec==y[2].sec && y[2].fst==y[0].sec) cout<<"yes\n";
  else cout<<"no\n";
  return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int cnt[112345] = {};
int gen[112345] = {};
int dat[112345] = {};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int num,mod;
    scanf("%d%d",&num,&mod);
    for(int i=0;i<num;i++)
	{
		int z;
		scanf("%d",&z);
		cnt[z%mod]++;
		dat[z]++;
	}
	for(int i=0;i<=100000;i++)
	{
		gen[i%mod]+=dat[i]/2;
	}

    int ret = 0;
    for(int i = 0; i+i <= mod; i++){
        if(i == 0 || i+i == mod){
            ret += cnt[i] / 2;
        }else{

			if(cnt[i]<cnt[mod-i])ret+=cnt[i]+min((cnt[mod-i]-cnt[i])/2,gen[mod-i]);
			else ret+=cnt[mod-i]+min((cnt[i]-cnt[mod-i])/2,gen[i]);

        }
    }
    printf("%d\n",ret);

}


Measured memory_bytes: 1408
from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in'_'*M]
z=i=0
for _ in'_'*N:M<t[i]or v[t[i]-1].append(t[i+1]);i+=2
q=[]
for i in v:
	for j in i:heappush(q,-j)
	z-=len(q)and heappop(q)
print(z)

Measured memory_bytes: 24932
#include<stdio.h>
#include<string.h>
#define LEN 100001

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN){
    tail=0;
  } else {
    tail=tail+1;
  }
}

P dequeue(){
  P x=Q[head];
  if(head+1==LEN){
    head = 0;
  } else {
    head=head+1;
  }
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0;i < n; i++){
    scanf("%s", u.name);
    scanf("%d", &u.t);
    enqueue(u);
    
  }
  while(tail != head){
    u=dequeue();
    if(u.t<=q){
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    } else {
      u.t-=q;
      elaps+=q;
      enqueue(u);
      
    }
  }
  
  return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e18

int N, M, K;
int main()
{

	cin>>N>>M;
	vector<int> A(N);
	rep(i,N)cin>>A[i];
	sort(A.begin(),A.end());

	vector<pair<int,int>> B(M); 

	rep(i,M) {
		cin >> B[i].first >> B[i].second;
	}

	sort(B.begin(),B.end(), [](const pair<int,int> &x, const pair<int,int> &y) {
		return x.second > y.second;
	});


	long long ans = 0;


	int add = 0;
	for (auto x : B) {
		for (int i = 0; i < x.first; i++) {
			A.push_back(x.second);
			add ++;
			if (add > N) break;
		}
		if (add > N) break;
	}


	sort(A.begin(),A.end(), [](const int &x, const int &y){
		return x > y;
	});

	for (int i = 0; i < N; i++) {
		ans += A[i];
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n,num[5010],hoge,ans;
	while(cin>>n,n!=0){
	hoge=0;
	for(int i=0;i<n;i++)cin>>num[i];
	ans=num[0];
	for(int i=0;i<n;i++){
		hoge=0;
		for(int j=i;j<n;j++){
			hoge+=num[j];
			ans=max(ans,hoge);
		}
	}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    int n,a,b,answer = 0;
    cin >> n >> a >> b;
    
    for(int i = 1; i <= n; i++){
        int t = 0;
        
        for(int j = 0; j < 5; j++){
            t += (i / (int)pow(10,j))%10;
        }
        
        if(a <= t && t <= b){
            answer += i;
        }
    }
    
    cout << answer << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <random>
#include <atcoder/all>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<lint, char> pa;

using namespace atcoder;
int N, K, A;
const lint MAX_V = 1e9;
int main() {
	cin >> N >> K;
	int s = N * 2, t = s + 1;
	mcf_graph<int, lint> G(t + 1);
	REP(i, N) {
		G.add_edge(s, i, K, 0);
		G.add_edge(i + N, t, K, 0);
	}
	G.add_edge(s, t, N* K, MAX_V);
	REP(i, N) {
		REP(j, N) {
			cin >> A;
			G.add_edge(i, j + N, 1, MAX_V - A);
		}
	}
	plint p = G.flow(s, t, N * K);
	cout << 1LL * N * K * MAX_V - p.second << endk;
	vector<string> grid(N, string(N, '.'));
	for (auto e : G.edges()) {
		if (e.flow == 0) continue;
		if (e.from == s || e.to == t) continue;
		grid[e.from][e.to - N] = 'X';
	}
	REP(i, N) {
		cout << grid[i] << endk;
	}
}


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

int cmp(char a,char b)
{
	return a>b;
}

int main()
{
	int i;
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if(s<t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <ios>
#include <iomanip>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;


int w,h,c[50][50];
int dx[] = {-1,0,1,-1,1,-1,0,1};
int dy[] = {1,1,1,0,0,-1,-1,-1};

bool inRange(int y,int x){
    if(0<=x && x<w && 0<=y && y<h) return true;
    else return false;
}

void dfs(int x,int y){
    c[x][y] = 0;
    rep(i,8){
        int x_next=x+dx[i],y_next=y+dy[i];
        if(inRange(x_next,y_next) && c[x_next][y_next]==1){
            dfs(x_next,y_next);
        }
    }
}

void solve() {
    while(1){
        cin >> w >> h;
        if(w==0 && h==0) break;
        rep(row,h){
            rep(col,w){
                cin >> c[row][col];
            }
        }

        int ans = 0;
        rep(row,h){
            rep(col,w){
                if(c[row][col]==1){
                    ans++;
                    dfs(row,col);
                }
            }
        }

        print(ans);
    }
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>
int main(void){
    int n,m,x,y,i,a[]={-1,-1,-1};
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        if(a[x-1]!=-1 && a[x-1]!=y){
            printf("-1");
            return 0;
        }
        a[x-1]=y;
    }
    if(n!=1 && a[0]==0){
        printf("-1");
        return 0;
    }
    if(n==1 && a[0]==-1) a[0]=0;
    if(n!=1 && a[0]==-1) a[0]=1;
    for(i=0;i<n;i++){
        if(a[i]==-1) printf("0");
        else printf("%d",a[i]); 
    }
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string S; cin >> S;
  string T; cin >> T;


  int ans = 999999;
  for (int i = 0; i + T.size() <= S.size(); i++) {
    int val = 0;
    for (int j = 0; j < (int)T.size(); j++) {
      if (S[i + j] != T[j]) val++;
    }
    chmin(ans, val);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main() {
    long long n;
    cin >> n;
    long long count=1;
    long long a=1e9+7;
    for(long long i=1;i<=n;i++){
        count=(count*i)%a;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()


int N;
vector<long> value;

void update(int i){
  i += N-1;
  while(i > 0){
    i = (i-1)/2;
    long c1 = value.at(i*2 + 1);
    long c2 = value.at(i*2 + 2);
    value.at(i) = max(c1, c2);
  }
}

long query(int a, int b, int k, int l, int r){
  if(r <= a || b <= l) return 0;
  if(a <= l && r <= b) return value.at(k);
  else{
    long c1 = query(a, b, 2*k+1, l, (l+r)/2);
    long c2 = query(a, b, 2*k+2, (l+r)/2, r);
    return max(c1, c2);
  }
}

int main(){
  int n;
  cin >> n;
  N = 1;
  while (N < n) N *= 2; // 葉の数を計算（n以上の最小の2冪数）
  value = vector<long>(2 * N - 1, 0);

  vi h(n);
  vl a(n);
  rep(i,n) cin >> h[i];
  rep(i,n) cin >> a[i];


  rep(i,n){
    long t = h[i];
    value[N-1 + t-1] = query(0,t,0,0,N) + a[i];
    update(t-1);
  }
  cout << query(0,n,0,0,N) << endl;
}

Measured memory_bytes: 9552
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


if __name__ == "__main__":
    A, B, C, D, E = tuple(map(int, input().split(" ")))
    K = [A, B, C, D, E]
    for i in range(len(K)):
        if K[i] == 0:
            print(i + 1)


Measured memory_bytes: 9488