akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------


int main()
{
    Phuong_; /// <3
    set<string> s;
    int n;
    cin >> n;
    while (n--)
    {
        string u;
        cin >> u;
        s.insert(u);
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 19216
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for an in range(a + 1):
  for bn in range(b + 1):
    for cn in range(c + 1):
      total = an * 500 + bn * 100 + cn * 50
      if total == x:
        ans += 1
print(ans)


Measured memory_bytes: 67468
#include<bits/stdc++.h>
using namespace std;
int n,k,arr[100005],dp[100005];
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	for(int i=0;i<n;i++){
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=0&&i-j<=k;j--){
			dp[i]=min(dp[i],abs(arr[i]-arr[j])+dp[j]);
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  char str[4];
  int r = 0;
  for(;scanf("%s", str) != EOF;)
  {
    r = 0;
	for(int i = 0;i < 3;i++)
	{
		if(str[i] == 'R' && i == 0) r++;
		else
		{
			if(str[i] == 'R' && str[i-1] == 'R' && r > 0) r++;
			else if(str[i] == 'R') r = 1;
		}
	}
    printf("%d\n", r);
  }
  return 0;
}

Measured memory_bytes: 3740
/*input
1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int pt=1;
set<ll> st;

int main(){
	IOS;
	ll cur;
	cin>>cur;
	st.insert(cur);
	while(1){
		if(cur&1) cur=3*cur+1;
		else cur/=2;
		pt++;
		if(st.count(cur)){
			cout<<pt<<'\n';
			return 0;
		}
		st.insert(cur);
	}
	return 0;
}


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

int main(void){
 int a,n;
 vector<int>A;
 for(int i=0; i<3; i++){
  cin>>a;
  A.push_back(a);
 }
 sort(A.begin(),A.end());

 if((A[2]-A[1])%2==0 && (A[2]-A[0])%2==0)std::cout<<(A[2]-A[1])/2+(A[2]-A[0])/2<<std::endl;
 else if((A[2]-A[1])%2==1 && (A[2]-A[0])%2==1)std::cout<<1+(A[2]-(A[1]+1))/2+(A[2]-(A[0]+1))/2<<std::endl;
 else if((A[2]-A[1])%2==0 && (A[2]-A[0])%2==1)std::cout<<1+(A[2]-A[1])/2+((A[2]+1)-A[0])/2<<std::endl;
 else if((A[2]-A[1])%2==1 && (A[2]-A[0])%2==0)std::cout<<1+((A[2]+1)-A[1])/2+(A[2]-A[0])/2<<std::endl;
 else ;
}
     

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;

int add(int x, int y) {
    x += y;
    if(x >= mod) x -= mod;
    return x;
}

int mul(int x, int y) {
    LL z = 1LL * x * y;
    return z - z / mod * mod;
}

int p[maxn];
vector<int> g[maxn], g2[maxn];
vector<int> fu[maxn];
int depth = 0, bn = 0, b[maxn << 1];
int f[maxn << 1], dfn[maxn], dis[maxn], fs[maxn];
LL ans[maxn];

void dfs(int u, int fa) {
    int tmp = ++depth;
    b[++bn] = tmp;
    f[tmp] = u;
    dfn[u] = bn;
    for (auto v : g[u]) {
        if (v == fa) continue;
        dis[v] = dis[u] + 1;
        dfs(v, u);
        b[++bn] = tmp;
    }
}

int st[maxn << 1][20];
int lg[maxn << 1];
void st_init() {
    for (int i = 2; i < maxn * 2; ++i) lg[i] = lg[i >> 1] + 1;
    for (int i = bn; i >= 1; --i) {
        st[i][0] = b[i];
        for (int j = 1; i + (1 << j) - 1 <= bn; ++j)
            st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
    }
}
int rmq(int l, int r) {
    int k = lg[r - l + 1];
    return min(st[l][k], st[r - (1 << k) + 1][k]);
}

int lca(int a, int b) {
    if(a == b) return a;
    if (dfn[a] > dfn[b]) swap(a, b);
    int k = rmq(dfn[a], dfn[b]);
    return f[k];
}

bool cmp(const int &i, const int &j) {
    return dfn[i] < dfn[j];
}

void build_tree(vector<int> &vec) {
    int sz = 0, k = vec.size();
    sort(vec.begin(), vec.end(), cmp);
    fs[sz] = 0;
    g2[0].clear();
    for (int i = 0; i < k; ++i) {
        int u = vec[i], ll = lca(u, fs[sz]);
        g2[u].clear();
        if (ll == fs[sz]) fs[++sz] = u;
        else {
            while (sz >= 1 && dis[fs[sz - 1]] >= dis[ll]) {
                g2[fs[sz - 1]].push_back(fs[sz]);
                sz--;
            }
            if (fs[sz] != ll) {
                g2[ll].clear();
                g2[ll].push_back(fs[sz--]);
                fs[++sz] = ll;
            }
            fs[++sz] = u;
        }
    }
    for (int i = 0; i < sz; ++i) g2[fs[i]].push_back(fs[i + 1]);
}

int dp[maxn][2];

void dfs2(int u) {
    int a,b,c;
    a = 1;
    b = c = 0;
    for(auto v:g2[u]) {
        dfs2(v);
        c = add(mul(c,add(dp[v][1],dp[v][0])),mul(b,dp[v][1]));
        b = add(mul(b,dp[v][0]),mul(a,dp[v][1]));
        a = mul(a,dp[v][0]);
    }
    if(g2[u].size() == 0) dp[u][0] = dp[u][1] = 1;
    else {
        dp[u][0] = add(a,c);
        dp[u][1] = b;
    }
}

int main() {
    int n, i, x, ans = 0;
    scanf("%d", &n);
    for(i = p[0] = 1; i < maxn; i++) p[i] = mul(p[i - 1], 2);
    for(i = 1; i <= n; i++) {
        scanf("%d", &x);
        g[x + 1].push_back(i + 1);
    }
    dis[1] = 1;
    dfs(1,0);
    st_init();
    for(i = 1;i <= n + 1; i++) fu[dis[i]].push_back(i);
    for(i = 1;i <= n + 1; i++) {
        if(fu[i].size()) {
            //cout<<i<<" = "<<fu[i].size()<<endl;
            build_tree(fu[i]);
            dfs2(0);
        //cout<<dp[0][1]<<endl;
            ans = add(ans,mul(dp[0][1],p[n + 1 - fu[i].size()]));
        }
    }
    printf("%d\n", ans);
    return 0;;
}

Measured memory_bytes: 81536
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

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

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

int a, b, c;

int main() {
    cin >> a >> b >> c;
    cout << max(0, b + c - a) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int,input().split())))
max_a = max(a)
ans = [0,10**9]
for i in a[:n-1]:
  if ans[1] > abs(max_a/2 - i):
    ans[0] = i
    ans[1] = abs(max_a/2 - i)
print(max_a,ans[0])

Measured memory_bytes: 14428
def base3(K):
    if K<3:
        return str(K)
    else:
        return str(K%3)+base3(K//3)
L=int(input())
T=base3(L)
N=len(T)
A=[]
for i in range(N-1):
    tmp=3**i
    for k in range(3):
        A.append((i+1,i+2,k*tmp))
bef=0
for i in range(N)[::-1]:
    tmp=3**i
    for k in range(int(T[i])):
        A.append((i+1,N+1,bef+k*tmp))
    bef+=int(T[i])*tmp
print(N+1,len(A))
for p in A:
    print(p[0],p[1],p[2])


Measured memory_bytes: 3064
N, M = map(int,input().split())
people = [list(map(int, input().split())) for _ in range(N)]
most_list = []

for i,p in enumerate(people):
    if i == 0:
        most_list = p[1:]
        continue
    tmp = []
    for j in range(1, len(p)):
        if p[j] in most_list:
            tmp.append(p[j])
    if len(tmp) == 0:
        print(0)
        exit()
    most_list = tmp
print(len(most_list))

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

using namespace std;

int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    --A; --B; --C; --D;
    string S; cin >> S;
    bool valid = true;
    bool jump = false;
    for(int i=A;i<C;i++){
        if(S[i] == '#' && S[i+1] == '#') valid = false;
    }
    for(int i=B;i<=D;i++){
        if(i+1 < N && S[i] == '#' && S[i+1] == '#') valid = false;
        if(i+1 < N && S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') jump = true;
    }
    if(C > D && !jump) valid = false;
    cout << (valid ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace ConsoleApp1
{
    using static Util;

    internal class Program
    {


        static void Main(string[] args)
        {
            var s = ReadLong();

            var hashN = new HashSet<long>();
            var cnt = 1;
            var m = s;
            hashN.Add(s);
            while (true)
            {
                cnt++;
                m = fn(m);
                if (hashN.Contains(m))
                {
                    break;
                }
                hashN.Add(m);
            }

            Console.WriteLine(cnt);
#if DEBUG
            Console.Read();
#endif
        }

        public static long fn(long n)
        {
            if (n % 2 == 0)
                return f1(n);
            else
                return f2(n);
        }

        public static long f1(long n)
        {
            return n / 2;
        }

        public static long f2(long n)
        {
            return 3*n +1;
        }

    }

    public static class Util
    {
        public static long[] ReadLongs() 
        {
            return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

    }
}


Measured memory_bytes: 13280
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 5010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

string rev(string &s) {
    string t = s;
    reverse(ALL(t));
    return t;
}

int n, k, f[MAXN * 2];
string s, res = "";

void solve(string str, int k) {
    FOR(i,1,k) {
        char last = str[SZ(str)-1];
        string u = str + rev(str);
        int r = n-1;
        FOR(j,n,2*n-1)
            if (u[j] == last) r++;
            else break;
        str = u.substr(r-n+1, n);
    }
    str = rev(str);
    if (SZ(res) == 0) res = str;
    else if (res > str) res = str;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    cin >> s;
    string u = s + rev(s);
    char a = s[0];
    FOR(i,0,n-1) a = min(a, s[i]);
    FOR(i,0,SZ(u)-1)
        if (i == 0) f[i] = (u[i] == a);
        else {
            if (u[i] == a) f[i] = f[i-1] + 1;
            else f[i] = 0;
        }
    int L = 0;
    FOR(i,0,SZ(u)-1) L = max(L, f[i]);

    if (k > 15) {
        FOR(i,1,n) cout << a;
        return 0;
    }

    int sum = 1;
    FOR(i,1,k-1) sum *= 2;
    sum *= L;

    if (sum > n) {
        FOR(i,1,n) cout << a;
        return 0;
    } 

    FOR(i,0,n) solve(u.substr(i, n), k-1);
    cout << res;
    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()

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; }

#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int a;
  cin >>a;
  cout << 3*a*a <<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    double x=0,y=0,b=0,p=0,a=5,c=2,flag=0;
    cin>>x>>y>>b>>p;
    if(b>5){
      a=b;
    }
    if(p>2){
      c=p;
    }
    for(double j=a;j<=6;j++){
      for(double k=c;k<=6;k++){
	if((x*j+y*k)*0.8 < x*b+y*p && flag==0){
	  flag++;
	  cout<<(x*j+y*k)*0.8<<'\n';
	}
      }
    }
    if(flag==0){
      cout<<x*b+y*p<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 3292
s=input()
count=0
st=0
for i in s:
    if i == 'g':
        if st>0:
            count+=1
            st-=1
        else:
            st+=1
    else:
        if st>0:
            st-=1
        else:
            count-=1
            st+=1
print(count)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void) {
  int i, j, k, n;
  while( 1 ) {
    scanf("%d", &n);
    if(!n) break;
    int b = 0, f[n], t;
    for(i = 0; i < n; ++i) f[i] = 0;
    char s[120];
    scanf("%s", s);
    for(i = 0; i < 100; ++i) {
      if(s[i] == 'M') f[i % n]++;
      else if(s[i] == 'S') b += f[i % n] + 1, f[i % n] = 0;
      else f[i % n] += 1 + b, b = 0;
    }
    for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(f[i] > f[j]) t = f[i], f[i] = f[j], f[j] = t;
    for(i = 0; i < n; ++i) printf("%d ", f[i]);
    printf("%d\n", b);
  }
  return 0;
}


Measured memory_bytes: 2752
using System;

namespace ABC149
{
	class Program
	{
		static void Main(string[] args)
		{
			int num = int.Parse(Console.ReadLine());
			while (true)
			{
				if(num == 2)
				{
					break;
				}
				else if(num % 2 != 0)
				{
					bool flag = true;

					//割り切れる数のチェック
					for(int i = 3; i < num; i += 2)
					{
						if(num % i == 0)
						{
							flag = false;
							break;
						}
					}

					if (flag)
					{
						break;
					}
				}

				num++;
			}

			Console.WriteLine(num);
		}
	}
}


Measured memory_bytes: 13140
s = input()
n = len(s)

s = "".join(reversed(list(s)))
while n:
    if s.startswith("maerd"):
        n -= 5
        s = s[5:]
    elif s.startswith("remaerd"):
        n -= 7
        s = s[7:]
    elif s.startswith("esare"):
        n -= 5
        s = s[5:]
    elif s.startswith("resare"):
        n -= 6
        s = s[6:]
    else:
        break
print("YES" if n == 0 else "NO")


Measured memory_bytes: 10492
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int ketawa(int a) {
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n; int d, x; cin >> d >> x;
	vector<int> a(n); rep(i, n)cin >> a[i];
	int sum = 0;
	rep(i, n) {
		sum += (a[i] + d - 1) / a[i];
	}
	cout << sum + x << endl;

	return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
   if (A > C && C > B) {
cout << "Yes" << endl;
}
  else if (A < C && C < B) {
cout << "Yes" << endl;
}
    else {
 cout << "No" << endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<30)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

map<int,int>zipX,zipY;
int unzipX[5005], unzipY[5005];
int cum[5005][5005];
int N,M;
vector<int> X, Y;

int compressX(vector<int>&x){
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  rep(i,x.size()){
    zipX[x[i]] = i;
    unzipX[i] = x[i];
  }
  return x.size();
}
int compressY(vector<int>&y){
  sort(y.begin(), y.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  rep(i,y.size()){
    zipY[y[i]] = i;
    unzipY[i] = y[i];
  }
  return y.size();
}

int main(){
  scanf("%d%d", &N,&M);
  X.resize(N); Y.resize(N);
  rep(i,N) scanf("%d%d", &X[i], &Y[i]);
  vector<int>x,y; x = X; y = Y;
  int W = compressX(x);
  int H = compressY(y);
  memset(cum, 0,sizeof(cum));
  rep(i,N) cum[zipX[X[i]]+1][zipY[Y[i]]+1]++;
  zipX[-INF] = 0; zipY[INF] = 0;
  zipX[INF] = W; zipY[INF] = H;
  rep(i,W+1) rep(j,H) cum[i][j+1] += cum[i][j];
  rep(j,H+1) rep(i,W) cum[i+1][j] += cum[i][j];
  /*  rep(i,W+1){
    rep(j,H+1) cout << cum[i][j] << " " ; cout << endl;
    }*/
  rep(i,M){
    int x1, x2, y1, y2;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    P a = *zipX.lower_bound(x1);
    P b = *zipY.lower_bound(y1);
    P c = *zipX.upper_bound(x2);
    P d = *zipY.upper_bound(y2);
    //    cout << a.second << " " << b.second << " " << c.second << " " <<d.second << " " << cum[a.second][d.second] << endl;
    printf("%d\n", cum[a.second][b.second]-cum[c.second][b.second]-cum[a.second][d.second]+cum[c.second][d.second]);
  }
  return 0;
}

Measured memory_bytes: 99648
S = input()
T = "abcdefghijklmnopqrstuvwxyz"
if len(S) != 26:
    for i in T:
        if i not in S:
            print(S+i)
            exit()
else:
    if S == "zyxwvutsrqponmlkjihgfedcba" :
        print(-1)
    else:
        dic = []
        for i in range(25,-1,-1):
            for j in dic:
                if j > S[i]:
                    print(S[:i]+j)
                    exit()
            dic.append(S[i])
            dic = sorted(dic)


Measured memory_bytes: 3060
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)


def main():
    N = int(readline())
    S = readline().strip()
    Q = int(readline())

    S = list(S)

    tree = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        tree[ord(c) - ord('a')].add(i)

    ans = []
    for _ in range(Q):
        A = readline().split()
        if A[0] == '1':
            i, c = int(A[1]) - 1, A[2]
            if S[i] != c:
                tree[ord(S[i]) - ord('a')].add(i, -1)
                tree[ord(A[2]) - ord('a')].add(i, 1)
                S[i] = c
        else:
            l, r = int(A[1]) - 1, int(A[2]) - 1
            tmp = 0
            for i in range(26):
                if tree[i].get_sum_range(l, r + 1) > 0:
                    tmp += 1
            ans.append(tmp)

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 202524
#include<bits/stdc++.h>
using namespace std;
const int limit = 50;
int N,M;
vector<bool> seen(limit,false);
vector<vector<bool>> G(limit,vector<bool> (limit,false));

void dfs(const vector<vector<bool>> &G,int v){
    seen[v] = true;
    for(int v2=0;v2<N;v2++){
        if(!G[v][v2]) continue;
        if(seen[v2]) continue;
        dfs(G,v2);
    }
}
int main(){
    
    cin >> N >> M;

    vector<int> a(M),b(M);
    for(int i=0;i<M;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]][b[i]]=G[b[i]][a[i]]=true;
    }

    int ans = 0;
    for(int i=0;i<M;i++){
        G[a[i]][b[i]]=G[b[i]][a[i]]=false;
        seen.assign(N, false);

        dfs(G,0);

        bool bridge=false;
        for(int j=0;j<N;j++){
            if(!seen[j]) bridge=true;
        }
        if(bridge) ans++;

        G[a[i]][b[i]]=G[b[i]][a[i]]=true;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

void solve() {
    double X, Y;
    cin >> X >> Y;
    double s, t;
    s = 2 * X - Y / 2;
    t = Y / 2 - X;
    if(s >= 0 && t >= 0)
    {
        if ((int)s == s && (int)t == t)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;


int main(){
  string s;
  cin >> s;
  // if(s == "zyxwvutsrqponmlkjihgfedcba"){
  //   cout << -1 << endl;
  //   return 0;
  // }

  map<char, bool> mp;
  for(char c : s){
    mp[c] = true;
  }

  char tmp = '@';
  for(char c = 'a'; c <= 'z'; c++){
    if(!mp[c]){
      tmp = c;
      break;
    }
  }

  if(tmp != '@') {
    cout << s << tmp << endl;
    return 0;
  }

  vector<char> tmp2(1, s[25]);
  s = s.substr(0, 25);
  for (int i = 24; i >= 0; i--) {
    // cout << s << endl;
    // print(tmp2);
    for (int j = 0; j < int(tmp2.size()); j++) {
      if(s[i] < tmp2[j]){
        s = s.substr(0, int(s.size())-1);
        cout << s << tmp2[j] << endl;
        return 0;
      }
    }
    tmp2.push_back(s[i]);
    sort(all(tmp2));
    s = s.substr(0, int(s.size())-1);
  }
  cout << -1 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s[102];
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(i=0;i<n;i++)
    {
        cout<<s[i];
    }
    cout<<"\n";
    return 0;
}



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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
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 (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
//const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair

int main() {
	string s;
	cin >> s;
	int w;
	cin >> w;
	for (int i = 0; i < s.size(); i += w) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)

typedef vector<int> Vi;

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

const int inf = 1 << 28;

int a_init, b_init, n;
Vi vc;
// dp[acting player][the number of cards remaining when a turn is passed]
int dp[2][2001];

void init()
{
	cin >> n >> a_init >> b_init;

	vc.resize(n);
	REP(i, n) cin >> vc[i];
}

int main()
{
	init();
//	dp[1][n] = abs(b_init - vc.back());

	for (int i = 1; i < n; ++i)
	{
		int c_other = vc[n - i - 1];
		int res;

		// p0, maximize
		res = abs(vc.back() - c_other);
		for (int j = i - 1; j >= 1; --j)
			chmax(res, dp[1][j]);

		dp[0][i] = res;

		// p1, minimize
		res = abs(vc.back() - c_other);
		for (int j = i - 1; j >= 1; --j)
			chmin(res, dp[0][j]);
		dp[1][i] = res;
	}

	int ans = abs(b_init - vc.back());
	for (int i = n - 1; i >= 1; --i)
		chmax(ans, dp[1][i]);

	cout << ans << endl;
}


Measured memory_bytes: 384
a = input()
b = input()
c = input()
start = a[0]
a = a[1:]
while True:
    if start == 'a':
        if len(a) == 0:
            print('A')
            exit()
        else:
            start = a[0]
            a = a[1:]
    elif start == 'b':
        if len(b) == 0:
            print('B')
            exit()
        else:
            start = b[0]
            b = b[1:]
    else:
        if len(c) == 0:
            print('C')
            exit()
        else:
            start = c[0]
            c = c[1:]

Measured memory_bytes: 3064
fn gcd(a: usize, b: usize) -> usize {
    if a == 0 || b == 0 {
        if a == 0 {
            return b;
        } else {
            return a;
        };
    }
    if a < b {
        return gcd(b % a, a);
    }
    gcd(a % b, b)
}
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: i32 = sc.read();
    let x: i32 = sc.read();
    let mut xs: Vec<i32> = sc.vec(n as usize);
    xs.sort();
    let mut result = (x - xs[0]).abs() as usize;
    for i in 1..n as usize {
        let diff = (x - xs[i]).abs();
        result = gcd(result as usize, diff as usize);
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  cin >> N >> M;

  if(M == 0){
    if(N == 1){
      cout << 0 << "\n";
    } else{
      cout << (ll)pow(10, N - 1) << "\n";
    }

    return 0;
  }
  
  vl s(M), c(M);
  rep(i, M) cin >> s[i] >> c[i];

  map<ll, ll> num;
  rep2(i, 1, 10) num[i] = -1;

  rep(i, M){
    if((num[s[i]] > -1) && (num[s[i]] != c[i])){
      cout << -1 << "\n";
      return 0;
    }
    if((s[i] == 1) && (c[i] == 0) && (N > 1)){
      cout << -1 << "\n";
      return 0;
    }
    num[s[i]] = c[i];
  }

  rep2(i, 1, N + 1){
    if(num[i] > -1){
      cout << num[i];
    } else{
      if(i == 1)
	cout << 1;
      else
	cout << 0;
    }
  }

  cout << "\n";
  
  return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int i = 1;
		while(x !=0){
			System.out.println("Case "+i+": "+x);
			x = sc.nextInt();
			i++;
		}
	}
}

Measured memory_bytes: 33044
//int a = int(s); 文字列sをintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

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

	ll sum = 0;
	rep(i, S.size()){
		int num = S[i] - '0';
		sum += num;
	}

	if(sum%9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}	

Measured memory_bytes: 11476
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
#include <set>

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;
ll a[26] = {};
ll b[26] = {};

int main() {
	ll N; string S; cin >> N >> S;
	ll maxV = 0;
	repe(i, 0, S.size()) {
		ll a[26] = {};
		ll b[26] = {};
		string T = S.substr(0, i);
		rep(t, 0, i) {
			a[T[t] - 'a'] = true;
		}
		string U = S.substr(i, S.size() - i);
		rep(t, 0, U.size()) {
			b[U[t] - 'a'] = true;
		}

		ll cnt = 0;
		rep(t, 0, 26) {
			if (a[t] && b[t]) {
				cnt++;
			}
		}
		maxV = max(cnt, maxV);
	}
	cout << maxV << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
ll fact(ll n){
	if(n==0)return 1;
	return n*fact(n-1);
}
int main(){
	fast;
	ll n; cin>>n;
	vector<pair<ll,ll>> arr(n);
	for(auto i=0;i<n;++i){
		ll a,b;
		cin>>a>>b;
		arr[i]={a,b};
	}
	vector<ll> towns(n);
	for(auto i=1;i<=n;++i){
		towns[i-1]=i;
	}
	double avg=0;
	do{
		double curavg=0;
		for(auto i=0;i+1<n;++i){
			double len;
			len=sqrt((arr[towns[i]-1].first-arr[towns[i+1]-1].first)*(arr[towns[i]-1].first-arr[towns[i+1]-1].first)+(arr[towns[i]-1].second-arr[towns[i+1]-1].second)*(arr[towns[i]-1].second-arr[towns[i+1]-1].second));
			curavg+=len;
			//cout<<len<<' ';
		}
		avg+=curavg;

	}while(next_permutation(towns.begin(), towns.end()));
	avg/=fact(n);
	printf("%0.10f\n",avg);
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int H,W;
int i,j;
 
while(1){
scanf("%d %d",&H,&W);
if (H == 0 && W == 0)break;
 
for (i = 0 ; i < H ; i++){
for (j = 0 ; j < W ; j++){
if (i == 0 || j == 0 || i == H - 1 || j == W - 1){printf("#");}else{printf(".");}
 
}
printf("\n");
}
printf("\n");
 
}
return 0;
}
 

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

void solve(){
  int n, m; cin >> n >> m;
  vector<pair<int, int> > ans(m);
  if(n % 2 == 1){
    int j = 2;
    for(int i = 0; i < m; i++){
      ans[i].first = j;
      ans[i].second = n - j + 2;
      j++;
    }
  }
  else{
    int j, t = 0, x;
    if(n % 4 == 0){
      j = 2;
      x = 2;
    }
    else{
      j = 1;
      x = 1;
    }
    for(int i = 0; i < m; i++){
      if(j == n / 4 + 1) t++;
      ans[i].first = j;
      ans[i].second = n - j + x - t;
      j++;
    }
  }
  for(int i = 0; i < m; i++){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return;
}

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


Measured memory_bytes: 3884
#include<stdio.h>
int main(void)
{
	int n,d[100001],a[100001]={0},x=0,i,j;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &d[i]);
		a[d[i]]++;
	}
	for(i=1; i<100001; i++)
	{
		if(a[i]>0)
		x+=a[i];
		if(x>=n/2)
		{
			if(x>n/2)
			printf("0\n");
			else
			{
				x=0;
				for(j=i+1; j<100001; j++)
				{
					x++;
					if(a[j]>0)
					break;
				}
				printf("%d\n", x);
			}
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}


ll com(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    ll n; cin >> n;
    vl a(n+1);
    map<ll,ll> mp;
    ll t;
    ll left=-1,right;
    rep(i,n+1){
        cin >> a[i];
        mp[a[i]]++;
        if(mp[a[i]] == 2) t = a[i];
    }
    rep(i,n+1){
        if(a[i] == t){
            if(left == -1) left = i;
            else right = n-i;
        }
    }
    comInit();
    //cout << left << right << endl;
    ll ans = 0;
    REP(i,1,n+2){
        ans = com(n+1,i) % MOD;
        ans %= MOD;
        ans -= com(left+right,i-1) % MOD;
        if(ans<0) ans += MOD;
        cout << ans << endl;
    }
}


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

const int MAX = 1001000;

int main() {
	bool is_p[MAX] = {0};
	for ( int i = 2; i < MAX; i++ ) {
		for ( int j = 2; j*i < MAX; j++ ) {
			is_p[i*j] = true;
		}
	}

	vector<int> p;	
	for ( int i = 2; i < MAX; i++ ) {
		if ( !is_p[i] ) p.push_back(i);
	}
		
	int N, P;
	while ( cin >> N >> P, N != -1 ) {
		vector<int> v;
		int id = upper_bound(p.begin(), p.end(), N)-p.begin();
		//cout << p[id] << endl;
		for ( int i = id; i < id+110; i++ ) {			
			for ( int j = i; j < id+110; j++ ) {
				v.push_back(p[i]+p[j]);
			}
		}
		sort(v.begin(), v.end());
		cout << v[P-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 4212
B, W = map(int, input().split())

MOD = 10 ** 9 + 7
M = 200005
fact = [0] * M
fact[0] = 1
for i in range(1, M):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * M
rfact[M - 1] = pow(fact[M - 1], MOD - 2, MOD)
for i in range(M - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD

pow2 = [0] * M
pow2[0] = 1
for i in range(1, M):
    pow2[i] = pow2[i - 1] * 2
    pow2[i] %= MOD


def comb(n, k):
    if k < 0 or k > n:
        return 0
    return fact[n] * rfact[n - k] * rfact[k] % MOD


num = [0] * 200005
f = [0] * 200005
for i in range(W):
    q = pow(pow2[i + B], MOD - 2, MOD) * comb(i + B - 1, B - 1) % MOD
    f[i + B] = q

g = [0] * 200005
for i in range(B):
    q = pow(pow2[i + W], MOD - 2, MOD) * comb(i + W - 1, W - 1) % MOD
    g[i + W] = q
    num[i + W + 1] = q


inv2 = pow(2, MOD - 2, MOD)
pB, pW = 0, 0
for i in range(1, B + W + 1):
    d = 1 - (pB + pW) + 2 * MOD
    d %= MOD
    pB += f[i]
    pB %= MOD
    pW += g[i]
    pW %= MOD

    num[i] += num[i - 1]
    num[i] %= MOD
    print((inv2 * d + num[i]) % MOD)


Measured memory_bytes: 97488
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    ll n;
    cin>>n;
    vector<vector<P>> v(n);
    for(ll i=0;i<n-1;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        v[a].push_back({b,c});
        v[b].push_back({a,c});        
    } 
    //BFS
    vector<ll> col(n),visit(n);
    queue<ll> q;
    ll sum=0;
    col[0]=0;
    q.push(0);
    visit[0]=1;
    while(q.empty()!=1){
        ll tmp=q.front(); 
        q.pop();
        for(ll j=0;j<v[tmp].size();j++){
            ll a=v[tmp][j].first,b=v[tmp][j].second;
            if(visit[a]==0){
                if(b%2==0) col[a]=col[tmp];
                else col[a]=1-col[tmp];
                q.push(a);
                visit[a]=1;
            }
        }
    }
    for(ll i=0;i<n;i++){
        cout<<col[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[105][105];
ll b[105][105];
int main(){
	int n,m,k;cin>>n>>m>>k;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	for(int i=0;i<m;i++)
		for(int j=0;j<k;j++)
			cin>>b[i][j];
	for(int i=0;i<n;i++){
		for(int j=0;j<k;j++){
			ll res=0;
			for(int t=0;t<m;t++)res+=a[i][t]*b[t][j];
			cout<<res;
			if(j!=k-1)cout<<' ';
		}cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3292
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */


#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());



struct DisjointSet {
    vector<int> par;
    vector<int> rak; // number of the vertices

    void init(int n) {
      par.resize(n);
      rak.resize(n);
      for(int i=0; i<n; i++) {
        par[i] = i;
        rak[i] = 1;
      }
    }

    int find(int x) {
      if (par[x] == x) {
        return x;
      } else {
        return par[x] = find(par[x]);
      }
    }

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x==y) return;
      if (rak[x] < rak[y]) {
        rak[y] += rak[x];
        par[x] = y;
      } else {
        rak[x] += rak[y];
        par[y] = x;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }
};


class AReachableTowns {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;

      DisjointSet dsu;
      dsu.init(n);

      vector<int> x(n), y(n);
      rep(i, n) {
        int a, b; cin >> a >> b;
        a--; b--;
        x[i] = a;
        y[a] = b;
      }

      set<P> st;
      for(int i=0; i<n; i++) {
        auto it = st.begin();
        bool kept = false;
        while(it != st.end() && (*it).first < y[i]) {
          dsu.unite((*it).second, i);
          if (!kept) {
            it++;
            kept = true;
          } else {
            it = st.erase(it);
          }
        }
        if (!kept) st.emplace(y[i], i);
      }

      for(int i=0; i<n; i++) {
        auto p = dsu.find(x[i]);
        cout << dsu.rak[p] << '\n';
      }
    }
};

signed main() {
  AReachableTowns solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main() {
	int N;
	cin >>N;
	string s[N+1];
	int t[N+1];
	for(int i=1;i<=N;i++){
		cin >>s[i]>>t[i];
	}
	string X;
	cin >>X;
	int c,d;
	c=0;
	d=0;
	for(int i=1;i<=N;i++){
		c=c+d*t[i];
		if(X==s[i]){
			d=1;
		}
	}
	cout <<c<<endl;
}

Measured memory_bytes: 256