akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 2e5 + 5;

int n, q, ans, idx, cg, l;
int a[N], freq[N], cov[N];

void work() {
    cin >> idx >> cg;
    l = a[idx] - freq[a[idx]] + 1;
    if(l > 0) {
        cov[l]--;
        if(!cov[l]) ans++;
    }
    freq[a[idx]]--;
    l = cg - freq[cg];
    if(l > 0) {
        cov[l]++;
        if(cov[l] == 1) ans--;
    }
    a[idx] = cg;
    freq[cg]++;
    cout << ans << "\n";
}

void solve() {
    cin >> n >> q;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        freq[a[i]]++;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = max(0, i - freq[i] + 1); j <= i; j++) {
            cov[j]++;
        }
    }
    ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!cov[i]) ans++;
    }
    while(q--) {
        work();
    }
}

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

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

int main(){
    int height[10];
    int i;
    for( i = 0; i < 10; i++){
        cin >> height[i];
    }
    for( i = 0; i < 10; i++){
        sort(height, height + 10);
    }
    for( i = 9; i > 6; i--){
        cout << height[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll d;
    cin>>n>>d;
    int ats=0;
    for (int i=0;i<n;i++) {
		ll a,b;
		cin>>a>>b;
		if (a*a+b*b<=d*d) {ats++;}
		}
	cout<<ats<<endl;
    return 0;
}


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

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

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

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N; cin >> N;
	VLL H(N+1);
	ll x,y;
	bool ok = true;
	bool add = false;
	for (int i = 0;i < N;i++) cin >> H[i];
	H[N] = 1e9 + 7;
	for (int i = 0;i < N;i++) {
		if (H[i] < H[i + 1]) {
			H[i + 1]--;
			continue;
		}
		else if (H[i]  == H[i + 1]) {
			continue;
		}
		else {
			ok = false;
			break;
		}
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1024
# # 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

N, X = MAP()
m = sorted([INT() for i in range(N)])
X = X - sum(m)

ans = N
ans += (X // m[0])

print(ans)


Measured memory_bytes: 27056
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N;
    cin >> K;
    int sum = 1;
    for(int i = 0;i < N;i++){
        if(sum * 2 < sum + K){
            sum *= 2;
        }
        else{
            sum += K;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, m, x = map(int, input().split())
book = []
for _ in range(n):
    info = [int(item) for item in input().split()]
    book.append(info)

ans = 10**10
for i in range(2**n):
    understanding = [0] * m
    cost = 0
    for j in range(n):
        if i & 1 << j:
            cost += book[j][0]
            for k in range(1, m+1):
                understanding[k-1] += book[j][k]
    ok = True
    for und in understanding:
        if und < x: 
            ok = False
            break
    if ok:
        ans = min(ans, cost)

if ans == 10**10:
    print(-1)
else:
    print(ans)

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

int main(void)
{
    int x, y, a, b;
    cin >> x >> y;
    a = (4 * x - y) / 2;
    b = (y - 2 * x) / 2;

    if (y % 2 == 0 && 4 * x - y >= 0 && y - 2 * x >= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    long long n, k, q;
    cin >> n >> k >> q;
    long long a[q];
    for (int i = 0; i < q; ++i) {
        cin >> a[i];
    }

    std::vector<long long> v(n, k-q);
    for (int i = 0; i < q; ++i) {
        v[a[i]-1]++;
    }

    for (int i = 0; i < n; ++i) {
        if ( v[i] > 0 ) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2176
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import collections
def resolve():
    N,P,Q=pin()#
    P-=1
    Q-=1#0-index
    ans=[0]*N
    
    
    for i in range(N):
        seen=[0]*N #BFS so 
        d=collections.deque()
        d.append((i,0))
        for j in range(1,N*10):
            if len(d)==0:break
            a,b=d.popleft()
            if a<0 or a>=N or seen[a]:
                continue
            seen[a]=1
            ans[b]+=1
            d.append((a+1,b+1))
            d.append((a-1,b+1))
            if a==P:
                d.append((Q,b+1))
            if a==Q:
                d.append((P,b+1))
    for n,a in enumerate(ans):
        if n!=0:print(a//2)
        
                
            
#%%submit!
resolve()

Measured memory_bytes: 48220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] a=cin.ArrayInt(2,0);
        if(a[0]<10&&a[1]<10)Console.WriteLine(a[0]*a[1]);
        else Console.WriteLine(-1);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <utility>
#include <set>
#include <bitset>
#define ls x<<1
#define rs x<<1|1
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(x) scanf("%d", &x)
#define scdd(x,y) scanf("%d%d", &x, &y)
#define scddd(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define eb emplace_back
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppp;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 2*acos(0.0);
const double eps = 1e-13;
const ll mod = 1e9+7;
const int maxn = 2e5 + 10;
const int maxm = 50000 + 10;

void solve() {
    string s;
    int k;
    cin>>s>>k;
    int n = s.length();
    if(n==1){
        printf("%d\n", k/2);
        return;
    }
    int i=0, j=n-1;
    while(s[i+1]==s[0]) i++;
    while(s[j-1]==s[n-1]) j--;
    if(j<i){
        ll ans = (1LL*n*k)/2LL;
        printf("%lld\n", ans);
        return;
    }
    ll ans=0;
    if(s[0]==s[n-1]){
        ans += (i+1)/2;
        ans += (n-j)/2;
        ans += 1LL*(i+1+n-j)/2*(k-1);
    }
    else{
        ans += 1LL*k*((i+1)/2);
        ans += 1LL*k*((n-j)/2);
    }
    int cnt=1;
    for(int o=i+1; o<j; o++){
        if(s[o]==s[o-1]) cnt++;
        else{
            ans += 1LL*k*(cnt/2);
            cnt = 1;
        }
    } ans += 1LL*k*(cnt/2);
    printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("ans.txt","w",stdout);
#endif
    //IOS;
    solve();

    return 0;
}


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

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



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
int flag=0;
map<int,int> D;
scanf("%d",&n);
for(int i=0;i<n;++i){
int temp;
scanf("%d",&temp);
if(D.find(temp)==D.end()) D[temp]=1;
else D[temp]++;
}
scanf("%d",&m);
for(int i=0;i<m;++i){
int temp;
scanf("%d",&temp);
if(D.find(temp)!=D.end()&&D[temp]>0){
D[temp]--;
}else flag++;
}
printf("%s\n",flag?"NO":"YES");
return 0;
}

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

using namespace std;

#define int long long

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int ans = 0;
	int f = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] <= f) {
			f = max(f, a[i] + 1);
		} else {
			ans += (a[i] - 1) / f;
			if (i == 0) f = 2;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))
money = 1000
stock = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        stock = stock + money // a[i]
        money = money % a[i] + stock * a[i + 1]
        stock = 0
    else:
        money = money + stock * a[i]
        stock = money // a[i + 1]
        money = money % a[i + 1]
        
ans = money + stock * a[n-1]
print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000005;
char a[maxn],b[maxn];
int q[maxn],head,tail;
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s%s",a+1,b+1);
    if(strcmp(a+1,b+1)==0)
    {
        puts("0");
        return 0;
    }
    int ans=0;
    head=tail=maxn-2;
    //q[tail++]=n+1;
    int last=n;
    int tag=0;
    for(int l=n,r;l;l--)
    {
        r=l;
        while(b[l]==b[l-1]) l--;
        while(last){
            if(last>l||a[last]!=b[l]) last--;
            else break;
        }
        //printf("%d %d %d\n",l,r,last);
        if(last==0){
            puts("-1");return 0;
        }
        while(head<tail){
            if(q[tail-1]-tag>r) tail--;
            else break;
        }
        if(head==tail){
            tag=0;
            q[--head]=last;
        }
        else{
            tag++;
            q[--head]=last+tag;
        }
        //printf("%d %d %d\n",l,head,tail);
        ans=max(tail-head,ans);
    }
    printf("%d\n",ans);
    return 0;
}


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

typedef pair<int, int> P;

queue<P> que;
int H, W;
char maze[1000][1000];
int r[1000][1000];

int bfs() {

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(maze[i][j] == '#') {
        que.push(P(i, j));
        r[i][j] = 0;
      }
    }
  }


    while(que.size()) {
      P p = que.front();
      que.pop();
      int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
      for(int i = 0; i < 4; i++) {
        int nx = p.first + dx[i];
        int ny = p.second + dy[i];
        if(0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] == '.') {
          que.push(P(nx, ny));
          maze[nx][ny] = '#';
          r[nx][ny] = r[p.first][p.second] + 1;
        }
      }

    }

  int ans = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      ans = max(ans, r[i][j]);
      }
    }
  return ans;

}



int main() {
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> maze[i][j];
    }
  }

  int res = bfs();
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 13328
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
xl=
  n.times.map do
    i=gsmi
    st=i[0]-i[1]
    en=i[0]+i[1]
    [st,en]
  end.sort{|x,y| x[1]<=>y[1]}

pos=-10**9

n.times do |i|
  tar=xl[i]
  if tar[0]>=pos
    cnt+=1
    pos=tar[1]
  end
end

puts cnt

Measured memory_bytes: 13176
#include <stdio.h>
#include <string.h>
char m[] = { 'X','Y','Z','A','B','C','D','E','F','G','H','I','J',
	     'K','L','M','N','O','P','Q','R','S','T','U','V','W'};
int main()
{
  char str[1002];
  int i;
  scanf("%s",str);
  for(i=0;i<strlen(str);i++){
    printf("%c",m[str[i]-'A']);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 0
N=gets.to_i
C=gets.chars
wht=*red=Array.new(N+1){0}
N.times do |i|
  wht[i+1]+=wht[i]
  wht[i+1]+=1 if C[i]==?W
  j=N-i
  red[j-1]+=red[j]
  red[j-1]+=1 if C[j-1]==?R
end
p wht.zip(red).map{|w,r|w+r-[w,r].min}.min

Measured memory_bytes: 39544
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, m, s[100001];

int main() {
	cin >> n >> m;
	inc(i, m) {
		int l, r;
		cin >> l >> r;
		l--;
		s[l]++;
		s[r]--;
	}
	
	inc(i, n) { s[i + 1] += s[i]; }
	
	int ans = 0;
	inc(i, n) { if(s[i] == m) { ans++; } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
char s[maxn+10];
char t[maxn+10];
int n,m;
int main()
{
    while(cin>>n>>m)
    {
        scanf("%s",s+1);
        scanf("%s",t+1);
        ll lcm=1ll*n*m/__gcd(n,m);
        ll nn=lcm/n;
        ll mm=lcm/m;
        ll sum=1;
        bool flag=true;
        for(int i=1;;i++)
        {
            if((sum-1)/nn+1>n || (sum-1)/mm+1>m)
                break;
            if(s[(sum-1)/nn+1] != t[(sum-1)/mm+1])
            {
                flag=false;
                break;
            }
            sum+=nn*mm;
        }
        if(!flag)
            puts("-1");
        else
            printf("%lld\n",lcm);
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
bool manzu(int num){
	int div=2;
	if(num%2==0)return false;
	for(int i=2;i<num;i++){
		if(num%i==0)div++;
	}
	if(div==8)return true;
	return false;
}
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=3;i<=n;i+=2){
		if(manzu(i))ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(void)
{
    int N, M;
    map<string, int> m;

    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        string si;
        cin >> si;
        auto p = m.insert(make_pair(si, 1));
        if(!p.second)
        {
            p.first->second++;
        }
    }
    cin >> M;
    for(int i = 0; i < M; ++i)
    {
        string ti;
        cin >> ti;
        auto p = m.insert(make_pair(ti, -1));
        if(!p.second)
        {
            p.first->second--;
        }
    }

    int X = -100;
    for(const auto& e : m)
    {
        if(X < e.second)
            X = e.second;
    }

    cout << (X >= 0 ? X : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] a = new int[10000001];
		//boolean[] done = new boolean[10000001];
		long result = 0;
		//Arrays.fill(a, 1);
		for(int i = 1; i <= N; i++) {
			//if(done[i])continue;
			int tmp = i;
			while(tmp <= N) {
				//System.out.println(tmp);
				a[tmp]++;
				//done[tmp] = true;
				tmp += i;				
			}
		}
		for(int i = 1; i <= N; i++) {			
			result += (long)i * a[i];
		}
		System.out.println(result);
			
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 65216
#include <cstdlib>
#include <iostream>
#include <stack>
#include <string>

typedef std::stack<std::string> TStack;
TStack GetInputStrings(std::istream& Input)
{
    TStack Stack;
    std::string s;
    while(std::getline(Input, s, ' ')){
        Stack.push(s);
    }
    return Stack;
}
int Rpn(TStack& Stack)
{
    std::string s = Stack.top(); Stack.pop();
    switch(s[0]){
       case '+':{
            int a = Rpn(Stack);
            int b = Rpn(Stack);
            return b + a;
        }
        case '-':{
            int a = Rpn(Stack);
            int b = Rpn(Stack);
            return b - a;
        }
        case '*':{
            int a = Rpn(Stack);
            int b = Rpn(Stack);
            return b * a;
        }
        default:{
            return std::atoi(s.c_str());
        }
    }
}
int main()
{
    TStack Stack = GetInputStrings(std::cin);
    std::cout << Rpn(Stack) << std::endl;
    return 0;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 1e6 + 7;
int n, sumtop;

struct T {
  int top;
  int mn;
};

bool operator < (T a, T b) {
  return min(a.mn, a.top + b.mn) > min(b.mn, b.top + a.mn);
}

T a[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    int top = 0, mn = 0;
    for (auto &ch : s) {
      if (ch == '(') {
        top++;
      } else {
        top--;
      }
      mn = min(mn, top);
    }
    a[i] = {top, mn};
    sumtop += top;
  }
  if (sumtop != 0) {
    cout << "No\n";
    return 0;
  }
  sort(a + 1, a + n + 1);
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    if (cur + a[i].mn < 0) {
      cout << "No\n";
      return 0;
    }
    cur += a[i].top;
  }
  cout << "Yes\n";
  return 0;
}


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

void function(int a) {
	if (a == 0) {
		cout << 0;
		return;
	}
	if (a == 1) {
		cout << a;
		return;
	}
	if (a == -1) {
		cout << 11;
		return;
	}
	if (a % (-2) == -1) {
		function(a / (-2) + 1);
		cout << 1;
	}
	else {
		function(a / (-2));
		cout << a % 2;
	}
}

int main(void) {
	int a;
	cin >> a;
	function(a);
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, n, tmp, sum;

  while (1) {
    int data[100];
    int max=0, min=0;
    int sum = 0;

    scanf("%d", &n);
    if(n == 0) break;

    for(i=0; i < n; i++) {
      scanf("%d", &data[i]);
      if (i==0) {
        min = data[i];
        max = 0;
      }
      if (data[i] > max) {
        max = data[i];
      }
      if (data[i] < min) {
        min = data[i];
      }
    }

    for(i=0; i < n; i++) {
      sum += data[i];
    }
    sum -= min+max;
    n -= 2;
    printf("%d\n", (int)sum/n);
  }

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
char lst[Max][Max];
int ls[Max][Max];

int main()
{
	ll x,y,z;
	cin >> x >> y >> z;
	cout << (x - z) / (z + y);

}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{

	int ans = 0;
	unsigned long long int x, y;
	unsigned long long int s;
	cin >> x >> y;
	s = x;
	while (y>=s) {
		s *= 2;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int d,g,m;
  m=pow(10,5);
  cin >> d >> g;
  vector<pair<int,int>> v;
  int a,b;
  for(int i=0;i<d;i++){
      cin >> a >> b;
      pair<int,int> p(a,b);
      v.push_back(p);
  }
  for(int i=0; i<(1<<d); i++){
    bitset<10> bit(i);
    bitset<10> check(0);
    int ans,item;
    ans=0;
    item=0;
    for(int j=0; j<d; j++){
      if(bit[j]==1){
        ans+=100*(j+1)*v.at(j).first+v.at(j).second;
        check.set(j,1);
        item+=v.at(j).first;
      }
    }
    int stop = d-1;
    while(true){
      if(ans>=g || stop<0){
        break;
      }
      if(check[stop]==0){
        check.set(stop,1);
        if(ans+100*(stop+1)*(v.at(stop).first-1)>g){
          item+=ceil(1.0*(g-ans)/(100*(stop+1)));
          ans = g;
          break;
        }
        else{
          ans += 100*(stop+1)*(v.at(stop).first-1);
          item+=v.at(stop).first-1;
        }
      }
      stop--;
    }
    if(m>item && ans >= g){
      m=item;
    }
  }
  cout << m << endl;  
}



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

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	char a[100][100];
	vector<bool> row(H, false);
	vector<bool> col(W, false);
	
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}

	}

	for (int i = 0; i < H; i++) {
		if (row[i]) {
			for (int j = 0; j < W; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
int main() {
    string S,T;
    cin >> S >> T;
    ll ma_x = 0;
    if(S.size() == T.size()){
        ll x = 0;
        REP(i, S.size()){
            if(S[i] == T[i]){
                x += 1;
            }
        }
        cout << T.size() - x << endl;
    } else {
        REP(i, S.size() - T.size()){
                ll x = 0;
                FOR(j,0, T.size()){
                    if(S[i+j] == T[j]){
                        x += 1;
                    }
                }
                ma_x = max(x,ma_x);
            }
        cout << T.size() - ma_x << endl;
    }
    
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n, num;
    cin >> n;
    string t;
    vector<vector<ll>> T(4, vector<ll>(13, 0));
    repi(i, n, 0)
    {
        cin >> t >> num;
        if (t == "S")
        {
            T.at(0).at(num - 1) = 1;
        }
        else if (t == "H")
        {
            T.at(1).at(num - 1) = 1;
        }
        else if (t == "C")
        {
            T.at(2).at(num - 1) = 1;
        }
        else if (t == "D")
        {
            T.at(3).at(num - 1) = 1;
        }
    }
    repi(i, 4, 0)
    {
        repi(j, 13, 0)
        {
            if (T.at(i).at(j) == 0)
            {
                if (i == 0)
                {
                    cout << "S " << j + 1 << endl;
                }
                else if (i == 1)
                {
                    cout << "H " << j + 1 << endl;
                }
                else if (i == 2)
                {
                    cout << "C " << j + 1 << endl;
                }
                else if (i == 3)
                {
                    cout << "D " << j + 1 << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3208
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a = -1;
    int b = -1;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == s[i + 1]) {
            a = i + 1;
            b = i + 2;
            break;
        }
        if (i < n - 2 && s[i] == s[i + 2]) {
            a = i + 1;
            b = i + 3;
            break;
        }
    }

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int x,y,z;
	scanf("%d %d",&x,&y);
	z=1;
	if(y%2!=0){
		z=0;
	}
	if(x*2>y||x*4<y){
		z=0;
	}
	if(z==1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
string s;
ll dp[100010][13];
int main(){
    cin>>s;
    dp[0][0]=1;
    for(int i=1;i<=s.size();i++){
        if(s[i-1]=='?'){
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++){
                    dp[i][j]+=dp[i-1][((j+13-k)%13)*4%13]%M;
                    dp[i][j]%=M;
                }
            }
        }else{
            for(int j=0;j<13;j++){
                dp[i][j]=dp[i-1][((j+13-(s[i-1]-'0'))%13)*4%13]%M;
            }
        }
    }
    cout<<dp[s.size()][5]<<endl;
    return 0;
}

Measured memory_bytes: 10624
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#define EPS (1e-7)
using namespace std;






int main() {

	string S;
	string ans="Good";

	cin >> S;
	

	for (auto i = 1; i < 4; i++)
	{
		if (S[i] == S[i - 1])ans = "Bad";
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, m, d[MAXN], dp[MAXN], ans;
vector<int> g[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> m;
    for(int i = 0; i < m; i++){
    	int a, b;
    	cin >> a >> b;
    	g[a].pb(b);
    	d[b]++;
    }
    queue<int> q;
    for(int i = 1; i <= n; i++){
    	if(d[i] == 0) q.push(i);
    }
    while(q.size()){
    	int x = q.front();
    	q.pop();
    	ans = max(ans, dp[x]);
    	for(auto i : g[x]){
    		dp[i] = max(dp[i], dp[x] + 1);
    		d[i]--;
    		if(d[i] == 0) q.push(i);
    	}
    }
    cout << ans;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string A, B;
    cin >> A >> B;
    if(A.length() > B.length()) {
        cout << "GREATER" << endl;
        return 0;
    } else if(A.length() < B.length()) {
        cout << "LESS" << endl;
        return 0;
    }
    REP(i, A.length()) {
        if(A[i] < B[i]) {
            cout << "LESS" << endl;
            return 0;
        } else if(A[i] > B[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define repr(i,a,b) for (int i = a; i > b; --i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
 
#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
//ll dp[200000];
 double dp[3001][3001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 	
	//freopen ("test.txt","r",stdin);
	//string a,b;
	//cin>>a>>b;
	int n;cin>>n;
	double p[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>p[i];
	}

	//double dp[n+1][n+1];
	dp[0][0] = 1 - p[0];
	dp[0][1] = p[0];

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

			if(j==0)
			{
				dp[i][j] = dp[i-1][j] * (1-p[i]);
			}
			dp[i][j] = dp[i-1][j] * (1- p[i])+
					   dp[i-1][j-1] * (p[i]);
		}
	}

	/*for (int i = 0; i < n; ++i)
	{
		for(int j = 0;j<=n;j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int t = n/2 + 1;
	double ans = 0;

	for (int i = n; i >= t ; i--)
	{
		ans += dp[n-1][i];
	}

	cout<<fixed<<setprecision(10)<<ans;



}

Measured memory_bytes: 70528
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int ans = s.length /2;
        for (int i = 0; i < s.length; i++) {
            if(s[i] == 'p') ans--;
        }

        System.out.println(ans);
        sc.close();
    }
}


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

int main() {
	int N, a, X[100002] = {};
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		X[a - 1]++;
		X[a]++;
		X[a + 1]++;
	}
	sort(X, X + 100002, greater<int>());
	cout << X[0];
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  str s; cin >> s;
  for(ll i = 0;i < s.size();i++)
  {
    if(i == a)
    {
      if(s[i] == '-')
      {
        continue;
      }
      fin("No") exit(0);
    }
    else
    {
      if(s[i] >= '0'&&s[i] <= '9')
      {
        continue;
      }
      fin("No") exit(0);
    }
  }
  fin("Yes")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

using namespace std;

string buildString(int a,int b){
	
	stringstream ss;
	stringstream ss2;
	
	ss << a; 
	
	ss2 << b;
	
	string as = ss.str();
	
	for(int i=as.size();i<6;i++){
		as = '0'+as;
	}
	
	string bs = ss2.str();
	
	for(int i=bs.size();i<6;i++){
		bs = '0'+bs;
	}
	
	return as+bs;
}


int main(){
	
	int n, m;
	
	int x , y ; 
	
	cin >> n >> m;
	
	vector<pair<pair<int,int>,int>> container; 
	
	for(int i=0;i<m;i++){
		
		cin >> x >> y;
		container.push_back(make_pair(make_pair(x,y),i));
	}
	
	sort(container.begin(),container.end());

	
	int lastIndex = -1;
	int cont = 1;
	
	vector<string> ans(100005);
	string s;
	for(int i=0;i<m;i++){
		
		if(lastIndex==-1){
			s = buildString(container[i].first.first,cont);
			ans[container[i].second] = s;
			lastIndex = container[i].first.first;
			continue;
		}
		
		if(lastIndex == container[i].first.first){
			cont++;
			s = buildString(container[i].first.first,cont);
			ans[container[i].second] = s;
			
		}else{
			cont = 1;
			s = buildString(container[i].first.first,cont);
			ans[container[i].second] = s;
			lastIndex = container[i].first.first;
		}
		
		
	}
	
	for(int i=0;i<m;i++){
		cout << ans[i] << endl;
	}
	
    return 0;
}


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

const int Maxm = 100005;

int n, m;
int p;
char tmp[Maxm];
vector <int> my[Maxm];

int main()
{
    scanf("%d %d", &n, &m);
    while (m--) {
        scanf("%d %s", &p, tmp);
        if (tmp[0] == 'A') my[p].push_back(1);
        else my[p].push_back(0);
    }
    int res = 0, pen = 0;
    for (int i = 1; i <= n; i++) {
        int pnt = 0;
        while (pnt < my[i].size() && my[i][pnt] == 0) pnt++;
        if (pnt < my[i].size()) { res++; pen += pnt; }
    }
    printf("%d %d\n", res, pen);
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<queue>

using namespace std;
int main(){
	while(1){
		int m,nmin,nmax; cin >> m >> nmin >> nmax;
		if (m + nmin + nmax == 0) break;
		int dis = 0;
		int max = 0;
		int maxi = 0;
		int pre_p = 0;
		for (int i = 1; i <= m; i++){
			int p1; cin >> p1;
			if (nmin < i and i <= nmax + 1){
				dis = pre_p - p1;
				if (max <= dis){
					max = dis;
					maxi = i;
				}		
			}
			pre_p = p1;
		}
		cout << maxi - 1 << endl;
	}
return 0;
}

Measured memory_bytes: 3008
import numpy as np

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

AB = [ list(map(int, input().split())) for _ in range(N) ]
AB = np.array(AB)
AB = AB[AB[:,0].argsort(), :]

m = 0
s = 0
for n in range(N):
    s += AB[n][0]*AB[n][1]
    m += AB[n][1]
    if m>=M:
        s -= AB[n][0]*(m-M)
        break
print(s)
        

        

Measured memory_bytes: 37900
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

int main(){
	int n;
	cin >> n;
	string s;
	rep(i, n){
		cin >> s;
		int h = (s[0]-'0') * 10 + s[1] - '0';
		int m = (s[3]-'0') * 10 + s[4] - '0';
		double angle1 = h * 30 + (double)m / 2;
		double angle2 = m * 6;
		double d = abs(angle1 - angle2);
		if(d > 180.0) d = 360.0 - d;
		if(d < 30.0) {
			cout << "alert" << endl;
		}else if(90.0 - EPS < d) cout << "safe" << endl;
		else cout << "warning" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
from time import time
from random import randint

from numba import njit
from numpy import int64

@njit('i8(i8[:], i8[:])')
def func(s, x):
    last = [0] * 26
    score = 0
    for i, v in enumerate(x, 1):
        last[v] = i
        c = 0
        for j in range(26):
            c += s[j] * (i - last[j])
        score += s[i * 26 + v] - c
    return score

def main():
    start = time()
    d, *s = map(int, open(0).read().split())
    s = int64(s)
    x = int64(([*range(26)] * 15)[:d])
    M = func(s, x)
    while time() - start < 1.35:
        y = x.copy()
        if randint(0, 1):
            y[randint(0, d - 1)] = randint(0, 25)
        elif randint(0, 1):
            i=randint(0, d - 16)
            j=randint(i + 1, i + 15)
            y[i], y[j] = y[j], y[i]
        else:
            i = randint(0, d - 15)
            j = randint(i + 1, i + 7)
            k = randint(j + 1, j + 7)
            if randint(0, 1):
                y[i], y[j], y[k] = y[j], y[k], y[i]
            else:
                y[i], y[j], y[k] = y[k], y[i], y[j]
        t = func(s, y)
        if t > M:
            M = t
            x = y
    print(*x + 1, sep='\n')

main()

Measured memory_bytes: 112492
import sys
import numpy as np
read = sys.stdin.read

N, C, *stc = map(int, read().split())
recoder = np.zeros((C + 1, 10 ** 5 + 1), np.int64)

for s, t, c in zip(*[iter(stc)] * 3):
    recoder[c, s - 1:t] = 1

answer = np.cumsum(recoder, axis=0).max()

print(answer)

Measured memory_bytes: 72472
///Bismillahir Rahmanir Rahim

#include<iostream>

using namespace std;
int main()
{
    int total_days,asgnum,days,i,dif;

    long long int total_need=0;

    cin>>total_days>>asgnum;

    for(i=0;i<asgnum;i++)
    {
        cin>>days;

        total_need +=days;
    }

    dif=total_days-total_need;

    if(dif>0)
    {
        cout<<dif;
    }
    else if(dif<0)
    {
        cout<<"-1";
    }
    else{
        cout<<"0";
    }

    return 0;
}


Measured memory_bytes: 3164
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = K
for i in range(N):
    start = A[i]
    end = K+A[i-1] if A[i-1] < A[i] else A[i-1]
    path = end-start
    ans = min(path, ans)

print(ans)

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

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

Measured memory_bytes: 256
#include<stdio.h>
int suzi[5];
int top=0;
void push(int x){
  top ++;
  suzi[top]=x;
}
int pop(){
  top--;
  return suzi[top+1];
}

int main(){
  char a[10];
  int c,b;
  while(scanf("%s",a)!=EOF){
    if(a[0]=='+')push(pop()+pop());
    else if(a[0]=='-'){
      c=pop();
      b=pop();
      push(b-c);}
    else if(a[0]=='*')push(pop()*pop());
    else push(atoi(a));
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2036