akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

typedef struct Coordinate{
  int x;
  int y;
}point;

//昇順
int acs(const void *a, const void *b) {
  return ((point *)a)->x - ((point *)b)->x;
}

int main() {
  int n;
  scanf("%d", &n);
  point r[n], b[n]; int ans = 0;
  for (int i=0; i<n; i++) scanf("%d%d", &(r[i].x), &(r[i].y));
  for (int i=0; i<n; i++) scanf("%d%d", &(b[i].x), &(b[i].y));
  qsort(b, n, sizeof(point), acs);
  for (int i=0; i<n; i++) {
    int k=-1, max=-1;
    for (int j=0; j<n; j++) {
      if (b[i].x > r[j].x && b[i].y > r[j].y) {
        if (max < r[j].y) {
          max = r[j].y;
          k=j;
        }
      }
    }
    if (k!=-1) {
      ans++;
      r[k].x = -1;
      r[k].y = -1;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N = 1e5+5;
void fast(){std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
bool prime(int n)
{
	if(n<=1)return false;
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
int main()
{
	fast();
	int n;
	cin>>n;
	while(n)
	{
		if(prime(n))
		{
			cout<<n<<endl;
			return 0;
		}
		n++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int A, B, C, K;
  int diff, i;
  
  scanf("%d %d %d\n", &A, &B, &C);
  scanf("%d\n", &K);
  
  while((K >= 0) && (A >= B)) {
    B *= 2;
    K--;
  }
  
  while((K >= 0) && (B >= C)) {
    C *= 2;
    K--;
  }
  
  printf("%s\n", (K >= 0) ? "Yes" : "No");
  
  return 0;
}
  

Measured memory_bytes: 1640
H,W=map(int,input().split())
S=[input() for i in range(H)]
for h in range(H):
        print("".join([("#" if S[h][w] == "#" else str(sum([s[max(0,w-1):min(W,w+2)].count("#") for s in S[max(0,h-1):min(H,h+2)]]))) for w in range(W)]))

Measured memory_bytes: 3064
from collections import deque

n, q = [int(_) for _ in input().split()]

queue = deque()
for _ in range(n):
    name, ti = input().split()
    queue.append((name, int(ti)))

t = 0
while queue:
    name, ti = queue.popleft()
    if ti <= q:
        print(name, t + ti)
        t += ti
    else:
        queue.append((name, ti - q))
        t += q



Measured memory_bytes: 12540
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

// g++ a.cpp -std=gnu++17

int main() {
  INCANT;
  cin >> N;
  string ans = N>=30?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

static const int MAX = 10000;
static const int INFTY = (1<<20);   // pow(10,19);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];   // 重み付き有向グラフの隣接リストを表現

void dijkstra(){
    priority_queue<pair<int, int> > PQ;
    int color[MAX], d[MAX];
    rep(i, n){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0; color[0] = GRAY;
    PQ.push(make_pair(0, 0));

    while(!PQ.empty()){
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        // 最小値を取り出し、それが最短でなければ無視
        if(d[u] < f.first*(-1)) continue;

        rep(j,adj[u].size()){
            int v = adj[u][j].first;
            if(color[v] == BLACK) continue;
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;
                // priority_queueは、デフォルトで大きい値を優先するため-1をかける
                PQ.push(make_pair(d[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }
    rep(i,n){
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main()
{
    int k, u, v, c;
    cin >> n;
    rep(i,n){
        cin >> u >> k;
        rep(j,k){
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 8076
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  string S; cin >> S;
  vector<int> a;

  for (int i = 0; i < S.size(); i++) {
    a.push_back(S[i]-'0');
  }

  int ans = 0;
  for (int i = 0; i < 1<<(S.size()-1); i++) {
    int tmp = a[0];
    for (int p = 0; p < S.size()-1; p++) {
      if (i & 1<<p) {
        ans += tmp;
        tmp = a[p+1];
      } else {
        tmp = tmp * 10 + a[p+1];
      }
    }
    ans += tmp;
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

int main(){

  string S;
  cin >> S;

  int start=0, end=0, flag1=1, flag2=1;

  for (int i=0; i<S.size(); i++){
    if (S.at(i)=='A'){
      flag1=0;
    }
    if (flag1==1){
      start++;
    }
  }

  for (int j=S.size()-1; j>=0; j--){
    if (S.at(j)=='Z'){
      flag2=0;
    }
    if (flag2==1){
      end++;
    }
  }
  cout << S.size()-start-end << endl;
}


Measured memory_bytes: 640
#https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2019-02-16abc-155
import numpy as np
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())))
A.sort()
G=A[A>0]
Z=A[A==0]
L=A[A<0]

ok=10**18+1
ng=-10**18-1

#x以下がK個以上であるxの最小値

while ok-ng>1:
  mid = (ng+ok)//2
  #mid以下のペアの個数を数える
  
  #正のもののうち、mid以下のペアの個数を数える
  cg=np.searchsorted(A,mid//G,side="right").sum()
  
  #負のもののうちmid以下のペアの個数を数える
  cl=(N-np.searchsorted(A,(-mid-1)//(-L),side="right")).sum()
  
  #同じ数字同士の積がmid以下のものを数える
  d = np.count_nonzero(A*A <= mid)
  
  #0がmid以下なら、それもプラスするために必要
  z=0
  if mid>=0:
    z += len(Z)*N
  
  c=cg+cl+z-d
  
  #二重になっているので、割る
  c //=2
  
  #mid以下のペアの個数がK個以上のとき
  if c>=K:
    ok=mid
  else:
    ng=mid
    
print(ok)   

Measured memory_bytes: 47720
import sys

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

# Reference: https://www.geeksforgeeks.org/queries-number-distinct-elements-subarray/
# Python3 code to find number of
# distinct numbers in a subarray
MAX = 1000001

# structure to store queries
class Query:
    def __init__(self, l, r, idx):
        self.l = l
        self.r = r
        self.idx = idx


# updating the bit array
def update(idx, val, bit, n):
    while idx <= n:
        bit[idx] += val
        idx += idx & -idx


# querying the bit array
def query(idx, bit, n):
    summ = 0
    while idx:
        summ += bit[idx]
        idx -= idx & -idx
    return summ


def answeringQueries(arr, n, queries, q):

    # initialising bit array
    bit = [0] * (n + 1)

    # holds the rightmost index of
    # any number as numbers of a[i]
    # are less than or equal to 10^6
    last_visit = [-1] * MAX

    # answer for each query
    ans = [0] * q

    query_counter = 0
    for i in range(n):

        # If last visit is not -1 update -1 at the
        # idx equal to last_visit[arr[i]]
        if last_visit[arr[i]] != -1:
            update(last_visit[arr[i]] + 1, -1, bit, n)

        # Setting last_visit[arr[i]] as i and
        # updating the bit array accordingly
        last_visit[arr[i]] = i
        update(i + 1, 1, bit, n)

        # If i is equal to r of any query store answer
        # for that query in ans[]
        while query_counter < q and queries[query_counter].r == i:
            ans[queries[query_counter].idx] = query(queries[query_counter].r + 1, bit, n) - query(
                queries[query_counter].l, bit, n
            )
            query_counter += 1

    # print answer for each query
    for i in range(q):
        print(ans[i])


# This code is contributed by
# sanjeev2552


def main():
    N, Q = map(int, readline().split())
    C = list(map(int, readline().split()))
    (*LR,) = map(int, read().split())

    queries = [0] * Q
    for i, (l, r) in enumerate(zip(*[iter(LR)] * 2)):
        queries[i] = Query(l - 1, r - 1, i)

    queries.sort(key=lambda x: x.r)
    answeringQueries(C, N, queries, Q)

    return


if __name__ == '__main__':
    main()



Measured memory_bytes: 247668
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N = 2*10**3
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

import time
S=input()
N=len(S)
#print(N)
start=time.time()
if N==1:
    exit(print(1))

dp=[[[-10**15 for i in range(N+2)] for j in range(N+2)] for k in range(N+1)]
dpf=[[[-10**15 for i in range(N+2)] for j in range(N+2)] for k in range(N+1)]

dpf[0][0][0]=1
if S[0]=="0":
    dp[1][1][0]=0
if S[1]=="0":
    dp[1][1][0]=0
if S[0]=="1":
    dp[1][0][1]=0
if S[1]=="1":
    dp[1][0][1]=0
dpf[1][0][0]=2
Zero=1-int(S[0])+1-int(S[1])
One=int(S[0])+int(S[1])
for i in range(2,N):
    Zero+=1-int(S[i])
    One+=int(S[i])
    for j in range(Zero+1):
        for k in range(One+1):
            a,b=1-int(S[i]),int(S[i])
            dp[i][j][k]=max(dp[i-1][j-a][k-b]-2,dpf[i-1][j-a][k-b]-1)
            a,b=1-int(S[i-1]),int(S[i-1])
            dpf[i][j][k]=max(dpf[i-1][j][k]+1,dp[i-1][j][k]+1-dp[i-1][j][k]%2)
            dp[i][j][k]=max(dp[i][j][k],2*(dpf[i-2][j-a][k-b]//2),2*(dp[i-2][j-a][k-b]//2))
            if dp[i][j][k]<0:
              dp[i][j][k]=-10**5
            if dpf[i][j][k]<0:
              dpf[i][j][k]=-10**5
    dpf[i][0][0]=i+1

med=time.time()
#print(med-start)

S=[S[-i-1] for i in range(N)]
Zero=0
One=0
ans=1
check=set([])
one,zero=S.count("1"),S.count("0")
for i in range(N):
    Zero+=(S[i]=="1")
    One+=(S[i]=="0")
    for j in range(zero+1):
        for k in range(one+1):
            if (dp[N-1-i][j][k]>=0 or dpf[N-1-i][j][k]>=0) and (j,k)!=(0,0):
                check.add((j,k))
    ncheck=set([])
    for j,k in check:
        A,B=1,1
        if j!=0:
            A=cmb(Zero+j-1,j,mod)
        if k!=0:
            B=cmb(One+k-1,k,mod)
        ans+=A*B
        ans%=mod
        a,b=1-int(S[i]),int(S[i])
        if j>=a and k>=b:
            ncheck.add((j-a,k-b))
    check=ncheck
    zero-=1-int(S[i])
    one-=int(S[i])

print(ans)

def check():
    res=0
    for i in range(N):
        for j in range(N+1):
            for k in range(N+1) :
                if data[i][j][k]:
                    print(i,j,k)
                    res+=1
    return res
#print(time.time()-start)

Measured memory_bytes: 577732
#include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long int ll;
     
    int main(){
        int t;
        cin>>t;
        ll sum = 0;
        for(int i = 1;i<= t;i++){
            if( i %3 == 0 || i% 5 == 0)continue;
            else sum+= i;
        }
        cout<<sum<<endl;
    }

Measured memory_bytes: 3644
#include<stdio.h>

#define NUM 4

int main(void)
{
        int a[NUM] = {0, 0, 0, 0};
        int b[NUM] = {0, 0, 0, 0};
        int i = 0 ,j = 0,t=0;
        int hit = 0;
        int blow = 0;


        while( scanf("%d",&a[0]) !=  EOF )
        {


                for(i = 1; i < NUM; i++)
                {
                        scanf("%d",&a[i]);
                }
                for(i = 0; i < NUM; i++)
                {
                        scanf("%d",&b[i]);
                }

                for(i = 0; i < NUM; i++)
                {
                        for(j = 0; j < NUM; j++)
                        {
                                if(a[i] == b[j] && i == j)
                                {
                                        hit++;
                                }
                                if(a[i] == b[j] && i != j)
                                {
                                        blow++;
                                }
                        }
                }
                printf("%d %d\n", hit, blow);
                hit = 0;
                blow = 0;
        }
        return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    ll ans=(b/c-(a-1)/c)+(b/d-(a-1)/d)-(b/lcm(c,d)-(a-1)/lcm(c,d));
    cout<<(b-a+1-ans)<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

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

b_list = np.array(list(map(int, input().split())))
correct = 0

for n in range(N):
  a_list = np.array(list(map(int, input().split())))
  ab = a_list * b_list 
  ab = np.sum(ab) + C
  
  if ab > 0:
    correct += 1
  
print(correct )
  


Measured memory_bytes: 12504
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int dp[11000];

int main(){
  for(int i=0;i<1100;i++) dp[i]=-100000;
  int N,M,A[10];
  cin>>N>>M;
  for(int i=0;i<M;i++) cin>>A[i];

  int need[11]={0,2,5,5,4,5,6,3,7,6};

  sort(A,A+M,greater<int>());
  
  dp[0]=0;
  for(int i=1;i<=N;i++){
    for(int j=0;j<M;j++){
      if(i-need[A[j]]>=0) dp[i]=max(dp[i],dp[i-need[A[j]]]+1);
    }
  }
  int n=N;
  for(int i=0;i<dp[N]-1;i++){
    for(int j=0;j<M;j++){
      if(dp[n-need[A[j]]]==dp[n]-1){
        n-=need[A[j]];
        cout<<A[j];
        break;
      }
    }
  }
  for(int i=0;i<M;i++){
    if(n==need[A[i]]){
      cout<<A[i];
      break;
    } 
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




//-----------------------------------------------------------------
#define rrep(i,a,b) for(int i=a;i>=b;i--)
vector<int> mul9(vector<int> s) {
	int n = s.size(), carry = 0;
	vector<int> ret;
	rrep(i, n - 1, 0) {
		int c = s[i] * 9 + carry;
		carry = c / 10;
		c %= 10;
		ret.push_back(c);
	}
	while (0 < carry) {
		ret.push_back(carry % 10);
		carry /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}
vector<int> add(vector<int> s, int x) {
	int n = s.size(), carry = x;
	vector<int> ret;
	rrep(i, n - 1, 0) {
		int c = s[i] + carry;
		carry = c / 10;
		c %= 10;
		ret.push_back(c);
	}
	while (0 < carry) {
		ret.push_back(carry % 10);
		carry /= 10;
	}

	return ret;
}
//-----------------------------------------------------------------
vector<int> S;
bool chk(int k) {
	auto s = add(mul9(S), k);
	int cnt = 0;
	for (int c : s) cnt += c;

	return cnt <= k;
}
//-----------------------------------------------------------------
int main() {
	string _S; cin >> _S;
	for (char c : _S) S.push_back(c - '0');

	int lo = 0, hi = 4501010;
	while (lo + 1 != hi) {
		int mi = (lo + hi) / 2;
		if (chk(mi)) hi = mi;
		else lo = mi;
	}
	int ans = hi / 9;
	if (hi % 9) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 10688
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
int n, k, A[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> A[i];
  FOR(i, k, n) cout << ((A[i]>A[i-k]) ? "Yes" : "No") << endl;
}

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

int main() {
    int n, sum;
    int a, b, c, d, e, f, g, h;
  	cin >> n;
    a = n % 10;
    b = (n % 100) / 10;
    c = (n % 1000) / 100;
    d = (n % 10000) / 1000;
    e = (n % 100000) / 10000;
    f = (n % 1000000) / 100000;
    g = (n % 10000000) / 1000000;
    h = (n % 100000000) / 10000000;
    sum = a + b + c + d + e + f + g + h;
    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 998244353
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back


ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

vec modcomb(ll n, ll k, ll m)
{
    vec c(k+1, 0);
    vec inv(k+1, 0);
    inv[1] = 1;
    c[0] = 1; c[1] = n;
    REP(i,2,k+1) {
        inv[i] = m - inv[m%i] * (m / i) % m;
        c[i] = (((c[i-1] * (n - i + 1)) % m) * inv[i]) % m;
    }
    return c;
}


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

    vec C = modcomb(N-1, K, MOD);
    ll sum = 0;
    REP(i,0,K+1) {
        sum = (sum + ((C[i] * modpow(M-1, N-1-i, MOD)) % MOD)) % MOD;
    }
    sum = (sum * M) % MOD;
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 6352
N=[i for i in input()]
if len(set(N))==1:
    print(''.join(N))
else:
    s=int(N[0]*2)
    t=int(N[1]+N[2])
    #print(s,t)
    if t<s:
        print(N[0]*3)
    else:
        print(str(int(N[0])+1)*3)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
  cin >> n;
  int arr[n+10] = {0};
  int num;
  for(int i = 1; i < n; i++) cin >> num, arr[num]++;
  for(int i = 1; i <= n; i++) cout << arr[i] << "\n";
  
  
    return 0; 
}

Measured memory_bytes: 4424
N = int(input())
H = list(map(int,input().split()))
gap = [0]*(N-1)
M = []

for i in range (N-1):
    gap[i] = H[i]-H[i+1]

c = 0
for i in range (N-1):
    if gap[i] >= 0:
        c += 1
        if i == N-2:
            M.append(c)
    else:
        M.append(c)
        c = 0

if N == 1:
    print(0)
else:
    print(max(M))

Measured memory_bytes: 63856
#include<iostream>
#include<cstdio>


using namespace std;



int main(){
  char JI[1000000];
  int i,JOIcou,IOIcou,k;
 

  i=0;
  JOIcou=0;
  IOIcou=0;
  
  
  while(scanf("%c",&JI[i])!=EOF)
    {
      
      if(JI[i]=='\n')
	{
	  
	
	  cout << JOIcou << endl;
	  cout << IOIcou << endl;
	   i=0;
  JOIcou=0;
  IOIcou=0;
  
	}	
      if(i==0){}
      else if(i==1){}
      else{
	
	if(JI[i]=='I' &&JI[i-1]=='O' && JI[i-2]=='J')JOIcou++;
	if(JI[i]=='I' &&JI[i-1]=='O' &&JI[i-2]=='I')IOIcou++; 
      }
      i++;
    }  
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
int main ()
{
	int a[4];
	int b[4];
	while(scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF)
	{
		int num1 = 0;
		int num2 = 0;
		for(int i=0; i<4; i++)
		{
			scanf("%d", &b[i]);
			if(b[i] == a[i])
				num1++;
		}
		for(int i=0; i<4; i++)
		for(int j=0; j<4; j++)
		{
			if(a[i] == b[j])
				num2++;
		}
		printf("%d %d\n", num1, num2 - num1);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define all(a) (a).begin(),(a).end()

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,c;
    cin >> n >> m >> c;
    vector<pair<int,int>> lim(c);
    vector<pair<int,int>> valc(n);
    for(int i = 0; i < c; i++){
        int x;
        cin >> x;
        lim[i] = {x,0};
    }
    for(int i = 0; i < n; i++){
        int col,val;
        cin >> col >> val;
        col--;
        valc[i] = {val,col};
    }
    sort(all(valc));
    reverse(all(valc));
    
    int cnt = 0;
    int ans = 0;
    int i = 0;
    while(cnt < m && i < n){
        pair<int,int> p;
        p = valc[i];
        if(lim[p.second].second < lim[p.second].first){
            ans += p.first;
            cnt++;
            lim[p.second].second++;
        }
        i++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4212
A=[list(map(int, input().split())) for i in range(3)]
K=[[0]*3 for i in range(3)]

N=int(input())
B=[int(input()) for i in range(N)]

for i in range(N):
  for a in range(3):
    for b in range(3):
      if A[a][b]==B[i]:
        K[a][b]=1
        
out='No'
for i in range(3):
  if K[i][0]+K[i][1]+K[i][2]==3:
    out='Yes'
  if K[0][i]+K[1][i]+K[2][i]==3:
    out='Yes'
if K[0][0]+K[1][1]+K[2][2]==3:
  out='Yes'
if K[0][2]+K[1][1]+K[2][0]==3:
  out='Yes'
print(out)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 20001
#define M 10000
void push(int *p, int x);
int empty();
int pop(int *p);

int n1=0,n2=0,ttp;

struct Node{
  int sum;
  int area;
};

void push1(struct Node *p, int x1,int x2);

int main()
{
  
  int n,r,i,j,str1[N],all=0;
  char sank[N];
  struct Node A[M];
  A[0].sum = -1;
  scanf("%s",sank);
  
  for(i=0; ; i++){
    if(sank[i-1]=='/' && sank[i]!='/')ttp=r;
    if(sank[i]=='\\')push(str1,i);
    else if(sank[i]=='/'){
      r=pop(str1);
      if(r!=-1)push1(A,i,r);
    }
    if(sank[i]=='\0')break;
  }

  for(j=1; j<=n2; j++)all+=A[j].area;

  printf("%d\n",all);
  
  if(n2==0)printf("%d",n2);
  else {
    printf("%d ",n2);
    for(j=1; j<=n2; j++){
      printf("%d",A[j].area);
      if(j!=n2)printf(" ");
    }
  }
  printf("\n");
  return 0;
}

void push(int *p, int x)
{
  n1=n1+1;
  p[n1]=x;
}
		   
void push1(struct Node *p, int x1,int x2)
{
  int i,res=0;

  if(p[n2].sum<x2){
    n2=n2+1;
    p[n2].sum=x2;
    p[n2].area=x1-x2;
  }
  
  else {
    p[n2].area += x1-x2;
    res = n2;
    for(i=n2-1; i>=1; i--){
      if(p[i].sum > x2){
	p[n2].area += p[i].area;
	res = i;
      }
    }
    p[res].area = p[n2].area;
    p[res].sum = p[n2].sum;
    n2 = res;
  }
}
int empty(){
  if(n1==0) return 1;
  else return 0;
}

int pop(int *p)
{
  if(empty()==1) return -1;
  else {
    n1 = n1-1;
    return p[n1+1];
  }
}




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

// one-based numbering
struct UnionFind {
    vector<int> data;
    // i: (data[i] < 0) -> group size, (data[i] > 0) -> parent;
    UnionFind(int n) {
        data.resize(n+1, -1);
    }
    int find(int x) {
        if(data[x] < 0) return x;
        else return data[x] = find(data[x]);
    }
    int size(int x) {
        return -data[find(x)];
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, h, w; cin >> n >> h >> w;
    auto enh = [&](int i, int j) { return i; };
    auto enw = [&](int i, int j) { return h + j; };
    UnionFind uf(h+w);
    vector<array<int, 3>> arr;
    for (int i = 0; i < n; i++) {
        int r, c, a; cin >> r >> c >> a;
        arr.push_back({a, r, c});
    } 
    sort(arr.rbegin(), arr.rend());
    vector<bool> r(h+w+1, 1);
    long long ans = 0;
    for (auto &x: arr) {
        int p = uf.find(enh(x[1], x[2]));
        int q = uf.find(enw(x[1], x[2]));
        if (!uf.same(p, q)) {
            if (r[p] || r[q]) {
                r[p] = r[p] & r[q];
                r[q] = r[p];
                ans += x[0];
                uf.unite(p, q);
            }
        } else {
            if (r[p]) {
                r[p] = 0;
                ans += x[0];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2680
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

int needed_kaisu(long long a, long long N, long long *A) {
	int count = 0;
	for (long long i = 0; i < N; i++) {
		count += (A[i]+a-1) / a -1;
	}
	return count;
}


int main() {


	string S;
	int N;
	long long X,K,D;

	cin >> X>>K>>D;

	long long minm, minp;

	X = abs(X);
	
	minp = X%D;
	minm = D - X%D;

	long long n;
	n = X / D;

	long long ans;

	if ((K - n)%2 == 0) {
		if (K >= n) {
			ans = minp;
		}
		else {
			ans = min(abs(X - K*D), abs(X + K*D));
		}
	}

	if ((K - n)%2 == 1 || (K - n) % 2 == -1) {
		if (K >= n+1) {
			ans = minm;
		}
		else {
			ans = min(abs(X - K*D), abs(X + K*D));
		}
	}

	cout << ans;

	cin >> N;

	return 0;


}



Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

  int flower[100] = {0};
  int h[100];
  int status[100] = {0};
  int count = 0;

void func(int a, int b){

  for(int i = a; i < b; ++i){
    if(status[i] == 1) return;
  }

  int flag = 0;
  while(flag == 0){
    for(int i = a; i < b; ++i){
      flower[i]++;
      if(flower[i] == h[i]){
        status[i] = 1;
        flag = 1;
      }
    }
    count ++;
  }
  return;
}

int main(){

  int n;
  scanf("%d",&n);
  for(int i = 0; i < n ; ++i){
    scanf("%d",h+i);
    if(h[i] == 0) status[i] = 1;
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j <= i; ++j){
      func(j,n-i+j);
    }
  }

  printf("%d",count);
  return 0;

}


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

using namespace std;

struct node{
	long long x,p;
}a[100010];

bool cmp(node a,node b){
	return a.x<b.x;
}

long long n,s,ans;

int main(){
	scanf("%lld%lld",&n,&s);
	for (int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i].x,&a[i].p);
	sort(a+1,a+n+1,cmp);
	long long l=n,l1=1;
	while (l>=l1){
		if (a[l].x<=s){
			ans+=s-a[l1].x;
			break;
		}
		if (a[l1].x>=s){
			ans+=a[l].x-s;
			break;
		}
		ans+=a[l].x-a[l1].x;
		if (a[l1].p>=a[l].p)
			while (l>l1 && a[l1].p>=a[l].p)	a[l1].p+=a[l].p,l--;
		else
			while (l>l1 && a[l].p>a[l1].p)	a[l].p+=a[l1].p,l1++;
	}
	printf("%lld",ans);
	return 0; 
} 

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

int main() {
  int N, R, A;
  cin >> N >> R;
  
  if ( N < 10 ) {
    A = R + 100 * ( 10 - N );
  }  
  
  else {
    A = R;
  }  
  
  cout << A << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <math.h>

int main(void)
{
    int i;

    int data_num;
    scanf("%d", &data_num);

    int cnt = 0;

    while (data_num--) {
        int n;
        scanf("%d", &n);

        bool isPrime = true;

        if (n == 2) {
            isPrime = true;
        } else if (n % 2 == 0) {
            isPrime = false;
        } else {
            for (i = 3; i <= sqrt(n); i += 2) {
                if (n % i == 0) {
                    isPrime = false;
                    break;
                }
            }
        }

        if (isPrime == true) {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 596
fun main(args: Array<String>){
    val s = readLine()!!.split(" ")[0]
    val ss = s.toCharArray().toMutableList()
    ss.sort()
    if (ss[0] == ss[1] && ss[2] == ss[3] && ss[1] != ss[2]) println("Yes")
    else println("No")
}

Measured memory_bytes: 37860
#include <stdio.h>

int main(void){
    int A,B,K;
    int i,j;

    scanf("%d %d %d",&A,&B,&K);
    if(B - A + 1 > 2 * K){
        for(i = A;i < A + K; ++i)   printf("%d\n",i);
        for(j = B - K + 1;j <= B; ++j)   printf("%d\n",j);
    }
    else{
        for(i = A;i <= B; ++i)  printf("%d\n",i);
    }
    return 0;
}


Measured memory_bytes: 128
s = input()
ans = len(s)
for v in set(s):
    cur = 0
    vstep = 0
    for i in range(len(s)):
        if s[i] != v:
            cur += 1
        else:
            vstep = max(cur,vstep)
            cur = 0
    vstep = max(cur,vstep)
    ans = min(ans,vstep)
print(ans)

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';
constexpr int INF = 1e9;

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

    int H, W;
    cin >> H >> W;

    map<int, int> dp;
    multiset<int> memo;
    memo.insert(INF);
    for (int i = 0; i < W; i++) {
        dp[i] = 0;
        memo.insert(0);
    }

    for (int i = 1; i <= H; i++) {
        int a, b;
        cin >> a >> b;
        --a;
         
        int val = INF;
        {
            auto it = dp.lower_bound(a);
            if (it != dp.begin()) {
                --it;
                val = it->second + b - it->first;
            }
        }
        
        vector<int> v;
        for (auto it = dp.lower_bound(a); it != dp.end(); ++it) {
            if (it->first >= b) break;
            v.push_back(it->first);
            if (b < W) {
                val = min(val, it->second + b - it->first);
            }
        }

        for (int x : v) {
            memo.erase(memo.find(dp[x]));
            dp.erase(x);
        }
        if (val < INF) {
            if (b < W) {
                if (dp.find(b) == dp.end()) {
                    dp[b] = val;
                    memo.insert(val);
                } else if (dp[b] > val) {
                    memo.erase(memo.find(dp[b]));
                    dp[b] = val;
                    memo.insert(val);
                }
            }
        }

        int ans = *memo.begin() + i;
        cout << (ans >= INF ? -1 : ans) << newl;
    }

    return 0;
}

Measured memory_bytes: 22400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

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

  bool flag = true;
  rep(i, n){
    int a;
    cin >> a;

    if (a % 2 == 0 && flag)
    {
      if (a % 3 == 0 || a % 5 == 0)
      {
        flag == true;
      } else {
        flag = false;
      }
    }
  }

  if (flag) cout << "APPROVED" << endl;
  else  cout << "DENIED" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
    }
    else{
        cout << n-k << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    //cout << set~~ << fixed << 4.2 << endl; 
    cout << setprecision( 5 ) << fixed;
    cout << a/b << " " << a%b << " " << 1.*a/b << endl;
       
    return 0;
}

Measured memory_bytes: 1248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0011
    {
        public static void Main(string[] args)
        {
            int line = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            int[] values = new int[line];

            for (int i = 0; i < line; i++)
            {
                values[i] = i + 1;
            }

            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(',');
                int a = int.Parse(s[0]);
                int b = int.Parse(s[1]);

                int value = values[a - 1];
                values[a - 1] = values[b - 1];
                values[b - 1] = value;
            }

            for (int i = 0; i < line; i++)
            {
                Console.WriteLine(values[i]);
            }

        }
    }
}

Measured memory_bytes: 5592
#include<stdio.h>

int main (){
	int n;
	scanf("%d", &n);
	int m = 1000;
	int c;
	if(n < m){
		c = m - n;
	}
	else{
		if(n % m == 0){
			c = n % m;
		}
		else{
			c = m - (n % m);
		}
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int N, A, B;
int kokunai = 0;
int kaigai = 0;
string s;

string solve(char c){
  if(c == 'a') if(kokunai+kaigai < A+B){
    kokunai++;
    return "Yes";
  }
  if(c == 'b') if(kokunai+kaigai < A+B && kaigai < B){
    kaigai++;
    return "Yes";
  }
  return "No";
}

signed main() {
  cin >> N >> A >> B >> s;

  REP(i, N) cout << solve(s[i]) << endl;

  return 0;
}

Measured memory_bytes: 896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskC   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int[] sa = new int[N];
        int mae = in.nextInt();
        for(int i = 0; i<N; i++){
            sa[i] = Math.abs(mae - in.nextInt());
        }
        int ans = sa[0];
        for(int i = 1; i<N; i++){
            ans = gcd(ans, sa[i]);
        }
        out.println(ans);
    }

public   static int gcd(int num1, int num2) {
        if(num2 == 0) {
            return num1;
        } else {
            return gcd(num2, num1 % num2);
        }
    }

}
}



Measured memory_bytes: 50940
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        List<long[]> ls = new List<long[]>();

        public void ParseLines() {
            n = int.Parse(InputReader.ReadLine());
            foreach (var i in Enumerable.Range(0, n))
            {
                ls.Add(InputReader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray());
            }

        }

        public class Table
        {
            public long PointA { get; set; } = 0;
            Person A { get; }
            Person B { get; }
            int[] _dishes;

            public Table(Person a, Person b, int ndish)
            {
                this.A = a;
                this.B = b;
                this._dishes = Enumerable.Range(0, ndish).ToArray();
            }

            public long CalculatePoint()
            {
                PointA += _dishes
                .Select(x => A.Taste[x] + B.Taste[x])
                .OrderBy(x => x).Reverse()
                .Where((x, i) => i % 2 == 0)
                .Sum();

                PointA -= B.Taste.Values.Sum(x => x);
                return PointA;
            }


        }


    public class Person{
            public Dictionary<int, long> Taste { get; }
            public long HappyScore { get; set; } = 0;

            public Person(Dictionary<int, long> taste)
            {
                Taste = taste;
            }

            public void EatWith(Person other)
            {
                var tmp = Taste.Keys
                .ToDictionary(key => key, key => this.Taste[key] + other.Taste[key])
                .OrderBy(x => -x.Value).Select(x => x.Key).Select((x, id) => {
                    if (id % 2 == 0)
                    {
                        this.HappyScore += this.Taste[x];
                    }
                    else
                    {
                        other.HappyScore += other.Taste[x];
                    }
                    return 0;
                });

            }

        }


        public string Resolve()
        {
            var a = new Person(Enumerable.Range(0, n).ToDictionary(i => i, i => ls[i][0]));
            var b = new Person(Enumerable.Range(0, n).ToDictionary(i => i, i => ls[i][1]));

            var table = new Table(a, b, n);

            return table.CalculatePoint().ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 42696
import sys

N = int(input())
c = list(str(input()))

left = [-1, False]  # 一番左の W　を記録
right = [len(c), False]  # 一番右の R を記録
count = 0

for i in range(len(c)):
    if not left[1]:
        left[0] += 1
        if c[left[0]] == 'W':
            left[1] = True

    if not right[1]:
        right[0] -= 1
        if c[right[0]] == 'R':
            right[1] = True

    if left[1] and right[1]:
        if left[0] > right[0]:
            break
        count += 1
        left[1] = False
        right[1] = False

    # if c[i] == 'W':
    #     left = i
    # if c[len(c) - 1 - i] == 'R':
    #     right = len(c) - 1 - i
    #
    # if (left is not None) and (right is not None) and (left < right):
    #     # print(f'left{left}, right {right}')
    #     count += 1
    #     left = None
    #     right = None

print(count)



Measured memory_bytes: 77528
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int x;
  cin >>x;
  int y = 0;
  int ans = 0;
  while (y < x){
    ans += 1;
    y += ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3536
# include<iostream>
# include<cstdio>
# include<cstring>
# include<set>
using namespace std;
set<string>s;
string a[200048],str;
int k;
int main() {
	cin>>str>>k;
	int len=str.length();
	for (int i=0; i<len; i++)
		for (int j=1; j<=5; j++) {
			if (i+j>len) continue;
			s.insert(str.substr(i,j));
		}
	for (int i=1; i<=k-1; i++) s.erase(s.begin());
	cout<<(*(s.begin()))<<endl;
	return 0;
}

Measured memory_bytes: 3200
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    auto s = sread();
    auto before = (s.length - 1) / 2;
    auto after = (s.length + 3) / 2 - 1;
    // writeln(s[0 .. before]);
    // writeln(s[after .. $]);
    if(s.is_reverse() && is_reverse(s[0 .. before]) && is_reverse(s[after .. $]))
        writeln("Yes");
    else
        writeln("No");
}

bool is_reverse(string s)
{
    bool ret = true;
    foreach(i; iota(s.length))
    {
        ret &= (s[i] == s[$ - 1 - i]);
    }
    return ret;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;
const ll inf = 1e18 + 42;

struct jewel {
	int c; ll val; int type;
	bool operator<(const jewel &o) const {
		// return tie(o.val, o.type) < tie(val, type);
		return o.val < val;
	}
};

vector<jewel> all_jewels;
vector<ll> jewels[N];
multiset<ll> used_pairs, used_singles;
multiset<ll, greater<ll>> avail_singles, triplets;
ll res[N];

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		int c, v;
		cin >> c >> v;
		jewels[c].pb(v);
	}
	for (int c = 1; c <= k; ++c) {
		sort(jewels[c].begin(), jewels[c].end(), greater<int>());
		int t = jewels[c].size();
		if (t >= 3) {
			triplets.insert(jewels[c][0] + jewels[c][1] + jewels[c][2]);
		}
		all_jewels.pb({c, jewels[c][0] + jewels[c][1], 2});
		for (int j = 2; j < t; ++j) {
			all_jewels.pb({c, 2 * jewels[c][j], 1});
		}
	}
	sort(all_jewels.begin(), all_jewels.end());
	avail_singles.insert(-inf);
	triplets.insert(-inf);
	used_pairs.insert(inf);
	used_singles.insert(inf);
	ll sum = 0, x = 0;
	for (auto &j : all_jewels) {
		int c = j.c;
		if (j.type == 2) {
			ll ans = -1;
			ans = max(ans, sum + *avail_singles.begin());
			ans = max(ans, sum - *used_pairs.begin() + *triplets.begin());
			ans = max(ans, sum - *used_singles.begin() + j.val);
			res[x + 1] = ans;
			sum += j.val;
			x += 2;
			int t = jewels[c].size();
			for (int i = 2; i < t; ++i) {
				avail_singles.insert(jewels[c][i]);
			}
			if (t >= 3) {
				triplets.erase(triplets.find(jewels[c][0] + jewels[c][1] + jewels[c][2]));
			}
			used_pairs.insert(j.val);
		} else {
			j.val /= 2;
			sum += j.val;
			++x;
			avail_singles.erase(avail_singles.find(j.val));
			used_singles.insert(j.val);
		}
		res[x] = sum;
	}
	for (int i = 1; i <= n; ++i) {
		cout << res[i] << '\n';
	}
}

Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string A,B;
    int i;
    for(i=0;i<2;i++)A+=s.at(i);
    for(i=2;i<4;i++)B+=s.at(i);
    //cout << A <<B<<endl;
    int a,b;
    a=atoi(A.c_str());
    b=atoi(B.c_str());
    if(a>12&&b<13&&0<b)cout << "YYMM" <<endl;
    else if(a==0&&b<13&&0<b)cout << "YYMM" <<endl;
    else if(0<a&&a<13&&b>12)cout << "MMYY" <<endl;
    else if(0<a&&a<13&&b==0)cout << "MMYY" <<endl;
    else if(0<a&&a<13&&0<b&&b<13)cout << "AMBIGUOUS" <<endl;
    else cout << "NA" <<endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define SIZE 101
#define SACK_SIZE 10001
int S, N;
int w[SIZE], v[SIZE], dp[SIZE][SACK_SIZE];
//int opt_val;
int mmax(int a, int b){
	if (a > b) return a;
	else return b;
}void init(){
	int i, j;
	for (i = 0; i < SIZE; i++){
		for (j = 0; j < SACK_SIZE; j++){
			dp[i][j] = -1;
		}
	}
}
int solve(int index, int cap){

	if (dp[index][cap] >= 0){
		return dp[index][cap];
	}
	if (index == N){
		return 0;
	}
	int left, right;

	left = solve(index + 1, cap);

	if (cap - w[index] >= 0){
		right = solve(index + 1, cap - w[index]) + v[index];
	}
	else
	{
		right = 0;
	}

	dp[index][cap] = mmax(left, right);
	return dp[index][cap];
}
int main(void){

	while (scanf("%d %d", &N, &S) != EOF){
		for (int i = 0; i < N; i++){
			scanf("%d %d", &v[i], &w[i]);
		}
		init();
		int value = solve(0, S);
		printf("%d\n", value);
	}
	return 0;
}

Measured memory_bytes: 6688
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public 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();
        int d = sc.nextInt();
        
        int count = 0;
        for (int i = a; i <= b; i++) {
			for (int j = c; j <= d; j++) {
				if (i == j) {
					count++;
					break;
				}
			}
		}
        
        if (count > 0) {
        	count--;
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 21332