akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

struct UnionFind {
    vll par;
    vll _size;

    UnionFind(ll N) {
        par.resize(N);
        _size.resize(N, 1);
        rep(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        _size[ry] += _size[rx];
        _size[rx] = 0;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x) {
        return _size[root(x)];
    }
};

int main()
{
    ll N, M, K; cin >> N >> M >> K;
    UnionFind uf(N);
    vvll friends(N);
    vvll blocks(N);

    rep(i, M) {
        ll a, b; cin >> a >> b; a--, b--;
        uf.unite(a, b);
        friends[a].push_back(b);
        friends[b].push_back(a);
    }

    rep(i, K) {
        ll c, d; cin >> c >> d; c--, d--;
        blocks[c].push_back(d);
        blocks[d].push_back(c);
    }

    //for (auto elem : uf._size) cout << elem << " "; cout << endl;

    rep(i, N) {
        ll num = uf.size(i) - friends[i].size() - 1;
        for (auto block : blocks[i]) {
            if (uf.same(i, block)) num--;
        }
        cout << num << " ";
    }
    cout << endl;
    return 0;
}

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

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

int main() {
	int k = 0;
	ll sum = 0;
	cin >> k;
	rep1(a,k){
		rep1(b,k){
			rep1(c,k){
				sum += gcd(gcd(a,b),c);
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;
typedef pair<int, int> p;

int main()
{
    lint n, k;
    lint cnt = 0;
    cin >> n >> k;
    if (k == 0) {
        cout << n * n << endl;
        return 0;
    }
    for (lint b = k + 1; b <= n; b++) {
        cnt += (n / b) * (b - k);
        if (n % b >= k) {
            cnt += (n % b) - k + 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
const int N=2e5+1;
int n, b[N], ch[N];
long long a[N], c[N];
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, c!=253&c>9);
	b=c==253;
	for(a=b?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int main() {
	n=read<int>();
	std::generate(a, a+n, read<long long>);
	std::generate(b, b+n, read<int>);
	int pos=std::max_element(a, a+n)-a;
	std::rotate(a, a+pos, a+n);
	std::rotate(b, b+pos, b+n);
	a[n]=a[0];
	for(int i=1; i<n; ++i) c[i+1]=2*c[i]-c[i-1]-2*b[i];
	for(int i=0; i<=n; ++i) a[i]+=c[i];
	int *top=ch;
	*top++ = 0;
	for(int i=1; i<=n; ++i) {
		while(top-ch>=2 && (top[-1]-top[-2])*(a[i]-a[top[-1]])>=(i-top[-1])*(a[top[-1]]-a[top[-2]])) --top;
		*top++ = i;
	}
	int size=top-ch;
	long double sum=0;
	for(int i=1; i<size; ++i) {
		int l=ch[i-1], r=ch[i];
		sum+=1.0L*(r-l)*a[l]+(a[r]-a[l])*(r-l-1.0L)/2;
	}
	for(int i=0; i<n; ++i) sum-=c[i];
	printf("%.12Lf\n", sum/n);
	return 0;
}


Measured memory_bytes: 6336
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#include<iomanip> 
#include<map>
#include<numeric>
#include<set>
#include<queue>
#include<stdio.h>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	cout << n - m + 1;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n,l,t;
    cin >> n >> l >> t;
    ll x[n], y[n];
    int w[n];
    for(int i=0;i<n;i++){
        cin >> x[i] >> w[i];
        if(w[i] == 1){
            y[i] = (x[i] + t) % l;
        }else{
            y[i] = (((x[i] - t) % l) + l) % l;
        }
    }
    sort(y, y+n);

    ll i0 = 0LL;
    for(int i=0;i<n;i++){
        if(w[i] == 1){
            if(l-x[i] >= t) continue;
            i0 -= (t-(l-x[i])+l-1)/l;
        }else{
            if(x[i] >= t) continue;
            i0 += (t-x[i]+l-1)/l;
        }
        // cerr << i << ": " << i0 << endl;
    }

    i0 = ((i0 % n) + n) % n;
    // cerr << i0 << endl;
    ll ans[n];
    for(int i=0;i<n;i++){
        ans[(i0+i)%n] = y[i];
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

// get<K>(tuple型の変数)

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    map<int, ll> div;

    repr(i, 2, n+1){
        int tmp = i;
        for(int j=2; j*j<=tmp; ++j){
            while(tmp%j == 0){
                div[j]++;
                tmp /= j;
            }
        }
        if(tmp!=1) div[tmp]++;
    }

    auto num = [&](auto x){
        int cnt = 0;
        for(auto itr=div.begin(); itr!=div.end(); ++itr) if(itr->second >= x) ++cnt;
        return cnt;
    };

    cout << num(74) + num(14)*(num(4)-1) + num(24)*(num(2)-1) + num(4)*(num(4)-1)/2*(num(2)-2) << endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N;
char Str[500005];
int cnt;
pair <int, int> X[1000005];
int DP[500005];
int Max[500005];
void Read()
{
    cin >> N;
    cin.get();
    cin.getline(Str + 1, 500005);

}
inline bool cmp(pair <int, int> a, pair <int, int> b)
{
    if(a.second == b.second)
        return a.first < b.first;
    return a.second < b.second;
}
void precalcX()
{

    for(int i = 1; i <= N; i++)
    {
        if(Str[i] == '0')
        {
            int left = i - 1, right = i + 1;
            while(left > 0 && Str[left] == '1')
                --left;
            ++left;
            while(right < N + 1 && Str[right] == '1')
                ++right;
            --right;
            if(left < i && right > i)
            {
                for(int j = i + 2; j <= right; j++)
                    X[++cnt] = make_pair(i - 1, j);
                for(int j = i - 2; j >= left; j--)
                    X[++cnt] = make_pair(j, i + 1);
                X[++cnt] = make_pair(i - 1, i + 1);
            }
        }
    }
    sort(X + 1, X + cnt + 1);
}

void Solve()
{
    int left = 0;
    for(int i = 1; i <= cnt; i++)
    {
        while(left < i && X[left].second < X[i].first)
            ++left;
        --left;
        DP[i] = Max[left] + X[i].second - X[i].first - 1;
        Max[i] = max(Max[i - 1], DP[i]);
    }
    cout << Max[cnt] << "\n";
}
int main()
{
    Read();
    precalcX();
    Solve();
    return 0;
}


Measured memory_bytes: 12416
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
long long a[222222],lef[222222],rig[222222],n,ans;
priority_queue<pair<long long,long long> > pq;
int main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
	{
		while(!pq.empty() && pq.top().first>a[i])
		{
			rig[pq.top().second]=i;
			pq.pop();
		}
		pq.push(make_pair(a[i],i)); 
	}
	while(!pq.empty())
	{
		rig[pq.top().second]=n+1;
		pq.pop();
	}
	for (int i=n;i>=1;i--)
	{
		while(!pq.empty() && pq.top().first>a[i])
		{
			lef[pq.top().second]=i;
			pq.pop();
		}
		pq.push(make_pair(a[i],i)); 
	}
	while(!pq.empty())
	{
		lef[pq.top().second]=0;
		pq.pop();
	}
	for (int i=1;i<=n;i++)
	{
		ans+=a[i]*(i-lef[i])*(rig[i]-i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9328
T = int(input())

for _ in range(T):
    N = int(input())
    A = list(map(int,input().split()))
    S = input()

    list0 = [0] * 64
    ans = 0

    for a, s in zip(reversed(A), reversed(S)):
        while a:
            b = a.bit_length() - 1
            if list0[b]:
                a ^= list0[b]
            else:
                if s == '1':
                    ans = 1
                else:
                    list0[b] = a

                break

        if ans: break

    print(ans)


Measured memory_bytes: 9036
import bisect
from operator import itemgetter
import math
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
ab = [IL() for i in range(N)]

ab.sort(key=itemgetter(1))

num = 0
for a,b in ab:
  num += a
  if num > b:
    print("No")
    exit()
else:
  print("Yes")

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

int main () {
    int n;
    while (cin >> n) {
        int result = 1;
        while (n > 3) {
            while (n % 3 != 0) {
                n++;
            }
            n /= 3;
            result++;
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

int n;
int need[3];
int have[3];
int len[1050];
int go[1050];
int ans = -1;

void rec(int pos) {
  if (pos == n) {
    int curAns = 0;
    for (int i = 0; i < 3; i++) {
      have[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      if (go[i] < 3) {
        if (have[go[i]]) {
          curAns += 10;
        }
        have[go[i]] += len[i];
      }
    }
    for (int i = 0; i < 3; i++) {
      if (have[i] == 0) {
        return;
      }
      curAns += abs(have[i] - need[i]);
    }
    if (ans == -1 || curAns < ans) {
      ans = curAns;
    }
    return;
  }
  for (int i = 0; i < 4; i++) {
    go[pos] = i;
    rec(pos + 1);
  }
}

int main() {

  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    scanf("%d", &need[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &len[i]);
  }

  rec(0);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
	int n,i,j,k,c=0;
	cin >> n;
	long long a[n+1];
	for(i=1;i<=n;i++) {
		cin>>a[i];
	}
	for(i=1;i<=n-2;i++) {
		for(j=i+1;j<=n-1;j++) {
			for(k=j+1;k<=n;k++) {
				if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]) {
					c++;
				}
			}
		}
	}
	cout<<c;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main() {
    int a, b, ans = 0;

    cin >> a >> b;

    for (int i=0; i<2; i++) {
    if (a >= b) {
        ans += a;
        a--;
    } else {
        ans += b;
        b--;
    }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] arg){
        int a, b, c, d;
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();
        if(a > c){
            d = a;
            a = c;
            c = d;
        }
        if(a > b){
            d = a;
            a = b;
            b = d;
        }
        if(b > c){
            d = b;
            b = c;
            c = d;
        }
        System.out.println(a + " " + b + " " + c);
        scan.close();
    }
}


Measured memory_bytes: 26304
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

ll arr[100010];
ll arr2[100010];

int main(){
    int a,b;
    int num;
    cin >> a >> b;
    rep(i,100010) arr[i] = arr2[i] = 0;

    num = a;
    for (int i = 2; i <= a; i++) {
		while (num%i == 0) {
            arr[i]++;
			num /= i;
		}
	}

    num = b;
    for (int i = 2; i <= b; i++) {
		while (num%i == 0) {
            arr2[i]++;
			num /= i;
		}
	}

    ll ans = 1;
    rep(i,100010){
        ll cnt = max(arr[i],arr2[i]);
        if(cnt > 0){
            while(cnt > 0){
                ans *= i;
                cnt--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
/**
 * 3つに割る方法は、同一方向に3分割、2分割して一方を2分割する方法があり、それぞれについて縦方向と横方向がある。
 */
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map(String::toLong)     // 2≤H,W≤10^5 積はInt.Maxを超えうる。

    /**
     * 水平方向の分割
     * @param a 3分割される辺の長さ
     * @return a == 2だとこの方向では分割できないのでnullを返す。
     */
    fun pararell(a: Long, b: Long): Long? {
        if (a < 3) return null
        return when (a % 3) {
            0L -> 0      // 等分できる
            1L, 2L -> b   // a方向の長さが1違う形に分割できる。
            else -> throw Exception()   // それ以外の場合はない
        }
    }

    /**
     * 長さaの辺を2分割して、分割した一方のみをさらに分割する。
     * @param a
     */
    fun vertical(a: Long, b: Long): Long {
        val a0 = a / 3      // a == 2でも最後のmin()により正しく動作する。
        return (a0 .. a0 + 2).map {     // きれいに割れないところについては全て試す。割り切れる場合も、最後のmin()により正しく動作する。
            /** 長方形の面積 */
            val areas = listOf(it * b, (a - it) * (b / 2), (a - it) * (b - (b / 2)))
            // 空のリストでないことは保証されている。
            areas.max()!! - areas.min()!!
        }.min()!!       // 空のリストでないことは保証されている。
    }

    val candidates = listOf(vertical(h, w), vertical(w, h), pararell(h, w), pararell(w, h)).filterNotNull()

    println(candidates.min()!!)       // 空のリストでないことはverticalの戻り値があることにより保証されている。
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int main() {
  string S;
  cin >> S;
  int ans = 0;
  REP(i, S.size()) {
    int cnt = 0;
    FOR(j, i, S.size()) {
      if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T')
        cnt++;
      else
        break;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
l = sorted(list(li()))
print(sum(l[0::2]))

Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println((a + b) * c / 2);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 21460
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int v[10];
int check(int x)
{
    while(x)
    {
        int k = x%10;
        x /= 10;
        if(v[k])
            return 0;
    }
    return 1;
}
int main()
{
    int n,k;
    int x;
    scanf("%d %d",&n,&k);
    for(int i=0;i<k;i++)
    {
        scanf("%d",&x);
        v[x] = 1;
    }
    int ans;
    for(int i=n; ;i++)
    {
        if(check(i))
        {
            ans = i;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = a;
    int ans = 0;
    while (a > 0) {
      ans += a % 10;
      a /= 10;
    }
    
    if(b % ans == 0){
      System.out.println("Yes");
    }
    else
      System.out.println("No");
  }
}


Measured memory_bytes: 22996
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    for i in 1..10 {
        if n <= i * 111 {
            println!("{}", i * 111);
            return;
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;

char Solve() {
    string s;
    long long K;

    cin >> s >> K;
    for (size_t i = 0; i < s.size(); ++i) {
        if (s[i] != '1') return s[i];
        else if (i + 1 == K) return s[i];
    }

    return '1';
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
y = int(s[:2])
m = int(s[2:])


def is_m(x):
    return 0 < x < 13


if is_m(y) and is_m(m):
    print('AMBIGUOUS')
elif not is_m(y) and not is_m(m):
    print('NA')
elif not is_m(y) and is_m(m):
    print('YYMM')
else:
    print('MMYY')

Measured memory_bytes: 3060
n,t=map(int,input().split())
clis=[]
tlis=[]
for i in range(n):
  a,b=map(int,input().split())
  clis.append(a)
  tlis.append(b)
lis2=[]
for i in range(n):
  if tlis[i] > t:
    pass
  else:
    lis2.append(clis[i])
if len(lis2)==0:
  print("TLE")
else:
  print(min(lis2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  map<int, int> a, b;
  rep(i, n) {
    int x;
    cin >> x;
    if(i % 2 == 0)
      a[x]++;
    else
      b[x]++;
  }
  a[0] = 0;
  b[0] = 0;
  vector<P> ra, rb;
  for(auto v : a) ra.push_back(P(v.second, v.first));
  for(auto v : b) rb.push_back(P(v.second, v.first));
  sort(all(ra));
  sort(all(rb));
  reverse(all(ra));
  reverse(all(rb));
  int ansa;
  if(ra[0].second == rb[0].second)
    ansa = max(ra[0].first + rb[1].first, ra[1].first + rb[0].first);
  else
    ansa = ra[0].first + rb[0].first;
  cout << n - ansa << endl;
}

Measured memory_bytes: 6136
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define pque(type) priority_queue<type,vector<type>,greater<type> >
 
int main(void){
	int r, g, b;
	cin >> r >> g >> b;
	if((g*10+b)%4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}
vll adj[2*MAXN];
ll LIS[2*MAXN];
vll a;
vll dp;
void dfs(ll s, ll p){
    auto it = lower_bound(all(dp), a[s])-dp.begin();
    ll sz = dp.size();
    ll store;
    if (it!=sz)
    {
        store = dp[it];
        dp[it] = a[s];
    }
    else {
        dp.pb(a[s]);
    }
    LIS[s] = dp.size();
    for(auto v: adj[s]){
        if(v==p){
            continue;
        }
        dfs(v,s);
    }

    if (it!=sz)
    {
        dp[it] = store;
    }
    else {
        dp.resize(sz);
    }
    return;
}
int solve(){
    ll n;
    cin>>n;
    a.resize(n+1);
    f(i,0,n){
        cin>>a[i+1];
    }
    f(i,0,n-1){
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1, 1);
    fo(i,1,n){
        cout<<LIS[i]<<endl;
    }
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);



    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif



    // tests(){solve();}
    solve();
    return 0;
}/*#ifndef ONLINE_JUDGE
    #endif*/

    // make_pair make_tuple  tuple<int,int,int> 

Measured memory_bytes: 34556
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        bool flag = true;
        var count = 0;
        while (flag)
        {
            flag = false;
            for (int i = N - 1; i > 0; i--)
            {
                if (a[i] < a[i - 1])
                {
                    var t = a[i];
                    a[i] = a[i - 1];
                    a[i - 1] = t;
                    flag = true;
                    count++;
                }
            }
        }
        Console.WriteLine(string.Join(" ", a));
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 20352
# 2019/10/09
# 解説かんにんぐ

n,t=map(int,input().split())
a=list(map(int,input().split()))
min_a=float('inf')
cost={}
for i in range(n):
    min_a=min(min_a,a[i])
    c=a[i]-min_a
    cost[c]=cost.get(c,0)+1
print(cost[max(cost.keys())])

Measured memory_bytes: 20620
fn input() -> Vec<String> {
    let mut x = String::new();
    std::io::stdin().read_line(&mut x).unwrap();
    x.split_whitespace().map(String::from).collect()
}

fn main() {
    let n: i32 = input()[0].parse().unwrap();
    let n = n % 10;
    println!(
        "{}",
        if [2, 4, 5, 7, 9].contains(&n) {
            "hon"
        } else if [0, 1, 6, 8].contains(&n) {
            "pon"
        } else {
            "bon"
        }
    );
}


Measured memory_bytes: 2096
#include <cstdio>
#include <algorithm>

int a[4];

int main()
{
	scanf("%d %d %d", &a[1],&a[2],&a[3]);
	std::sort(a+1,a+4);
	printf("%d\n", a[3]*10+a[2]+a[1]);
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

int main() {
  char *no = "No";
  int n;
  scanf("%d", &n);
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
    if (p[i] % 2 != i % 2) {
      puts(no);
      return 0;
    }
  }

  for (int i = 0; i + 1 < n; i++) {
    if (p[i] != i) {
      int j = i;
      while (j + 2 < n && p[j + 1] == j + 1) {
        j += 2;
      }
      int lastLeft = -1, lastRight = -1;
      for (int k = i; k <= j; k += 2) {
        if (p[k] < i || p[k] > j) {
          puts(no);
          return 0;
        }
        if (p[k] <= k) {
          if (lastLeft > p[k]) {
            puts(no);
            return 0;
          }
          lastLeft = p[k];
        }
        if (p[k] >= k) {
          if (lastRight > p[k]) {
            puts(no);
            return 0;
          }
          lastRight = p[k];
        }
      }
      i = j;
    }
  }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	ll N;
	cin >> N;
	vll L(N);
	for (auto& e : L)cin >> e;
	vector<vll> VA;
	for (ll p = 0; p < N; p++) {
		vll A(2020, 0LL);
		for (i = p; i < N; i++) {
			ll len = L[i];
			A[len]++;
		}
		ll acc = 0;
		for (auto& a : A) {
			acc += a;
			a = acc;
		}
		VA.push_back(A);

	}
	ll ans = 0;
	for (i = 0; i < N - 2; i++) {
		for (j = i + 1; j < N - 1; j++) {
			ll a, b; 
			a = L[i];
			b = L[j];
			ll min = abs(a - b);
			ll max = a + b;
			ans += VA[j + 1][max - 1] - VA[j + 1][min];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 32000
import java.util.Scanner;


public class Main {
    
    public static void main(String[] args) {
        
        int n,m;
        
        Scanner input = new Scanner(System.in);
        
        n = input.nextInt();
        m = input.nextInt();
        
        if(n >= 2 && n <= 100 && m >= 2 && m <= 100){
            
            int sum = (n-1) * (m-1);
        
        System.out.println(sum);
        
        }
        
      }
    }
    

Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <utility>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef pair<int,int> pii;
typedef long long LL;

const LL MOD = 1000000007;
const char *p;
void *stptr;
long long esp_org, esp_new;

pii expr();

pii factor(){
	if(*p == '~'){
		++p;
		pii a = factor();
		return pii(a.second, a.first);
	}
	if(*p == '('){
		++p;
		pii a = expr();
		++p;
		return a;
	}
	int d;
	sscanf(p, "x%*d%n", &d);
	p += d;
	return pii(1, 1);
}

pii term(){
	pii a = factor();
	while(*p == '&'){
		++p;
		pii b = factor();
		LL t = (LL)a.first * b.first;
		LL f = a.second * LL(b.first + b.second) + (LL)a.first * b.second;
		a = pii(t % MOD, f % MOD);
	}
	return a;
}

pii expr(){
	pii a = term();
	while(*p == '|'){
		++p;
		pii b = term();
		LL t = a.first * LL(b.first + b.second) + (LL)a.second * b.first;
		LL f = (LL)a.second * b.second;
		a = pii(t % MOD, f % MOD);
	}
	return a;
}

int main(){
	const int sz = 48 << 20;
	stptr = malloc(sz);
	esp_new = (long long)stptr + sz - 1;
	__asm__ volatile("mov %rsp, esp_org");
	__asm__ volatile("mov esp_new, %rsp");

	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	p = s.c_str();

	pii p = expr();
	cout << p.first << endl;
	
	__asm__ volatile("mov esp_org, %rsp");
	free(stptr);
}

Measured memory_bytes: 50744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int H = 12;
const int W = 6;

const int dy[4]={1,-1,0,0};
const int dx[4]={0,0,1,-1};

const vector<vector<bool>> B(H, vector<bool>(W, false));

bool IN(int y, int x){
    return 0<=y && y<H && 0<=x && x<W;
}

vector<string> f(const vector<string> &s){
    vector<string> t(s);

    vector<vector<bool>> er(B), vis(B);

    rep(i,H)rep(j,W){
        if(vis[i][j]) continue;

        char c = s[i][j];
        if(c=='O' || c=='.') continue;

        queue<pi> que;
        vector<pi> cc;

        vis[i][j] = true;
        cc.pb({i,j});
        que.push({i,j});
        while(!que.empty()){
            pi now = que.front();
            que.pop();
            rep(d,4){
                int ny = now.fi+dy[d], nx = now.se+dx[d];
                if(!IN(ny,nx)) continue;
                if(!vis[ny][nx] && s[ny][nx]==c){
                    vis[ny][nx] = true;
                    cc.pb({ny,nx});
                    que.push({ny,nx});
                }
            }
        }

        if(cc.size()>=4){
            for(pi p:cc){
                er[p.fi][p.se] = true;
                rep(d,4){
                    int ny = p.fi+dy[d], nx = p.se+dx[d];
                    if(!IN(ny,nx)) continue;
                    if(s[ny][nx]=='O') er[ny][nx] = true;
                }
            }
        }
    }

    rep(i,H)rep(j,W)if(er[i][j]) t[i][j] = '.';

    rep(j,W){
        vector<char> obj;
        for(int i=H-1; i>=0; --i){
            if(t[i][j]!='.') obj.pb(t[i][j]);
            t[i][j] = '.';
        }

        int idx = H-1;
        for(char c:obj) t[idx--][j] = c;
    }
    return t;
}

int solve(){
    vector<string> s(H);
    rep(i,H) cin >>s[i];

    int ret = 0;
    while(1){
        vector<string> nx = f(s);
        if(nx == s) break;
        ++ret;
        s = nx;
    }
    return ret;
}

int main(){
    int T;
    cin >>T;
    while(T--) cout << solve() << "\n";
    return 0;
}



Measured memory_bytes: 3080
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int A[110000], SA[110000];

int main(){
	long long int N, M;
	cin >> N >> M;
	for(int i = 1; i <= N; i++){
		cin >> A[i];
	}
	sort(A, A + N + 1);
	for(int i = 1; i <= N; i++){
		SA[i] = SA[i - 1] + A[i];
	}
	A[N + 1] = INF;
	long long int L = 0, R = 1000000;
	long long int S = 0;
	while(R - L > 1){
		long long int mid = (L + R) / 2;
		S = 0;
		for(int i = 1; i <= N; i++){
			int pos = distance(A + 1, lower_bound(A + 1, A + N + 2, mid - A[i]));
			S += N - pos;
		}
		if(S <= M){
			R = mid;
		}else{
			L = mid;
		}
	}
	long long int ans = 0;
	S = 0;
	for(int i = 1; i <= N; i++){
		int pos = distance(A + 1, lower_bound(A + 1, A + N + 2, R - A[i]));
		S += N - pos;
		ans += (N - pos) * A[i];
		ans += SA[N] - SA[pos];
	}
	ans += (M - S) * (R - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = I();
        int[] B = I();
        int[] C = I();
        int[] b = new int[N];
        long[] bb = new long[N + 1];
        int index = 0;
        for (int i = 0; i < B.Length; i++)
        {
            while (index < N && B[i] >= C[index])
            {
                index++;
            }
            b[i] = N - index;
        }
        bb[N - 1] = b[N - 1];
        for (int i = N - 2; i >= 0; i--)
        {
            bb[i] = bb[i + 1] + b[i];
        }
        long res = 0;
        index = 0;
        for (int i = 0; i < N; i++)
        {
            while (index < N && A[i] >= B[index])
            {
                index++;
            }
            res += bb[index];
        }
        Console.WriteLine(res);
    }
    static int[] I()
    {
        return Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
    }
}

Measured memory_bytes: 39352
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    
	  Scanner sc = new Scanner(System.in);
	  
	  int a = sc.nextInt();
	  
	  int b = sc.nextInt();
	  
	  int c = sc.nextInt();
	  
	 if(a<b && b<c){
		 System.out.println("Yes");
	 }else{
		 System.out.println("No");
	 }
	 
	  
  }
}

Measured memory_bytes: 26384
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);
    let mut T = read!(i64, usize; N);

    T.sort();

    let mut sum = 0_i64;
    let mut num = 0;
    for (a, b) in T {
        let k = min(M - num, b);
        sum += (k as i64) * a;
        num += k;
        debug!(k);
    }
    assert_eq!(num, M);

    println!("{}", sum)
}


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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
h,w = map(int,input().split())
ar = np.array([list(input()) for _ in range(h)]) == '.'
l = np.zeros((h,w),dtype=int)
r = np.zeros((h,w),dtype=int)
u = np.zeros((h,w),dtype=int)
d = np.zeros((h,w),dtype=int)
for i in range(h):
  u[i, :] = (u[i-1]+1)*ar[i]
  d[-i-1, :] = (d[-i]+1)*ar[-i-1]

for j in range(w):
  l[:,j] = (l[:,j-1]+1)*ar[:,j]
  r[:,-j-1] = (r[:,-j]+1)*ar[:,-j-1]
print(np.max(u+d+l+r)-3)

Measured memory_bytes: 219796
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
#define REPS(i,a,b) for(int i = a; i<b; ++i)
#define PB push_back
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N,A;
    cin >> N;
    VI EMPL(N+1);
    REPS(i,1,N){
        cin >> A;
        EMPL[A]++;
    }
    REPS(i,1,N+1) cout << EMPL[i] << '\n';
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    
    if (22 <= a1 + a2 + a3) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())

answer = ""

answer += "U" * (ty-sy) + "R" * (tx-sx)
answer += "D" * (ty-sy) + "L" * (tx-sx)
answer += "L" + "U" * (ty-sy+1) + "R" * (tx-sx+1) + "D"
answer += "R" + "D" * (ty-sy+1) + "L" * (tx-sx+1) + "U"

print(answer)

Measured memory_bytes: 3060
import numpy as np
pi = np.pi
A, B, H, M = map(int, input().split())

Hrad = 2 * pi * (60 * H + M) / 720
Mrad = 2 * pi * M / 60

drad = abs(Hrad-Mrad)
d = np.sqrt(A**2+B**2-2*A*B*np.cos(drad))
print(d)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 998244353;
const int maxn = 1e6 + 5;

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

int n;
ll cnt[maxn];

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

    cin>>n;
    int hi = 0;
    for (int i=1; i<=n; i++) {
	int d;
	cin>>d;
	if (d==0) {
	    if (i!=1) out(0);
	}
	hi = max(hi, d);
	cnt[d]++;
    }

    if (cnt[0] != 1) out(0);

    ll ans = 1;
    for (int i=1; i<=hi; i++) {
	ll cur = pw(cnt[i-1], cnt[i]);
	ans=ans*cur%mod;
    }

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


Measured memory_bytes: 4436
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
int main(){
    int d,g;
    cin>>d>>g;
    int p[d],c[d];
    rep(i,d)    cin>>p[i]>>c[i];
    int ans=INF;
    rep(i,(1<<d)){
        long long sum=0;int tmp=-1,counter=0,times=0;bool flag=true;
        rep(j,d){
            if(i>>j&1){
                sum+=(j+1)*p[j]*100+c[j];times+=p[j];
            }
            else{
                tmp=j;
            }
        }
        if(sum<g){
            int bi=0;
            while(sum<g&&bi<p[tmp]-1){
                sum+=100*(tmp+1);bi++;times++;
            }
            if(sum<g){
                flag=false;
            }
        }
        if(flag==false){
            continue;
        }
        ans=min(ans,times);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int64_t a, b, c, k;
  cin >> a >> b >> c >> k;

  cout << (k & 1 ? -1 : 1) * (a - b) << endl;
}


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

class KMP {
public:
    KMP(const string &pat): pat(pat) {
        int n = pat.size();
        T.resize(n + 1, -1);
        for(int i = 0, j = -1; i < n; T[++i] = ++j) {
            while(j >= 0 && pat[i] != pat[j]) j = T[j];
        }
    }

    vector<int> operator()(const string &corp) {
        size_t corpPos = 0, patPos = 0;
        
        vector<int> ret;
        while(corpPos + patPos < corp.size()) {
            if(pat[patPos] == corp[corpPos + patPos]) {
                ++patPos;
                if(patPos < pat.size()) continue;
            }

            if(patPos == pat.size()) ret.push_back(corpPos);
            corpPos = corpPos + patPos - T[patPos];
            if(patPos > 0) patPos = T[patPos];
        }
        return ret;
    }

private:
    string pat;
    vector<int> T;
};

class DAG {
public:
    DAG(const vector<vector<int>> &edges)
    : tsort_done(false), acyc(false) {
        V = edges.size();
        E.resize(V);
        for(int i = 0; i < V; ++i) {
            for(int to : edges[i]) {
                E[i].push_back(to);
            }
        }
    }

    bool tsort() {
        vector<int> indeg(V, 0);
        for(int i = 0; i < V; ++i) {
            for(int to : E[i]) ++indeg[to];
        }

        stack<int> done;
        for(int i = 0; i < V; ++i) {
            if(indeg[i] == 0) done.push(i);
        }

        while(!done.empty()) {
            int cur = done.top();
            done.pop();
            order.push_back(cur);
            for(int to : E[cur]) {
                --indeg[to];
                if(indeg[to] == 0) done.push(to);
            }
        }

        tsort_done = true;
        acyc = (order.size() == V);
        return acyc;
    }

    int longest_path() {
        if(!tsort_done) tsort();
        if(!acyc) return -1;

        dp.resize(V);
        for(int i = 0; i < V; ++i) {
            int cur = order[i];
            for(int to : E[cur]) {
                dp[to] = max(dp[to], dp[cur] + 1);
            }
        }

        return *max_element(begin(dp), end(dp));
    }

    bool acyclic() {
        if(!tsort_done) tsort();
        return acyc;
    }

    int operator[](int i) {
        if(!tsort_done) tsort();
        return order[i];
    }

private:
    int V;
    vector<vector<int>> E;
    vector<int> order;
    bool tsort_done;
    bool acyc;
    vector<int> dp;
};

int main() {
    string s, t;
    cin >> s >> t;
    string S = s;
    while(S.size() < s.size() + t.size() - 1) S += s;

    KMP kmp(t);
    vector<int> pos = kmp(S);

    vector<vector<int>> E(s.size());
    for(int i : pos) {
        if(i >= s.size()) break;
        E[i].push_back((i + t.size()) % s.size());
    }

    DAG dag(E);
    cout << (!dag.acyclic() ? -1 : dag.longest_path()) << endl;  
}

Measured memory_bytes: 63228