akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

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

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int a, b, k;
  cin >> a >> b >> k;

  for(int i=a; i<a+k && i<=b; i++) {
    cout << i << endl;
  }
  for(int i=b-k+1; i<=b; i++) {
    if(i < a+k) continue;
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import           Data.Functor

main :: IO ()
main = solve =<< fmap read . words <$> getLine

solve :: [Integer] -> IO ()
solve [w,h,x,y,r] = putStrLn $ if fit then "Yes" else "No"
  where
    fit = fitW && fitH
    fitW = x-r >= 0 && x+r <= w
    fitH = y-r >= 0 && y+r <= h



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

int main()
{
	int e, m, x;
	while (cin >> e, e) {
		m = 1000000;
		for (int z = 0;z*z*z <= e; z++) {
			for (int y = 0;; y++) {
				if ((x = e - y*y - z*z*z) >= 0) {
					m = min(m, x + y + z);
				}
				else
					break;
			}
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll X, K, D;
    cin >> X >> K >> D;
    
    X = abs(X);

    ll straight = min(K, X/D);
    K -= straight;
    X -= straight*D;

    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod

int f(int x){
    if(x < 0) return 0;
    if(x % 4 == 0) return x;
    if(x % 4 == 1) return 1;
    if(x % 4 == 2) return x ^ 1;
    if(x % 4 == 3) return 0;
}

signed main(){

    int A, B; cin >> A >> B;
    cout << (f(A - 1) ^ f(B)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,q,k;
long long dt[101010];
vector<pair<int,int> >e[101010];
void dfs(int x,int y)
{
	for(int i=0;i<e[x].size();i++)
	{
		pair<int,int>p=e[x][i];
		if(p.first==y)
		{
			continue;
		}
		dt[p.first]=dt[x]+p.second;
		dfs(p.first,x);
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		e[a].push_back(make_pair(b,c));
		e[b].push_back(make_pair(a,c));
	}
	cin>>q>>k;
	dfs(k,0);
	for(int i=0;i<q;i++)
	{
		int a,b;
		cin>>a>>b;
		cout<<dt[a]+dt[b]<<endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll K;
    cin >> K;
    if(K == 1){
        cout <<K << endl;
        return 0;
    }
    auto check = [&](ll X){
        string S = to_string(X);
        int N = S.size();
        //i桁目までで未満フラグj,最後の数字l
        ll dp[N+1][2][10];
        rep(i,N+1)rep(j,2)rep(k,10)
            dp[i][j][k] = 0;
        dp[1][0][S[0]-'0'] = 1;
        rep1(i, S[0]-'0')dp[1][1][i] = 1;
        for(int i = 1; i < N;i++){
            rep1(l, 10)dp[i+1][1][l] += 1;
            rep(j,2)rep(k,10){
                int minn = max(0,k - 1);
                int maxx = min({k+1, (j ? 9:S[i]-'0')});
                for(int x = minn; x <= maxx;x++){
                    dp[i+1][j || x < S[i]-'0'][x] += dp[i][j][k];
                }
            }
        }
        ll cnt = 0;
        rep(j,2)rep(k,10){
            cnt += dp[N][j][k];
        }
        //cerr << X << " " << cnt << endl;
        return cnt < K;
    };
    ll ok = -1;
    ll ng = 1e11;
    while(ng - ok > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout << ng << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;

int main(){
	char a,b,c,d;
	scanf("%c%c%c%c",&a,&b,&c,&d);
	if((a==b and b==c) or (b==c and c==d)) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <math.h>
#include <list>
#include <bits/stdc++.h>

using namespace std;

int main(void){
  long X ,K ,D;
  cin >> X >> K >> D;
  X = abs(X);

  long until = ceil((double)X / (double)D);
  //cout << until << endl;
  if(until >= K){
    cout << abs(X - K*D) << endl;
  }else{
    K = K - until;
    X = (X - until*D);
    if(K % 2 == 0){
      cout << abs(X) << endl;
    }else{
      cout << abs(X + D) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <map>
#include <cstdlib>

static std::map<char, std::string> bin_table;

void init() {
	bin_table[' '] = "101";
	bin_table['\''] = "000000";
	bin_table[','] = "000011";
	bin_table['-'] = "10010001";
	bin_table['.'] = "010001";
	bin_table['?'] = "000001";
	bin_table['A'] = "100101";
	bin_table['B'] = "10011010";
	bin_table['C'] = "0101";
	bin_table['D'] = "0001";
	bin_table['E'] = "110";
	bin_table['F'] = "01001";
	bin_table['G'] = "10011011";
	bin_table['H'] = "010000";
	bin_table['I'] = "0111";
	bin_table['J'] = "10011000";
	bin_table['K'] = "0110";
	bin_table['L'] = "00100";
	bin_table['M'] = "10011001";
	bin_table['N'] = "10011110";
	bin_table['O'] = "00101";
	bin_table['P'] = "111";
	bin_table['Q'] = "10011111";
	bin_table['R'] = "1000";
	bin_table['S'] = "00110";
	bin_table['T'] = "00111";
	bin_table['U'] = "10011100";
	bin_table['V'] = "10011101";
	bin_table['W'] = "000010";
	bin_table['X'] = "10010010";
	bin_table['Y'] = "10010011";
	bin_table['Z'] = "10010000";
}

std::string to_bin_str( const std::string& gen )
{
	std::string ret;

	std::string::const_iterator end = gen.end();
	for( std::string::const_iterator it=gen.begin(); it<end; ++it )
		ret += bin_table[*it];

	if ( ret.size()%5 != 0 )
		ret.append( (ret.size()/5+1)*5-ret.size(), '0' );

	return ret;
}

std::string to_encrypted_str( const std::string& gen )
{
	const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-\'?";
	std::string ret;

	std::string::const_iterator end = gen.end();
	for( std::string::const_iterator it=gen.begin(); it<end; it+=5 )
		ret += table[std::strtol( std::string( it, it+5 ).c_str(), 0, 2 )];

	return ret;
}

int main() {
	init();
	std::string s;
	while( getline( std::cin, s ) )
		std::cout << to_encrypted_str( to_bin_str( s ) ) << std::endl;
}

Measured memory_bytes: 0
A, B = map(int, input().split())

def f(x):
    if x % 4 <= 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return x + 1
    else:
        return 0
print(f(B) ^ f(A-1))


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

#define ll long long
#define ld long double

using namespace std;

const ld pi = 3.1415926535897932384626433832795;

int main()
{
    ld a,b,x;
    ld ostv, r,t,angle;
    cin >> a >> b >> x;
    if(2 * x >= a * a * b)
    {
        ostv = a * a * b - x;
        ostv /= a;
        r = 2.0 * ostv / a;
        t = a / r;
        angle = atan(t);
        angle = pi / 2.0 - angle;
        angle = angle / pi * 180.0;
        cout << fixed << setprecision(20) << angle;
    } else
        {
            ostv = x;
            ostv /= a;
            r = 2.0 * ostv / b;
            t = b / r;
            angle = atan(t);
            angle = angle / pi * 180.0;
            cout << fixed << setprecision(20) << angle;
        }

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxn = 1e6 + 10;
int n, m, g[105][105], dp[105][105];
int main()
{
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n; i++)
    {
        getchar();
        for(int j = 1; j <= m; j++)
        {
            char ch = getchar();
            if(ch == '.')
                g[i][j] = 1;
            else
                g[i][j] = 0;
        }
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][1] = dp[1][0] = 0;
    g[0][1] = g[1][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(g[i][j])
                dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
            else
                dp[i][j] = min(dp[i-1][j] + g[i-1][j], dp[i][j-1] + g[i][j-1]);
        }
    }
    printf("%d\n", dp[n][m]);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	Vec2 operator/(T s) const { return Vec2(x/s, y/s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }
	T sqlength() const { return x*x + y*y; }
	double length() const { return sqrt(sqlength()); }
	bool operator<(const Vec2& rhs) const
	{
		if (x != rhs.x) return x < rhs.x;
		return y < rhs.y;
	}

	T x;
	T y;
};

template<class T>
T cross(const Vec2<T> &O, const Vec2<T> &A, const Vec2<T> &B)
{
	return (A - O).cross(B - O);
}

template<class T>
bool IsIntSegments(const Vec2<T>& A1, const Vec2<T>& A2, const Vec2<T>& B1, const Vec2<T>& B2)
{
	return (cross(A1, A2, B1)*cross(A1, A2, B2) < 0 && cross(B1, B2, A1)*cross(B1, B2, A2) < 0);
}

template<class T>
double DistPoint2Seg(const Vec2<T>& P, const Vec2<T>& A, const Vec2<T>& B)
{
	if ((B - A).dot(P - A) < 0) return (P - A).length();
	if ((A - B).dot(P - B) < 0) return (P - B).length();
	return fabs(double((B - A).cross(P - A))) / (B - A).length();
}

int main()
{
	typedef Vec2<long long> Vec;

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		Vec P[4];
		for (int j = 0; j < 4; j++) {
			cin >> P[j].x >> P[j].y;
		}

		if (IsIntSegments(P[0], P[1], P[2], P[3])) {
			puts("0");
			continue;
		}

		double d1 = DistPoint2Seg(P[0], P[2], P[3]);
		double d2 = DistPoint2Seg(P[1], P[2], P[3]);
		double d3 = DistPoint2Seg(P[2], P[0], P[1]);
		double d4 = DistPoint2Seg(P[3], P[0], P[1]);
		printf("%.10f\n", min(d1, min(d2, min(d3, d4))));
	}
	return 0;
}


Measured memory_bytes: 3204
//
//  main.cpp
//  atCoder
//
//  Created by 佐々木勇星 on 2019/07/23.
//  Copyright © 2019 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <regex>


int main(void) {
    
    using namespace std;
    
    int N;
    int count = 0,countmax = 0;
    //int flag=0;
    cin >> N;
    
    vector<int> height(N);
    
    for(int i=0; i<N; i++){
        cin >> height[i];
    }
    
    reverse(height.begin(), height.end());
    
//    for(int i=0; i<N; i++){
//        if(height[flag+i] >= height[flag+i+1]){
//            cout << height[flag+i]  << " " << height[flag+i+1] << endl;
//            count++;
//        }else{
//            flag=i+1;
//            countmax=count;
//            count=0;
//        }
//    }
    
    for(int i=1; i<N; i++){
        if(height[i-1] <= height[i]) count++;
            else count=0;
        countmax = max(countmax, count);
    }
    
    cout << countmax << endl;
    
    return 0;
}


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


public class Main {
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		String s=sc.next();
		int[] mojisu=new int[3];
		Arrays.fill(mojisu,0);
		for(int i=0; i<s.length(); i++) {
			mojisu[s.charAt(i)-97]++;
		}
		int syurui=0;
		for(int i=0; i<3; i++) {
			if(mojisu[i]>0) {
				syurui++;
			}
		}
		if(syurui==1) {
			if(s.length()==1) {
				pl("YES");
			}
			else {
				pl("NO");	//2文字以上の同じ文字列はパリンドローム
			}
		}
		else if(syurui==2) {
			if(s.length()<=2) {
				pl("YES");
			}
			else {
				pl("NO");
			}
		}
		else {
			int length=0;
			Arrays.sort(mojisu);
			mojisu[1]-=mojisu[0];
			mojisu[2]-=mojisu[0];
			mojisu[0]=0;
			length=mojisu[1]+mojisu[2];
			syurui=0;
			for(int i=0; i<3; i++) {
				if(mojisu[i]>0) {
					syurui++;
				}
			}
			if(syurui==0) {
				pl("YES");
			}
			else if(syurui==1) {
				if(length==1) {
					pl("YES");
				}
				else {
					pl("NO");	//2文字以上の同じ文字列はパリンドローム
				}
			}
			else if(syurui==2) {
				if(length<=2) {
					pl("YES");
				}
				else {
					pl("NO");
				}
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


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

long long n, id = -1;
vector<long long> base, fizzcnt, buzzcnt, fizzbuzzcnt,
    numcnt, lensum, sum;

string solve();
long long calc(long long num);

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

string solve() {
  string res, tmp;
  long long now = 1, l, r;
  base.push_back(0);
  fizzcnt.push_back(0);
  buzzcnt.push_back(0);
  fizzbuzzcnt.push_back(0);
  numcnt.push_back(0);
  lensum.push_back(0);
  sum.push_back(0);
  for(long long i = 1; i < 18; ++i) {
    base.push_back(now);
    now *= 10;
    fizzcnt.push_back((now - 1) / 3);
    buzzcnt.push_back((now - 1) / 5);
    fizzbuzzcnt.push_back((now - 1) / 15);
    numcnt.push_back(
        now - 1 -
        (fizzcnt[i] + buzzcnt[i] - fizzbuzzcnt[i]));
    sum.push_back(sum[i - 1] +
                  i * (numcnt[i] - numcnt[i - 1]));
    lensum.push_back(sum[i] +
                     4 * (fizzcnt[i] + buzzcnt[i]));
  }
  for(int i = 1; i < 18; ++i)
    if(n >= lensum[i - 1] + 1) id = i;
  assert(id != -1);
  l = base[id], r = base[id] * 10;
  while(r - l > 1) {
    now = (r + l) / 2;
    if(calc(now) <= n)
      l = now;
    else
      r = now;
  }
  now = calc(l);
  for(int i = 0; i < 20; ++i) {
    bool ch = 0;
    if((l + i) % 3 == 0) {
      ch = 1;
      tmp += "Fizz";
    }
    if((l + i) % 5 == 0) {
      ch = 1;
      tmp += "Buzz";
    }
    if(!ch) tmp += to_string(l + i);
  }

  for(int i = 0; i < tmp.size(); ++i)
    if(n <= now + i && now + i < n + 20) res += tmp[i];
  return res;
}

long long calc(long long num) {
  long long res = sum[id - 1];
  --num;
  res += 4 * (num / 3 + num / 5);
  res += id * (num - num / 3 - num / 5 + num / 15 -
               numcnt[id - 1]);
  return res + 1;
}



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

int main(){
  int i,j,n,flag=1,min;
  char a[36][3],b[36][3],r1[3],r2[3];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s",a[i]);
    for(j=0; j<3; j++)
      b[i][j]=a[i][j];
  }

  /* Babble  */
  while(flag){
    flag=0;
    for(i=n-1; i>0; i--){
      if(a[i][1]<a[i-1][1]){
	strcpy(r1,a[i]);
	strcpy(a[i],a[i-1]);
	strcpy(a[i-1],r1);
 
	flag=1;
      }
    }
  }

    
  for(i=0; i<n-1; i++)
    printf("%s ",a[i]);
  
  printf("%s\n",a[i]);
  printf("Stable\n");

  
  /* Selection */
  for(i=0; i<n; i++){
    min = i;
    for(j=i; j<n; j++)
      if(b[j][1]<b[min][1])
	min = j;
    if(i!=min){
    strcpy(r2,b[i]);
    strcpy(b[i],b[min]);
    strcpy(b[min],r2);
    }
    
  }

  
  for(i=0; i<n-1; i++)
    printf("%s ",b[i]);
  
  printf("%s\n",b[i]);

  flag=0;
  for(i=0; i<n; i++)
    if(a[i][0]!=b[i][0])
      flag=1;
  
  if(flag==0)
     printf("Stable\n");
  else
     printf("Not stable\n");
    
  
  return 0;

}



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

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

  vector<int> A(N + 2, 0);
  for (int i = 1; i < N + 1; i++) cin >> A.at(i);

  long long time = 0;
  for (int i = 0; i < N + 1; i++) time += abs(A.at(i + 1) - A.at(i));

  for (int i = 0; i < N; i++) {
    long long ans = time;
    ans += abs(A.at(i + 2) - A.at(i)) - abs(A.at(i + 1) - A.at(i)) -
           abs(A.at(i + 2) - A.at(i + 1));
    cout << ans << endl;
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define FIO "agc31D"
using namespace std;

const int N=1e5+5;

int n,k;

struct per{
  int a[N];
  inline void rd(){
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
  }

  inline int& operator [](int x){return a[x];}
  inline const int& operator [](const int &x)const {return a[x];}

  inline per inv(){
    static per ret;
    for(int i=1;i<=n;i++)ret[a[i]]=i;
    return ret;
  }

  inline per operator *(const per &b)const{
    static per ret;
    for(int i=1;i<=n;i++)ret[i]=a[b[i]];
    return ret;
  }
  inline per& operator *=(const per &b){return *this=*this*b;}
  inline void set(){
    for(int i=1;i<=n;i++)a[i]=i;
  }
  inline void out(){
    for(int i=1;i<=n;i++)printf("%d%c",a[i],i^n?' ':'\n');
    cout.flush();
  }
  inline per operator ^(int b)const{
    static per a=*this,ret;
    ret.set();
    for(;b;b>>=1,a*=a)
      if(b&1)ret*=a;
    return ret;
  }
}p,q,ip,iq,a[7],cur;

int main(){
  scanf("%d%d",&n,&k);
  p.rd();
  q.rd();
  ip=p.inv();
  iq=q.inv();
  a[1]=p;a[2]=q;
  for(int i=3;i<=6;i++)a[i]=a[i-1]*(a[i-2].inv());
  cur=(q*ip*iq*p)^((k-1)/6);
  (cur*a[(k-1)%6+1]*(cur.inv())).out();
  return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

int main() {
	optimizar_io
	int l, r, d;

	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; i++)
		if (i % d == 0)
			cnt++;
	cout << cnt << "\n";
	return 0;
}

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

void output(std::vector<int> vec) {
    for (int i = 0; i < vec.size(); i ++) {
        if (i > 0) std::cout << " ";
        std::cout << vec[i];
    }
    std::cout << std::endl;
}

int main() {
    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for (int i = 0; i < N; i ++) {
        std::cin >> A[i];
    }

    output(A);
    for (int i = 1; i < N; i ++) {
        int v = A[i];
        int j;
        for (j = i - 1; j >= 0; j --) {
            if (A[j] <= v) break;
            A[j+1] = A[j];
        }
        A[j+1] = v;

        output(A);
    }
}



Measured memory_bytes: 3132
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=1e5+5;
const int mod=1e9;
const double pi=acos(-1.0);
ll a,b,c,k;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sc(a),sc(b),sc(c),sc(k);
    if(a>k) pr(k);
    else if(a+b>=k) pr(a);
    else pr(a-(k-(a+b)));
    return 0;
}

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

int main(){
	int n; cin >> n;
	long long sum = 0;

	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0) continue;
		else sum += i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
using namespace std;
int main()
{
        int n,ans=0;
        cin >> n;
        vector<int> p(n);             
        for (int i = 0; i < n; i ++)
                cin >> p[i];
        for (int i = 1; i < n - 1; i++)
        {   
                if (p[i-1] < p[i] && p[i] < p[i+1])
                                ans++;
                else if (p[i-1] > p[i] && p[i] > p[i+1])
                                ans++;
        }   
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #define int long long
    int X,Y,A,B,C,D,N,A5;
    string S,T;
    cin >> S >> T;
    int rs = 0;
    for(int i = 0;i<S.size();i++){
        if(S.at(i) !=T.at(i)){
            rs = 1;
            break;
        }
    }
    if(rs ==0){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    
    
}



Measured memory_bytes: 3632
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int A = 0, B = 0;
	int ans = 0;
	scanf("%d %d", &A, &B);
	if ((A >= 10) || (B >= 10)) {
		ans = -1;
	} else {
		ans = A * B;
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int count=0;
    for(int i=1;i<=N;i++){
        string str=to_string(i);
        if(str.length()%2==1)count++;
    }
    cout << count << endl;
}


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

using namespace std;

int main(){
    long N, A, B;
    cin >> N >> A >> B;
    if(A+B > N+1 || A*B < N){
        cout << -1 << endl;
    }else{
        vector<int> v;
        v.push_back(A);
        for(int i = 1; i < B; i++){
            if(i <= (N-A)%(B-1)) v.push_back((N-A)/(B-1)+1);
            else v.push_back((N-A)/(B-1));
        }
        int tmp = N;
        vector<int> ans;
        for(int i = 0; i < v.size(); i++){
            for(int j = 0; j < v[i]; j++){
                ans.push_back(tmp-v[i]+j+1);
            }
            tmp -= v[i];
            //cout << v[i] << ' ';
        }
        //cout << endl;
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i];
            if(i == ans.size()-1) cout << endl;
            else cout << ' ';
        }
    }
}

Measured memory_bytes: 4080
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n != -1)
	{
		double x = 0;
		double y = 0;
		double angle = 0;
		while(n--)
		{
			x += cos(angle);
			y += sin(angle);	
			angle = M_PI / 2 + atan2(y, x);
		}
		cout << x << endl;
		cout << y << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
#define F(a,b,c,d) for (register int a=b;a<=c;a+=d)
#define FD(a,b,c,d) for (register int a=b;a>=c;a-=d)
using namespace std;
int main(){
	int n,m,c,ans=0;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>m;
		while (m%2==0)
		{
			m/=2;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := scanRunes()
	q := scanInt()
 
	b := make([]bit, 26)
	for i := 0; i < 26; i++ {
		b[i] = make(bit, n+1)
	}
 
	for i, e := range s {
		val := e-'a'
		b[val].add(i,1)
	}
 
 
	for i := 0; i < q; i++ {
		act := scanInt()
		if act == 1 {
			idx := scanInt()-1
			c := scanString()
			
			b[s[idx]-'a'].add(idx, -1)
			s[idx] = rune(c[0])
			b[c[0]-'a'].add(idx, 1)
		} else {
			l := scanInt()-1
			r := scanInt()-1
			cnt := 0
			for j := 0; j < 26; j++ {
				if b[j].sum(r)-b[j].sum(l-1) > 0 {
					cnt++
				}
			}
			fmt.Fprintln(wr, cnt)
		}
	}
}

type bit []int
 
func (t bit) sum(i int) int {
	s := 0
	for i++; i > 0; i -= i & -i { s += t[i] }
	return s
}
 
func (t bit) add(i, x int) {
	for i++; i < len(t); i += i & -i { t[i] += x }
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a + b) {
    cout << min(k, a) << "\n";
    return 0;
  }
  k -= a + b;
  cout << a - k << "\n";
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y)
{
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i = 0; i <= m; i++)
    c[i][0] = 0;
  for (int j = 0; j <= n; j++)
    c[0][j] = 0;
  for (int i = 1; i <= m; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      if (X[i] == Y[j])
      {
        c[i][j] = c[i - 1][j - 1] + 1;
      }
      else
      {
        c[i][j] = max(c[i][j - 1], c[i - 1][j]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    string X, Y;
    cin >> X;
    cin >> Y;
    cout << lcs(X, Y) << endl;
  }
  return 0;
}


Measured memory_bytes: 7088
program main
  implicit none
  
  integer :: a(5), b(5),i,j,n= 5,t,s
  do i = 1, 5
    read(*,*)a(i)
    b(i) = mod(a(i),10)
    if (b(i) == 0) then
      b(i) = 10
    end if
  end do
  
    do i=1,N-1
     do j=i+1,N
        if(b(i) .gt. b(j))then
           t=b(i)
           b(i)=b(j)
           b(j)=t
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  
  s = a(1)
  do i = 2, 5
    if (b(i) == 10) then
      s = s + a(i)
    else
      s = s + a(i) + (10 - b(i))
    end if
  end do
  
  write(*,*)s
end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll n;cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n) {
    cin>>a[i];
    b[i]=a[i];
  }
  sort(all(a));
  rep(i,n){
    if(b[i]<a[n/2]){
      cout<<a[n/2]<<endl;
    }
    else{
      cout<<a[n/2-1]<<endl;
    }
  }
}



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

using namespace std;

bool X( long long int N, vector<bool>D ) {
	while( N ) {
		if( D[N % 10] ) {
			return true;
		}
		N /= 10;
	}
	return false;
}

int main() {
	long long int N, K;
	cin >> N >> K;
	vector<bool>D( 10 );
	for( size_t i = 0; i < K; i++ ) {
		long long int x;
		cin >> x;
		D[x] = true;
	}
	while( X( N, D ) ) {
		N++;
	}
	cout << N << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [tuple(map(typ, input().split())) if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, M = read_h()
    roads = read_v(M, m=2)
    cnt = [0] * N

    for a, b in roads:
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for c in cnt:
        print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
s[r] - s[l] = r - l (mod k)
s[r] - r = s[l] - l (mod k)
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 200010;

int n, k;
ll s[N];
map<ll,ll>S;

int main() {
	cin >> n >> k;
	for(int i = 1, x; i <= n; ++i) {
		cin >> x;
		s[i] = s[i - 1] + x;
	}
	S[0] = 1;
	ll ans = 0;
	int l = 0;
//	for(int i = 1; i <= n; ++i) printf("%d ", (s[i] - i + k) % k);
//	puts("");
	for(int i = 1; i <= n; ++i) {
		if(i >= k) {S[(s[l] - l + k) % k]--; ++l;}
		ans += S[(s[i] - i + k) % k];
//		printf("%d ", S[(s[i] - i + k) % k]);
		S[(s[i] - i + k) % k]++;
	}//puts("");
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 17724
ab = input().split(" ")
start = int(ab[0])
stop = int(ab[1])+1
ans = 0
for i in range(start, stop):
  x = i%10*10 + int(i/10)%10
  y = int(i/1000)
  #print(i%10*10 + int(i/10)%10)
  #print(int(i/1000))
  if x==y:
    ans = ans+1
   # print("{} {} {}".format(i,x,y))
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
struct Point { long double px, py; };
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
long double norm(const Point& a) { return a.px*a.px + a.py*a.py; }
int ccw(Point p0, Point p1, Point p2) { Point a, b; a.px = p1.px - p0.px; a.py = p1.py - p0.py; b.px = p2.px - p0.px; b.py = p2.py - p0.py; if (crs(a, b) > 1e-10) return 1; if (crs(a, b) < -1e-10) return -1; if (dot(a, b) < -1e-10) return 2; if (norm(a) < norm(b)) return -2; return 0; }
bool its(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); }
int main() { int N; Point A1, A2, A3, A4; cin >> N; for (int i = 0; i < N; i++) { cin >> A1.px >> A1.py >> A2.px >> A2.py >> A3.px >> A3.py >> A4.px >> A4.py; bool res = its(A1, A2, A3, A4); if (res == true) { cout << "1" << endl; } else { cout << "0" << endl; } } }

Measured memory_bytes: 1228
def isMonth(n):
    return 1 <= n and n <= 12

def isYear(n):
    return True

s = input()
x = int(s[0:2])
y = int(s[2:4])

yymm = isYear(x) and isMonth(y)
mmyy = isMonth(x) and isYear(y)

if yymm and mmyy:
    print("AMBIGUOUS")
elif yymm:
    print("YYMM")
elif mmyy:
    print("MMYY")
else:
    print("NA")


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k, d, a, ans = 0;
	cin >> n >> k;
	bool check[n];
	for (int i = 0; i < n; i++) 
		check[i] = 0;
	
	while (k--) {
		cin >> d;
		while (d--) {
			cin >> a;
			check[a-1] = 1;
		}
	}
	for (int i = 0; i < n; i++)
		if (check[i] == 0)
			ans++;

	cout << ans;
}

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

int main()
{
    int a[15];
    int cnt;
    int f = 1;

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

    sort(a, a + 12);

    for (int i = 0; i < 12; i += 4) {

        cnt = 0;
        int num[105] = {};

        for (int j = i; j < i + 4; j++) {
            if (num[a[j]] == 0) {
                cnt++;
                num[a[j]] = 1;
            }
        }

        if (cnt != 1) {
            f = 0;
        }
    }

    if (f) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
            
    return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; ll k; cin >> n >> k;
    int a[n+1];
    int mita[n+1];
    for(int i = 1; i <= n; i++) {
        cin >> a[i]; mita[i] = -1;
    }

    int now = 1, c = 1;
    while(mita[now] == -1){
        mita[now] = c; c++;
        now = a[now];
    }

    int r = c - mita[now], nr = mita[now] -1;
    int t;
    // cout << r << " " << nr << endl;
    if(k < nr){
        t = k+1;
    }else{
        k -= nr;
        t = k % r + nr + 1;
    }
    // cout << t << endl;
    int ans = -1;
    for(int i = 1; i <= n; i++){
        // cout << mita[i] << " ";
        if(mita[i] == t){
            ans = i;
        }
    }
    // cout << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5124
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


N, K = map(int, input().split())
A = [0]*N
for _ in range(K):
    d = int(input())
    tmp = list(map(int, input().split()))
    for a in tmp:
        A[a-1] += 1

print(A.count(0))


Measured memory_bytes: 9112
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> p(N);
    rep(0, i, N)
    {
        cin >> p.at(i);
        p.at(i)--;
    }

    ll ans = 0;
    rep(0, i, N)
    {
        if (p.at(i) == i)
        {
            ans++;
            i++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4024
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);   
      //取得
	  int A = sc.nextInt();
      int B = sc.nextInt();
      String S = sc.next();
      
      Pattern p = Pattern.compile("^[0-9]{"+A+"}-[0-9]{"+B+"}$");
      Matcher m = p.matcher(S);
      
      if(m.matches()){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

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

int main(void){
  char c;
  int i=0, count_a=0, count_b=0;
  while(std::cin >> c){
    if(i%2==0){
      if(c=='0'){
        count_a++;
      }else{
        count_b++;
      }
    }else{
      if(c=='1'){
        count_a++;
      }else{
        count_b++;
      }
    }
    i++;
  }
  std::cout << std::min(count_a, count_b) << std::endl;
}

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

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

	vector<int> a(26);

	for (int i = 0; i < n; i++) {
		string p;
		cin >> p;
		a[p[0] - 'A']++;
	}

	int ans = 0;
	while (true) {
		sort(a.rbegin(), a.rend());
		if (a[K - 1] == 0) break;
		for (int i = 0; i < K; i++) a[i]--;
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//input



//processing
int cnt;



//dpTable
//int dp[100050];
int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep (i,N) cin >> p.at(i);
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    rep (i,N) {
        if (i == 0) cnt += p.at(0) / 2;
        else cnt += p.at(i);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int a,b,c; cin >>a>>b>>c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);

    cout << s.size() << endl;
    
    return 0;
}





Measured memory_bytes: 256
package main

import "fmt"

var h, w int

func main() {
	fmt.Scan(&h, &w)
	as := make([][]int, h)
	for y := range as {
		as[y] = make([]int, w)
		for x := range as[y] {
			fmt.Scan(&as[y][x])
		}
	}

	routey := make([]int, 0, h*w)
	routex := make([]int, 0, h*w)
	for i := 0; i < h; i++ {
		if i%2 == 0 {
			for j := 0; j < w; j++ {
				routey = append(routey, i)
				routex = append(routex, j)
			}
		} else {
			for j := 0; j < w; j++ {
				routey = append(routey, i)
				routex = append(routex, w-j-1)
			}
		}
	}
	edit := make([]struct{ a, b, c, d int }, 0)
	for k := range routey {
		if k == len(routey)-1 {
			continue
		}
		if as[routey[k]][routex[k]]%2 == 1 {
			edit = append(edit, struct{ a, b, c, d int }{1 + routey[k], 1 + routex[k], 1 + routey[k+1], 1 + routex[k+1]})
			as[routey[k]][routex[k]]--
			as[routey[k+1]][routex[k+1]]++
		}
	}
	fmt.Println(len(edit))
	for i := range edit {
		x := edit[i]
		fmt.Println(x.a, x.b, x.c, x.d)
	}
}


Measured memory_bytes: 27136
N,K = map(int,input().split())
moji = str(input())
ans = [0]
for i in range(N-1):
    if moji[i] == "A" and moji[i+1] == "C":
        ans.append(ans[i]+1)
    else:
        ans.append(ans[i])

        
for i in range(K):
    st,sp = map(int,input().split())
    print(ans[sp-1]-ans[st-1])


Measured memory_bytes: 11500
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int N,a[100000],b[100000];
   int maxs=0,mins=1000000000;
   cin>>N;
   for(int i=1;i<=N;i++)
   {
       cin>>a[i]>>b[i];
   }
   for(int j=1;j<=N;j++)
    {
        if(maxs<a[j])
            maxs=a[j];
    }
   for(int j=1;j<=N;j++)
    {
        if(mins>b[j])
            mins=b[j];
    }
    int ans;
    ans=maxs+mins;
    cout<<ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {
  int A,B,C;
  cin >> A >> B >> C;

  cout << B*A/2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define VALS(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define INF 1234567890ll
#define EPS (1e-7)
#define PI (acos((ld)-1.0))
#define ll long long int 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
typedef pair <int, int> pi;
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << '\n'; err(++it, args...);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(ll x){stringstream s; s << x; return s.str(); }
ll stl(string x){stringstream s(x); ll temp; s >> temp; return temp; }
const int MOD = 1e9 + 7;


ll val[505], weight[505], dp[100005];

int main()
{
	IAMSPEED
    ll n, w;
    cin >> n >> w;
    for (ll i = 0; i < n; i++)
    {
        cin >> weight[i] >> val[i];
    }
    for (ll i = 0; i < n; i++)
    {
        for (ll j = w; j >= weight[i]; j--)
        {
            dp[j] = max(dp[j], val[i] + dp[j-weight[i]]);
        }
    }
    cout << dp[w];
}



Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int cnt=0;
		for(int i=0;i<n;i++){
			int m=s.nextInt();
			int c=0;
			for(int j=2;j<=Math.sqrt(m);j++){
				if(m%j==0) c=1;
			}
			if(c==0) cnt++;
		}
		System.out.println(cnt);
	}
}


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

#define rep(i, n)	for(int i = 0; i < (int)(n); i++)

int N, W;
int weight[1010] = {};
int value[1010] = {};

int dp[110][10010] = {};

int main() {
	cin >> N >> W;

	rep (i, N) {
		cin >> value[i + 1] >> weight[i + 1];
	}

	for (int n = 1; n <= N; n++) {
		for (int w = 0; w <= W; w++) {
			// 入れてないときの価値
			dp[n - 1][w - weight[n]];

			// そもそも入るか
			if (w >= weight[n]) {
				dp[n][w] = max(dp[n - 1][w], dp[n - 1][w - weight[n]] + value[n]);
			}
			else {
				dp[n][w] = dp[n - 1][w];
			}

		}
	}

	cout << dp[N][W] << endl;

	return 0;
}


Measured memory_bytes: 6992
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	int n;
	int a[100000];
	cin>>n;
	long long ans=0;
	map<int,int> m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i];
		m[a[i]]=0;
	}
	for(int i=0;i<n;i++){
		m[a[i]]++;
	}
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int b,c;
		cin>>b>>c;
		if(m.find(b)==m.end()){
			cout<<ans<<endl;
		}else{
			if(m.find(c)==m.end()){
				m[c]=m[b];
				ans+=(c-b)*m[b];
				m[b]=0;
			}else{
				m[c]+=m[b];
				ans+=(c-b)*m[b];
				m[b]=0;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7876
#include <stdio.h>

int main(void)
{
	int A, B;
	int cnt = 0, soc = 1;

	scanf("%d", &A);
	scanf("%d", &B);

	while (soc < B){
		soc--;
		soc += A ;
		cnt++;
	}

	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if(A[i] == A[i-1]+1 and i != 0):
        ans += C[A[i]-2]
print(ans)

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

using namespace std;

int main()
{
    long long int x,count=0,a,b,i,ans=0;
    cin >> x;
    for(i=100;i<x;)
    {
        count++;
        i += (double)(.01*i);
    }
    if(x==100)
    {
        cout << 1;
    }else
        cout << count;
    return 0;
}



Measured memory_bytes: 3652