akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n,n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		
		int res;
		for(res=0;res<=10000;res++){
			bool ok=true;
			rep(i,a.size()) ok&=a[i]==i+1;
			if(ok) break;
			vi b;
			rep(i,a.size()) if(a[i]>1)
				b.push_back(a[i]-1);
			b.push_back(a.size());
			swap(a,b);
		}
		
		cout<<(res>10000?-1:res)<<endl;
	}
	
	return 0;
}

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

int solve(int e) {
  int m = -1;
  for(int z = 0; z*z*z <= e; ++z) {
    for(int y = 0; z*z*z+y*y <= e; ++y) {
      int x = e - z*z*z - y*y;
      int newValue = x+y+z;
      if(m == -1 || newValue < m) m = newValue;
    }
  }
  return m;
}

int main() {
  int e;
  while(cin >> e && e) cout << solve(e) << endl;
  return 0;
}

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

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

int main() {
	int H, W, N; cin >> H >> W >> N;
	map<int, map<int, int>>mp; long long cnt[10] = {};
	cnt[0] = (long long)(H - 2) * (W - 2);
	for (int i = 0, a, b; i < N; i++) {
		cin >> a >> b;
		for (int j = 0; j < 9; j++)mp[a + dy[j]][b + dx[j]]++;
	}
	for (auto&& row : mp) {
		int y = row.first;
		if (y < 2 || H - 1 < y)continue;
		for (auto&& col : row.second) {
			int x = col.first;
			if (x < 2 || W - 1 < x)continue;
			cnt[col.second]++; cnt[0]--;
		}
	}
	for (int i = 0; i < 10; i++)cout << cnt[i] << endl;

	return 0;
}

Measured memory_bytes: 70528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextDouble()) {
			double ans = sc.nextDouble();
			double x = ans * 2; // S(2)
			ans += x;
			// S(3)??\???
			for (int i = 3; i <= 10; i++) {
				if (i % 2 == 0) {
					x = x* 2;
					ans += x;
				} else {
					x = x/ 3;
					ans += x;
				}
			}
			System.out.println(ans);
		}
		sc.close();
	}
}

Measured memory_bytes: 28072
ff=255
clr=["black","blue","lime","aqua","red","fuchsia","yellow","white"]
val=[[0,0,0],[0,0,ff],[0,ff,0],[0,ff,ff],[ff,0,0],[ff,0,ff],[ff,ff,0],[ff,ff,ff]]

def L(s1,s2):
	return ((s1[0]-s2[0])**2+(s1[1]-s2[1])**2+(s1[2]-s2[2])**2)**0.5
	
while 1:
	rgb=raw_input()
	if rgb=="0":break
	rgb=[int(rgb[1:3],16),int(rgb[3:5],16),int(rgb[5:],16)]
	print clr[min([[L(rgb,val[i]),i] for i in range(8)])[1]]

Measured memory_bytes: 4340
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	deque<ll> que;
	for (int i = 0; i < n; i++) {
		que.push_back(a[i]);
	}
	vector<P> ans;
	while (que.size() > 2) {
		ll maxi = que.back();
		ll mini = que.front();
		que.pop_front();
		que.pop_back();
		ll max2 = que.back();
		ll min2 = que.front();
		ll d1   = max2 - (mini - maxi);
		ll d2   = (maxi - mini) - min2;
		if (d2 <= d1) {
			que.push_front(mini - maxi);
			ans.push_back(P(mini, maxi));
		} else {
			que.push_back(maxi - mini);
			ans.push_back(P(maxi, mini));
		}
	}
	dump(que.back() - que.front());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	cout << que.back() << " " << que.front() << endl;
	return 0;
}

Measured memory_bytes: 5620
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
    ll x;
    cin>>x;
    ll ans=0;
    ans=1000*(x/500);
    ans+=5*((x%500)/5);

    cout<<ans;
}

Measured memory_bytes: 384
#! -*- coding: utf-8 -*-

import numpy as np

n = int(raw_input())
a = map(int,raw_input().split())
b = map(int,raw_input().split())

a_sum = sum(a)
b_sum = sum(b)

x = b_sum-a_sum

a_over = 0
b_over = 0

for i in range(n):
    check = b[i] - a[i]
    if check > 0:
        b_over += check / 2 + check % 2
    else:
        a_over -= check

#print a_over
#print b_over

if a_over <= x and b_over <= x:
    ans = "Yes"
else:
    ans = "No"

print ans


Measured memory_bytes: 19056
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	// vector<string> s(n);

	// int cnt = n;
	// for(int i=0;i<n;i++){
	// 	cin >> s.at(i);
	// }
	// sort(s.begin(),s.end());
	// for(int i=0;i<n-1;i++){
	// 	if(s.at(i)==s.at(i+1)){
	// 		cnt--;
	// 	}
	// }
	// cout << cnt << endl;

	set<string> st;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 19256
N = int(input())
a = [input() for _ in range(N)]
a = sorted(a)
#print(a)
c = 0
ans = 0
for i in range(N):
    c += 1
    if i == N-1:
        if c % 2 == 1:
            ans += 1
    elif a[i] != a[i+1]:
        #print(a[i])
        if c % 2 == 1:
            ans += 1
        c = 0

print(ans)


Measured memory_bytes: 83800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main() {
  int A,B,K;
  cin>>A>>B>>K;
  
  vector<int> c(100);
  
  int m=min(A,B);
  int x=0;
  int count=0;
  
  for(int i=1;i<=m;++i){
    if(A%i==0 && B%i==0){
      c[x]=i;
      ++x;
      ++count;
    }
  }
  
  cout<<c[count-K]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    char s[200001],t[200001];
    cin>>s>>t;
    int i = 0, sum = 0;
    while(s[i]!='\0'){
        if(s[i]!=t[i])
            sum++;
        i++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
long N;
vector<string>S;
long solve(long s){
  queue<long>q;q.push(s);
  vector<long>D(N,-1);D[s]=0;
  while(q.size()){
    long p=q.front();q.pop();
    for(long i=0;i<N;i++)if(S[p][i]=='1'){
      if(D[i]!=-1&&abs(D[p]-D[i])!=1)return -1;
      if(D[i]==-1){D[i]=D[p]+1;q.push(i);}
    }
  }
  long ans=-1;
  for(long x:D)ans=max(ans,x);
  return ans+1;
}
int main(){
  cin>>N;S=vector<string>(N);
  for(long i=0;i<N;i++)cin>>S[i];
  long ans=-1;
  for(long i=0;i<N;i++)ans=max(ans,solve(i));
  cout<<ans;
}

Measured memory_bytes: 3716
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    cout<<a*b/2<<endl;
    
}

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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ans = "";
    for(int i = 0;i<s.length();i++){
        ans += alpha[(s[i]-'A' + n)% 26];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
a,b = map(int, input().split())
s = input()

for i in range(a):
    if not '0' <= s[i] and s[i] <= '9':
        print('No')
        exit()

if s[a] != '-':
    print('No')
    exit()

for i in range(a+1, a+b+1):
    if not '0' <= s[i] and s[i] <= '9':
        print('No')
        exit()

print('Yes')



Measured memory_bytes: 3060
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

vi adj[100010];
int ans[100010];

void bfs() {
    queue<int> q;
    ans[1] = 1;
    q.push(1);
    while(!q.empty()) {
        int u = q.front(); q.pop();

        for(int v : adj[u]) {
            if(ans[v] == 0) {
                ans[v] = u;
                q.push(v);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].PB(b);
        adj[b].PB(a);
    }

    bfs();
    bool ok = true;
    for(int i = 2; i <= n; i++) if(ans[i] == 0) ok = false;
    if(!ok) cout << "No\n";
    else {
        cout << "Yes\n";
        for(int i = 2; i <= n; i++) {
            cout << ans[i] << "\n";
        }
    }
}


Measured memory_bytes: 10524
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	string s;
	cin >> s;
	int result = 0;
	int start = 0, temp = 0;
	bool is_start = false;
	rep(i, s.size()) {
		if (s[i] == 'A' && is_start == false) {
			start = i;
			is_start = true;
		}
		if (is_start && s[i] == 'Z') {
			temp = i - start + 1;
			if (result < temp) result = temp;
		}
	}

	cout << result << endl;
  return 0;
}


Measured memory_bytes: 640
n,m = map(int,input().split())

store = []

for i in range(n):
  price,stock = map(int,input().split())
  store.append([price,stock])

store.sort()

total_cost = 0
for i in range(n):
  if m > 0:
    buy = min([m,store[i][1]])
    total_cost += buy * store[i][0]
    m -= buy
  else:
    break

print(total_cost)


Measured memory_bytes: 20072
#include <iostream>
using namespace std;
using ll=long long;
int main(){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k<=a) cout << k;
  else if(k<=a+b) cout << a;
  else cout << a-(k-a-b);
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];
int prim()
{
    int minv;
    int d[MAX], color[MAX];
    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0;
    color[0] = GRAY;
    while (1)
    {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++)
        {
            if (minv > d[i] && color[i] != BLACK)
            {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
            break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++)
        {
            if (color[v] != BLACK && M[u][v] != INFTY)
            {
                if (d[v] > d[u] + M[u][v])
                {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            M[i][j] = INFTY;
        }
    }
    int k, c, u, v;
    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    prim();
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

// Binary Indexed Tree (Fenwick Tree)
template<typename T> // T: type of cost
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

int main(){
  
  int n;
  long long k;
  cin>>n>>k;
  long long a[n];
  REP(i,n){
    cin>>a[i];
    a[i] -= k;
  }
  vector<long long> s(n+1,0);
  REP(i,n+1){
    if(i==0)continue;
    s[i] = s[i-1] + a[i-1];
  }
  //各iについてj<iかつs[j]<=s[i]となるjの個数を知りたい。
  
  vector<long long> temps(n+1);
  REP(i,n+1){
    temps[i] = s[i];
  }
  //sの値を座標圧縮
  sort(temps.begin(),temps.end());
  temps.erase(unique(temps.begin(),temps.end()),temps.end());
  map<long long, int> zip;
  for(int i = 0; i < temps.size(); i++){
        zip[temps[i]] = i;
  }
  
  int MAP = temps.size();
  BIT<int> bit(MAP);
  long long ans = 0;
  REP(i,n+1){
    ans += (long long)bit.sum(zip[s[i]]);
    bit.add(zip[s[i]]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 18304
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
ul gcd(ul a, ul b){return b? gcd(b, a%b):a;}
using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ul A[N];
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A+N);
    ul tmp = 0;
    bool odd = false;
    int count = 0;
    for(int i = 0; i < N; i++){
        if(A[i] != tmp){
            if(odd){
                count++;
            }
            odd = true;
            tmp = A[i];
        }else{
            odd = !odd;
        }
    }
    if(odd){
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	
	puts([&] {
		ll s = (c - a - b);
		if (s < 0) return false;
		
		return a * b * 4 < s * s;
	}() ? "Yes": "No");
	
	return 0;
}


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

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

int main(){
    int n;
    while(cin>>n,n){
        vector<vector<int>> map(500,vector<int>(500,0));
        vector<pair<int,int>> p(n);
        p[0]=make_pair(250,250);
        map[250][250]=1;
        for(int i=1;i<n;i++){
            int nn,d;
            cin>>nn>>d;
            p[i]=make_pair(p[nn].first+dy[d],p[nn].second+dx[d]);
            map[p[nn].first+dy[d]][p[nn].second+dx[d]]=1;


        }
        int l=500;
        int r=0;
        int u=500;
        int d=0;
        for(int i=0;i<500;i++){
            for(int j=0;j<500;j++){
                if(map[i][j]){
                    l=min(l,j);
                    r=max(r,j);
                    u=min(u,i);
                    d=max(d,i);


                }
            }

        }
        cout<<r-l+1<<" "<<d-u+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  cout << setprecision(20) << fixed;
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double diff = 5.5*(60*H+M);
  cout << sqrt(A*A+B*B-2*A*B*cos(PI*diff/180)) << endl;
  return 0;
}

Measured memory_bytes: 4232
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
  
N = int(input()) - 1
ans_bool = False

while ans_bool==False:
  N = N + 1
  ans_bool = is_prime(N)

print(N)

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int MOD = 1e9+7;
const int N = 1e6+5;

int fastpow(int n, int p){
	int res = 1;
	while(p){
		if(p&1) res = (res * n) % MOD;
		n = (n * n) % MOD;
		p>>=1;
	}
	return res;
}

void solve(){
	int n;
	cin >> n;
	cout << (((fastpow(10,n)+fastpow(8,n)+MOD)%MOD-fastpow(9,n)+MOD)%MOD-fastpow(9,n)+MOD)%MOD << "\n";
}

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

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

using namespace std;


int main(){

int num,ans;
char mark;


cin>>ans;

while(1){

cin>>mark>>num;

if(mark == '=')break;

if(mark == '+')ans=ans+num;

if(mark == '-')ans=ans-num;

if(mark == '*')ans=ans*num;

if(mark == '/')ans=ans/num;

}

cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int a[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	bool ans = false;
	REP(i, N) ans |= a[i] % 2;
	puts(ans ? "first" : "second");
	return 0;
}


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

int main() {
	string line;
	getline(cin, line);
	for (int i = 0; i < line.size(); i++) {
		if ('a' <= line[i] && line[i] <= 'z') {
			line[i] -= 32;
			cout << line[i];

		}
		else {
			cout << line[i];
		}
	}
	cout << endl;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

const int N = 1e6 + 50;

int main()
{
	string s, t;
	int k, len;
	sd(k);
	cin >> s;
	len = s.size();
	t.clear();
	bool flag = 1;
	rep(i, 0, k - 1)
	{

		t += s[i];
		if (i == len - 1)
		{
			flag = 0;
			break;
		}
	}
	if (flag)
		t += "...";
	cout << t << endl;
	return 0;
}

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

S = list(str(input()))
length = len(S)

abc_cnt = 0
a_cnt = 0
ans = 0
for i in range(length):
    s = S[i]
    if s=='A':
        if abc_cnt!=1:
            a_cnt = 0
        a_cnt += 1
        abc_cnt = 1
    elif s=='B':
        if abc_cnt==1:
            abc_cnt += 1
        else:
            a_cnt = 0
            abc_cnt = 0
    else:
        if abc_cnt==2:
            abc_cnt = 1
            ans += a_cnt
        else:
            a_cnt = 0
            abc_cnt = 0
print(ans)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i];
    ll ans = 0;
    for(int i = 1; i < N; i++) A[i] += A[i-1];
    for(int i = 1; i < M; i++) B[i] += B[i-1];
    int ia = 0, ib = M-1;

    
    for(int i = 0; i < M; i++) if(B[i] <= K) ans = i+1;

    for(;ia < N; ia++){
        int na = ia+1;
        ll ta = A[ia];
        if(K < ta) continue;

        //ll tb = max((ll)0, K-ta);
        ll tb = K -ta;
        while(ib >= 0 && tb < B[ib])ib--;
        ll nb = ib+1;

        ans = max(ans, na+nb);
    } 
    cout << ans << endl;

}

Measured memory_bytes: 6436
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>


using namespace std;
typedef long long ll;
ll N;

int main(){

    ll n_rows = 3;
    ll n_cols = 3;
    ll value = 0;
    vector<vector<ll > > vec(n_rows, vector<ll >(n_cols, value));

    for(ll i = 0; i < n_rows; i++){
        for(ll j = 0; j < n_cols; j++){
            cin >> vec[i][j];
        }        
    }

    ll ans = 0;
    bool flg = true;
    for(ll i = 0; i <= vec[0][0]; i++){
        flg = true;
        vector<ll > a(3, 0);
        for(ll j = 0; j < 3; j++){
            a[j] = vec[j][0] - i;
            //cout << a[j] << endl;
            if(a[j]  < 0){
                flg = false;
                break;
            }
        }

        if(flg == false) continue;
        
        vector<ll > b(3, 0);
        for(ll j = 0; j < 3; j++){
            b[j] = vec[0][j] - a[0];
            //cout << b[j] << endl;
            if(b[j] < 0){
                flg = false;
                break;
            }
        }

        if(flg == false) continue;

        for(ll j = 1; j < 3; j++){
            for(ll k = 1; k < 3; k++){
                if(a[j] + b[k] != vec[j][k] ){
                    flg = false;
                    break;
                }
            }
        }

        if(flg == false) continue;

        ans++;
    }

    if(ans > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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


int main() {
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,n;
       cin>>a>>b>>n;
       
        ll x = min(n , b-1);
        ll ans = floor((double)(a*x)/ (double)b) -  (a*floor((double)(x)/ (double)b));
        cout<<ans;
    
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[100001];
int main(){

	int n;
	ll k;
	ll total=0;

	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
	}
	ll k1=0;
	ll m=1;
	rep(i,48){
		m*=2;
	}
	for(int i=48; i>=0; i--){
		m/=2;
		int t1=0;
		rep(j,n){
			if((a[j]&m)==m)t1++;
		}
		if(t1<n-t1){
			if(k1+m<=k){
				k1+=m;
			}
		}
	}
	for(ll j=0; j<n;j++){
		total+=a[j]^k1;
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 1024
//C++初期コード

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main(void) {
    int n;
    int ans = 0;
    int a[10656] = {0};
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        while (a[i] % 2 == 0) {
            ans++;
            a[i] /= 2;
        }
    }
    cae
    r0
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		StringBuffer sb = new StringBuffer();

		for (int i = 0; i < s.length(); i++) {
			String s2 = String.valueOf(s.charAt(i));
			
			if (s2.equals("0") || s2.equals("1")) {
				sb.append(s2);
			} else if (s2.equals("B") && sb.length()>0) {
				sb.deleteCharAt(sb.length() -1);
			}

		}
		
		System.out.println(sb.toString());

	}

}

Measured memory_bytes: 8148
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))

ans = 0

for i in range(N - 1):
	if a[i] + a[i + 1] <= x:
		pass
	else:
		if a[i] <= x:
			ans += a[i] + a[i + 1] - x
			a[i + 1] = x - a[i]
		else:
			ans += a[i] + a[i + 1] - x
			a[i + 1] = 0

print(ans)


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

using namespace std;

#define MAX 100
typedef pair<int,int> P;

int main(){
  int a, b, c, N;

  while(cin >> a >> b >> c, a){
    cin >> N;
    int x, y, z, r;
    bool I[MAX], J[MAX], K[MAX];

    for(int i = 0 ; i < MAX ; i++){
      I[i] = J[i] = K[i] = false;
    }

    vector<P> A[MAX], B[MAX], C[MAX];
    for(int i = 0 ; i < N ; i++){
      cin >> x >> y >> z >> r; 
      x--, y = y-a-1, z = z-a-b-1;

      if(r == 1){
        I[x] = J[y] = K[z] = true;
      }
      A[x].push_back(P(y,z));
      B[y].push_back(P(x,z));
      C[z].push_back(P(x,y));
    }

    for(int i = 0 ; i < a ; i++){
      if(I[i]){
        cout << 1 << endl;
      }else{
        bool flg = false;
        for(int j = 0 ; j < A[i].size() ; j++){
          if(J[A[i][j].first] && K[A[i][j].second]){
            flg = true;
            break;
          }
        }
        cout << (flg?0:2) << endl;
      }
    }

    for(int i = 0 ; i < b ; i++){
      if(J[i]){
        cout << 1 << endl;
      }else{
        bool flg = false;
        for(int j = 0 ; j < B[i].size() ; j++){
          if(I[B[i][j].first] && K[B[i][j].second]){
            flg = true;
            break;
          }
        }
        cout << (flg?0:2) << endl;
      }
    }
    for(int i = 0 ; i < c ; i++){
      if(K[i]){
        cout << 1 << endl;
      }else{
        bool flg = false;
        for(int j = 0 ; j < C[i].size() ; j++){
          if(I[C[i][j].first] && J[C[i][j].second]){
            flg = true;
            break;
          }
        }
        cout << (flg?0:2) << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

int a[200001];
int f[1000001];

bool cmp(int a, int b) {
	return (a < b);
}

int main()
{
	int n;
	while (scanf("%d", &n) != EOF) {
		int i, j;
		memset(f, 0, sizeof(f));
		for (i = 0; i < n; i ++) {
			scanf("%d", &a[i]);
			f[a[i]] ++;
		}
		
		sort(a, a + n, cmp);
		
		int cnt = 0;
		for (i = 0; i < 1000001; i ++) {
			if (f[i] == 1) {
				cnt ++;
			}
			if (f[i] > 0) {
				for (j = i; j < 1000001; j += i) {
					f[j] = 0;
				}
			}
		}
		
		printf("%d\n", cnt);
	}
	return (0);
}


Measured memory_bytes: 6416
# -*- coding: utf-8 -*-

import sys
import os
import math

N = int(input())

A = [0] * 6

for i in range(N):
    h = float(input())

    if h < 165.0:
        A[0] += 1
    elif h < 170.0:
        A[1] += 1
    elif h < 175.0:
        A[2] += 1
    elif h < 180.0:
        A[3] += 1
    elif h < 185.0:
        A[4] += 1
    else:
        A[5] += 1

for i, a in enumerate(A):
    s = "{}:{}".format(i+1, '*' * a)
    print(s)

Measured memory_bytes: 7580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	if (n + 1 < k << 1){
		printf("-1\n");
		return 0;
	}
	for (int i = n - 1, j = n - 1, w = n >> 1; j >= 0; --i, j -= 2, ++w)printf("%d %d %d\n", k + w, k + n + j, k + 2 * n + i);
	for (int i = n / 2 - 1, j = n - 2, w = 0; j >= 0; --i, j -= 2, ++w)printf("%d %d %d\n", k + w, k + n + j, k + 2 * n + i);
}

Measured memory_bytes: 2304
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,D = list(map(int,list(_in[0])))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    for a in [1,-1]:
        for b in [1,-1]:
            for c in [1,-1]:
                if A+a*B+b*C+c*D == 7:
                    s = str(A)+("+" if a==1 else "-")+str(B)+("+" if b==1 else "-")+str(C)+("+" if c==1 else "-")+str(D)+'=7'
                    break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(s)


Measured memory_bytes: 38256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int ans=1<<30;
	cin>>s;
	for(int i=1; i<s.length(); i++)
		if(s[i-1]!=s[i])
			ans=min(ans,max(i,int(s.length())-i));
	cout<<min(ans,int(s.length()))<<'\n';
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std; 
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"

int main(){
  int N,A; cin>>N>>A;
  bool f = (N%500<=A);
  cout << (f?Liny:Linn);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int i = 0;
    int A[101];

    while (scanf("%d", &n) != EOF){
        if (n != 0){
            A[i] = n;
            i++;
        }else{
            i--;
            printf("%d\n", A[i]);
        }
    }
    return (0);
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int n,v[60];
int main() {
	priority_queue<double,vector<double>,greater<double> > pq;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&v[i]),pq.push((double)v[i]);
	for(int i=1;i<n;i++) {
		double a=pq.top();pq.pop();
		double b=pq.top();pq.pop();
		pq.push((a+b)/2.0);
	}
	printf("%lf\n",pq.top());
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    ll n = 0, k = 0;
    cin >> n >> k;
    vector<pair<ll, int>> sushi(n);
    for (ll i=0; i<n; i++) {
        cin >> sushi.at(i).second >> sushi.at(i).first;
    }
    sort(sushi.begin(), sushi.end(), greater<pair<ll, int>>());
    vector<int> check(n+1, 0);
    priority_queue<ll, vector<ll>, greater<ll>> que;
    ll point = 0;
    ll kind = 0;
    for (int i=0; i<k; i++) {
        point += sushi.at(i).first;
        check.at(sushi.at(i).second)++;
        if (check.at(sushi.at(i).second) > 1) {
            que.push(sushi.at(i).first);
        }
        else {
            kind++;
        }
    }
    ll ans = point + kind * kind;
    for (int i=k; i<n; i++) {
        if (check.at(sushi.at(i).second) > 0) {
            continue;
        }
        if (que.empty()) {
            break;
        }
        ll tmp = que.top(); que.pop();
        point += sushi.at(i).first - tmp;
        check.at(sushi.at(i).second)++;
        kind++;
        ans = max(ans, point + kind * kind);
    }
    cout << ans << endl;
    return 0;
}
 

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a > 0 || c > 0) {
        c -= b;
        if(c <= 0) break;
        a -= d;
    }
    Yn(a > 0);
    
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
bool col[8];
int main(){
    int n;
    cin >> n;
    int a;
    int artf = 0;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a<400)col[0] = true;
        if(a>=400&&a<800)col[1] = true;
        if(a>=800&&a<1200)col[2] = true;
        if(a>=1200&&a<1600)col[3] = true;
        if(a>=1600&&a<2000)col[4] = true;
        if(a>=2000&&a<2400)col[5] = true;
        if(a>=2400&&a<2800)col[6] = true;
        if(a>=2800&&a<3200)col[7] = true;
        if(a>=3200) artf++;
    }
    int c = 0;
    for(int i =0; i<8; i++){
        if(col[i]) c++;
    }
    int mi = max(c,1);
    int ans = c+artf;
    cout << mi <<" "<< ans << endl;
}

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

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

int main() {
  int a, b, deg;
  double rad;
  double PI = acos(-1);

  cin >> a >> b >> deg;
  rad = deg * PI / 180;

  double s = a * b * sin(rad) / 2;
  double l = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad)) + a + b;
  double h = 2 * s / a;

  printf("%f\n%f\n%f\n", s, l, h);
}



Measured memory_bytes: 3380
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){

    int i;
    int count[26] = {0};
    char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    char text[1200] = {0};

    //printf("%s\n",text);

    //printf("%c",text[i]);
    while(scanf("%s",text) != EOF){

        if(text[0] =='\n'){
                break;
            }
    for(i = 0; i < strlen(text); i++){
        if(text[i] == 'a' || text[i] == 'A') {
            count[0] += 1;
        }else if(text[i] == 'b' || text[i] == 'B') {
            count[1] += 1;
        }else if(text[i] == 'c' || text[i] == 'C') {
            count[2] += 1;
        }else if(text[i] == 'd' || text[i] == 'D') {
            count[3] += 1;
        }else if(text[i] == 'e' || text[i] == 'E') {
            count[4] += 1;
        }else if(text[i] == 'f' || text[i] == 'F') {
            count[5] += 1;
        }else if(text[i] == 'g' || text[i] == 'G') {
            count[6] += 1;
        }else if(text[i] == 'h' || text[i] == 'H') {
            count[7] += 1;
        }else if(text[i] == 'i' || text[i] == 'I') {
            count[8] += 1;
        }else if(text[i] == 'j' || text[i] == 'J') {
            count[9] += 1;
        }else if(text[i] == 'k' || text[i] == 'K') {
            count[10] += 1;
        }else if(text[i] == 'l' || text[i] == 'L') {
            count[11] += 1;
        }else if(text[i] == 'm' || text[i] == 'M') {
            count[12] += 1;
        }else if(text[i] == 'n' || text[i] == 'N') {
            count[13] += 1;
        }else if(text[i] == 'o' || text[i] == 'O') {
            count[14] += 1;
        }else if(text[i] == 'p' || text[i] == 'P') {
            count[15] += 1;
        }else if(text[i] == 'q' || text[i] == 'Q') {
            count[16] += 1;
        }else if(text[i] == 'r' || text[i] == 'R') {
            count[17] += 1;
        }else if(text[i] == 's' || text[i] == 'S') {
            count[18] += 1;
        }else if(text[i] == 't' || text[i] == 'T') {
            count[19] += 1;
        }else if(text[i] == 'u' || text[i] == 'U') {
            count[20] += 1;
        }else if(text[i] == 'v' || text[i] == 'V') {
            count[21] += 1;
        }else if(text[i] == 'w' || text[i] == 'W') {
            count[22] += 1;
        }else if(text[i] == 'x' || text[i] == 'X') {
            count[23] += 1;
        }else if(text[i] == 'y' || text[i] == 'Y') {
            count[24] += 1;
        }else if(text[i] == 'z' || text[i] == 'Z') {
            count[25] += 1;
        }
    }
}

    for(i = 0; i < 26; i++){
    printf("%c : %d\n",alpha[i],count[i]);
    }

    return 0;
}


Measured memory_bytes: 1956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numStores = Integer.parseInt(scanner.nextLine());
		int[] storeWorkdays = new int[numStores];
		int[][] profitTable = new int[numStores][11];

		for (int storeIndex = 0; storeIndex < numStores; storeIndex++) {
			for (String isWorkday :scanner.nextLine().split(" ")) {
				storeWorkdays[storeIndex] <<= 1;
				if (isWorkday.equals("1")) storeWorkdays[storeIndex]++;
			}
		}

		for (int storeIndex = 0; storeIndex < numStores; storeIndex++) {
			String[] strProfits = scanner.nextLine().split(" ");
			for (int profitIndex = 0; profitIndex < 11; profitIndex++) {
				profitTable[storeIndex][profitIndex] = Integer.parseInt(strProfits[profitIndex]);
			}
		}

		int maxProfitSum = Integer.MIN_VALUE;
		for (int openPlan = 1; openPlan < 1024; openPlan++) {
			int profitSum = 0;
			for (int storeIndex = 0; storeIndex < numStores; storeIndex++) {
				profitSum += profitTable[storeIndex][Integer.bitCount(storeWorkdays[storeIndex] & openPlan)];
			}
			if (maxProfitSum < profitSum) maxProfitSum = profitSum;
		}
		System.out.println(maxProfitSum);
	}
}


Measured memory_bytes: 24404
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll n,m;
string s[21];

ll func(ll a,ll b,ll x,ll y)
{
    int ar[n][m];
    int vis[n][m];
    for(ll i=0;i<n;++i){
        for(ll j=0;j<m;++j){
            vis[i][j]=0;
            if(s[i][j]=='#'){
                vis[i][j]=1;
                ar[i][j]=INT_MAX;
            }
        }
    }
    vis[a][b]=1;
    ar[a][b]=0;
    queue<pi> q;
    q.push(mp(a,b));
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    while(!q.empty())
    {
        ll u=q.front().first;
        ll v=q.front().second;
        q.pop();
        for(int i=0;i<4;++i)
        {
            int xx=u+dx[i];
            int yy=v+dy[i];
            if(xx>=0&&xx<n&&yy>=0&&yy<m&&vis[xx][yy]==0)
            {
                vis[xx][yy]=1;
                q.push(mp(xx,yy));
                ar[xx][yy]=1+ar[u][v];
                if(xx==x&&yy==y){
                    return ar[xx][yy];
                }
            }
        }
    }
    return -1;
}

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

    cin>>n>>m;
    for(ll i=0;i<n;++i)
    {
        cin>>s[i];
    }
    ll ans=0;
    for(ll i=0;i<n;++i){
        for(ll j=0;j<m;++j){
            if(s[i][j]=='.')
            {
                for(ll a=0;a<n;++a){
                    for(ll b=0;b<m;++b){
                        if(s[a][b]=='.'){
                            ans=max(ans,func(i,j,a,b));
                        }
                    }
                }
            }
        }
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 256
s = input()
k = int(input())

sub = []

for i in range(len(s)):
    for j in range(1,6):
        if s[i:i+j] not in sub:
            sub.append(s[i:i+j])
            sub.sort()
        if len(sub) > 5:
            sub = sub[:5]

print(sub[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long div(long long pow){//逆元(引数^1000000005)を返す
    long long x=1;
    for(int i=mod-2;i>0;i/=2){
        if(i%2){
            x*=pow;
            x%=mod;
        }
        pow*=pow;
        pow%=mod;
    }
    return x;
}
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    long long max=0,min=0,c=1;
    for(int i=0;i<=n-k;i++){
        max+=a[k+i-1]*c;
        min+=a[n-k-i]*c;
        max%=mod;
        min%=mod;
        c*=i+k;
        c%=mod;
        c*=div(i+1);
        c%=mod;
    }
    cout<<(max-min+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 768