akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

struct tv { int s, t, c; };
int N, C, sum[100001];
tv TV[100000];

int main() {
    cin >> N >> C;
    int s, t, c;
    REP(i, N) {
        cin >> s >> t >> c; c--;
        TV[i] = {s, t, c};
    }
    sort(TV, TV + N, [](const tv& a, const tv& b) { return a.s < b.s; });
    REP(i, C) {
        int before = -1;
        REP(j, N) {
            if (TV[j].c == i) {
                if (TV[j].s == before) sum[TV[j].s]++;
                else sum[TV[j].s - 1]++;
                sum[TV[j].t]--;
                before = TV[j].t;
            }
        }
    }
    int ans = 0;
    FOR(i, 1, 100001) {
        sum[i] += sum[i - 1];
        ans = max(ans, sum[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main( void )
{
  while( 1 ){
    int n,p,d[55],b,i;
    cin >> n >> p;
    if( n == 0 ) break;
    for( i=0; i<n; i++ ){
      d[i] = 0;
    }
    b = p;
    i = 0;
    while( 1 ){
      if( b > 0 ){
        d[i]++;
        b--;
        if( d[i] == p ){
          cout << i << endl;
          break;
        }
      } else if( d[i] > 0 ) {
        b = d[i];
        d[i] = 0;
      }
      i = (i+1) % n;
    }
  }
}

Measured memory_bytes: 1160
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int[] arr = new int[N];
    int sum =0;
    for (int i = 0; i < N; i++) {
        arr[i] = Integer.parseInt(sc.next());
        sum += arr[i];
    }
    if(sum>= H){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
}  
}



Measured memory_bytes: 47556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int h, w; cin >> h >> w;
    vector<string> a(h); cin >> a;

    VI cnt(26, 0);
    FOR(i, 0, h)FOR(j, 0, w)cnt[a[i][j] - 'a']++;
    int four = (h / 2) * (w / 2);
    int two = (h / 2) * (w % 2) + (w / 2) * (h % 2);
    for (int i = 0; i < 26 && four > 0; i += (cnt[i] < 4)) {
        if (cnt[i] < 4)continue;
        cnt[i] -= 4;
        four--;
    }
    for (int i = 0; i < 26 && two > 0; i += (cnt[i] < 2)) {
        if (cnt[i] < 2)continue;
        cnt[i] -= 2;
        two--;
    }
    cout << (four || two ? "No\n" : "Yes\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
/*----------------------------------------------------------------------*/

const ll FINDSIZE = 1e5+5;
ll p[FINDSIZE],sizes[FINDSIZE];

//if it is the representative then return itself otherwise return parent of it's immediate parent
ll findSet(ll i){
	return (p[i]==i)? i : p[i]=findSet(p[i]);
}

bool isSameSet(ll i, ll j){
	return findSet(i) == findSet(j);
}

void join(ll i, ll j){
	if (!isSameSet(i,j))
	{
		ll x = findSet(i),y = findSet(j);
		if(sizes[x] < sizes[y]){
			p[x] = y;
			sizes[y]+=sizes[x];
			
		}else{
			p[y] = x;
			sizes[x]+=sizes[y];
		}

	}
}

void initialiseUnionFind(){
	for(ll i=0;i<FINDSIZE;i++){
		p[i] = i;
		sizes[i] = 1;
	}
}

vll ans;
vector<lll> edges;

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    initialiseUnionFind();

    ll n,m,u,v;
    cin>>n>>m;

    ans.resize(m);

    F(i, 0, m) {
    	cin>>u>>v; u--; v--;
    	edges.push_back({u, v});
    }

    ll curr = n*(n-1LL)/2LL;
	RF(i, m-1, 0) {
		ans[i] = curr;
		if(isSameSet(edges[i].first, edges[i].second)) continue;
		curr -= sizes[findSet(edges[i].first)]*1LL*sizes[findSet(edges[i].second)];
		join(edges[i].first, edges[i].second);
	}

	F(i, 0, m) {
		cout<<ans[i]<<endl;
	}

    return 0;
}/*

*/

Measured memory_bytes: 5360
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int N  =1e7+5;
ll n,f[N];
bool Mark[N];
void Pre() {
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j*i <= n; ++j) {
            ++f[j*i];
        }
    }
}
int main() {
    cin >> n;
    Pre();
    ll sum = 0;
    for(int i = 1; i <= n; ++i) {
        //printf("f[%d] = %lld\n",i,f[i]);
        sum += ll(i)*f[i];
    }
    cout << sum << '\n';
return 0;
}

Measured memory_bytes: 81640
N = int(input())
ABCDE = [int(input()) for _ in range(5)]

def ceil(x,y):
    if x%y == 0:
        return x//y
    else:
        return x//y + 1

# 5分後以降、最後の都市にmin(N,A,B,C,D,E)人ずつ人が到着する    
print(4 + ceil(N, min(N,min(ABCDE))))

Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  string S;
  cin >> S;
  S.erase(S.size()-1);
  int n = S.size();
  int ans = 0;

  for (int i = 0; i < n; i++) {

    int num = S.size();
    if(num % 2 == 0){
      string a = S.substr(0,num/2);
      string b = S.substr(num/2,num/2);
      if(a == b){
        cout << num << endl;
        return 0;
      }
    }
    S = S.erase(num-1); // 1文字削除
  }

  return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

N, M = map(int, input().split())
Hs = list(map(int, input().split()))

s = set()

for i in range(0, M):
    A, B = map(int, input().split())
    if Hs[A - 1] <= Hs[B - 1]:
        s.add(A)
    if Hs[A - 1] >= Hs[B - 1]:
        s.add(B)

# print(s)
# print(len(s))
print(N - len(s))


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


void solve(long long X){
    long long tmp = 100;
    for (long long i = 0; ; i++) {
        if (tmp >= (long long)X) {
            cout << i << endl;
            return;
        }
        tmp += tmp / 100;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3696
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 512 * 1024;
char st[MAX_N], init_st[MAX_N];
int nnew[MAX_N];
string ttt;

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	
	cin>>ttt;
	strcpy(st,ttt.c_str());

	int n = (int) strlen(st);
	if (n < 26) {
		for (int i=0; st[i]; i++) nnew[st[i]-'a'] = 1;
		for (int i=0; i<26; i++)
			if (!nnew[i]) {
				printf("%s%c",st,(char) 'a'+i);
				return 0;
			}
	}

	strcpy(init_st, st);
	if (!next_permutation(st,st+n)) printf("-1");
	else {
		int qq = 0;
		while (st[qq]) {
			if (st[qq] > init_st[qq]) {
				st[qq+1] = 0;
				break;
			}
			qq++;
		}
		printf("%s",st);
	}
    return 0;
}  


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll long long
# define ln cout<<'\n'
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;

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

void rec(int n,vector<string> &v,string x){
    if (n==0){
        //v.pb(x);
        
    }
    else{
        string kouho[3] = {"7","5","3"};
        rep(i,3){
            string tmp = x+kouho[i];
            v.pb(tmp);
            rec(n-1,v,tmp);
        }
    }

}

bool Find(string s){
    if( (s.find("7")!=string::npos) and (s.find("5")!=string::npos) and (s.find("3")!=string::npos)){
        return true;
    }
    else{
        return false;
    }
}


int main(){
    ll N;
    int cnt=0;
    string tmp2;
    cin >> N;
    int digit = floor(log10(N))+1;
    vector<string> List;
    rec(digit,List,"");
    rep(i,List.size()){
        tmp2 = List[i];
        if ((stoi(tmp2)<=N) && Find(tmp2)){
            cnt += 1;
            
        }
        
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define N 2020
using namespace std;
char grid[N][N];
vector<int> ln[N],vln[N];
int main(){
	int n,m,i,j,k,l,num,ans=0,pos1,pos2,posa,posb;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin>>grid[i][j];
			if(grid[i][j]=='#')
			{
				ln[i].push_back(j);
				vln[j].push_back(i);
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(grid[i][j]=='#')
			{
				continue;
			}
			pos1=upper_bound(ln[i].begin(),ln[i].end(),j)-ln[i].begin();
			pos2=upper_bound(vln[j].begin(),vln[j].end(),i)-vln[j].begin();
			posa=pos1-1;
			posb=pos2-1;
			if(pos1==ln[i].size())
			{
				pos1=m-1;
			}
			else
			{
				pos1=ln[i][pos1]-1;
			}
			if(pos2==vln[j].size())
			{
				pos2=n-1;
			}
			else
			{
				pos2=vln[j][pos2]-1;
			}
			if(posa==-1)
			{
				posa=0;
			}
			else
			{
				posa=ln[i][posa]+1;
			}
			if(posb==-1)
			{
				posb=0;
			}
			else
			{
				posb=vln[j][posb]+1;
			}
			num=pos1-posa+pos2-posb+1;
			ans=max(ans,num);
		}
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 38400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R,G,B,N;cin>>R>>G>>B>>N;
  int M=0;
  for(int r=0;r<=5000;r++){
    for(int g=0;g<=5000;g++){
      if((N-(R*r+G*g))%B==0&&(N-(R*r+G*g))>=0)M++;
    }
  }
  cout<<M<<endl;
}

Measured memory_bytes: 3592
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int dm = 1 << 21;
char dn[dm], * di = dn, dt;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = ' ';
		return;
	}
	int keta = 0;
	char C[7];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int M, K;
	scanf("%d %d", &M, &K);

	if (M == 0) {
		if (K == 0) printf("0 0");
		else printf("-1");
	}
	else if (M == 1) {
		if (K == 0) printf("0 0 1 1");
		else printf("-1");
	}
	else {
		if ((1 << M) <= K) {
			printf("-1");
		}
		else {
			putint(K);
			rep(i, 1 << M) {
				if (i != K) putint(i);
			}
			putint(K);
			rep(i, 1 << M) {
				if ((1 << M) - 1 - i != K) putint((1 << M) - 1 - i);
			}
			fwrite_unlocked(dn, di - dn, 1, stdout);
		}
	}
	Would you please return 0;
}

Measured memory_bytes: 3328
def gcd(n,m)
  if n % m == 0
    return n/m
  end
  return gcd(m,n%m)
end

datas = gets.split(" ").map{|nn|nn.to_i}
n = datas[0]
x = datas[1]
datas = gets.split(" ").map{|nn|nn.to_i}
datas << x
datas.sort!
minus = []
1.upto(datas.size-1) do|nn|
  minus << datas[nn] - datas[nn-1]
end

puts minus.inject(:gcd).to_s;

Measured memory_bytes: 10480
#include <stdio.h>

int main(int argc, char const *argv[])
{
    char S[20], T[20];
    scanf("%s", S);
    scanf("%s", T);
    size_t i = 0;
    while (S[i] != '\0')
    {
        if (S[i] != T[i])
        {
            printf("No\n");
            return 0;
        }
        i++;
    }
    if (T[++i] != '\0')
    {
            printf("No\n");
            return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1660
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))


# ----------

N = ii()
A = lmii()

bd = defaultdict(int)
ac = defaultdict(int)
for i in range(N):
    a = b = i + 1
    c = d = A[i]
    bd[b-d] += 1
    ac[a+c] += 1

ans = 0
for k, v in bd.items():
    ans += v * ac[k]

print(ans)


Measured memory_bytes: 70600
($n,$na,$nb) = split / /,<>;
@s=split //,<>;
pop @s;
$pass = 0;
$bcnt = 0;
for (@s){
    my $flag = 'No';
    $bcnt++ if $_ eq 'b';
    $flag = 'Yes' if $pass < $na + $nb and (($_ eq 'a') or ($_ eq 'b' and $bcnt <= $nb));
    print "$flag\n";
    $pass++ if $flag eq 'Yes';
}

Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x, (val), sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


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

ll solve(ll X, ll A, ll B) {
  X-=A;
  while (X>=0) X-=B;
  return X+B;
}

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

  ll X, A, B;
  cin >> X >> A >> B;

  auto ans = solve(X, A, B);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3176
from math import factorial

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))


def cnt(x):
  pattern = 0
  numbers = list(i for i in range(1, n+1))
  for i in range(n):
    if x[i] > min(numbers): 
      pattern += numbers.index(x[i]) * factorial(n-i-1)
    numbers.remove(x[i])
  return pattern


print(abs(cnt(p) - cnt(q)))

Measured memory_bytes: 9128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	if (N < 1000)cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N, A, B; cin >> N >> A >> B;
	string S; cin >> S;
	int J = 0, F = 0, U = 0;
	REP(i,N){
		bool flg = false;
		if (S[i] == 'a') {
			J++;
			if (U < A + B) {
				U++;
				flg = true;
			}
		}
		if (S[i] == 'b') {
			F++;
			if (U < A + B && F <= B) {
				U++;
				flg = true;
			}
		}
		Yn(flg);
	}
	return 0;
}



Measured memory_bytes: 896
import bisect

A, B, Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]

for _ in range(Q):
    x = int(input())
    a = bisect.bisect_left(S,x)
    b = bisect.bisect_left(T,x)
    a1 = float("inf")
    a2 = float("inf")
    b1 = float("inf")
    b2 = float("inf")
    
    if a == 0:
        a2 = S[a] - x
    elif a == A:
        a1 = x - S[a-1]
    else:
        a1 = x - S[a-1]
        a2 = S[a] - x
    if b == 0:
        b2 = T[b] - x
    elif b == B:
        b1 = x - T[b-1]
    else:
        b1 = x - T[b-1]
        b2 = T[b] - x
    
    print(min(max(a1,b1),max(a2,b2), min(a1,b2)*2+max(a1,b2), min(a2,b1)*2+max(a2,b1)))

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

const int MAX_P = 2e4;

signed main(void){ 
  int n,p; cin >> n >> p;
  string s; cin >> s;
  int ans = 0;
  
  if( p % 2 == 0 || p % 5 == 0 ){ 
    
    for(int i = 0; i < n; i++){ 
      int d = (int)(s[i]-'0');
      if( d % p == 0 ){ 
        
        ans += i+1;
      }
    }
    
    cout << ans << endl; 
    
    return 0;
  }
  
  //そうじゃない時
  
  int base = 1LL;
  
  map<int,int> mp;
  int sum = 0;
  
  for(int i = n-1; i >= 0; i--){ //桁とSの向きが逆なことに注意
    int d = (int)(s[i]-'0');
    
    sum = (sum+d*base)%p;
    
    mp[sum]++;
    
    base = (base*10)%p;
    
  }
  
  mp[0]++;
  
  for(auto ne : mp ){ 
    
    int val = ne.second;
    
   
    
    ans += (val*(val-1))/2;
    
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1028
#include <vector>

class UnionFind {
private:
  std::vector<int> info;
  int num_of_groups;

public:
  UnionFind(int n) {
    info.assign(n, -1);
    num_of_groups = n;
  }

  int find_root(int x) {
    return info[x] < 0 ? x : info[x] = find_root(info[x]);
  }

  void unite(int x, int y) {
    int rx = find_root(x);
    int ry = find_root(y);
    if (rx == ry)
      return;
    if (info[rx] > info[ry])
      std::swap(rx, ry);
    info[rx] += info[ry];
    info[ry] = rx;
    num_of_groups--;
  }

  bool is_same_group(int x, int y) { return find_root(x) == find_root(y); }

  int get_group_size(int x) { return -info[find_root(x)]; }

  int get_num_of_groups() { return num_of_groups; }
};

#include <iostream>
using namespace std;

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  auto uf = UnionFind(n);
  vector<int> blocking(n, 0);
  vector<int> direct_friend(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    direct_friend[a]++;
    direct_friend[b]++;
    uf.unite(a, b);
  }
  for (int i = 0; i < k; i++) {
    int c, d;
    cin >> c >> d;
    c--, d--;
    if (uf.is_same_group(c, d)) {
      blocking[c]++;
      blocking[d]++;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << uf.get_group_size(i) - 1 - blocking[i] - direct_friend[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2048
a,b,c=map(int,input().split())
f=a*7+b
z=c//f
d=c%f
e=d//a
j=d%a
if d!=0:
    if d<=7*a:
        if d%a==0:
            print(7*z+e)
        if d%a!=0:
            print(7*z+e+1)
    else:
        print(7*z+7)
else:
    print(7*z)


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int m, d;
    int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    while(cin >> m >> d, m + d) {
        REP(i,m-1) {
            d += months[i];
        }
        d -= 1;
        switch (d % 7) {
            case 0:
                cout << "Thursday" << endl;
                break;
                
            case 1:
                cout << "Friday" << endl;
                break;
                
            case 2:
                cout << "Saturday" << endl;
                break;
                
            case 3:
                cout << "Sunday" << endl;
                break;
                
            case 4:
                cout << "Monday" << endl;
                break;
                
            case 5:
                cout << "Tuesday" << endl;
                break;
                
            case 6:
                cout << "Wednesday" << endl;
                break;
                
            default:
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#ABC045.A
s1 = input()
s2 = input()
s3 = input()

turn = s1[0]
s1 = s1[1:]

while True:
    if turn =='a':
        if not s1:
            winner = 'A'
            break
        else:
            turn = s1[0]
            s1 = s1[1:]
    elif turn =='b':
        if not s2:
            winner ='B'
            break
        else:
            turn = s2[0]
            s2 =s2[1:]
    elif turn =='c':
        if not s3:
            winner ='C'
            break
        else:
            turn =s3[0]
            s3 = s3[1:]
print(winner)

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

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

    ll n,x;
    cin >> n >> x;

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

    if(sum < x){
        cout << n - 1 << endl;
        return 0;
    } else {
        ll ans = 0;
        sort(a.begin(),a.end());
        for(int i = 0; i < n; i++){
            if(x >= a[i]){
                x -= a[i];
                ans++;
            } else {
                break;
            }
        }
        cout << ans << endl;
    }

}

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

int main(){
    int N;
    int n;
    string str;
    cin>>N;
    n=N%10;
    if (n==3){
        cout<<"bon"<<endl;
    }else if (n==0||n==1||n==6||n==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long[] x = new long[n];
		for (int i = 0; i < n; i++) {
			long a = in.nextInt();
			long b = in.nextInt();
			x[i] = 1000000001 * b + a;
		}
		System.out.println(solve(n, x));
		in.close();
	}

	private static String solve(int n, long[] x) {
		Arrays.sort(x);
		long r = 0;
		for (int i = 0; i < n; i++) {
			r += x[i] % 1000000001;
			if (r > x[i] / 1000000001)
				return "No";
		}
		return "Yes";
	}
}


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

int main() {
  int n;
  while(cin >> n && n!=0) {
    int a=n, b=0,c=0;
    while(a>=2) {
      b+=a/2;
      a/=2;
    }
    a=n;
    while(a>=5) {
      c+=a/5;
      a/=5;
    }
    cout << min(c,b) << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
//
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N;
    cin >> N;
    vector<ll> L(N);
    REP(i, N) cin >> L[i];
    sort(L.begin(), L.end(), greater<ll>());
    ll ans = 0;
    for (int i = 0; i < N - 2; ++i)
    {
        ll c = L[i];
        for (int j = i + 1; j < N - 1; ++j)
        {
            ll b = L[j];
            if (c == b) continue;
            for (int k = j + 1; k < N; ++k)
            {
                ll a = L[k];
                if (b == a || a == c) continue;
                if (a + b > c)
                {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3540
h,w = map(int, input().split())
S = [["." for i in range(w+2)]]
S += [["."] + list(input()) + ["."] for i in range(h)]
S += [["." for i in range(w+2)]]
ans = False
for i in range(1,h+1): #i = 1,2,..,hについて処理
    for j in range(1,w+1): #j = 1,2,...,wについて処理
        if S[i][j] == "#":
            if S[i-1][j] == ("#" or "a") or S[i+1][j] == ("#" or "a") or S[i][j-1] == ("#" or "a") or S[i][j+1] == ("#" or "a"):
                S[i][j] == "a"
            else:
                break
    else:
        continue
    #print(S)
    print("No")
    break
else:
    print("Yes")



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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll count = 0;
    set<ll> s;
    ll N;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll a;
        cin >> a;
        if(s.find(a) == s.end()) {
            s.insert(a);
            count++;
        } else {
            s.erase(a);
            count--;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4864
# 175 C
X, K, D = list(map(int, input().split()))
div = abs(X)//D
mod = abs(X)%D
if abs(X) > K*D:
    print(abs(X) - K*D)
elif (K-div)%2 == 0:
    print(mod)
else:
    print(D-mod)

Measured memory_bytes: 9096
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long int ll;
using namespace std;

int main(){
	string s; cin >>s;
	bool ok=false;
	if(s[0]==s[1]&&s[2]==s[3]&&s[2]!=s[1])ok=true;
	if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])ok=true;
	if(s[0]==s[3]&&s[2]==s[1]&&s[0]!=s[1])ok=true;
	cout << (ok?"Yes":"No") << endl;
}


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

max_dis=A[0] + K - A[-1]
for i in range(N-1):
    dis = A[i+1] - A[i]
    if max_dis < dis:
        max_dis = dis
        
print(K-max_dis)

Measured memory_bytes: 26444
N, K = map(int, input().split())
D = list(map(int, input().split()))

i = N
while True:
  flg = True
  for j in str(i):
    if int(j) in D:
      flg = False
      break

  if flg == True:
    print(i)
    exit()

  i += 1

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll funct(int n)
{
    ll val = 0;
    for(int i = 1; i*i < n; ++i)
    {
        if(n % i == 0) val++;
    }
    if((int)sqrt(n) * sqrt(n) == n) return 2*val + 1;
    return 2*val;
}
int main()
{
    ios_base ::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    //ll mul, sum;
    ll lans = 0;
    for(int i = 1; i<n; ++i)
    {
        lans += funct(i);
    }
    ll sum = 0;
    cout << lans + sum << '\n';
    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, W;
ll w[105], v[105];
ll DP[105][int(1e5+5)];

int main(){
  cin >> N >> W;
  for (int i = 1; i <= N; i++){
    cin >> w[i] >> v[i];
  }

  fill((ll*)DP, (ll*)(DP + N + 1), 1e18);
  DP[0][0] = 0;

  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= int(1e5); j++){
      DP[i][j] = DP[i-1][j];
    }
    for (int j = 0; j + v[i] <= int(1e5); j++){
      DP[i][j+v[i]] = min(DP[i][j+v[i]], DP[i-1][j] + w[i]);
    }
  }

  for (int j = 1e5; j >= 0; j--){
    if (DP[N][j] <= W){
      cout << j << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 82456
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0

A.sort()
C.sort()


for b in B:
  a = bisect.bisect_left(A, b)
  c = N - bisect.bisect_right(C, b)
  ans += a * c
  
print(ans)

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    vector<int> b(n);
    for(int i = 0; i < n; i++)
        b[a[i]] = i;
    for(int i = 0; i < n; i++)
        cout << b[i] + 1 << " ";
    return 0;
}

Measured memory_bytes: 3948
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAX = 100005;
const int NIL = -1;


struct Node {
	int parent, left, right;
};
Node Tree[MAX];
int n, Depth[MAX], Height[MAX];

int getDegree(int u) {
	int deg = 0;
	if (Tree[u].left != NIL)
		deg++;
	if (Tree[u].right != NIL)
		deg++;
	return deg;
}
void setDepth(int u, int depth) {
	if (u == NIL)
		return;
	Depth[u] = depth;
	setDepth(Tree[u].left, depth + 1);
	setDepth(Tree[u].right, depth + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (Tree[u].left != NIL)
		h1 = setHeight(Tree[u].left) + 1;
	if (Tree[u].right != NIL)
		h2 = setHeight(Tree[u].right) + 1;
	return Height[u] = max(h1, h2);
}

int getSibling(int u) {
	if (Tree[u].parent == NIL)
		return NIL;
	//?????¨?????????
	if (Tree[Tree[u].parent].left != u && Tree[Tree[u].parent].left != NIL)
		return Tree[Tree[u].parent].left;
	//?????¨?????????
	if (Tree[Tree[u].parent].right != u && Tree[Tree[u].parent].right != NIL)
		return Tree[Tree[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
		, u, Tree[u].parent, getSibling(u), getDegree(u), Depth[u], Height[u]);

	if (Tree[u].parent == NIL)
		printf("root\n");
	else if (Tree[u].left != NIL || Tree[u].right != NIL)
		printf("internal node\n");
	else
		printf("leaf\n");
}

int main() {
	int n;
	int u, l, r, root;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		Tree[i].parent = Tree[i].left = Tree[i].right = NIL;
	}
	
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &u, &l, &r);
		Tree[u].left = l;
		Tree[u].right = r;
		Tree[l].parent = u;
		Tree[r].parent = u;
	}
	for (int i = 0; i < n; i++) {
		if (Tree[i].parent == NIL)
			root = i;
	}
	setHeight(root);
	setDepth(root, 0);
	for (int i = 0; i < n; i++)
		print(i);
	return 0;
}

Measured memory_bytes: 3232
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    sc.close();

    int[] dp = new int[100001];
    
    dp[0] = 0;

    for (int i = 1; i <= 100000; i++) {

      dp[i] = i;

      int cost = 1;

      while (cost <= i && 6 <= i) {
        dp[i] = Math.min(dp[i],dp[i-cost]+1);
        cost *= 6;
      }

      cost = 1;

      while (cost <= i && 9 <= i) {
        dp[i] = Math.min(dp[i],dp[i-cost]+1);
        cost *= 9;
      }

    }

    System.out.println(dp[N]);

  }

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
int main(){
	int n,x,t=0,maxi=0,last=2000000000;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x>last){
			t=1;
		}else t++;
		last=x;
		maxi=max(maxi,t);
	}
	cout<<maxi-1;
	return 0;
}

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

int main() {
    int a, b;
    char op;
    while (cin >> a >> op >> b) {
        switch (op) {
            case '+': cout << a + b << endl; break;
            case '-': cout << a - b << endl; break;
            case '*': cout << a * b << endl; break;
            case '/': cout << a / b << endl; break;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
const int N=310;
bool vis[N];
int a[N][N],num[N];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int ans=n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=m;k++) if(!vis[a[j][k]]) {
				++num[a[j][k]]; 
				break;
			}
		}
		int ans2=1;
		for(int j=1;j<=m;j++) if(num[j]>num[ans2]) ans2=j;
		ans=min(num[ans2],ans),vis[ans2]=1;
		memset(num,0,sizeof(int)*(m+1));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		String s = sc.next();

		int[]x = new int[n];

		for (int i=0; i<n; i++){
			x[i] = s.charAt(i) - '0';
		}

		int pc =0;
		for (int i=0; i<n; i++){
			if (x[i] == 1){
				pc++;
			}
		}

		int[] ans = new int[n];
		int[] f = new int[n];
		for (int i=0; i<2; i++){


			int npc;
			if (i == 0) {
				npc = pc +1;
			} else {
				npc = pc -1;
			}
			if (npc <= 0){
				continue;
			}
			int r0=0;
			for (int k=0; k<n; k++){
				r0 = (r0*2) % npc;
				r0 += x[k];
			}
			int l = 1;
			for (int j=n-1; j>=0 ; j--){
				if (x[j] == i){
					int r = r0;
					if (i == 0) {
						r = (r + l) % npc;
					} else {
						r = (r - l + npc) % npc;
					}
					ans[j] = f(r) + 1;
				}
				l = (l*2) % npc;
			}
		}
		for (int i=0; i<n; i++){
			System.out.println(ans[i]);
		}
	}

	public static int f(int n){

		if (n == 0){
			return 0;
		}
		return f(n % pcnt(n)) + 1;

	}

	public static int pcnt(int n){
		String b = Integer.toBinaryString(n);
		int ret = 0;
		for (int i=0; i<b.length(); i++){
			if (b.charAt(i) == '1'){
				ret ++;
			}
		}
		return ret;
	}

}


Measured memory_bytes: 59240
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

pair <int, int> fac_25 (long long x) {
    pair <int, int> ans = make_pair(0, 0);
    while (x % 2 == 0) {
        x /= 2;
        ++ ans.first;
    }

    while (x % 5 == 0) {
        x /= 5;
        ++ ans.second;
    }

    return ans;
}

long long to_long_long (string x) {
    long long s = 0;
    assert(!x.empty());
    for (int i = 0 ; i < int(x.size()); ++ i) {
        s *= 10;
        s += x[i] - '0';
    }
    return s;
}

pair <int, int> read_double () {
    string s;
    cin >> s;
    int pos = -1;
    int n = int(s.size());

    for (int i = 0 ; i < n ; ++ i) {
        if (s[i] == '.') pos = i;
    }

    if (pos == -1) return fac_25(to_long_long(s));

    string integer, decimal;

    for (int i = 0 ; i < pos ; ++ i)
        integer += s[i];

    for (int i = pos + 1 ; i < n ; ++ i)
        decimal += s[i];

    long long get_int = to_long_long(integer);
    long long get_deci = to_long_long(decimal);

    int p10 = int(decimal.size());
    long long f10 = 1;
    for (int i = 0 ; i < p10 ; ++ i)
        f10 *= 10LL;
    long long up = f10 * get_int + get_deci;
    long long down = f10;
    long long fgcd = __gcd(up, down);
    pair <int, int> a = fac_25(up);
    pair <int, int> b = fac_25(down);
    a.first -= b.first;
    a.second -= b.second;
    return a;

}

int n;
pair <int, int> a[nax];
int mp[2048];
const int C = 100;

int main () {
    cin.tie(0)->sync_with_stdio(false);
    cin >> n;

    for (int i = 1 ; i <= n ; ++ i) {
        a[i] = read_double();
    }


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


    long long ans = 0;

    int r = n;

    for (int i = 1 ; i <= n ; ++ i) {
        while (r > i && a[r].first + a[i].first >= 0) {
            ++ mp[a[r].second + C];
            -- r;
        }

        while (r + 1 <= i) {
            -- mp[a[r + 1].second + C];
            ++ r;
        }


        int lowest = -a[i].second + C;

        for (int j = lowest ; j <= 200 ; ++ j)
            ans += mp[j], assert(mp[j] >= 0);
    }


    cout << ans << '\n';
}


Measured memory_bytes: 5100
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;

int main(){
    int len_array,num_query;
    int b,e;
    scanf("%d",&len_array);
    vector<int> int_array(len_array,0);
    
    for(int i = 0;i < len_array;i++){
        cin >> int_array[i];
    }
    scanf("%d",&num_query);
    
    for(int i = 0;i < num_query;i++){
        scanf("%d %d",&b,&e);
        reverse(int_array.begin()+b,int_array.begin()+e);
    }
    
    for(int i = 0; i < len_array;i++){
        cout << int_array[i];
        if(i!=len_array-1)cout << " ";
        else cout << "\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;

int main(void) {
	int n, m;
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
	return 0;
}

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

const int MAXN = 100000;
int n , j , a[ MAXN + 5 ];

bool cmp( const int &x , const int &y ) {
	return x > y;
}

int main( ) {
	scanf("%d",&n);
	for( int i = 1 ; i <= n ; i ++ )
		scanf("%d",&a[ i ]);
	sort( a + 1 , a + n + 1 , cmp );
	
	for( int i = 1 ; i <= n ; i ++ )
		if( i + 1 > a[ i + 1 ] ) {
			for( j = 0 ; a[ j + i + 1 ] == i ; j ++ );
			puts( ( ( a[ i ] - i ) & 1 || ( j & 1 ) ) ? "First" : "Second" );
			break;
		}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define N 10010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)  for(int i = n - 1; i >= 0; --i)
#define forr1(i, n) for(int i = n; i >= 1; --i)
#define form(l, r, i)   for(int i = l; i <= r; ++i)
#define forv(r, l, i)   for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
  
const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 9;
  
using namespace std;

queue<ll> q;

int main()
{
    barnarnar
    ll k;
    cin >> k;
    forn1(i, 9)	q.push(i);
    ll a = 0;
    ll pos = 0;
    while(!q.empty() && pos < k)
    {
        a = q.front();
        q.pop();
        pos++;
        ll b = 10 * a + a % 10;
        if(a % 10 != 0)	q.push(b - 1);
        q.push(b);
        if(a % 10 != 9)	q.push(b + 1);
    }
    cout << a;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
def f():
    for i in range(n):
        if a[i] % 2 == 0:
            if a[i] % 3 != 0 and a[i] % 5 != 0:
                return "DENIED"
    return "APPROVED"
print(f())

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

int K, S;
int X, Y, Z;

int main(){
    cin >> K >> S;
    int ans=0;
    for(X = 0; X <= K; X++){
        for(Y = 0; Y <= K; Y++){
            Z = S-X-Y;
            if(Z <= K && Z >= 0 && X+Y+Z == S) ans++;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;
const int lim = 100001;
int a[lim]={};
void solve(){
    int n;cin>>n;
    int ans =0;
    int k;
    fol(i,n){
        cin>>k;
        if (k>=lim)ans++;
        else{
            if (k==a[k]) ans++;
            else a[k]++;
        }
    }
    fol(i,lim){
        if (i!=a[i]){
            ans += a[i];
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, A = 0, B = 0;
  cin >> n;
  vector<int> a(n);
  rep(i,n)
    cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  rep(i,n)
    if (i % 2) {
      B += a[i];
    } else {
      A += a[i];
    }
  cout << A - B;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define int long long int
#define FILEIO  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
#define maxn 1000000
 

using namespace std;

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

signed main() {
//FILEIO;
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int n;
cin>>n;
int arr[n];
int su = 0;
for (int i = 0; i < n; ++i)
{
	/* code */
	cin>>arr[i];
	su = su^arr[i];
}
//vector<int>ans(n);
for (int i = 0; i < n; ++i)
{
	/* code */
	cout<<(su^arr[i])<<" ";
}











    return 0;
}


Measured memory_bytes: 5168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#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 eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; string S;
    cin >> N >> S;
    int cnt=0;
    rep(s,10){
        rep(t,10){
            rep(u,10){
                bool frag1=false,frag2=false,frag3=false;
                rep(i,N){
                    if(S[i]==(char)('0'+u) && frag2){
                        frag3=true;
                    }
                    if(S[i]==(char)('0'+t) && frag1){
                        frag2=true;
                    }
                    if(S[i]==(char)('0'+s)){
                        frag1=true;
                    }
                }  
                if(frag3) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384