akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#define Lens 105
#define Nil -1
using namespace std;
struct card
{
	char suit;
	int key;
};

int N;
card b[Lens],c[Lens];

void bubblesort(card a[])
{
	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j > i; j--)
		{
			if (a[j].key < a[j - 1].key)
			{
				swap(a[j], a[j - 1]);
			}
		}
	}


}

void selectionsort(card a[])
{
	for (int i = 0; i < N; i++)
	{
		int mini = i;
		for (int j = i + 1; j < N; j++)
		{
			if (a[j].key < a[mini].key)
				mini = j;
		}
		if (i != mini)
		{
			swap(a[i], a[mini]);
		}
	}
}

int isstable(card a[], card b[])
{
	card t[Lens];
	for (int i = 0; i < N; i++)
	{
		t[i].suit = a[i].suit;
		t[i].key = a[i].key;
	}

	for (int i = 1; i < N; i++)
	{
		if (b[i].key == b[i - 1].key)
		{
			char c = b[i - 1].suit;
			int k = b[i].key;
			for (int j = 0; j < N; j++)
			{
				if (t[j].key == k&&t[j].suit != c)
					return 1;
				else if (t[j].key == k&&t[j].suit == c)
				{
					t[j].key = Nil;
					break;
				}
			}
		}
	}
	return 0;
}

void printcard(card a[])
{
	for (int i = 0; i < N; i++)
	{
		if (i > 0)
			cout << ' ';
		cout << a[i].suit << a[i].key;
	}
	cout << endl;
}

int main()
{
	cin >> N;
	card a[Lens];
	for (int i = 0; i < N; i++)
	{
		cin >> a[i].suit >> a[i].key;
		b[i].suit = a[i].suit;
		b[i].key = a[i].key;
		c[i].suit = a[i].suit;
		c[i].key = a[i].key;
	}
	bubblesort(b);
	printcard(b);
	if (!isstable(a,b))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	selectionsort(c);
	printcard(c);
	if (!isstable(a,c))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	return 0;
}



Measured memory_bytes: 3104
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com

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

#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double

#define pii   pair<int, int>
#define piii  pair<int, pair<int, int>>
#define pll   pair<ll, ll>

#define F  first
#define S  second
#define PB push_back
#define MP make_pair

#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename T>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}

// add templates here

template<class T>
void println(const vector<T> &data) {
    cout << to_string<vector<T>, T>(data) <<endl;
}

template<class T>
void println(const T &data) {
    cout << to_string((T)data) << endl;
}

const int MOD = int(1e9+7);
const int oo  = int(1e9 + 20);
const ll lloo  = (ll)(1e18 + 10);

string solve() {
    int n;
    cin >> n;
    vector<int> val(n);
    vector<int> sorted(n);
    for(int i = 0; i < n; ++i) {
        cin >> val[i];
        sorted[i] = val[i];
    }
    sort(all(sorted));
    vector<bool> visited(n, false);
    int count = 0;
    for(int i = 0; i < n; ++i) {
        int idx1 = lower_bound(all(sorted), val[i]) - sorted.begin();
        int idx2 = lower_bound(all(sorted), val[idx1]) - sorted.begin();
        
        if(idx1 != idx2) {
            count++;
        }
    }
    if(count <= 2) return "YES";
    return "NO";
}
    
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,q; cin >> n >> q;
    string s; cin >> s;
    int num[n];
    rep(i,n) num[i]=0;
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C') num[i+1]=1;
    }
    rep(i,n-1) num[i+1]+=num[i];
    //rep(i,n) cout << num[i] << endl;
    rep(i,q){
        int l,r; cin >> l >> r;
        l--; r--;
        cout << num[r]-num[l] << endl;
    }
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint H, W, K;
char mp[10][1000];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> H >> W >> K;
	REP(i, H) {
		REP(j, W) {
			cin >> mp[i][j];
		}
	}

	lint minv = INF;
	REP(i, 1 << (H - 1)) {
		vector<plint> sec;
		lint l = 0;
		REP(j, H - 1) {
			if ((i >> j) % 2 == 1) {
				sec.push_back({ l, j });
				l = j + 1;
			}
		}
		sec.push_back({ l, H - 1 });

		lint vertic_cnt = 0;
		vector<lint> cnt(SZ(sec));
		vector<lint> curr_cnt(SZ(sec));
		bool isAble = true;
		REP(j, W) {
			REP(k, SZ(sec)) curr_cnt[k] = 0;
			REP(k, SZ(sec)) {
				for (int ver = sec[k].first; ver <= sec[k].second; ver++) {
					if (mp[ver][j] == '1') curr_cnt[k]++;
				}
			}
			bool flag = true;
			REP(k, SZ(sec)) {
				if (K < curr_cnt[k] + cnt[k]) {
					flag = false;
				}
				if (curr_cnt[k] > K) isAble = false;
			}
			if (!flag) {
				vertic_cnt++;
				REP(k, SZ(sec)) {
					cnt[k] = curr_cnt[k];
				}
			}
			else {
				REP(k, SZ(sec)) {
					cnt[k] += curr_cnt[k];
				}
			}
		}

		if(isAble) chmin(minv, vertic_cnt + SZ(sec) - 1);
	}
	cout << minv << endl;
}


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

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

	int c1 = 0, c2 = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'R') c1++;
		else c2++;
	}

	if (c1 > c2) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
int main(){
int temp,a[5];
  for(int i=0;i<5;i++)a[i]=0;
  for(int i=0;i<6;i++){
    scanf("%d",&temp);
    a[temp]++;
}
  for(int i=1;i<5;i++)if(a[i]>=3){printf("NO\n");
                                 return 0;}
  printf("YES\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	vector<int> a;

	cin >> n;

	int b = 0;
	a.resize(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		b = b ^ a[i];
	}

	cout << (b == 0 ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 640
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt

  def rec(cnt:Int, num:Int):Int = {
    if(num % 2 != 0) cnt
    else rec(cnt+1, num/2)
  }

  val ans = in.readLine.split(" ").map(s => rec(0,s.toInt)).sum
  println(ans)
}

Measured memory_bytes: 31020
//ABC103B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	int num = s.size();
	string u;
	for(int i=0;i<num;i++){
		u = s;
		for(int j=1;j<=num;j++){
			s.at(j%num) = u.at(j-1);
		}
		if(s == t){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

# Set max recursion limit
sys.setrecursionlimit(1000000)


def li_input():
    return [int(_) for _ in input().split()]

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

def lcm_list(L):
    _lcm = lcm(L[0], L[1])

    for i in range(2, len(L)):
        _lcm = lcm(_lcm, L[i])

    return _lcm

def main():
    N = int(input())
    L = li_input()

    print(lcm_list(L))


main()



Measured memory_bytes: 5608
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 

    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 

    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 

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

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

    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
    int n, q;
    cin>>n>>q;
    int a[n];
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    Query queries[q]; 
    for (int i=0; i<q; i++) {
        int ll, rr;
        cin>>ll>>rr;
        queries[i].l=ll-1;
        queries[i].r=rr-1;
        queries[i].idx=i;
    }
    // queries[0].l = 0; 
    // queries[0].r = 4; 
    // queries[0].idx = 0; 
    // queries[1].l = 1; 
    // queries[1].r = 3; 
    // queries[1].idx = 1; 
    // queries[2].l = 2; 
    // queries[2].r = 4; 
    // queries[2].idx = 2; 
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 


Measured memory_bytes: 19384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            for (int i = 1; i <= 50000; i++)
            {
                var a = Floor(i * 1.08);
                if (a == n)
                {
                    WriteLine(i);
                    return;
                }
            }
            WriteLine(":(");

        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
  std::cin >> x;
  std::cout << x*x << '\n';
  std::vector<int> v(x);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    LL a, b, k;
    cin >> a >> b >> k;
    LL A = max(0LL, a-k);
    b = min(b, max(0LL, a+b-k));
    cout << A << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    
    string s;
    cin >> s;
    int n = s.size(), K;
    cin >> K;
    int dp[110][4][2];
    rep(i, 110) rep(j, 4) rep(l, 2) dp[i][j][l] = 0;
    dp[0][0][0] = 1;
    rep(i, n) rep(j, 4) rep(k, 2) {
        int nd = s[i] - '0';
        rep(d, 10) {
            int ni = i + 1;
            int nj = j;
            int nk = k;
            if(d != 0) nj++;
            if(nj > K) continue;
            if(nk == 0) { // きつい状態
                if(d > nd) continue;
                if(d < nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    cout << dp[n][K][0] + dp[n][K][1] << endl;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

counter = Counter(s)
index = 0
ans = []
for k, v in counter.most_common():
    if index == 0:
        max_v = v
        ans.append(k)
    else:
        if v == max_v:
            ans.append(k)
        else:
            break
    index += 1
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

vector<vector<int>> Tr(100010);
vector<int> Arr(100010, INT32_MIN);

int main(){
	int N, a, b;
	cin >> N;
	for (int i = 1;i < N;i++) {
		cin >> a >> b;
		a--;b--;
		Tr[a].push_back(b);
		Tr[b].push_back(a);
	}
	int K, v, p;
	cin >> K;
	priority_queue<pair<int, int>> Q;
	for (int i = 0;i < K;i++) {
		cin >> v >> p;
		v--;
		Q.push({ p,v });
	}
	while (!Q.empty()) {
		tie(p, v) = Q.top();
		Q.pop();
		if (Arr[v] > p) {
			cout << "No" << endl;
			return 0;
		}
		if (Arr[v] == p)continue;
		Arr[v] = p;
		for (int i : Tr[v]) {
			if (Arr[i] == INT32_MIN) {
				Q.push({ p - 1, i });
			}
		}
	}
	cout << "Yes" << endl;
	for (int i = 0;i < N;i++)
		cout << Arr[i] << endl;
}

Measured memory_bytes: 8692
from copy import deepcopy
n = input()
ans = 0
li = ["3", "5", "7"]
st = ["3", "5", "7"]
are = []
for i in range(len(n)-1):
    for i in range(len(st)):
        for j in range(len(li)):
            k = st[i] + li[j]
            are.append(k)
            if k.count("3") >= 1 and k.count("5") >= 1 and k.count("7") >= 1 and int(k) <= int(n):
                ans += 1
    li = deepcopy(are)
    are = []
print(ans)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
ll n, k, r, s, p;
string t;
char win[255];
int scr[255];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k >> scr['r'] >> scr['s'] >> scr['p'] >> t;
	vector<vector<int>> a(n);
	for (int i = 0; i < n; i++) {
		a[i % k].push_back(t[i]);
	}
	win['r'] = 'p';
	win['p'] = 's';
	win['s'] = 'r';
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int sz = a[i].size();
		if (sz > 0) {
			char lst = win[a[i][0]];
			ans += scr[lst];
			for (int j = 1; j < sz; j++) {
				if (win[a[i][j]] == lst) {
					if (j != sz - 1) {
						j++;
						lst = win[a[i][j]];
						ans += scr[lst];
					}
				} else {
					lst = win[a[i][j]];
					ans += scr[lst];
				}
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5456
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 10000
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end
using namespace std;
typedef pair<int, int> P;
int main(){
    
    
    int n,n1,n2;
    cin >> n >> n1 >> n2;
    int array[100] = {0};
    array[n]++;
    array[n1]++;
    array[n2]++;
    if(array[7] == 1  && array[5] == 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  cout<<(n+1)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ld, ld> P;
typedef vector<ld> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    VP vec(n);
    rep(i,n)cin>>vec[i].F>>vec[i].S;
    V vec1(n);
    V vec2(n);
    rep(i,n){
        vec1[i]=vec[i].F;
        vec2[i]=vec[i].S;
    }
    sort(all(vec1));
    sort(all(vec2));
    ld s,l;
    if(n%2==0){
        s=(vec2[n/2-1]+vec2[n/2])/2;
        l=(vec1[n/2-1]+vec1[n/2])/2;
       // cout<<s<<" "<<l<<endl;
        cout<<(ll)((s-l)/0.5+1)<<endl;
    }else{
        s=vec1[n/2];
        l=vec2[n/2];
        cout<<(ll)(l-s+1)<<endl;
    }
}


Measured memory_bytes: 15928
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
hl = inpl()
pre = -1
ans = 0
tmp = 0
for h in hl:
    if(pre >= h):
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
    pre = h
print(ans)

Measured memory_bytes: 91376
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
/*
NumnerOfDice?????????????????????????????§????????????????????????(No)????????????????????°??????(Yes)???????????????CheckConsistentDice_N
?????????????????????????????°???????????§?????????????????????CheckConsistentLabel
?????????????????????????????????????????¢????????????????????????TopFront
*/
class DICE
{
private:
	int Label[6];
public:
	DICE();
	void Input();
	void RotateDirection(std::string);
	void Rotate(int, int, int, int);
	 int GetLabel(int x) { return Label[x]; }
	void TopFront(int, int);
	bool CheckConsistentLabel(DICE AnotherDice);
};
DICE::DICE()
{
}
void DICE::Input()
{
	for (int i = 0; i < 6; ++i)
	{
		std::cin >> Label[i];
	}
}
void DICE::RotateDirection(std::string s)
{
	if (s == "E") { Rotate(0, 3, 5, 2); }
	if (s == "N") { Rotate(0, 1, 5, 4); }
	if (s == "S") { Rotate(0, 4, 5, 1); }
	if (s == "W") { Rotate(0, 2, 5, 3); }
}
void DICE::Rotate(int a, int b, int c, int d)
{
	std::swap(Label[a], Label[b]);
	std::swap(Label[b], Label[c]);
	std::swap(Label[c], Label[d]);
}
void DICE::TopFront(int top, int front)
{
	const int size_str = 7;
	std::string str[size_str] = {"N","N","N","W","N","N","N"};
	for (unsigned int i = 0; i < size_str; ++i)
	{
		if (front == Label[1]) { break; }
		RotateDirection(str[i]);
	}

    {
    	for (unsigned int i = 0; i < 4; ++i)
	    {
            if (top == Label[0]) break;
		    RotateDirection("W");
	    }
    }
}
bool DICE::CheckConsistentLabel( DICE AnotherDice) {
	int NumberLabel[101] = { 0 };
	for (int i = 0; i < 6; ++i) {
		NumberLabel[Label[i]] += 1;
		NumberLabel[AnotherDice.GetLabel(i)] -= 1;
	}
	int i = 0;
	while (i <= 100) {
		if (NumberLabel[i] != 0) {
			return false;
		}
		++i;
	}
	return true;
}
bool CheckConsistentDice_N( std::vector<DICE >&dice) {
	const int LastNumberDice = 5;
	for (unsigned int i = 0; i < dice.size(); ++i) {
		for (unsigned int j = i + 1; j < dice.size(); ++j) {
			if (dice[i].CheckConsistentLabel(dice[j])) {
				dice[i].TopFront(dice[j].GetLabel(0), dice[j].GetLabel(1));
				for (int k = 0; k <= LastNumberDice; ++k)
				{
					if (dice[i].GetLabel(k) != dice[j].GetLabel(k)) {
						break;
					}
					else {
						if (k == LastNumberDice) {							
							return false;
						}
					}
				}
			}
		}
	}
	return true;
}

int main(void)
{
	int NumberOfDice;
	std::cin >> NumberOfDice;
	std::vector<DICE> dice(NumberOfDice);
    for (int i = 0; i < dice.size(); i++) {
        dice[i].Input();
    }
	if (CheckConsistentDice_N(dice)) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}	
	//system("pause");
	return 0;
}

Measured memory_bytes: 3168
using System;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0] + input[1]);

            double b = Math.Sqrt(a);

            if ((int)b == b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

bool p1[3009], p2[3009]; int a, b, c, d, e, f; long double T = -1; pair<int, int>ans;

int main() {
	cin >> a >> b >> c >> d >> e >> f;
	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			int G = a*i + b*j; G *= 100;
			if (G <= 3000) p1[G] = true;
		}
	}
	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			int G = c*i + d*j;
			if (G <= 3000) p2[G] = true;
		}
	}
	for (int i = 0; i <= f; i++) {
		for (int j = 0; j <= f - i; j++) {
			if (p1[i] == false || p2[j] == false || j * 100 > i*e) continue;
			if (T < 1.0L*j / i) {
				T = 1.0L*j / i;
				ans = make_pair(i, j);
			}
		}
	}
	cout << ans.first + ans.second << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 256
(let* ((n (read))
       (b-list (sort (loop for i from 1 upto n collect (- (read) i)) #'<))
       (b (if (oddp n)
              (nth (1- (/ (1+ n) 2)) b-list)
              (floor (+ (nth (1- (floor n 2)) b-list)
                        (nth (floor n 2) b-list))
                     2))))
  (princ (apply #'+ (mapcar #'(lambda (bn) (abs (- bn b))) b-list))))

Measured memory_bytes: 62568
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto AS = readln.split.to!(long[]);
    AS ~= 0;

    foreach (_; 0..K) {
        auto BS = new long[](N+1);
        foreach (i, a; AS) {
            BS[max(0, i.to!long - a)] += 1;
            BS[min(N, i.to!long + a + 1)] -= 1;
        }
        auto all = true;
        long n;
        foreach (i, ref b; BS) {
            n += b;
            if (i != N && n != N) all = false;
            b = n;
        }
        AS = BS;
        if (all) break;
    }

    writeln(AS[0..$-1].to!(string[]).join(" "));
}

Measured memory_bytes: 33308
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
 
int main(){
    int n;
    cin >> n;
    int a[n];
    int ans = 1;
    rep(i,n) {
        cin >> a[i];
        if (a[i]%2 == 0){
            if (a[i]%3 == 0 || a[i]%5 == 0){
                continue;
            }
            else {
                ans = 0;
            }
        }
    }
    if (ans == 0) cout << "DENIED";
    else cout << "APPROVED";

    

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}

		Arrays.sort(a);
		Arrays.sort(c);


		long count = 0;
		for (int i = 0; i < n; i++) {
			int x = b[i];
			int lo = lowerBound(a, x);
			int hi = upperBound(c, x);
			count += (long) lo * (n - hi);
		}

		System.out.println(count);
	}

	private static int lowerBound(int[] a, int x) {
		int l = -1, r = a.length - 1;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (x <= a[m]) r = m;
			else l = m;
		}
		if (r == a.length - 1 && a[r] < x) r++;
		return r;
	}

	private static int upperBound(int[] a, int x) {
		int l = 0, r = a.length;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (a[m] <= x) l = m;
			else r = m;
		}

		if (l == 0 && a[l] > x) l--;
		return l + 1;
	}
}


Measured memory_bytes: 91924
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
As.sort()

from bisect import bisect_right
maxA = As[-1]
idx = bisect_right(As, maxA/2)

if abs(As[idx]-(maxA/2))>=abs(As[idx-1]-(maxA/2)):
    print(maxA, As[idx-1])
else:
    print(maxA, As[idx])

Measured memory_bytes: 86320
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,k,s;
	cin>>n>>k>>s;
	while(n--) {
		if(k>0)cout<<s<<" ",--k;
		else if(s!=1000000000)cout<<s+1<<" ";
		else cout<<s-1<<" ";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

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

    if(s.at(0) == '7' | s.at(1) == '7' |s.at(2) == '7')
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

// input
int N, M;
vector<int> A, B;


void input() {
    cin >> N >> M;
    A = B = vector<int>(N);
    rep(i, N) cin >> A[i] >> B[i];
}


int main() {
    input();
    vector<P> w(N);
    rep(i, N) w[i] = P(A[i], B[i]);
    sort(w.begin(), w.end());
    ll ans = 0;
    int m = M;
    rep(i, N) {
        if (m <= w[i].second) {
            ans += ll(w[i].first) * m;
            break;
        } else {
            ans += ll(w[i].first) * w[i].second;
            m -= w[i].second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(60, vector<ll>(60, INF));

int main()
{
	cin >> n >> k;
	if(k==1)
	{
		cout << n - 1 << endl;
		return 0;
	}
	v.resize(k);
	REP(i,k)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end(), greater<ll>());
	ans = 2 * v[0] - n - 1;
	if (ans < 0) ans = 0;
	cout << ans << endl;
}

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

int main() {
    int64_t N, M;
    std::cin >> N >> M;

    int64_t H[N];
    bool flag[N];
    for (int64_t i = 0; i < N; ++i) {
        std::cin >> H[i];
        flag[i] = true;
    }

    int A, B;
    for (int i = 0; i < M; ++i) {
        std::cin >> A >> B;
        --A; 
        --B;

        if (H[A] <= H[B]) {
            flag[A] = false;
        }

        if (H[B] <= H[A]) {
            flag[B] = false;
        }
    }

    int64_t ans = 0;
    for (int i = 0; i < N; ++i) {
        if (flag[i]) {
            ++ans;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 4512
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

#define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://code//in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)

const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;

int n, x;
priority_queue<int> q;

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &x);
        q.push(-x);
    }
    x = -q.top(); q.pop();
    int y;
    while(!q.empty()) {
        y = -q.top(); q.pop();
        if(y < x) swap(x, y);
        y = y % x;
        if(y) q.push(-y);
    }
    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main(){
	int n;
	int l;
	cin>>n>>l;
	int a[n];
	for (int i=0;i<n;i++){
		a[i]=l+i;
	}
	int ans=1000000000;
	int ans1;
	int sum=0;
	for (int i=0;i<n;i++){
		sum+=a[i];
		if (ans>abs(a[i])){
			ans=abs(a[i]);
			ans1=a[i];
		}
	}
	cout<<sum-ans1<<endl;
}

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

int main()
{
    int n;
    scanf("%d", &n);
    if(n==1)
    {
        printf("Hello World\n");
    } 
    else if(n==2)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        printf("%d\n", a + b);
    }
    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans;
  if (a != b && a != c && b != c) ans = 3;
  else if (a==b && b==c) ans = 1;
  else ans = 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def num(n):
    cnt = 0
    while n:
        if n % 2 == 0:
            cnt += 1
            n /= 2
        else:
            break
    return cnt


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

ans = num(A[0])
for i in A:
    ans =min(ans, num(i))
print(ans)


Measured memory_bytes: 3064
def main():
    n, threshould = [int(x) for x in input().split()]
    count = 0
    for _ in range(n):
        x, y = [int(x) for x in input().split()]
        distance = (x ** 2 + y ** 2) ** 0.5
        if distance <= threshould:
            count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9632
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    a: i64,
    b: i64,
    c: i64,
    d: i64,
    e: i64,
    k: i64,
    }

    if e - a > k {
      println!("{}", ":(");

    }else{
      println!("{}", "Yay!");

    }

}


Measured memory_bytes: 2168
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n;
    double t, a;
    cin >> n >> t >> a;
    
    double d = 1e9;
    int ind = n;
    for(int i = 0; i<n; i++){
        double x;
        cin >> x;
        x = t - 0.006*x;
        if(d > sqrt((x-a)*(x-a))){
            ind = i;
            d = sqrt((x-a)*(x-a));
            // cout << ind << ","<< d << endl;
        }
    }
    
    cout << ind +1 << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
def lcm(a,b):
    return a*b//fractions.gcd(a,b)
r = 1

for i in a:
    r = lcm(i,r)
r %= mod
res = 0
for i in a:
    res += r*pow(i,mod-2,mod)
    res %= mod
print(res)

Measured memory_bytes: 68072
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(int x, int y) {
    if (x == 2 || y == 2) return false;

    auto a = [1, 3, 5, 7, 8, 10, 12];
    auto b = [4, 6, 9, 11];
    if (a.canFind(x) && a.canFind(y)) return true;
    if (b.canFind(x) && b.canFind(y)) return true;
    return false;
}

void main() {
    auto xy = readints;
    int x = xy[0], y = xy[1];

    writeln(calc(x, y) ? "Yes" : "No");
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int,n);
  in(string,s);
  int ans=0;
  for(int i=0;i<s.size()-2;++i){
    if(s.substr(i,3)=="ABC")++ans;
  }
  out(ans);
}


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int a,b;
    cin>>a>>b;
    f(i,1,M)
    {
        double ca=(double)i*(0.08);
        double cb=(double)i*(0.1);
        int na=ca;
        int nb=cb;
        if(na==a && nb==b)
        {
            cout<<i<<endl;
            return 0;
        }

    }
    cout<<"-1"<<endl;

















    return 0;

}














Measured memory_bytes: 256
def resolve():
    N, M = [int(i) for i in input().split()]
    AABB = [list(map(int, input().split())) for _ in range(N)]
    AABB.sort()
    ans = 0
    drink = 0
    for A, B in AABB:
        need = M - drink
        if need <= B:
            ans += A * need
            break
        else:
            ans += A * B
            drink += B
    print(ans)


resolve()


Measured memory_bytes: 27764
x = gets()
x = x.split
d = x[0].to_i / x[1].to_i
r = x[0].to_i % x[1].to_i
f = (x[0].to_f / x[1].to_i).round(6)

puts d.to_s + " " + r.to_s + " " + f.to_s



Measured memory_bytes: 6932
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

bool done[5010];
vector<int> list[5010];
int num[5010],cnt=0;

void search(int x){
    int i,tmp;
    for(i = list[x].size()-1; i>=0; i--){
        tmp = list[x][i];
        if(!done[tmp]){
            done[tmp] = true;
            search(tmp);
        }
    }
    cnt++;
    num[cnt] = x;
    cout << x << endl;
}

int main(void){
    bool chk[5010];
    int n,m,k,i,j,flag=0;
    cin >> n >> m;
    fill(done,done+n,false);
    fill(chk,chk+n,false);
    for(k=0; k<m; k++){
        cin >> i >> j;
        list[j].push_back(i);
    }
    fill(done,done+n,false);
    for(k=1; k<=n; k++){
        if(!done[k]){
            done[k] = true;
            search(k);
        }
    }
    for(k=n; k>1; k--){
        flag=1;
        i = num[k];
        for(j = list[i].size()-1; j>=0; j--){
            if(list[i][j]==num[k-1]){
                flag=0;
            }
        }
        if(flag==1){
            break;
        }
    }
    cout << flag << endl;
    return 0;
}

Measured memory_bytes: 2092
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    A = [LI() for _ in range(N)]

    ctr = [0] * N

    sp = [0] * (M+1)
    for i in range(N):
        sp[A[i][ctr[i]]] += 1
    ans = max(sp)

    for _ in range(M-1):
        mi = sp.index(max(sp))
        sp[mi] = -1
        for i in range(N):
            if A[i][ctr[i]] == mi:
                while sp[A[i][ctr[i]]] < 0:
                    ctr[i] += 1
                sp[A[i][ctr[i]]] += 1
        ans = min(ans,max(sp))

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 76612
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;
#include<atcoder/all>
using namespace atcoder;


#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

using mint = modint998244353;

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N, K;
	cin >> N >> K;
	vll x(N + 1);
	repn(i, N)cin >> x[i];

	vll ri(N + 2);
	vll lef(N + 2);
	ri[0]=lef[0] = 0;
	ri[N + 1]=lef[N+1] = N + 1;
	repn(i, N) {
		auto itr = lower_bound(++x.begin(), x.end(), x[i] + K);
		ri[i] = distance(x.begin(), itr);
		auto itr2 = upper_bound(++x.begin(), x.end(), x[i] - K);
		lef[i] = distance(x.begin(), itr2) - 1;

		//cout << lef[i] << ri[i] << endl;
	}

	ll P = 25;
	vvll dri(N + 2, vll(P, 0)), dlef(N + 2, vll(P, 0));
	rep(i, N+2) {
		dri[i][0] = ri[i];
		dlef[i][0] = lef[i];
	}
	repn(j, P - 1) {
		//cout << j << endl;
		rep(i, N+2) {
			dri[i][j] = dri[dri[i][j - 1]][j - 1];
			dlef[i][j] = dlef[dlef[i][j - 1]][j - 1];
			//cout << i << j << dri[i][j] << dlef[i][j] << endl;
		}
	}

	vvll gri(N + 1), glef(N + 1);
	repn(i, N) {
		if (ri[i] <= N) { gri[ri[i]].push_back(i); }
		if (lef[i] > 0) { glef[lef[i]].push_back(i); }
	}
	
	vll ruiri(N + 2,0), ruilef(N + 2,0);
	repn(i, N) {
		ruilef[i] = i + ruilef[lef[i]];
		
		//cout << i << " " << ruilef[i] << endl;
	}
	for (ll i = N; i >= 1; i--) {
		ruiri[i] = i + ruiri[ri[i]];
		
		//cout << i << " " << ruiri[i] << endl;
	}

	ll Q;
	cin >> Q;
	repn(q, Q) {
		ll l, r;
		cin >> l >> r;
		
		ll cnt = 0;
		ll giriri = l;
		for (ll j = P - 1; j >= 0; j--) {
			if (dri[giriri][j] <= r) {
				giriri = dri[giriri][j];
				cnt += 1ull << j;
			}
		}

		//cout << giriri << cnt << endl;

		ll girilef = r;
		for (ll j = P - 1; j >= 0; j--) {
			if (dlef[girilef][j] >= l) {
				girilef = dlef[girilef][j];
			}
		}

		//cout << girilef << endl;

		ll ans = cnt+1;
		ans += ruilef[r] - ruilef[girilef] + girilef;
		ans -= ruiri[l] - ruiri[giriri] + giriri;
		cout << ans << endl;
	}

}


Measured memory_bytes: 123676
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long n = sc.nextLong();
    static long m = sc.nextLong();
    static long l = sc.nextLong();
    static long nm[][] = new long[(int)n][(int)m];
    static long ml[][] = new long[(int)m][(int)l];

    public static void main(String[] args) {
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                nm[i][j] = sc.nextLong();
            }
        }
        for (int i = 0; i < m; i++){
            for (int j = 0; j < l; j++){
                ml[i][j] = sc.nextLong();
            }
        }
        for (int i = 0; i < n; i++){
            for (int j = 0; j < l; j++){
                long result = 0;
                for (int k = 0; k < m; k++){
                 result += nm[i][k] * ml[k][j];
                }
                System.out.print(result);
                if (j != l - 1)
                    System.out.print(" ");
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 55528