akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

struct T {
    int y, x, d;
    T(){}
    T(int y, int x, int d):y(y),x(x),d(d){}
};


constexpr P dd[4] = {{-1,0}, {0,1}, {1,0}, {0,-1}};
int main(int argc, char const *argv[]) {
    int h,w,k; cin>>h>>w>>k;
    int sx,sy,gx,gy;
    cin>>sy>>sx>>gy>>gx;
    --sx,--sy,--gx,--gy;
    vector<string> g(h);
    rep(i,h) cin>>g[i];

    queue<T> q;
    vector<vector<vector<P>>> dp(h+1, vector<vector<P>> (w+1, vector<P>(4, P(INF,INF))));
    rep(i,4) {
        dp[sy][sx][i] = P(1, 0);
        q.emplace(sy,sx,i);
    }

    while (!q.empty()) {
        T cur = q.front(); q.pop();
        int cy = cur.y; int cx = cur.x; int cd = cur.d;
        // cout << "cy = " << cy << ", cx = " << cx << ", cd = " << cd << '\n';
        rep(i,4) {
            if (i==cd) continue;
            int ny = cy; int nx = cx; int nd = i;
            P cur_dist = dp[cy][cx][cd];
            cur_dist.first++; cur_dist.second = 0;
            if (chmin(dp[ny][nx][nd], cur_dist)) {
                q.emplace(ny,nx,nd);
            }
        }

        P new_dist = dp[cy][cx][cd];
        if (new_dist.second==k) {
            new_dist.second=1;
            new_dist.first++;
        }
        else {
            new_dist.second++;
        }

        int ny = cy+dd[cd].first; int nx = cx+dd[cd].second;
        int nd = cd;
        // cout << "ny = " << ny << ", nx = " << nx << ", nd = " << nd << '\n';
        if (ny < 0 || ny >= h || nx < 0 || nx>=w) continue;
        if (g[ny][nx] == '@') continue;
        if (chmin(dp[ny][nx][nd], new_dist)) {
            q.emplace(ny,nx,nd);
        }
    }

    ll ans = INF;
    rep(i,4) chmin(ans, dp[gy][gx][i].first);
    if (ans == INF) {
        cout << -1 << '\n';
    }
    else {
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 308872
N = int(input())
S = []
for _ in range(N):
    S.append(input())

AC = []
WA = []
TLE = []
RE = []

for i in range(N):
    if S[i] == "AC":
        AC.append(i)
    elif S[i] == "WA":
        WA.append(i)
    elif S[i] == "TLE":
        TLE.append(i)
    else:
        RE.append(i)
print("AC",  "x",  len(AC))
print("WA",  "x",  len(WA))
print("TLE",  "x",  len(TLE))
print("RE",  "x",  len(RE))

Measured memory_bytes: 20176
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
int n;
cin>>n;
int flag=0;
vector<int> a(10000000);
for(int i=0;i<n;i++){
  cin>>a[i];
  if(a[i]%2==0){
    if(a[i]%3==0){

    }else if(a[i]%5==0){

    }
    else{
      flag=1;
    }
  }
}
if(flag==1){
  cout<<"DENIED"<<endl;
}
else if(flag==0){
  cout<<"APPROVED"<<endl;
}
    return 0;
}





Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t k; cin >> k;
	int64_t n; cin >> n;
	int64_t a[n]; rep(i,n) cin >> a[i];
	int64_t sum = 0;
	int64_t b[n] = {};
	for(int i = 0; i < n - 1; ++i) {
		b[i] = a[i + 1] - a[i];
		sum += b[i];
	}
	b[n - 1] = a[0] + (k - a[n - 1]);
	sum += b[n - 1];
	int64_t ans = LINF;
	rep(i,n) {
		ans = min(ans, sum - b[i]);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())

"""
tmp = [a, b]
tmp.sort()
if tmp[0] == 2:
    print(1)
if tmp[0] == 1 and tmp[1] == 3:
    print(2)
else:
    print(3)
"""

if (a == 1 and b == 2) or (b == 1 and a == 2):
    print(3)
elif (a == 2 and b == 3) or (b == 2 and a == 3):
    print(1)
else:
    print(2)

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

int main (){
	int n,ans=0;
	cin >> n;
	vector<int> d(n);
 
    for(int i=0;i<n;i++){
        cin>>d.at(i);
    }

    for(int i=0;i<n;i++){
        for(int i2=i+1;i2<n;i2++){
            ans += d.at(i)*d.at(i2);
        }
    }
     cout<<ans<<endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    S = [A[0]]
    for a in A[1:]:
        S.append(S[-1]+a)

    def f(sig):
        o = 0
        ans = 0
        for s in S:
            s += o
            if s == 0:
                ans += 1
                o -= sig
            elif sig * s > 0:
                ans += abs(s) + 1
                o -= sig*(abs(s) + 1)
            sig *= -1
        return ans
            
    return min(f(1), f(-1))


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


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

vector<pair<int,int>> item[210];

int N;

int chmax(int &a,int b){
	if( a < b ) a = b;
}
double f(int M){
	int dp[210][210] = {};
	dp[0][0] = 0;
	for(int i = 0 ; i < N-1 ; i++){
		int cost = 0;
		int height = 0;
		
		//??????????????????
		for(int j = 0 ; j <= M ; j++){
			chmax(dp[i+1][j],dp[i][j]);	
		}
		for( auto itm : item[i] ){
			int S = itm.first;
			int H = itm.second;
			cost += S * H;
			height += H;
			for(int j = 0 ; j+cost <= M ; j++){
				chmax(dp[i+1][j+cost],dp[i][j]+height);	
			}
		}
	}
	double ans = 0;
	for(int j = 0 ; j <= M ; j++){
		double rem = M-j;
		double tot = dp[N-1][j];
		for( auto itm : item[N-1] ){
			int S = itm.first;
			int H = itm.second;
			if( rem >= S*H ){
				rem -= S*H;
				tot += H;
			}else{
				tot += (rem / (S*H)) * H;
				rem = 0;
			}
		}
		ans = max(ans,tot);
	}
	return ans;
}
int main(){
	int M;
	cin >> N >> M;
	for(int i = 0 ; i < N ; i++){
		int K;
		cin >> K;
		for(int j = 0 ; j < K ; j++){
			int s,h;
			cin >> s >> h;
			item[i].push_back(make_pair(s,h));
		}
	}
	double answer = 0;
	for(int i = 0 ; i < N ; i++){
		swap(item[i],item[N-1]);
		answer = max(answer,f(M));
		swap(item[i],item[N-1]);
	}
	printf("%.10lf\n",answer);
	
}

Measured memory_bytes: 1412
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {
	int N, K, X, Y;
	scanf("%d%d%d%d", &N, &K, &X, &Y);

	if (N <= K) {
		printf("%d", N*X);
	}
	else {
		printf("%d", K * X + (N - K)* Y);
	}






}

Measured memory_bytes: 128
import math

X,K,D = map(int,input().split())

KL = (X+K*D)/(2*D)

if 0 <= KL < K:
    ans1 = X - math.floor(KL)*D + (K-math.floor(KL))*D
    ans2 = X - math.ceil(KL)*D + (K-math.ceil(KL))*D
    if abs(ans1) < abs(ans2):
        print(abs(ans1))
    else:
        print(abs(ans2))
elif 0 > KL:
    print(abs(X+K*D))
else:
    print(abs(X-K*D))

Measured memory_bytes: 9196
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def calc(x, y):
        cnt[x] += 1
        cnt[y] -= 1
        res.append(S[x])

    n, *cnt = map(int, input().split())
    S = "ABC"
    query = []
    for _ in range(n):
        s = input().rstrip()
        a = 0 if s == "AB" else 0 if s == "AC" else 1
        b = 1 if s == "AB" else 2 if s == "AC" else 2
        query.append((a, b))
    query.append((None, None))

    res = []
    for i in range(n):
        a, b = query[i]
        if cnt[a] == cnt[b] == 0:
            print("No")
            return
        elif cnt[a] == 0:
            calc(a, b)
        elif cnt[b] == 0:
            calc(b, a)
        else:
            next_a, next_b = query[i + 1]
            if a == next_a or a == next_b:
                calc(a, b)
            else:
                calc(b, a)
    print("Yes")
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 18324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] tenbo = new int[n][2];

		for (int i = 0; i < n; i++) {
			tenbo[i][0] = sc.nextInt();
		}

		for (int i = 0; i < m; i++) {
			int[] a = tenbo[sc.nextInt() - 1];
			int[] b = tenbo[sc.nextInt() - 1];
			if (a[0] == b[0]) {
				a[1] = 1;
				b[1] = 1;
			} else if (a[0] > b[0]) {
				b[1] = 1;
			} else {
				a[1] = 1;
			}

		}
		System.out.println(Arrays.stream(tenbo).filter(s -> s[1] == 0).count());

	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

Measured memory_bytes: 59204
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    let c = read::<usize>();
    println!("{}", if a + b + c >= 22 { "bust" } else { "win" });
}


Measured memory_bytes: 2156
#include <iostream>
#include <vector>

using namespace std;

void print_vector(vector<int> v)
{
    for (auto it = v.begin(); it < v.end() - 1; it++)
    {
        cout << *it << " ";
    }
    cout << *(v.end() - 1) << endl;
}

void bubble_sort(vector<int> vec, int n)
{
    int buf, count = 0;
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int i = n - 1; i >= 0; i--)
        {
            if (vec[i - 1] > vec[i])
            {
                swap(vec[i - 1], vec[i]);
                count += 1;
                flag = true;
            }
        }
    }
    cout << count << endl;
    return;
}

int main()
{
    int n = 1;
    while (true)
    {
        {
            cin >> n;
            if (n == 0)
            {
                return 0;
            }
            vector<int> v(n);
            for (int i = 0; i < n; i++)
            {
                cin >> v[i];
            }
            bubble_sort(v, n);
            vector<int>().swap(v);
        }
    }
}



Measured memory_bytes: 3152
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s) a--;
	else b--;

	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}



main(){
    int n,k;cin>>n>>k;
    int mem;cin>>mem;
    int mx=mem;
    rep(i,n-1){
        int t;cin>>t;
        chmax(mx,t);
        mem=__gcd(mem,t);
    }
    //debug(mx,k,mem);
    if(mx>=k&&k%mem==0)dump("POSSIBLE");
    else dump("IMPOSSIBLE");
}









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

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 888
// (c) 2020, redotter

// Roses are red
// The Tardis is blue
// The Doctor once said
// Rose Tyler...

#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:500000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forr(i, s, n) for (int i = (s); i < (n); i++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i32 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

const i64 MAXN = 1e5 + 1;

i64 n, W;
v64 w, v;

void Problem::solve() {
	vv64 dp(n + 1, v64(MAXN, inf));
	dp[0][0] = 0;
	forr(i, 0, n) {
		forn(j, MAXN) {
			check_min(dp[i + 1][j], dp[i][j]);
			if (j + v[i + 1] < MAXN) {
				check_min(dp[i + 1][j + v[i + 1]], dp[i][j] + w[i + 1]);
			}
		}
	}
	i64 ans = -inf;
	forn(j, MAXN) {
		if (dp[n][j] <= W) {
			check_max(ans, j);
		}
	}
	println(ans);
}

void Problem::input() {
	read(n, W);
	w.resize(n + 1), v.resize(n + 1);
	forr(i, 1, n + 1) {
		read(w[i], v[i]);
	}
}


Measured memory_bytes: 83168
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	scanInit()

	n := nextInt()
	p := make([]pair, n)

	for i := 0; i < n; i++ {
		x := nextInt()
		l := nextInt()
		p[i] = pair{x + l, x - l, x, l}
	}

	removecnt := 0

	sortPairs(p)
	last := p[0].f
	for i := 1; i < n; i++ {
		// startがlastよりも未満だったらスルー
		if p[i].s < last {
			removecnt++
			continue
		}

		last = p[i].f
	}

	fmt.Println(n - removecnt)

}

// Pair ソート
// s := make([]pair, n)
// sortPairs(s)
type pair struct { // f=first, s=second
	f int
	s int
	x int
	l int
}

// []pair をf->sの順でソートする
func sortPairs(s []pair) {
	sort.Slice(s, func(i, j int) bool {
		if s[i].f == s[j].f { // fが同じ場合はsを比較する
			return s[i].s < s[j].s
		}
		return s[i].f < s[j].f
	})
	return
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
	int N;
    cin >> N;
    long long T[N];
    for(int i = 0; i < N; i++){
        cin >> T[i];
    }
    int M;
    cin >> M;
    long long P[M],X[M];
    for(int i = 0; i < M; i++){
        cin >> P[i] >> X[i];
    }
    for(int i = 0; i < M; i++){
        long long ans = 0;
        for(int j = 0; j < N; j++){
            if(P[i]-1 == j){
               ans += X[i];
            }else{
               ans += T[j];
            }
        }
        cout << ans << endl;
    }
	return 0;
}

Measured memory_bytes: 256
K = int(input())
S = input()

m = 1000000007

result = 0
t = pow(26, K, m)
u = pow(26, m - 2, m) * 25 % m
l = len(S)
for i in range(K + 1):
    # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m)
    result = (result + t) % m
    t = (t * u) % m * (l + i) % m * pow(i + 1, m - 2, m) % m
print(result)


Measured memory_bytes: 71180
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		ArrayList<Integer> array = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String ai = "";
		long goukei = 0;
		int max = 0, min = 0;
		br.readLine();
		ai = br.readLine();
		
		String [] hairetsu = ai.split(" ", 0);
		
		for(int i = 0; i < hairetsu.length; i++) {
			array.add(Integer.parseInt(hairetsu[i]));
		}
		
		min = array.get(0);
		max = array.get(0);
		
		for(int i = 0; i < array.size(); i++) {
			goukei = goukei + array.get(i);
			if(min > array.get(i)) {
				min = array.get(i);;
			}
			if(max < array.get(i)) {
				max = array.get(i);;
			}
		}
		
		System.out.println(min + " " + max + " " + goukei);
		

	}
}

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

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int m = in.readInt();
	    int c = in.readInt();
	    int b[] = new int[m]; 
	    for(int i = 0; i<m; i++) {
	    	b[i] = in.readInt();
	    }
	    
	    int sum = 0; 
	    for(int i = 0; i<n; i++) {
	    	int a = 0;
	    	for(int j = 0; j<m; j++) {
	    		int s = in.readInt();
	    		a += s * b[j];
	    	}
	    	if(a + c > 0)sum++; 
	    }
	    System.out.println(sum); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i, n) cin >> s[i];
  vector<vector<int>> a(n, vector<int>(26, 0));
  REP(i, n){
    REP(j, s[i].size()) a[i][s[i][j] - 'a']++;
  }
  string ans;
  REP(i, 26){ 
    int num = INF;
    REP(j, n) chmin(num, a[j][i]);
    if(num > 0) ans += string(num, 'a'+i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define cinf(n,a) rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(int argc,char* argv[])
{
    int a,b,c,ans=0;
    cin>>a>>b>>c;
    if(a+b<c)ans=a+b+b+1;
    else ans=b+c;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())

count=[0]*M

for k in range(N):
    a=list(map(int,input().split()))
    for i in range(1,a[0]+1):
        count[a[i]-1]+=1
    
ans=0
for i in range(M):
    if count[i]==N: ans+=1
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int check(char c[]){
	int i,len;
	len=strlen(c);
	if(len==3){
		if(strcmp(c,"the")==0){
			return 1;
		}
	}
	else if(len==4){
		if(strcmp(c,"this")==0||strcmp(c,"that")==0){
			return 1;
		}
	}
	return 0;
}

void change(char c[]){
	int i,len;
	len=strlen(c);
	for(i=0; i<len; i++){
		if(c[i]>='a'&&c[i]<='z'){
			c[i]++;
			if(c[i]>'z')c[i]-=26;
		}
	}
}

int main(){
	char c[1000],d[1000]={'\0'},e[1000];
	int i=0,j,k=0;
	int len;
	int b=0,b1=1,b2=0;

	while(gets(d)!=NULL){
		//printf("%s\n","test");
		b1=1;
		while(b1){
			j=0;
			//printf("%lu\n",strlen(d));
			while(j<strlen(d)){
				for(i=0; i<1000; i++){
					if(d[j]==' '||d[j]=='\0'||d[j]=='.'){
						c[i]='\0';
						//printf("test\n");
						j++;
						break;
					}
					else{
						c[i]=d[j];
						j++;
					}
				}
				if(check(c)){
					printf("%s\n",d);
					b1=0;
					break;
				}
			}
			change(d);
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int h,w;
    char s[52][52];
    int ans[52][52];
    int white = 0;
    int black = 0;
    cin >> h >> w;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> s[i][j];
            if(s[i][j] == '#'){
                black++;
            } else {
                white++;
            }
            ans[i][j] = -1;
        }
    }

    queue<tuple<int,int,int> > q;
    q.push(make_tuple(1,1,1));
    int m_x[] = {1,0,-1,0};
    int m_y[] = {0,1,0,-1};

    while(q.size() > 0){
        auto t = q.front();
        q.pop();
        int y = get<0>(t);
        int x = get<1>(t);
        int c = get<2>(t);
        if(x < 1 || x > w || y < 1 || y > h) continue;
        if(s[y][x] == '#' || ans[y][x] != -1) continue;
        ans[y][x] = c;
        for(int i = 0; i < 4; i++){
            q.push(make_tuple(y+m_y[i],x+m_x[i],c+1));
        }
    }

    if(ans[h][w] == -1){
        cout << -1 << endl;
    } else {
        cout << white-ans[h][w] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
	{
	long long int n,k=0,ans =0;
	cin>>n;
	vector<long long int> v(n,0);
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
		k = v[i];
		while(k%2 == 0){
			k = k/2;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (a*n > b) cout << b << endl;
	else cout << a*n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <iomanip>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
#include <limits>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <set>
#include <cstdio>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define FOR(i, a) for(int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int N = 1e5 + 10;
int n;
bool isp[N];
int a[N];
void init() {
    for (int i = 2; i < N; i++) {
        bool ok = true;
        for (int j = 2; 1ll * j * j <= i; j++) {
            if (i % j == 0) {
                ok = false;
                break;
            }
        }
        if (ok) isp[i] = 1;
        else isp[i] = 0;
    }
    for (int i = 2; i < N; i++) {
        if (i % 2 == 1 && isp[i] && isp[(i + 1) / 2]) a[i] = 1;
    }
    for (int i = 2; i < N; i++) a[i] += a[i - 1];
}
int l, r;
int main() {
    init();
    cin >> n;
    while (n--) {
        cin >> l >> r;
        cout << a[r] - a[l - 1] << endl;
    }
    return 0;
}




Measured memory_bytes: 1152
def main(str)
  lines = str.split("\n")
  _, k = lines[0].split(" ").map(&:to_i)
  ps = lines[1].split(" ").map(&:to_i)
  ps.sort[0...k].sum.to_s
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("210", main("5 3
50 100 80 120 80"))
    # assert_equal("", main(""))
  end
end




Measured memory_bytes: 14376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y % 2 != 0) {
			System.out.println("No");
		} else if (4 * x < y || 2 * x > y) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 27044
import collections 
N=int(input())
T=[list(map(int,input().split())) for _ in range(N)]
T.sort(reverse=True)
TMP=[]
if N==1:
    print(1)
else:
    for i in range(N-1):
        for b in range(i,N-1):
            TMP.append((T[i][0]-T[b+1][0],T[i][1]-T[b+1][1]))
    c=collections.Counter(TMP)
    print(N-c.most_common(n=1)[0][1])

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

int N;
vector<vector<int> > to;
vector<int> dist;

void dfs(int v,int d=0,int p=-1){
  dist[v]=d;
  for(int nv:to[v]){
    if(nv==p) continue;
    dfs(nv,d+1,v);
  }
}

vector<int> calcdist(int v){
  dist=vector<int>(N);
  dfs(v);
  return dist;
}

int main(){
  cin >> N;
  int u,v;
  cin >> u >> v;
  u--; v--;
  to.resize(N,vector<int>(0));
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b); 
    to[b].push_back(a); 
  }

  vector<int> distT=calcdist(u);
  vector<int> distA=calcdist(v);
  
  int mx=0;
  rep(i,N){
    if(distT[i]<distA[i]){
      mx=max(mx,distA[i]);
    }
  }
  int ans=mx-1;
  cout << ans << endl;

}

Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    char op;
    
    while(true){
        cin >> a >> op >> b;

        if(op == '?') break;
        switch(op){
            case '+': cout << a + b << endl; break;
            case '-': cout << a - b << endl; break;
            case '*': cout << a * b << endl; break;
            case '/': cout << a / b << endl; break;
        }
    }
    return 0;
}

Measured memory_bytes: 3084
n=int(input())
a,b = map(int, input().split())
pList = list(map(int, input().split()))

area1=0
area2=0
area3=0
for i in range(n):
  if pList[i]<=a:
    area1+=1
  elif a+1<= pList[i]<=b:
    area2+=1
  else:
    area3+=1

ans=min(min(area1,area2),area3)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
void cntr(){ cout << 0 << "\n"; }
int main(){
int N; cin >> N; int L=N-1;
unsigned long long T[N], A[N], ans=1;
for(int i=0; i<N; i++){ cin >> T[i]; }  
for(int i=0; i<N; i++){ cin >> A[i]; }  
if(N==1){ if(A[0]==T[0]){ cout << 1 << "\n"; }else{ cntr(); } }
else if(A[0]<T[0] || (A[0]>A[1] && A[0]!=T[0])){ cntr(); }
else if(A[N-1]>T[N-1] || (T[N-1]>T[N-2] && A[N-1]!=T[N-1])){ cntr(); }
else{  
for(int i=1; i<N-1; i++){ 
  if(T[i-1]==T[i] && A[i]==A[i+1]){ ans=(ans*min(T[i], A[i]))%MOD; }
  else if(T[i-1]<T[i] && A[i]>A[i+1]){ if(A[i]!=T[i]){cntr(); return 0;} }
  else if(T[i-1]<T[i]){ if(A[i]<T[i]){cntr(); return 0;} }
  else if(A[i]>A[i+1]){ if(A[i]>T[i]){cntr(); return 0;} }
}
cout << ans << "\n";
}
}

Measured memory_bytes: 1792
<?php
list($k, $n) = explode(' ', trim(fgets(STDIN)));
$as = explode(' ', trim(fgets(STDIN)));
 
$max = 0;
for ($i=0; $i < $n; $i++) {
  if (isset($as[$i+1])) {
    $d = $as[$i+1] - $as[$i];
  } else {
    $d = $k + $as[0] - $as[$i];
  }
 
  if ($max < $d) {
    $max = $d;
  }
}
 
echo $k - $max;

Measured memory_bytes: 39980
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, a[N];
ll s = 0, k = 0, h, cnt, u;
int main()
{
	ll i, j, w;
//	freopen ("input.txt", "r", stdin);
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
	}
	i = 1;
	s = 1;
	h = -1;
	u = n;
	w = 0;
	while (i <= n) {
		for (; i <= n; i++) {
			h += 2;
			if (h + k > a[i]) break;
		}
		i++;
		if(i > n) {
			for (j = 2; j <= u; j++) {
				s = (s * j) % M;
			}
		} else {
			cnt = (i - 1) - w;
			s = (s * cnt) % M;
		}
		k -= 2;
		u--;
		w++;
	}
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Thu Jun  4 22:35:46 2020

@author: naoki
"""

import sys

N = int(input()) # ボタンの個数
a = [int(input()) for i in range(N)] #k番目のボタンに書いてある番号
a = [0] + a #配列の番号合わせ
count = 0 #ボタンを押す回数
light = 1 # 光っているボタンの番号
if 2 not in a: # 2と書かれたボタンがない場合は不可能なので-1を出力
    print(-1)
    sys.exit()
else: # 2と書かれたボタンがある場合
    while light != 2 and count <= N : # 光っているボタンが2になるか、ボタンを押した回数がNを超えてしまったら終了
        count += 1 
        light = a[light]#左から数えたときに光っているボタンの番号の順番にあるボタンに書かれている数字が次に光るボタンの番号である。

if count <= N:        
        print(count)
else:
    print(-1)

Measured memory_bytes: 7852
using System;
using System.Collections.Generic;
using System.Linq;
namespace AOJ
{
    internal class Program
    {
        public static void Main(string[] args) { new Program().solve(); }
        void solve() {
            var D = new DiceClass();
            var inputs = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
            var orderNum = int.Parse(Console.ReadLine());
            D.SetDice(inputs);
            for (int i = 0; i < orderNum; ++i) {
                var af = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
                Console.WriteLine(D.Right(af[0], af[1]));
            }
        }
    }
    class DiceClass
    {
        //above figure is |0|
        //front figure is |1|
        //     N
        //    |0|
        //W |3|1|2|4| E
        //    |5|
        //     S
        public int[] Dice = new int[6];
        public int Above { get { return Dice[0]; } }
        public void SetDice(int[] a) {
            for (int i = 0; i < 6; ++i) Dice[i] = a[i];
        }
        public void SetBasicDice() {
            SetDice(Enumerable.Range(1, 6).ToArray());
        }
        private int[] genArr(params int[] a) {
            return new int[] { Dice[a[0]], Dice[a[1]], Dice[a[2]], Dice[a[3]], Dice[a[4]], Dice[a[5]] };
        }
        public void RollN() {
            SetDice(genArr(1, 5, 2, 3, 0, 4));
        }
        public void RollW() {
            SetDice(genArr(2, 1, 5, 0, 4, 3));
        }
        public void RollE() {
            SetDice(genArr(3, 1, 0, 5, 4, 2));
        }
        public void RollS() {
            SetDice(genArr(4, 0, 2, 3, 5, 1));
        }
        public void Show() {
            //     N
            //    |0|
            //W |3|1|2|4| E
            //    |5|       
            //     S
            Console.WriteLine("     N");
            Console.WriteLine("    |" + Dice[0] + "|");
            Console.WriteLine("W |" + Dice[3] + "|" + Dice[1] + "|" + Dice[2] + "|" + Dice[4] + "| E");
            Console.WriteLine("    |" + Dice[5] + "|");
            Console.WriteLine("     S");
        }
        public int Right(int above, int front) {
            Func<int, int, bool> f = (a, b) => Dice[a] == above && Dice[b] == front;
            if (f(1, 2) || f(2, 4) || f(4, 3) || f(3, 1)) return Dice[0];
            if (f(0, 3) || f(3, 5) || f(5, 2) || f(2, 0)) return Dice[1];
            if (f(0, 1) || f(1, 5) || f(5, 4) || f(4, 0)) return Dice[2];
            if (f(1, 0) || f(0, 4) || f(4, 5) || f(5, 1)) return Dice[3];
            if (f(0, 2) || f(2, 5) || f(5, 3) || f(3, 0)) return Dice[4];
            return Dice[5];            
        }




    }
}


Measured memory_bytes: 9524
N, K = [int(i) for i in input().split()]
D = [(1+int(i))/2 for i in input().split()]
v = sum(D[0:K])
maxv = v
for i in range(N-K):
    v -= D[i]
    v += D[i+K]
    maxv = max(maxv, v)
print(maxv)

Measured memory_bytes: 23148
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
//#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
#define rep(i,init,n) for(ll i=init;i<=n;++i)
using P = pair<string , int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    string s,t;
    cin >> s >> t ;
    int flag = 1;
    rep(i, 0, s.size()-1){
        if(s.at(i) != t.at(i)) flag = 0;
    }
    if(flag==1 && s.size()+1 == t.size()) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

int imos[SIZE];

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

    int n, c;
    cin >> n >> c;
    vector< pair<int, P> > v;
    for( int i = 0; i < n; ++i ) {
        int s, t, c;
        cin >> s >> t >> c;
        v.pb(MP(c, MP(s, t)));

    }
    sort(all(v));

    for( int i = 0; i < n; ++i ) {
        if( i - 1 >= 0 ) {
            if( v[i - 1].F == v[i].F && v[i - 1].S.S == v[i].S.F ) {
                imos[v[i].S.F + 1]++;

            } else {
                imos[v[i].S.F]++;

            }
        } else {
            imos[v[i].S.F]++;

        }
        imos[v[i].S.S + 1]--;
    }

    int res = 0;
    int cnt = 0;
    for( int i = 0; i <= 100005; ++i ) {
        cnt += imos[i];
        res = max(res, cnt);

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <cmath>
typedef long long ll;
struct D {
	int x;
	int y;
	ll h;
};
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<D> d(N + 1);

	for(int i = 0; i < N; i++) {
		cin >> d[i].x >> d[i].y >> d[i].h;
		if(d[i].h > 0) {
			d[N] = d[i];
		}
	}

	for(int x = 0; x <= 100; x++) {
		for(int y = 0; y <= 100; y++) {
			ll H = d[N].h + abs(x - d[N].x) + abs(y - d[N].y);
			for(int i = 0; i < N; i++) {
				ll h = max(H - abs(x - d[i].x) - abs(y - d[i].y), 0LL);
				if(h != d[i].h) goto next;
			}
			//passed all. it's vertex!
			cout << x <<" " << y << " " <<  H << endl;
			return 0;
			next:
			;
		}
	}

	return 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  char c[50][50];
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (c[i][j] == '#' && c[i][j + 1] != '#' && c[i][j - 1] != '#' && c[i + 1][j] != '#' && c[i - 1][j] != '#') {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}

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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < (e); ++i)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define FILEIO                          \
    freopen("./input.txt", "r", stdin); \
    freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                               \
    for (                                                                       \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                                       \
        debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T &x) { return x > 0 ? x : -x; }
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }

int main()
{
    // FASTIO
#ifdef LOCAL
    FILEIO
#endif
    ll n;
    cin >> n;
    ll ans = 0, cnt;
    for (ll i = 2; i * i <= n; ++i)
    {
        cnt = 0;
        while (n % i == 0)
        {
            n /= i;
            ++cnt;
        }
        for (int j = 1; j <= cnt; ++j)
        {
            cnt -= j;
            ++ans;
        }
    }
    if (n != 1)
        ++ans;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N,c=0,d=0;
  cin >> N;
  int n=N;
  while(N>0){
    N/=10;
    d++;
  }
  if(d>=2) c +=9;
  if(d>=4) c +=900;
  if(d>=6) c +=90000;
  if(d%2==1){
    n = n - pow(10,d-1);
    //cout << n << endl;
    c += n+1;
  }
cout << c << endl;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
A = list(map(int, input().split()))

A_dict = {}
for a in A:
    if a in A_dict:
        A_dict[a] += 1
    else:
        A_dict[a] = 1

A_sorted = sorted(A_dict.items(), key=lambda x:x[1], reverse=True)
rewrite = 0
while len(A_sorted) > K:
    tmp = A_sorted.pop()
    rewrite += tmp[1]

print(rewrite)


Measured memory_bytes: 38964
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if (a <= 5) cout << 0;
    else if (a <= 12) cout << b/2;
    else cout << b;
    return 0;
}

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],k,q,u,v,x,y,tc,c,l,r,ans,cnt[N];

char s[N];

int main(){
	scanf("%d%d",&n,&q);
	scanf("%s",s+1);
	for(int i=1;s[i];i++){
		cnt[i]+=cnt[i-1];
		if (s[i]=='C' && s[i-1]=='A')
			cnt[i]++;
	}
	while(q--){
		scanf("%d%d",&l,&r);
		printf("%d\n",cnt[r]-cnt[l]);
	}
}



Measured memory_bytes: 3328