akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
	int ans[4], count, n;

	while (scanf("%d", &n) != EOF){
		count = 0;
		for (ans[0] = 0; ans[0] <= 9; ans[0]++){
			for (ans[1] = 0; ans[1] <= 9; ans[1]++){
				for (ans[2] = 0; ans[2] <= 9; ans[2]++){
					for (ans[3] = 0; ans[3] <= 9; ans[3]++){
						if (ans[0] + ans[1] + ans[2] + ans[3] == n) count++;
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 596
from collections import defaultdict
from bisect import bisect

n,m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(m)]

a = defaultdict(list)

for p_i in sorted(p):
  a[p_i[0]].append(p_i[1])
  
for p_i in p:
  x = p_i[0]
  y = bisect(a[x], p_i[1])
  
  print(str(x).zfill(6), str(y).zfill(6), sep='')

Measured memory_bytes: 43328
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+2];
		a[0] = 0;
		for(int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		a[n+1] = 0;

		// 全ルートの計算
		int sum = 0;
		int pos = 0;
		for(int i = 0; i <= n; i++) {
			sum += Math.abs(pos - a[i]);
			pos = a[i];
		}
		sum += Math.abs(pos);

		for(int i = 1; i <= n; i++) {
			int sum2 = sum;
			if( (a[i] - a[i - 1]) >= 0 && ((a[i+1] - a[i]) >= 0) || (a[i] - a[i - 1]) <= 0 && ((a[i+1] - a[i]) <= 0) ) {
				System.out.println(sum2);
				continue;
			}
			sum2 -= Math.abs(a[i - 1] - a[i]);
			sum2 -= Math.abs(a[i] - a[i + 1]);
			sum2 += Math.abs(a[i - 1] - a[i+1]);
			System.out.println(sum2);
		}
	}
}


Measured memory_bytes: 75992
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b;
long long sum;
vector<int> arrn[100005];
priority_queue<int> pq;
int arrm[100005];
int main(void)
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		arrn[a].push_back(b);
	}
	for (int i = 1; i <= m; i++)
	{
		for (int j = 0; j < arrn[i].size(); j++)
		{
			pq.push(arrn[i][j]);
		}
		if (!pq.empty())
		{
			sum += pq.top();
			pq.pop();
		}
	}
	cout << sum << endl;
	return 0;
}

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

struct Button {
  int number;
  bool visited;
  Button() : number(0),visited(false) {}
};

int main() {
  int N;
  Button A[100050];

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i + 1].number;
  }

  int ans = 0;
  int i = 1;
  bool ok = false;
  while (!(ok || A[i].visited)) {
    ++ans;
    if (A[i].number == 2) {
      ok = true;
    } else {
      A[i].visited = true;
      i = A[i].number;
    }
  }

  if (ok) {
    cout << ans << endl;
  } else {
    cout << "-1" << endl;
  }

  return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

#define lam [&]


signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N, M; scanf("%d%d", &N, &M);

    vector<set<int>> S(N);
    times(M, i) {
        int x, y; scanf("%d%d", &x, &y);
        S[x-1].insert(y-1);
        S[y-1].insert(x-1);
    }

    bool ans = false;
    times(N, i) if(!ans) {
        ans = S[i].find(0) != S[i].end() && S[i].find(N-1) != S[i].end();
    }

    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)



long upDiv(long a,long b){
  return (a+b-1)/b;
}

/////////////////////////


//Answer


int main() {

string S;
cin>>S;
if(S=="MON"){
cout<<6<<endl;
}else if(S=="TUE"){
cout<<5<<endl;
}else if(S=="WED"){
cout<<4<<endl;
}else if(S=="THU"){
cout<<3<<endl;
}else if(S=="FRI"){
cout<<2<<endl;
}else if(S=="SAT"){
cout<<1<<endl;
}else{
cout<<7<<endl;
}


}

Measured memory_bytes: 3536
#include <iostream>
#define MAXN 100001

using namespace std;

int height[MAXN];

int getCost(int a,int b){
	return abs(height[a]-height[b]);
}

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

	for (int i = 0; i < n; ++i)
	{
		cin >> height[i];
	}

 	int dp[n];
	dp[0]=0;
	dp[1]=getCost(1,0);
 	for (int i = 2; i < n; ++i)
 	{
 		
 		dp[i] = min(getCost(i,i-1) + dp[i-1], getCost(i,i-2) + dp[i-2]);
 	}

 	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 4368
// helloworld.cpp : アプリケーションのエントリ ポイントを定義します。
//
//#include "stdafx.h"
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
//
int W[50], R[50], B[50];
int main() {
    int N, M;
    char F[50][50];
    cin >> N >> M;
    FOR(i, 0, N) {
        FOR(j, 0, M) {
            cin >> F[i][j];
            if (F[i][j] == 'W') {
                W[i]++;
            }
            else if (F[i][j] == 'R') {
                R[i]++;
            }
            else if (F[i][j] == 'B') {
                B[i]++;
            }
        }
    }
    FOR(i, 1, N) {
        W[i] += W[i - 1];
        R[i] += R[i - 1];
        B[i] += B[i - 1];
    }
    int ans = INF;
    FOR(i, 0, N - 2) {
        FOR(j, i + 1, N-1) {
            int nw = W[i];
            int nb = B[j] - B[i];
            int nr = R[N - 1] - R[j];
            ans = min(ans, N*M - nw - nb - nr);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define mp make_pair
#define frab(i, a, b) for (int i = a; i < b; ++i)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007;
const ll P1 = 17;
const ll P2 = 19;
const ld PI = acos(-1);
const ll MAX = 63211236 + 10;
const ll INF = 1e9 + 10;
const ld EPS = 1e-9;
const int M = 5e3 + 2;
const int N = 1e6 + 5;

ll a[N];

int main() {
    //freopen("a.in", "r", stdin);
    int n, k;
    cin >> n >> k;
    fr(i, n)
        cin >> a[i];
    ll gcd = a[0];
    frab(i, 1, n)
        gcd = __gcd(gcd, a[i]);
    int mx = *max_element(a, a + n);
    if (k % gcd == 0 && mx >= k)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";
}


Measured memory_bytes: 1024
s = input()

if s == 'SUN':
    print(7)
if s == 'MON':
    print(6)
if s == 'TUE':
    print(5)
if s == 'WED':
    print(4)
if s == 'THU':
    print(3)
if s == 'FRI':
    print(2)
if s == 'SAT':
    print(1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0, w = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			r++;
		}
		else {
			w++;
		}
	}
	int count = 0;
	for (int i = n - 1; i >= n - w; i--) {
		if (s[i] != 'W') {
			count++;
		}
	}
	cout << count << "\n";
}

int32_t main() {
	_ __
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    for (int r = 0; r * R <= N; ++r)
    {
        for (int g = 0; r * R + g * G <= N; ++g)
        {
            const int bB = N - (r * R + g * G);
            if (bB >= 0 && bB % B == 0)
            {
                ++ans;
            }
        }
    }
    cout << ans << endl;
}


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

int a;
long l,r;
long sum;
//bool cari;
int main(){
	a=0;
	//cari=true;
	cin>>a;
	for(int i =0; i<a; i++){
		cin>>l>>r;
		sum+=r+1-l;
	}
	cout<<sum<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll i,j;
    
    ll n;
    cin>>n;
    
    
    string s="";
    
    while(n)
    {
        --n;
        ll x=n%26;
        s+=('a'+x);
        n/=26;
    }
    reverse(all(s));
    cout<<s;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string word,str,p;
  int q,a,b;
  cin >> str >> q;
  for(int i=0;i<q;i++){
    cin >> word;
    if(word == "print"){
      cin >> a >> b;
      cout <<str.substr(a, b-a+1) << endl;
    }
    else if(word == "reverse"){
      cin >> a >> b;
      reverse(str.begin()+a,str.begin()+b+1);
    }else{
      cin >> a >> b >> p;
      str.replace(a,b-a+1,p);
    }
  }
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int d[N];
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    sort(d,d+N);
    if(N%2==1){
        cout << 0 << endl;
        return 0;
    } else {
        cout << d[(N/2)] - d[(N/2)-1] << endl;
        return 0;

    }
}

Measured memory_bytes: 640
n, k, c = map(int, input().split())
S = input()

DP1 = []
DP2 = []

day = 0
work = 0
while day < n and work < k:
    if S[day] == 'o':
        DP1.append(day)
        day += c + 1
        work += 1

    else:
        day += 1

day = n-1
work = 0
while day >= 0 and work < k:
    if S[day] == 'o':
        DP2.append(day)
        day -= c + 1
        work += 1
    else:
        day -= 1

for day1, day2 in zip(DP1, DP2[::-1]):
    if day1 == day2:
        print(day1+1)


Measured memory_bytes: 22212
n = int(input())
if n % 10 == 2 or n % 10 == 4 or n % 10 == 5 or n % 10 == 7 or n % 10 == 9:
    print("hon")
elif n % 10 == 0 or n % 10 == 6 or n % 10 == 1 or n % 10 == 8:
    print("pon")
else:
    print("bon")

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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int totl = 0, totr = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(') totl++;
        else
        {
            if (totl > 0) totl--;
            else totr++;
        }
    }
    for (int i = 0; i < totl; i++) s = s + ')';
    for (int i = 0; i < totr; i++) s = '(' + s;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
int H,W,N,w[100005],x[100005],y[100005],R[100005][2],i;

int ch(int M,int *p)
{
	int i,j,t;
	memset(R,0,sizeof(R));
	for(i=0;i<N;i++)
	{
		R[max(0,p[i]-w[i])][0]++;
		R[min(M,p[i]+w[i])][1]++;
	}
	for(i=t=0;i<=M;i++)
	{
		t+=R[i][0];
		if(t<1)return 0;
		t-=R[i][1];
		if(i<M&&t<1)return 0;

	}
	return 1;
}

int main()
{
	scanf("%d%d%d",&N,&W,&H);
	for(i=0;i<N;i++)
		scanf("%d%d%d",&x[i],&y[i],&w[i]);
	puts(ch(H,y)||ch(W,x)?"Yes":"No");
	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    int hz[h][w] = {};
    for (int i = 0; i < h; i++) {
        int cw = 0;
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') {
                cw++;
                if (j == w - 1) {
                    for (int k = 0; k < cw; k++) {
                        hz[i][j-k] = cw;
                    }
                }
            }
            if (s[i][j] == '#') {
                for (int k = 0; k < cw; k++) {
                    hz[i][j-k-1] = cw;
                }
                cw = 0;
            }
        }
    }

    int vt[h][w] = {};
    for (int i = 0; i < w; i++) {
        int ch = 0;
        for (int j = 0; j < h; j++) {
            if (s[j][i] == '.') {
                ch++;
                if (j == h - 1) {
                    for (int k = 0; k < ch; k++) {
                        vt[j-k][i] = ch;
                    }
                }
            }
            if (s[j][i] == '#') {
                for (int k = 0; k < ch; k++) {
                    vt[j-k-1][i] = ch;
                }
                ch = 0;
            }
        }
    }

    int m = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            m = max(m, hz[i][j]+vt[i][j]);
        }
    }
    cout << m - 1 << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int p,q,r;
  cin >> p >> q >> r;
  int ans = 10000l;
  mins(ans,p+q);
  mins(ans,p+r);
  mins(ans,q+r);
  cout<<ans<<endl;
  return 0;
}

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

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

    int sn = s.length();
    int tn = t.length();

    map<char, int> m;
    vector<vector<int> > v(26);
    for(int i = 0; i < sn; i++){
        auto itr = m.find(s[i]);
        if(itr == m.end()){
            m[s[i]] = 1;
        }
        v[s[i] - 'a'].push_back(i);
    }

    int flag = 0;
    for(int i = 0; i < tn; i++){
        auto itr = m.find(t[i]);
        if(itr == m.end()){
            flag = 1;
            break;
        }
    }

    if(flag == 0){
        int now = 0;
        ll cou = 0;
        int k = -1;
        while(1){
            if(now == tn){
                break;
            }

            auto itr = upper_bound(v[t[now] - 'a'].begin(), v[t[now] - 'a'].end(), k);
            if(itr == v[t[now] - 'a'].end()){
                k = v[t[now] - 'a'][0];
                cou++;
            }else{
                k = *itr;
            }
            now++;
        }

        cout << sn * cou + k + 1 << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    string s, t; cin >> s >> t;
    int n = sz(s);
    int m = sz(t);

    vector <vector<int>> dp(n+1, vector <int>(m+1, 0));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
        }
    }
    // cout << dp[n][m];

    string ans;
    for (int i = n, j = m; i > 0 and j > 0;) {
        if (dp[i][j] == dp[i-1][j]) i = i - 1;
        else if (dp[i][j] == dp[i][j-1]) j = j-1;
        else {
            ans += s[i-1];
            i = i - 1;
            j = j - 1;
        }
    }
    reverse(all(ans));
    cout << ans;

    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  
  vll dp(n+1,LINF);
  rep(i,n+1) dp[i]=i;
  
  for(ll i=6; i<=n; i*=6){
    for(ll j=0; j+i<=n; j++){
      chmin(dp[i+j], dp[j]+1);
    }
  }
  
  for(ll i=9; i<=n; i*=9){
    for(ll j=0; j+i<=n; j++){
      chmin(dp[i+j], dp[j]+1);
    }
  }
  
  cout<<dp[n]<<endl;
  
}

Measured memory_bytes: 3924
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    X, Y, Z = map(int, input().split())
    X -= Z
    print(max(0, X // (Z + Y)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
 long long int a;
 float b;
 cin >> a >> b;
 long long int ib = b*100+0.1;
 long long int result =a*ib;
 printf("%lld",result/100);
return 0;
}

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

int main()
{
    string s;
    cin >> s;
    ll a[s.size()]={0},i=0;
    while(i<s.size()){
        int r = 0, l = 0;
        int rp, lp;
        while(s[i]=='R'){r++; i++;}
        if(s[i]=='L'){lp = i; rp = lp-1;}
        while(s[i]=='L'){l++; i++;}
        a[rp] += (r+1)/2;
        a[lp] += r/2;
        a[lp] += (l+1)/2;
        a[rp] += l/2;
    }
    // rep(j, s.size())
    // {
    //     ll tmp[s.size()] = {0};
    //     rep(i, s.size())
    //     {
    //         if (s[i] == 'R')
    //             tmp[i + 1] += a[i];
    //         else
    //             tmp[i - 1] += a[i];
    //     }
    //     rep(i, s.size())
    //         a[i] = tmp[i];
    // }
    rep(i, s.size()) cout << a[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

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

int main(void)
{ long long int n,k,mod;

  scanf("%lld%lld", &n, &k);

  mod=n%k;
   if (mod<k-mod)
    printf("%lld", mod);
   else
    printf("%lld", k-mod);

  return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
S = input()

ans = ""
for i in range(len(S)):
    _S = S[i]
    if i == K-1:
        if _S == "A":
            _S = "a"
        elif _S == "B":
            _S = "b"
        elif _S == "C":
            _S = "c"
    ans += _S
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

bool compare(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.second == b.second) return a.first < b.first;
  else                      return a.second < b.second;
}

int main() {
  int N; cin >> N;
  vector<pair<int, int>> ps(N);
  for (int i = 0; i < N; ++i) {
    int x, l; cin >> x >> l;
    ps[i] = {x-l, x+l};
  }

  sort(ps.begin(), ps.end(), compare);

  int cnt = N;
  int end = ps[0].first - 1;
  for (auto p : ps) {
    if (end <= p.first) {
      end = p.second;
    } else {
      --cnt;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  
  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') ans += '0';
    else if (s[i] == '1') ans += '1';
    else if (s[i] == 'B' && !ans.empty()) ans.pop_back();
  }
  cout << ans << endl;
  
  return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    ans += (n/500)*1000;
    n = n%500;
    ans += (n/5)*5;
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
	int N,i,res=1;
	scanf("%d",&N);
	int t[N],x[N],y[N];
	for(i=0;i<N;i++)
    {
	  scanf("%d %d %d",&t[i],&x[i],&y[i]);
      if((x[i]+y[i])>t[i])
        res=0;
      else if((t[i]-x[i]-y[i])%2!=0)
        res=0;
    }
    if(res)
        printf("Yes");
    else
        printf("No");
        
    return 0;
        
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define int long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=305,inf=1e18;

int n,m,L,Q,w[N][N],c[N][N];

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{
	n=read();m=read();L=read();
	Rf(i,1,n) Rf(j,1,n) if(i!=j) w[i][j]=inf;
	Rf(i,1,m) {
		R int u=read(),v=read();
		w[u][v]=w[v][u]=read();
	}
	Rf(k,1,n) Rf(i,1,n) Rf(j,1,n) w[i][j]=min(w[i][j],w[i][k]+w[k][j]);
	Rf(i,1,n-1) Rf(j,i+1,n) {
		if(w[i][j]<=L) c[i][j]=c[j][i]=1;
		else c[i][j]=c[j][i]=inf;
	}
	Rf(k,1,n) Rf(i,1,n) Rf(j,1,n) c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
	Q=read();
	while(Q--) {
		R int s=read(),t=read();
		if(c[s][t]==inf) write(-1);
		else write(c[s][t]-1);
		puts("");
	}
		
    return 0;
}


Measured memory_bytes: 5016
#include <stdio.h>
#include <math.h>
int main(void)
{
    int N, K;
    scanf("%i %i", &N, &K);

    int num_of_sweets[100] = {0};

    for (int i = 1; i <= K; i++)
    {
        int d;
        scanf("%i", &d);
        for (int j = 1; j <= d; j++)
        {
            int tmp;
            scanf("%i", &tmp);
            num_of_sweets[tmp - 1]++;
        }
    }
    int sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (num_of_sweets[i - 1] == 0)
        {
            sum++;
        }
    }
    printf("%i\n", sum);
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 10000000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

//#define DEBUG

int main_(){
  int N;
  cin>>N;
  vector<pii>no;
  if(N%2){
    for(int i=0;i<(N-1)/2;i++){
      //cout<<i+1<<" "<<N-1-i<<endl;
      no.push_back({i+1,N-1-i});
    }
  }
  else{
    for(int i=0;i<N;i++){
      no.push_back({i+1,N-i});
    }
  }
  vector<pii>ans;
  for(int i=1;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      bool flg=true;
      for(auto it:no){
        if(i==it.first&&j==it.second){
          flg=false;
        }
      }
      if(flg){
        ans.push_back({i,j});
      }
    }
  }
  cout<<ans.size()<<endl;
  for(auto it:ans)cout<<it.first<<" "<<it.second<<endl;
  return 0;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  vector<string>test;
  /*
   * input for debug
   */
  for(int i=0;i<test.size();++i){
    stringbuf buf;
    streambuf*out=cout.rdbuf(&buf);
    cout<<test[i]<<flush;
    cout.rdbuf(out);
    streambuf*in=cin.rdbuf(&buf);
    main_();
    cin.rdbuf(in);
    cout<<endl;
  }
#else
  main_();
#endif

  return 0;
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


const ll MOD = 1000000007;
void solve(ll H, ll W, vector<string> a){
    ll G[H][W];
    fill(G[0], G[H], 0);
    G[0][0] = 1;
    rep(i, H + W - 1) {
        rep(j, i+1) {
            if (j < H && i-j < W) {
                if (j > 0) G[j][i-j] += G[j-1][i-j];
                if (i-j > 0) G[j][i-j] += G[j][i-j-1];
                if (is(a[j][i-j], '#')) G[j][i-j] = 0;
                G[j][i-j] %= MOD;
            }
        }
    }
    cout << G[H-1][W-1] << endl;
}

int main() {
  ll H;
    scanf("%lld",&H);
    ll W;
    scanf("%lld",&W);
    vector<string> a(H);
    for(int i = 0 ; i < H ; i++){
        cin >> a[i];
    }
  solve(H, W, move(a));
  return 0;
}


Measured memory_bytes: 9088
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*A = map(int,read().split())

"""
・任意の i に対して A[i] <= i が必要
・このときできる。次のようにすればよい
・A[i] = i となる 最大の i を取り除く（i=1が満たすので存在）。帰納法がまわってできる。
"""

bl = all(x <= i for i,x in enumerate(A,1))
if not bl:
    print(-1)
    exit()

answer = []
while A:
    I = [i for i,x in enumerate(A) if i + 1 == x]
    i = I[-1]
    answer.append(i + 1)
    A = A[:i] + A[i+1:]

answer = answer[::-1]
print('\n'.join(map(str,answer)))

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

signed main(){
	long long n, a, b;
	cin >> n >> a >> b;
	if(a > b) swap(a, b);
	long long ans = 0LL;
	if((b-a)%2==0) ans = (b-a)/2LL;
	else{
		if(a-1 < n-b){
			ans += a-1;
			b -= a-1;
			a = 1;
		}
		else{
			ans += n-b;
			a += n-b;
			b = n;
		}
		++ans;
		ans += (b-a)/2LL;
	}
	cout << ans << "\n";
}

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

long long my_gcd(long long a, long long b){
    if(a < b) swap(a,b);
    long long t;
    while((t=a%b)){
        a = b;
        b = t;
    }
    return b;
}

int main(){
    long long a,b;
    cin >> a >> b;
    long long c = my_gcd(a,b);
    int ans = 1;
    for(long long i = 2; i*i <= c; i++){
        if(!(c%i)){
            ans++;
            while(!(c%i)){
                c /= i;
            }
        }
    }
    if(c != 1) ans++;
    cout <<  ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//e
int main(){

    int N; cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    sort(all(A));
    sort(all(B));

    if(N%2==1) cout << B[N/2]-A[N/2]+1 << endl;
    if(N%2==0) cout << (B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1])+1 << endl;

}

Measured memory_bytes: 4800
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int n,k,a[10],power[6];
vector<string>vec;
int main(){
	while(true){
		cin>>n>>k;vec.clear();power[0]=1;for(int i=1;i<5;i++)power[i]=power[i-1]*n;
		if(n==0 && k==0)break;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=0;i<power[k];i++){
			int bit[4];for(int j=0;j<k;j++)bit[j]=(i/power[j])%n;
			bool OK=true;
			if(k==2 && (bit[0]==bit[1]))OK=false;
			if(k==3 && (bit[0]==bit[1] || bit[0]==bit[2] || bit[1]==bit[2]))OK=false;
			if(k==4 && (bit[0]==bit[1] || bit[0]==bit[2] || bit[1]==bit[2]))OK=false;
			if(k==4 && (bit[0]==bit[3] || bit[1]==bit[3] || bit[2]==bit[3]))OK=false;
			if(OK==true){
				string S="";
				for(int j=0;j<k;j++)S+=to_string(a[bit[j]]);
				vec.push_back(S);
			}
		}
		sort(vec.begin(),vec.end());int cnt=1;
		for(int i=1;i<vec.size();i++){
			if(vec[i-1]!=vec[i])cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3296
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    vector<int> R, G, B;
    for (int n = 0; n < N; ++n) {
        if (S[n] == 'R') {
            R.emplace_back(n);
        } else if (S[n] == 'G') {
            G.emplace_back(n);
        } else {
            B.emplace_back(n);
        }
    }
    
    ll Res = 0;
    for (int n = 0; n < R.size(); ++n) {
        int r = R[n];
        for (int m = 0; m < G.size(); ++m) {
            int g = G[m];
            
            vector<int> Cand;
            Cand.emplace_back(2*r-g);
            Cand.emplace_back(2*g-r);
            if ((r+g)%2 == 0) {
                Cand.emplace_back((r+g)/2);
            }
            int Temp = B.size();
            for (int k = 0; k < Cand.size(); ++k) {
                if (binary_search(B.begin(), B.end(), Cand[k])) {
                    --Temp;
                }
            }
            Res += Temp;
        }
    }
    cout << Res << endl;
    

    return 0;
}


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

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  rep(i, n) {
    ll d;
    cin >> d;
    mp[d]++;
  }
  for(auto p : mp) {
    ll d = p.first;
    ll m = p.second;
    if(m >= 3 || d == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 0;
  rep(i, 1 << 12) {
    vl v = {0, 24};
    rep(j, 12) {
      ll k = j + 1;
      if(mp[k] == 0) continue;
      if(mp[k] == 2) {
        v.push_back(k);
        v.push_back(24 - k);
        continue;
      }
      if(i >> j & 1)
        v.push_back(k);
      else
        v.push_back(24 - k);
    }
    sort(all(v));
    ll now = 12;
    rep(j, v.size() - 1) now = min(now, v[j + 1] - v[j]);
    ans = max(ans, now);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans = 0;
    rep(i,n){
        while(a[i]%2==0){
            a[i]/=2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
 
int main() {
	int m;
	cin>>m;
		float a;
		float s=0;
		int i;
	for(i=0;i<m;i++){
		cin>>a;
		a=1/a;
		s+=a;
	}
	cout<<1/s;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;
int main(){

  ll n;cin>>n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)out("hon");
  else if(n%10==3)out("bon");
  else out("pon");

  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main(){
  int a,b,end_flag = 1;
  char op;

  while(end_flag){
    scanf("%d %c %d",&a,&op,&b);

    switch(op){
    case '+':
      printf("%d\n",a+b);
      break;
    case '-':
      printf("%d\n",a-b);
      break;
    case '/':
      printf("%d\n",a/b);
      break;
    case '*':
      printf("%d\n",a*b);
      break;
    default:
      end_flag = 0;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>
int main()
{
	int n,m,sum,i,x;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		x=1;
		for(i=0;i<m;i++)
		{
			x*=2;
		}
		sum=(m*1900+(n-m)*100)*x;
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 128
n = int(input())
b = input()
v = []
v.append(b.split())
v = v[0]
count = 0
for v1 in v:
    v.remove(v1)
    v.insert(count, int(v1))
s = input()
c = []
c.append(s.split())
c = c[0]
count = 0
for c1 in c:
    c.remove(c1)
    c.insert(count, int(c1))
a = []
for (v1,c1) in zip(v,c):
    add = v1 - c1
    a.append(add)
ans = 0
for a1 in a:
    if a1 >= 0:
        ans += a1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
bool f[110][10];
ll p[110][20];

int main() {
	cin >> n;
	rep(i, n) {
		rep(j, 10)cin >> f[i][j];
	}
	rep(i, n) {
		rep(j, 11)cin >> p[i][j];
	}
	ll ans = -INF;
	FOR(i, 1, (1 << 10)) {
		vector<ll> cnt(n, 0);
		rep(j, 10) {
			if (i&(1 << j)) {
				rep(k, n)if(f[k][j])cnt[k]++;
			}
		}
		ll sum = 0;
		rep(j, n)sum += p[j][cnt[j]];
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    rep(i,n)cin >> h[i];
    int c = 0;
    rep(i,n)if(h[i]>=k)c++;
    cout << c << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    map<string,int> mep;
    bool valid=true;
    string s;
    cin>>s;
    mep[s]=1;
    for(int a=1;a<n;a++){
        string s2;
        cin>>s2;
        if(mep[s2]||s2[0]!=s[s.length()-1]) valid=false;
        mep[s2]=1;
        s=s2;
    }
    if(valid) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int r = Integer.parseInt(scanner.nextLine());
        if (r < 1200) {
            System.out.println("ABC");
        } else if (r < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}


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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, c[500], s[500], f[500], p, r, t;

signed main() {
	cin >> n;
	rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
	rep(i,n) {
		t = 0;
		reps(j,i,n-1) {
			chmax(t,s[j]);
			t = s[j] + (t-s[j]+f[j]-1)/f[j] * f[j] + c[j];
		}
		cout << t << ln;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int>C(n);
  vector<vector<int>>A(n,vector<int>(m));
  for(int i=0;i<n;i++){
    cin >> C[i];
    for(int j=0;j<m;j++){
      cin >> A[i][j];
    }
  }

  int ans = 1000000007;
  for(int bit=0;bit<(1<<n);bit++){
    int money = 0;
    vector<int>sum(n);
    for(int i=0;i<n;i++){
      if(bit & (1<<i)){
        money += C[i];
        for(int j=0;j<m;j++){
          sum[j] += A[i][j];
        }
      }
    }
    bool ok = true;
    for(int i=0;i<m;i++){
      if(sum[i]<x) ok = false;
    }
    if(ok) ans = min(ans,money);
  }
  if(ans==1000000007) cout<< -1 <<endl;
  else cout<< ans <<endl;
}


Measured memory_bytes: 3672
K, S = [int(x) for x in input().split()]

ans = 0

for X in range(K + 1):
	if X > S:
		break
	for Y in range(K + 1):
		if X + Y <= S:
			if S - (X + Y) <= K:
				ans += 1
		else:
			break

print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] acarr = new int[100000];
		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'C' && i != 0 && s.charAt(i - 1) == 'A' && i != 0) {
				count++;
				acarr[i] = count;
			}else {
				acarr[i]=count;
			}
		}

		for(int i=0;i<q;i++) {
			int l1=sc.nextInt()-1;
			int l2=sc.nextInt()-1;
			System.out.println(acarr[l2]-acarr[l1]);
		}
	}
}


Measured memory_bytes: 67112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;


ll n,p;
ll cnt[10005];
ll dp[MAXn];
ll ten;
ll fpow(ll a,ll b){
    ll ret = 1;
    while (b) {
        if (b&1) ret = ret * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return ret;
}
int main(){
    IOS();
    cin >> n >> p;
    string s;
    cin >> s;
    if (p == 2 || p == 5) {
        ll ans = 0;
        REP (i,n) {
            if ((s[i]-'0') % p == 0) ans += (i+1);
        }
        cout << ans << endl;
    }
    else {
        ten = fpow(10,p-2);
        dp[0] = (s[0]-'0') % p;
        ll cur = 1;
        cnt[dp[0] * cur % p] = 1;
        ll ans = 0;
        if (dp[0] == 0) ans++;
        cur = cur * ten % p;
        REP1 (i,n-1) {
            dp[i] = ((dp[i-1]*10%p) + (s[i]-'0')%p) % p;
            if (dp[i] == 0) ans++;
            ll nxt = dp[i] * cur % p;
            ans += cnt[nxt];
            cnt[nxt]++;
            cur = cur * ten % p;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

int N, A, B;
int count(int x) {
  int ans = 0;
  while (x > 0) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}
void solve() {
  int ans = 0;
  REPI(i, 1, N+1) {
    int tmp = count(i);
    if (A <= tmp && tmp <= B) {
      ans += i;
    }
  }
  cout << ans << endl;
}

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

  solve();
}


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

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

int main() {
  int n, m;
  vector<int> a(1000);
  cin >> n >> m;
  int count = 0;
  double No = 0;
  rep(i, n) {
    cin >> a.at(i);
    No += a.at(i);
  }
    // cout << No << endl;
  rep(i, n) {
    if (a.at(i) >= No / (4 * m)) {
      count++;
    }
  }
  if(count >= m) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  }


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b < c + d) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3604
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.next();
		if(a.toUpperCase().equals(a)) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}
	}
}

Measured memory_bytes: 35728