akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> vec(n, vector<int>(m+1));
    for (vector<int>& arr: vec)
        for (int& it: arr)
            cin >> it;
    int ans = INT_MAX;
    for (int ms = 0; ms < (1 << n); ms++) {
        vector<int> kek(m, 0);
        int cc = 0;
        for (int i = 0; i < n; i++) {
            if (((ms >> i) & 1) == 1) {
                for (int j = 0; j < m; j++)
                    kek[j] += vec[i][j+1];
                cc += vec[i][0];
            }
        }
        bool ok = true;
        for (int it: kek)
            ok &= it >= x;
        if (!ok) continue;
        ans = min(ans, cc);
    }
    cout << (ans == INT_MAX ? -1 : ans);

    return 0;
}


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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())

typedef long long ll;

using namespace std;

int main(){
  int n;
  cin >> n;
  rep3(i,n,1000){
    if(i%10 == (i/10)%10 && i%10 == (i/100)%10){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
e = [int(input())]

def f(n):
    if n % 2 == 0:
        return n // 2
    else :
        return 3 * n + 1


for i in range(10000):
    e.append(f(e[i]))
    for j in range(0, len(e) - 1):
        if e[-1] == e[j] :
            print(len(e))
            break
    else:
        continue
    break

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  map<string,pair<int,int>> mp;
  rep(i,n){
    string s;
    int l,r;
    cin >> s >> l >> r;
    mp[s]={l,r};
  }
  cin >> n;
  stack<bitset<256>> st;
  bitset<256> a,b;
  rep(i,n){
    string s;
    cin >> s;
    if(mp.find(s)==mp.end()){
      if(s=="+"){
        b=st.top();st.pop();a=st.top();st.pop();
        bitset<256> bit;
        rep(i,256){
          if(!a.test(i)) continue;
          rep(j,256){
            if(!b.test(j)) continue;
            bit.set((i+j)%256);
          }
        }
        st.push(bit);
      }else if(s=="-"){
        b=st.top();st.pop();a=st.top();st.pop();
        bitset<256> bit;
        rep(i,256){
          if(!a.test(i)) continue;
          rep(j,256){
            if(!b.test(j)) continue;
            bit.set((i-j+256)%256);
          }
        }
        st.push(bit);
      }else if(s=="*"){
        b=st.top();st.pop();a=st.top();st.pop();
        bitset<256> bit;
        rep(i,256){
          if(!a.test(i)) continue;
          rep(j,256){
            if(!b.test(j)) continue;
            bit.set((i*j)%256);
          }
        }
        st.push(bit);
      }else if(s=="/"){
        b=st.top();st.pop();a=st.top();st.pop();
        if(b.test(0)){
          cout << "error" << endl;
          return 0;
        }
        bitset<256> bit;
        rep(i,256){
          if(!a.test(i)) continue;
          rep(j,256){
            if(!b.test(j)) continue;
            bit.set((i/j)%256);
          }
        }
        st.push(bit);
      }else{
        int num=stoi(s);
        bitset<256> bit;
        bit.set(num);
        st.push(bit);
      }
    }else{
      auto p = mp[s];
      bitset<256> bit;
      repp(i,p.first,p.second+1) bit.set(i);
      st.push(bit);
    }
  }
  cout << "correct" << endl;
  return 0;
}



Measured memory_bytes: 3240
#include <stdio.h>

int main() {
	int a, b,d,r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a/(double)b;
	printf("%d %d %f\n", d, r, f);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	string s, t;
	int q, a, b, c, d;
	cin>>s>>t>>q;
	int snum[114514], tnum[114514];
	snum[0]=0;
	REP(i, s.size()){
		snum[i+1]+=snum[i]+(s[i]=='A' ? 1 : 2);
	}
	tnum[0]=0;
	REP(i, t.size()){
		tnum[i+1]+=tnum[i]+(t[i]=='A' ? 1 : 2);
	}
	REP(i, q){
		cin>>a>>b>>c>>d;
		cout<<((snum[b]-snum[a-1])%3==(tnum[d]-tnum[c-1])%3 ? "YES" : "NO")<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e10
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> bool chmax(T &a, T &b){ if(a<b) { a=b; return 1; }}
template<typename T> bool chmin(T &a, T &b){ if(b<a) { a=b; return 1; }}
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T arrdebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, tmp;
    vector<int> evenind(100001, 0);
    vector<int> oddind(100001, 0);
    cin >> n;
    rep(i, n){
        cin >> tmp;
        if(i%2==0) oddind[tmp]++;
        else evenind[tmp]++;
    }

    int evenmax = 0;
    int oddmax = 0;
    bool flg = false;
    int buf = 0;
    rep(i, 1e5+1){
        if(evenind[i] == 0 && oddind[i] == 0) continue;
        if(evenind[i] > 0 && oddind[i] > 0){
            if(evenind[i] > oddind[i]){
                evenmax = evenind[i];
            }else if(evenind[i] < oddind[i]){
                oddmax = oddind[i];
            }else{
                if(flg){
                    evenmax = max(evenmax, evenind[i]);
                    oddmax = max(oddmax, oddind[i]);
                    continue;
                }
                flg = true;
                buf = i;
            }
            continue;
        }
        evenmax = max(evenmax, evenind[i]);
        oddmax = max(oddmax, oddind[i]);
    }

    if(flg){
        //cout << evenmax << " " << oddmax << endl;
        if(evenmax > oddmax){
            oddmax = oddind[buf];
        }else{
            evenmax = evenind[buf];
        }
    }

    cout << n/2-evenmax + ceil(n, 2)-oddmax << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define mod 1000000007
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x; i<n; i++)
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)),x.resize(distance(x.begin(),unique(all(x))))
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// #define inf 100000000000000
using namespace std;
ll min(ll a,ll b)
{
 return a<b?a:b;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    f(i,0,n)
    cin>>arr[i];
    
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    
    f(i,2,n)
    {
        ll mn=-1;
        f(j,1,min(k+1,i+1))
        {
            ll tt = abs(arr[i]-arr[i-j]);
            tt +=dp[i-j];
            if(mn==-1)
            mn=tt;
            else
            {
                if(tt<mn)
                mn=tt;
            }
        }
        dp[i]=mn;
    }
    cout<<dp[n-1];

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    while (true) {
        int x, y, s;
        cin >> x >> y >> s;
        if (x == 0) break;
        int ans = 0;
        for (int i=1; i<=1000; i++) {
            for (int j=1; j<=1000; j++) {
                int sum = i * (100 + x) / 100 + j * (100 + x) / 100;
                if (sum == s) {
                    ans = max(ans, i * (100 + y) / 100 + j * (100 + y) / 100);
                }
            }
        }
        cout << ans << '\n';
}
    return 0;
}


Measured memory_bytes: 3068
def strcmp(x, y):
    short = min(len(x), len(y))
    for i in range(short):
        if ord(x[i]) < ord(y[i]): #xの方が辞書順で小さい
            return 0
        elif ord(x[i]) > ord(y[i]):
            return 1
    if short == len(x):
        return 0
    else:
        return 1

s = input()
lens = len(s)
K = int(input())
jisho = [] #辞書順に文字列を格納
#列挙するパターン: 25000通り以下
#K文字以下の文字列を全て格納する
for i in range(1, K+1):
    for j in range(lens-i+1):
        temp = s[j:j+i]
        if temp not in jisho:
            jisho.append(temp)

size = len(jisho)-1
for i in range(K):
    for j in range(size, 0, -1):
        if strcmp(jisho[j], jisho[j-1]) == 0:
            temp = jisho[j-1]
            jisho[j-1] = jisho[j]
            jisho[j] = temp
print(jisho[K-1])

Measured memory_bytes: 3956
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    int i,j,f=0;
    char s[1000];
    scanf("%s",&s);
    j=strlen(s);
    for(i=0;i<j;i++)
    {
        if(i%2==0&&s[i]=='L'){
            f=1;
            break;
        }
        else if(i%2!=0&&s[i]=='R')
        {
            f=1;
            break;
        }
    }
    if(f==1)
    {
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
  int a, b, n;
  while(cin >> a >> b >> n){
    int ans = 0;
    a %= b;
    
    for(int i = 0 ; i < n ; i++){
      a *= 10;
      ans += a / b;
      //cout << a / b << endl;
      a %= b;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
s=input()
n=len(s)
ss=''

def even_strings(a):
  n=len(a)
  if n%2!=0:
    return False
  
  if a[0:n//2]==a[n//2:n]:
    return True
  else:
    return False

for i in range(n-1): #手前までやる､最後まではやらない 1文字以上だから
  ss+=s[i]
  if even_strings(ss):
    ret=i
    
print(ret+1)
    

Measured memory_bytes: 3060
#include<cstdio>
int main()
{
	int n,x,max=0,min=1000000;
	scanf("%d",&n);
	while(n--)
        {
        scanf("%d",&x);
        if(x>max) max=x;
        if(x<min) min=x;
        }
        printf("%d\n",max-min);
	return 0;
}

Measured memory_bytes: 128
import math
n = int(input())
sum_ij = 1000000000000
sq_n = int(math.sqrt(n))
for i in range(1, sq_n+1):
  if (n%i==0):
    j = int(n/i)
    if(i+j < sum_ij):
      sum_ij = i+j-2
print(int(sum_ij))

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

using namespace std;

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

    int n;
    cin >> n;

    struct Restaurant {
        string city;
        int score, id;
        // 比較関数が必要
        bool operator<(const Restaurant &rhs) {
            return (this->city < rhs.city) ||
                (this->city == rhs.city && this->score >= rhs.score);
        }
    };

    vector<Restaurant> rs(n);
    for (int i = 0; i < n; ++i) {
        cin >> rs[i].city >> rs[i].score;
        rs[i].id = i + 1;
    }

    sort(rs.begin(), rs.end());

    for (const auto &r : rs)
        cout << r.id << '\n';

    return 0;
}

Measured memory_bytes: 256
print(*[11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451,1471,1481,1511,1531][:int(input())],sep=" ")


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n,k,N;
int main(void){
    cin>>n>>k;
    N=n-1+(n-1)*(n-2)/2-k;
    if(N-n+1<0){
        cout<<"-1"<<endl;
        return 0;
    }
    cout<<N<<endl;
    for(int j=1;j<n;j++){
        for(int k=j+1;k<=n;k++){
            if(N>0)cout<<j<<" "<<k<<endl;
            N-=1;
        }
    }
}


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

ll solve(ll N, ll A, ll B, ll C, ll D, unordered_map<ll, ll> &memo) {
    // cout << N << endl;
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.find(N) != memo.end()) return memo[N];
    ll N2 = (N / 2) * 2;
    ll N3 = (N / 3) * 3;
    ll N5 = (N / 5) * 5;
    ll ret = 1e18;
    if (N < ret / D) ret = N * D;
    ret = min(ret, solve(N2 / 2, A, B, C, D, memo) + A + D * abs(N - N2));
    if (N % 2 != 0) ret = min(ret, solve((N2 + 2) / 2, A, B, C, D, memo) + A + D * abs(N2 + 2 - N));
    ret = min(ret, solve(N3 / 3, A, B, C, D, memo) + B + D * abs(N - N3));
    if (N % 3 != 0) ret = min(ret, solve((N3 + 3) / 3, A, B, C, D, memo) + B + D * abs(N3 + 3 - N));
    ret = min(ret, solve(N5 / 5, A, B, C, D, memo) + C + D * abs(N - N5));
    if (N % 5 != 0) ret = min(ret, solve((N5 + 5) / 5, A, B, C, D, memo) + C + D * abs(N5 + 5 - N));
    return memo[N] = ret;
}

int main() {
    int T; cin >> T;
    for (int i = 0; i < T; ++i) {
        ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
        unordered_map<ll, ll> memo;
        ll ans = solve(N, A, B, C, D, memo);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4096
import math

data = input()
data = data.split()
n = data[0]
m = data[1]
v1 = 0
v2 = 0

if int(n) > 1:
	v1 = (math.factorial(int(n)) // (math.factorial(int(n) - 2) * math.factorial(2)))

if int(m) > 1:
    v2 = (math.factorial(int(m)) // (math.factorial(int(m) - 2) * math.factorial(2)))

print(v1+v2)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int s = int.Parse(Console.ReadLine());
        var list = new List<int>();
        list.Add(s);
        int ans = 1;
        while (true)
        {
            if (s % 2 == 0)
            {
                s = s / 2;
                list.Add(s);
            }
            else
            {
                s = 3 * s + 1;
                list.Add(s);
            }
            if (list.Where(f => f == s).Count() >= 2) break;
            else ans++;
        }
        Console.WriteLine(ans+1);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n, m;
  cin >> n >> m;
  rep(i, m) {
    ll a;
    cin >> a;
    n -= a;
  }
  if (n >= 0) cout << n << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3612
//abc164-D//
//#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
//#include <string.h>
using namespace std;

int main(){
    //input
    vector<vector<int>>a(3,vector<int>(3));
    rep(i,3){
    rep(j,3){
        cin >> a[i][j];
    }
    }
    //bingo
    int n;
    cin >> n;
    rep(i,n){
        int x;
        cin >>x;
        rep(i,3){
        rep(j,3){
            if(a[i][j] == x)
                a[i][j]=0;
        }
        }
    }
    //judge
    bool bingo = false;
    vector<int>tate(3);
    vector<int>yoko(3);
    vector<int>naname(2);
    
    rep(i,3){
    rep(j,3){
        yoko[i]+=a[i][j];
    }
        if(yoko[i]==0){
            bingo = true;
            break;
        }
            
    }
    
    if(bingo){
    }
    else{
        rep(j,3){
        rep(i,3){
            tate[j]+=a[i][j];
        }
            if(tate[j]==0){
                bingo = true;
                break;
            }
                
        }
    }
         
    if(bingo){
    }
    else{
        naname[0] = a[0][0]+a[1][1]+a[2][2];
        naname[1] = a[0][2]+a[1][1]+a[2][0];
        
        rep(i,2){
            if(naname[i]==0){
                bingo = true;
                break;
            }
        }
    }
    
    if(bingo)
      cout << "Yes" <<endl;
    else
        cout <<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
const int mxn = 17;
ll a[mxn][mxn], dp[(1<<17)];
vector<int> mask_of_k_bits[mxn];


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

	int N; cin>>N;
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++) cin>>a[i][j];

	for(int i=1; i<(1<<N); i++) {
		vector<int> taken;
		for(int j=0; j<N; j++)
			if(i&(1<<j)) taken.push_back(j);
		for(int j=0; j<(int) taken.size(); j++)
			for(int k = j+1; k<(int) taken.size(); k++)
				dp[i]+=a[taken[j]][taken[k]];
	}

	for(int i=1; i<(1<<N); i++) {
		int cnt = 0;
		for(int j=0; j<N; j++)
			if(i&(1<<j)) cnt++;
		mask_of_k_bits[cnt].push_back(i);
	}

	//k is the number of set bit of the mask
	for(int k=2; k<=N; k++) {
		for(auto mask:mask_of_k_bits[k])
			if(k==2) dp[mask] = max(dp[mask], 0ll); 
			else {
				for(int s=mask; s>0; s=(s-1)&mask)
					dp[mask] = max(dp[mask], dp[s]+dp[mask^s]);
			}
	}

	cout << dp[(1<<N)-1] << '\n';
	return 0;

}

Measured memory_bytes: 1152
import math
import itertools
import statistics
#import numpy as np
import collections

#n = int(input())
n, m = list(map(int, input().split()))
a =  list(map(int, input().split()))
total = sum(a)

#print(total)
p = total/(4*m)
count = 0

for i in range(n):
    if a[i] >= p:
        count += 1


if count >= m:
    print("Yes")
else:
    print("No")

#print(p)
#print(count)

Measured memory_bytes: 5660
#include<bits/stdc++.h>
#define ll long long
#define R register
using namespace std;
const int N =2e6+200;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
char s[N];
int n;
int main()
{
	scanf("%s", s+1);int ans=0; n=strlen(s+1);
	for(R int i=1; i<=n/2; i++)
	{
		if(s[i]!=s[n-i+1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;
int main() {
	int n; cin >> n;
	for (int i = 0; i <= n; i++) {
		if ((i * 1.08) < n + 1 && (i * 1.08) >= n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    if(h < w){
        //wずつぬっていきたい
        cout << (n+w-1)/w << endl;
    }else{
        cout << (n+h-1)/h << endl;
    }

}


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


int main()
{
	std::string s;

	std::cin >> s;


	int a, b, c, d;
	char op1, op2, op3;

	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';

	std::string op = "+-";

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

				if (j == 0) {
					ans += c;
				}
				else {
					ans -= c;
				}

				if (k == 0) {
					ans += d;
				}
				else {
					ans -= d;
				}

				if (ans == 7) {
					std::cout << a << (i == 0 ? "+" : "-") << b << (j == 0 ? "+" : "-") << c << (k == 0 ? "+" : "-") << d << "=7" << std::endl;
					return 0;
				}
				ans = 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
typedef struct {
    ll lv;
    ll rv;
} Q;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll P[100010] = {};
    rep(i,0,N) cin >> P[i];
    vector<Q> arr(100010);
    arr[0] = (Q){-1, 1};
    arr[1] = (Q){0, 2};
    ll pos[100010] = {};
    rep(i,0,N){
        arr[i+2] = (Q){i+1, i+3};
        pos[P[i]] = i+2;
    }
    arr[N+2] = (Q){N+1, N+3};
    arr[N+3] = (Q){N+2, N+4};

    ll ans = 0;
    rep(n,1,N){
        ll p = pos[n];
        ll lv = arr[p].lv;
        ll rv = arr[p].rv;
        if(lv != 1){
            ans += n * (lv - arr[lv].lv) * (rv - p);
        }
        if(rv != N+2){
            ans += n * (arr[rv].rv - rv) * (p - lv);
        }

        arr[lv].rv = arr[p].rv;
        arr[rv].lv = arr[p].lv;
    }
    print(ans);



    
}

Measured memory_bytes: 3456
#include <stdio.h>
#define true 1

int main(void)
{
    int n=0;
    int boss[200001]={};
    int bossNum[200001]={};
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        scanf("%d",&boss[i]);
        bossNum[boss[i]]+=1;
    }

    for(int i=1;i<=n;i++){
        printf("%d\n",bossNum[i]);
    }

    return 0;
}


Measured memory_bytes: 3284
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#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 ll;
typedef pair<ll, ll> mp;

//未AC

int main(void){
	bool can=true;
	int n,a[100010],A=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	if(abs(a[0]-a[n-1])==0){
		if(a[0]==n-1 || n>=2*a[0]){
			can=true;
		}else{
			can=false;
		}
	}else if(abs(a[0]-a[n-1])==1){
		rep(i,n){
			if(a[0]==a[i]){
				A++;
			}else{
				break;
			}
		}
		if(a[n-1]>A && n-A>=2*(a[n-1]-A)){
			can=true;
		}else{
			can=false;
		}
	}else{
		can=false;
	}
	if(can){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vll;
typedef vector<vector<long long>> vvll;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e8);
const double eps9 = 1e-9;


int main() {
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((a + b + c) >= 22 ? "bust" : "win");
	return 0;
}

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

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

  int b,w;
  b = 0;
  w = 0;
    
  for(int i = 0 ; i < s.size() ; i++){
    if(s.at(i) == '1'){
      b++;
    }
    else {
      w++;
    }
  }
  
  int Ans = min(b,w)*2 ;
  
  cout << Ans << endl;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, x; cin >> n >> x;
	vector<int> l(n + 1);
	rep(i,n){
		int a; cin >> a;
		l.at(i + 1) = l.at(i) + a;
	}
	rep(i,n){
		if(l.at(n) <= x){
			cout << n + 1 << endl;
			break;
		}
		if(l.at(i + 1) > x){
			cout << i + 1 << endl;
			break;
		}
	}
} 

Measured memory_bytes: 256
import sys
x,N=list(map(int, input().split()))
if N==0:
  print(x)
  sys.exit()
p=list(map(int, input().split()))


z=float("inf")
ans_temp=[0,0]
ans=[0,0]

y=[i for i in range(-1,102) if i not in p]

for i in y:
  if z>abs(x-i):
    ans[0]=abs(x-i)
    ans[1]=i
  elif z==abs(x-i):
    ans_temp[0]=abs(x-i)
    ans_temp[1]=i
    if ans_temp[1]<ans[1]:
      ans[1]=ans_temp[1]
  z=abs(x-i)
print(ans[1])

Measured memory_bytes: 9192
n = int(input())
h = list(map(int, input().split()))

for i in reversed(range(1, len(h))):
  if h[i-1] > h[i]:
    h[i-1] = h[i-1] - 1


ans = 'Yes'
for i in reversed(range(1, len(h))):
  if h[i-1] > h[i]:
     ans = 'No'
print(ans)

Measured memory_bytes: 63856
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> qe;
const int N=1e5+5;
vector<int> ve[N];
int main()
{
	int n,m;
	cin>>n>>m;
	int a,b;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		if(m-a+1>0) ve[m-a+1].push_back(b);
	}
	int sum=0;
	for(int i=m;i>=1;i--)
	{
		for(int j=0;j<ve[i].size();j++)
		{
			qe.push(ve[i][j]);
		}
		if(qe.size())
		{
			sum+=qe.top();
			qe.pop();
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 8992
#include<iostream>
#include <stdio.h>
using namespace std;

int main(){
    int n,x;
    int c;
    int i,j,k;

    for (;;){
        cin >> n >> x;
        c=0;
        if (n==0 && x==0)break;
        for (i=0;i<n;i++){
            for (j=0;j<n;j++){
                for (k=0;k<n;k++){
                    if (i + j + k + 3 == x){
                        if (i==j || j==k || i==k){
                        
                        }else{
                            //cout << i + 1 <<" " << j + 1<< " " << k + 1<< endl;
                            c = c + 1;
                        }
                    }
                }  
            }    
        }
        cout << c/6 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3116
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	class Line implements Comparable<Line>{
		int h, l, r;

		Line(int h, int l, int r) {
			this.h = h;
			this.l = l;
			this.r = r;
		}

		@Override
		public int compareTo(Line o) {
			if (this.h != o.h) return o.h - this.h;
			if (this.l != o.l) return this.l - o.l;
			return this.r - o.r;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int k = sc.nextInt();
			if ((n | m | k) == 0) break;

			int[] a = new int[n];
			Line[] l = new Line[m];
			for (int i = 0; i < n; i++) {
				a[i] = i + 1;
			}
			for (int i = 0; i < m; i++) {
				l[i] = new Line(sc.nextInt(), sc.nextInt() - 1, sc.nextInt() - 1);
			}
			Arrays.sort(l);

			for (int i = 0; i < m; i++) {
				int id1 = l[i].l;
				int id2 = l[i].r;
				int tmp = a[id1];
				a[id1] = a[id2];
				a[id2] = tmp;
			}

			for (int i = 0; i < n; i++) {
				if (a[i] == k) {
					System.out.println(++i);
					break;
				}
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

typedef long long ll;

const int Maxn = 2005;
const int mod = 1000000007;

int C[Maxn][Maxn];
int dp[Maxn][Maxn][2];
int n, k;

int Solve(int b, int r)
{
    if (abs(b - r) > 1) return 0;
    if (b == 0 && k > 0 || r == 0 && n - k > 0 || b > k || r > n - k) return 0;
    int res = b == r? 2: 1;
    if (b != 0) res = ll(res) * C[k - 1][b - 1] % mod;
    if (r != 0) res = ll(res) * C[n - k - 1][r - 1] % mod;
    return res;
}

int main()
{
    for (int i = 0; i < Maxn; i++) {
        C[i][0] = C[i][i] = 1;
        for (int j = 1; j < i; j++)
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    }

    scanf("%d %d", &n, &k);
    for (int i = 1; i <= k; i++) {
        int res = 0;
        for (int j = 0; j <= n - k; j++)
            res = (res + Solve(i, j)) % mod;
        printf("%d\n", res);
    }
    return 0;
}


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

int main() {
  int a[3] = {};
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if( (3*a[2])%2 == (a[0]+a[1]+a[2])%2 ){
    int ans = ((a[2] - a[1]) + (a[2] - a[0]) + 1) / 2;
    cout << ans << endl;
  }else{
    int ans = ((a[2] - a[1]) + (a[2] - a[0]) + 3) / 2;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int SIZE = 100005;
		boolean table[] = new boolean[SIZE];
		boolean zero_FLG = false;

		StringBuilder ans = new StringBuilder();
		Queue<Info> Q = new ArrayDeque<Info>();

		while(true){

			int N = scanner.nextInt();
			int K = scanner.nextInt();

			if(N == 0 && K == 0)break;

			Q.clear();

			zero_FLG = false;

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

				table[i] = false;
			}

			for(int loop = 0; loop < K; loop++){

				int tmp = scanner.nextInt();
				if(tmp != 0){

					table[tmp] = true;

				}else{

					zero_FLG = true;
				}
			}

			int maximum = 0,count;
			for(int i = 1; i <= N; ){
				if(!table[i]){

					i += 1;
					continue;
				}
				for(count = 0; i+count <= N && table[i+count] == true; count++);
				maximum = Math.max(maximum, count);

				Q.add(new Info(i,i+count-1,count));
				i += count;
			}

			if(!zero_FLG){
				ans.append(Integer.toString(maximum)).append("\n");
				continue;
			}

			maximum += 1;

			Info info = Q.poll();

			while(!Q.isEmpty()){

				if(info.right+2 == Q.peek().left){

					maximum = Math.max(maximum, info.length+Q.peek().length+1);
				}

				info = Q.poll();
			}

			ans.append(Integer.toString(maximum)).append("\n");
		}
		System.out.printf(ans.toString());
	}
}

class Info{

	Info(int arg_left,int arg_right,int arg_length){
		left = arg_left;
		right = arg_right;
		length = arg_length;
	}
	public int left;
	public int right;
	public int length;
}

class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 65528
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n;
  cin >> n;
  if(n / 100 == n % 10) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
h = $<.gets.to_i
given = [nil] + $<.gets.split.map(&:to_i)

max_heapify = ->(i) {
  l, r = i * 2, i * 2 + 1
  largest = (l <= h and given[l] > given[i]) ? l : i
  largest = r if r <= h and given[r] > given[largest]
  unless largest == i
    given[i], given[largest] = given[largest], given[i]
    max_heapify.(largest)
  end
}

(h / 2).downto(1) {|i| max_heapify.(i)}
puts given.drop(1).map {|i| " #{i}"}.join


Measured memory_bytes: 50860
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<iostream>
#define MAXN 105
#define LL long long
#define ULL unsigned LL
#define rg register
#define lowbit(x) (-(x) & (x))
#define ENDL putchar('\n')
#define DB double
//#pragma GCC optimize(2)
//#pragma G++ optimize(3) 
//#define int LL
using namespace std;
inline int read() {
	int f = 1,x = 0;char s = getchar();
	while(s < '0' || s > '9') {if(s == '-') f = -1;s = getchar();}
	while(s >= '0' && s <= '9') {x = x * 10 - '0' + s;s = getchar();}
	return x * f;
}
int n,m,i,j,s,o,k;
bool f[MAXN];
signed main() {
	n = read(); m = read();
	for(int i = 1;i <= m;i ++) {
		k = read();
		for(int j = 1;j <= k;j ++) {
			f[read()] = 1;
		}
	}
	int ans = n;
	for(int i = 1;i <= n;i ++) {
		ans -= f[i];
	}
	printf("%d\n",ans);
	return 0;
}  

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


  








int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3588
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

n = ni()
p  = nl()
ans = 0
for i in range(1,n-1):
    if p[i-1] < p[i] < p[i+1]:
        ans += 1
    elif p[i-1] > p[i] > p[i+1]:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++)
	{
		if(a*i>=b&&a*i<=c)
		{
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0; 
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int ans=0;
  int B;
  int C;
  int E,F;
  vector<int> A(N);
  for(int i=0; i<N ; i++)
  {
    cin >> A.at(i);
  }
  for(int j=0; j<N ; j++)
  {
  
      C=A.at(j);
      C--;
      B=A.at(C);
      B--;

      if(B==j)
      {
        ans++;
      }
    
  }
  cout << (ans/2) << endl;
}

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

using namespace std;

int main() {
  int n, m; cin >> n >> m;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  int c[m], d[m];
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  int dis, idx;
  for (int i = 0; i < n; i++) {
    dis = INT_MAX;
    idx = 0;
    for (int j = 0; j < m; j++) {
      if (dis > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
        idx = j+1;
      }
     }
    cout << idx << '\n';
  }
  return 0;
}

Measured memory_bytes: 3600
//PseudoName

	#pragma GCC optimize("O3")
	#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace std;
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


	#define FOR(i,n) for(i=0;i<n;i++)
	#define FOR1(i,n) for(i=1;i<=n;i++)
	#define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
	#define pb push_back
	#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
	#define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
	#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
	#define endl "\n"
	#define min3(a,b,c) min(a,min(b,c))
	#define forr(n) for(int i=0;i<n;i++)
	#define frr(n) for(int i=1;i<=n;i++)
	#define rep(i,a,b) for(int i=a;i<=b;i++)



	typedef long long ll;
	typedef long li;
	typedef vector<int> vi;
	typedef vector<ll> vli;
	typedef vector<vi> vvi;
	typedef vector<vli> vvli;
	typedef pair<int,int> pi;
	typedef pair<ll,ll> pli;
	typedef vector<pi> vpi;
	typedef vector<pli> vpli;



	//const ll MOD=1e9+7;

	/*
	ll fast_exp(ll base, ll exp) {
	    ll res=1;
	    while(exp>0) {
	       if(exp%2==1) res=(res*base)%MOD;
	       base=(base*base)%MOD;
	       exp/=2;
	    }
	    return res%MOD;
	}
	ll imod(ll a)
	{
		return fast_exp(a, MOD-2);
	}
	*/

	const ll MOD=1e9+7;

	ll sum;

	ll n;


	ll lk(ll k)
	{
	   // if(k==n+1)return sum;
	    k=n-k;
	    return sum-(k*(k+1))/2;
	}

	ll mk(ll k)
	{
	    k--;
	    return (k*(k+1))/2;
	}



	int main() {
	    fast();

	    ll k;
	    cin>>n>>k;
	    sum=n*(n+1)/2;

	    ll ans=0;

	    for(ll i=k;i<=n+1;i++)
        {
            //cout<<lk(i)<<"  "<<mk(i)<<endl;
            ans+=(lk(i)-mk(i)+1+MOD)%MOD;
            ans%=MOD;
        }

        cout<<ans<<endl;


	}


Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
	int a[10];
	while(scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9])!=EOF){
		printf("%d\n",(a[0]+a[9]+(a[1]+a[8])*9+(a[2]+a[7])*6+(a[3]+a[6])*4+(a[4]+a[5])*6)%10);
	}
	return 0;
}

Measured memory_bytes: 596
from collections import deque

A = deque(input())
B = deque(input())
C = deque(input())

def main(A, B, C):
    u = A.popleft()
    while True:
        if u == "a":
            if len(A) == 0:
                return "A"
            u = A.popleft()
        elif u == "b":
            if len(B) == 0:
                return "B"
            u = B.popleft()
        else:
            if len(C) == 0:
                return "C"
            u = C.popleft()

print(main(A, B, C))



Measured memory_bytes: 3316
var ans,n  :integer;
    c:char;
begin
  ans:=0;n:=0;
  repeat
    read(c);
    if (c='A')or(c='C')or(c='G')or(c='T')
      then n+=1
      else if n<>0 then begin
        if ans<n then ans:=n;
        n:=0
      end;
  until eoln;
  if ans<n then ans:=n;
  write(ans);
end.

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

const int k = 9;
vector<vector<int>> d;
vector<int> w;
vector<int> v;

int dp(int x, int y){
  if (y<0) return -1000000;
  if (x<pow(2,k-1)){
    return d[x][y];
  }else{
  int a = dp(x/2,y);
  int b = dp(x/2,y-w[x-1]) + v[x-1];
  return max(a,b);
  }
}

int main() {
  int n;
  cin >> n;
  v = w = vector<int>(n);
  rep (i,n) cin >> v[i] >> w[i];

  int q;
  cin >> q;
  vector<int> u(q);
  vector<int> l(q);
  rep (i,q){
    cin >> u[i] >> l[i];
  }

  int N = min(int(pow(2,k-1))-1,n);
  int M = *max_element(l.begin(),l.end());
  d.push_back(vector<int>(M,0));
  for(int i=1;i<N+1;i++){
    vector<int> row;
    rep(j,M+1){
      if (i==1){
        if (w[0]<=j) {
          row.push_back(v[0]);
        } else {
          row.push_back(0);
        }
      }else{
        int a1 = d[i/2][j];
        int a2 = 0;
        if (j>=w[i-1]) a2 = d[i/2][j-w[i-1]]+v[i-1];
        row.push_back(max(a1,a2));
      }
    }
    d.push_back(row);
  }
  vector<int> res(q);
  rep(i,q){
    int x1 = u[i];
    int x2 = l[i];
    res[i] = dp(x1,x2);
  }

  rep(i,q){
    cout << res[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 106532
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<iterator>
#include <stack>
#define ll long long
typedef long double ld;
#define all(v) ((v).begin()),((v).end())
#define vec2(n,m) vector<vector<ll>>vv(n + 10, vector<ll>(m + 10, 0));
#define p_q1   priority_queue<int,vector<int>,greater<int>>pq1;
#define format(n) fixed<<setprecision(n)
#define ll_min LLONG_MIN;
#define ll_max LLONG_MIN;
#define endl "\n"
#define F first 
#define S second
#define mkpr(x,y)  make_pair(x,y)
using namespace std;
void weza()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main()
{
    weza();
    int n, m,a,mx=0;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a;
        mx += a;
    }
    if (mx > n)
        cout << -1 << endl;
    else
        cout << n - mx << endl;

}

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

using namespace std;

int main() {

	char b;

	cin >> b;

	if (b == 'A')
		cout << 'T' << endl;
	else if (b == 'C')
		cout << 'G' << endl;
	else if (b == 'G')
		cout << 'C' << endl;
	else if (b == 'T')
		cout << 'A' << endl;

	return 0;
}

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

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

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] V = cin.ArrayInt(N,0);
        int[] C=cin.ArrayInt(N,0);
        int ans=0;
        for(int i=0;i<N;i++)
        {
          V[i]-=C[i];
          if(V[i]>=0)ans+=V[i];
        }
        Console.WriteLine(ans);
        
    }


}



class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define pp pair<int,int>
#define fi first
#define se second
#define maxx 200012
#define ll long long
#define pb push_back
#define mp make_pair
#define lb lower_bound

using namespace std;

int n,q;
ll cnt[maxx];
vector<int> g[maxx];
int visited[maxx];

void input(){
//    freopen("TEST.INP","r",stdin);
//    freopen("TEST.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>q;
    for(int i=1;i<=n-1;i++){
        int a,b;cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    while(q--){
        int u,v;cin>>u>>v;
        cnt[u]+=v;
    }
}
int main()
{
    input();
    queue<int> myq;
    visited[1]=1;
    myq.push(1);
    while(!myq.empty()){
        int u=myq.front();myq.pop();
        for(int v:g[u]){
            if(visited[v])continue;
            cnt[v]+=cnt[u];
            visited[v]=1;
            myq.push(v);
        }
    }
    for(int i=1;i<=n;i++){
        cout<<cnt[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 17140
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, c, x, y = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

kotae = 1000000001
if (x > y):
    max = x
else:
    max = y
for i in range(0,max+1):
    j = x - i
    k = y - i
    if(j < 0):
        j = 0
    if(k < 0):
        k = 0
    temp = a * j + b * k + 2 * c * i
    if (temp < kotae):
        kotae = temp

print(kotae)

Measured memory_bytes: 12480
# coding: utf-8
# Your code here!
S=input()


A=int(S[:2])
B=int(S[2:])



if A==0:
    if B==0:
        print("NA")
    elif 1<=B<=12:
        print("YYMM")
    elif 12<B:
        print("NA")
if 1<=A<=12:
    if B==0:
        print("MMYY")
    elif 1<=B<=12:
        print("AMBIGUOUS")
    elif 12<B:
        print("MMYY")
if 12<A:
    if B==0:
        print("NA")
    elif 1<=B<=12:
        print("YYMM")
    elif 12<B:
        print("NA")
    

Measured memory_bytes: 3064