akhauriyash/Code-Regression huggingface dataset:
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define mset(v, a) memset(v, a, sizeof v);
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    fast;
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//fib; 1=1, 2=2

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> weak(M+2);
  weak[0] = -1;
  weak[M+1] = N+1;
  ll mx = 0;
  for (ll i = 1; i < M+1; i++) {
    cin >> weak[i];
    if (i > 0 && weak[i]-weak[i-1] == 1) {
      cout << 0 << endl;
      return 0;
    }
    else {
      mx = max(mx,weak[i]-weak[i-1]);
    }
  }
  mx = max(mx,weak[M+1]-weak[M]);
  
  vector<ll> fib(mx,1);
  for (ll i = 2; i < mx; i++) {
    fib[i] = (fib[i-1] + fib[i-2]) % 1000000007;
  }
  
  ll pat = 1; 
  for (ll i = 0; i < M+1; i++) {
    pat = pat * fib[weak[i+1]-weak[i]-2] % 1000000007;
  }
  cout << pat << endl;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	x, y := nextInt(), nextInt()
	fmt.Println(x + y/2)
}

Measured memory_bytes: 640
using System;

namespace TravelingSalesmanaroundLake
{
    class Program
    {
        static void Main(string[] args)
        {
            var kyoriSu = Console.ReadLine().Split(' ');
            var homes = Console.ReadLine().Split(' ');

            int enshu = int.Parse(kyoriSu[0]);
            int su = int.Parse(kyoriSu[1]);
            int saicho = 0;
            int kyori = 0;

            for (int i = 0; i <= su - 1; i++)
            {
                if(i == 0)
                {
                    continue;
                }
                else
                {
                    kyori = int.Parse(homes[i]) - int.Parse(homes[i - 1]);
                }
                if(saicho <= kyori)
                {
                    saicho = kyori;
                }
            }
            kyori = enshu - int.Parse(homes[su - 1]) + int.Parse(homes[0]);
            if (saicho <= kyori)
            {
                saicho = kyori;
            }
            int kotae = enshu - saicho;

            Console.WriteLine(kotae.ToString());
        }
    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll v,e;
    cin >> v >> e;
    vector<ll> invec(v, 0);
    vector<vector<ll>> graph(v);
    for(i = 0;i < e;++i){
        ll s,t;
        cin >> s >> t;
        graph.at(s).push_back(t);
        ++invec.at(t);
    }
    queue<ll> que;
    for(i = 0;i < v;++i){
        if(invec.at(i) == 0){
            que.push(i);
            --invec.at(i);
        }
    }
    vector<ll> ans;
    while(!que.empty()){
        ll top = que.front();
        que.pop();
        ans.push_back(top);
        for(auto next: graph.at(top)){
            if(--invec.at(next) == 0) que.push(next);
        }
    }
    for(i = 0;i < v;++i){
        cout << ans.at(i) << endl;
    }

    return 0;
}


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

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> point(n,k-q);
    rep(i,q) {
        int a;
        cin >> a;
        point[a-1]++;
    }
    rep(i,n) {
        if (point[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


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

int main(){ 
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for(int i=0;i<q;i++){
    cin >> a.at(i);
  }
  vector<int> x(n,0);
  for(int i=0;i<q;i++){
    x.at(a.at(i)-1)++;
  }
  
  for(int i=0;i<n;i++){
    if(k-q+x.at(i)>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
    x=0; char c=getchar(); int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
    while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
int a[N],n,c[N][2];
int Log(int x)
{
//	cout<<x<<' ';
	int cnt=0; x--;
	while(x) cnt++,x>>=1;
//	cout<<cnt<<endl;
	return cnt;
}
int dp[N][2];
int main()
{
	rd(n); ll ans=0;
	for(int i=1;i<=n;++i) rd(a[i]),c[i][0]=Log(a[i]),c[i][1]=((1<<c[i][0])==a[i])?c[i][0]:c[i][0]-1,ans+=c[i][0];
	for(int i=1;i<=n;++i)
		for(int j=0;j<2;++j)
			for(int k=0;k<2;++k)
				dp[i][j]=max(dp[i][j],dp[i-1][k]+min(c[i-1][k^1],c[i][j]));
//	cout<<endl;
	printf("%lld\n",ans-max(dp[n][0],dp[n][1]));
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include <numeric>
#include <algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;

int main(){
  int N, X, T;
  cin >> N >> X >> T;
  if(N%X == 0) cout << (N/X)*T << endl;
  else cout << (N/X+1)*T << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,k;
  while(cin>>n>>k,n+k){
    vector<ll>sum(n);
    ll ans=-llINF;
    for(int i=0;i<k-1;i++){
      cin>>sum[i];
    }
    for(int i=k-1;i<n;i++){
      cin>>sum[i];
      ll mi=0;
      for(int j=0;j<k;j++){
	mi+=sum[i-j];
      }
      //cout<<mi<<endl;
	ans=max(mi,ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

#define MAX_VAL 110
#define int long long
constexpr long long INF = (long long)1e18;

int d[MAX_VAL][MAX_VAL];
int V = MAX_VAL;

void warshall_floyd(){
	for(int k = 0; k < V; k++)
		for(int i = 0; i < V; i++)
			for(int j = 0; j < V; j++) {
				if(d[i][k] == INF || d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
			}
}

bool negative_cycle(){
	for(int k = 0; k < V; k++)
		for(int i = 0; i < V; i++)
			for(int j = 0; j < V; j++) {
				if(d[i][k] == INF || d[k][j] == INF) continue;
				if(d[i][k]+d[k][j] < d[i][j]) return true;
			}
		
	return false;
}

signed main(){
	
	int E;
	
	cin>>V>>E;
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			if(i == j ) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
	
	for(int i = 0; i < E; i++){
		int s, t, D;
		
		cin>>s>>t>>D;
		
		d[s][t] = D;
	}
	
	warshall_floyd();
	negative_cycle;
	if(negative_cycle()) {
		cout<<"NEGATIVE CYCLE"<<endl;
		return 0;
	}
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			if(j) cout<<" ";
			if(d[i][j] == INF) cout<<"INF";
			else cout<<d[i][j];
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3200
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    S = readline().strip()

    S = S[::-1]
    idx = 0
    ans = []
    while idx < N:
        step = 0
        for i in range(min(M, N - idx), 0, -1):
            if S[idx + i] == '0':
                step = i
                break
        if step == 0:
            print(-1)
            return
        ans.append(step)
        idx += step

    print(*reversed(ans))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 85064
N = int(input())

count = 0
for i in range(1, N+1):
    yakusu_count = 0

    if i % 2 == 0:
        continue

    for j in range(1, i+1):
        if i % j == 0:
            yakusu_count += 1

    if yakusu_count == 8:
        count += 1

print(count)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////

int main(){
    int n;
    cin>>n;
   string a,b;
   cin>>a>>b;
   string res;
   for(int i=0;i<a.size();i++){
       res+=a[i];
       res+=b[i];
   }
   cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = (1LL << 63);


int main() {
	int n;
	cin >> n;
	hei(llint) a(n);
	rep(i, 0, n)cin >> a[i];
	llint ans = 0;
	llint x = a[0];
	rep(i, 0, n) {
		if (x <= a[i]) {
			x = a[i];
			continue;
		}
		ans += x - a[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<double> p(N);
    rep(i,N) cin >> p[i];
    vector<vector<double>> dp(N+1,vector<double>(N+1,0));
    dp[1][0] = 1-p[0];
    dp[1][1] = p[0];

    rep(i,N)rep(j,N){
        dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        dp[i + 1][j+1] += dp[i][j] * (p[i]);
    }
    
    double ans = 0;
    for(int i=(N+1)/2;i<=N;i++){
      ans += dp[N][i];
    }
    cout << fixed << setprecision(9);
    cout << ans << endl;
}

Measured memory_bytes: 70784
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;


string st;
set<string>sts;
 
void getans(bitset<26>&bs, const int num,const string&nst) {
	if (num == st.size()) {
		sts.emplace(nst);
	}
	else {
		char c(st[num]);
		if (c == 'a') {
			if (!bs[1]) {
				bs[1] = true;
				getans(bs, num + 1, nst + 'b');
				bs[1] = false;
			}
			getans(bs, num + 1, nst + 'a');
		}
		else if (c == 'z') {
			if (bs[25]) {
				getans(bs, num + 1, nst + 'z');
			}
		}
		else {
			if (!bs[c - 'a'+1]) {
				bs[c - 'a' + 1] = true;
				getans(bs, num + 1, nst + char(c+1));
				bs[c - 'a' + 1] = false;
			}
			if (bs[c - 'a']) {
				getans(bs, num + 1, nst + c);
			}
		}
	}
	return;
}

int main() {
	while (1) { 
		cin >> st;
		sts.clear();
		if (st == "#")break;
		else {
			bitset<26>bs(0);
			getans(bs, 0, "");
			cout << sts.size() << endl;
			if (sts.size() <= 10) {
				for (auto it = sts.begin(); it != sts.end(); ++it) {
					cout << (*it) << endl;
				}
			}
			else {
				auto sit = sts.begin();
				auto fit = sts.end();
				for (int i = 0; i < 5; ++i) {
					cout << (*sit) << endl;
					sit++;
					fit--;
				}
				for (int i = 0; i < 5; ++i) {
					cout << (*fit) << endl;
					fit++;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 5088
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int A[] = new int[N];
        int B[] = new int[N];
        int C[] = new int[N];
        int sum = 0;


        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            B[i] = sc.nextInt();
        }
        for(int i = 0; i < N-1; i++){
            C[i] = sc.nextInt();
        }
        sum +=  B[A[0]-1];

        for(int i = 1; i < N; i++){
            sum +=  B[A[i]-1];
            if(A[i]-A[i-1] == 1){
                sum += C[A[i-1]-1];
            }
        }

        System.out.println(sum);

    }
}





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

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

int judge(char *s, int b, int e){
    //cout<<b<<e<<endl;
    int flag=1;
    for(int i=b;i<e;i++){
        //cout<<" "<<i<<e-i-1<<endl;
        if(s[i]!=s[e-i-1])flag=0;
    }
    return flag;
}

int main(){
    char s[100]={};
    scanf("%s",s);
    int l = strlen(s);
    if(judge(s,0,l) && judge(s,0,l/2) && judge(s,l/2+1,l)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    int N=in();
    int a;
    rep(i, N){
        cin>>a;
        if(a%2==1||(a%2==0&&(a%3==0)||a%5==0)){}
        else{
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
}

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

int main(){
	int n, i, idx=0;
	char s[100001];

	scanf("%s", s);
	n = strlen(s);

	for(i=0; i<n; i+=2){
		s[idx++] = s[i];
	}
	s[idx] = '\0';

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

	return 0;
}

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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;

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

    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int cnt[100005];
int n;
int main()
{
	read(n);
	int x;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		read(x);
		if(x<=n)
			cnt[x]++;
		else
			ans++;
	}
	for(int i=1;i<=n;i++)
		ans+=(cnt[i]>=i?cnt[i]-i:cnt[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
/*
Koch Curve
2019. 4/30
*/

struct Point { double x, y; };

void koch(int n, Point a, Point b){
    if (n == 0) return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;  // degree to rad
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
}

int main() {
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}



Measured memory_bytes: 2660
l = ['11', '31', '41', '61', '71', '101', '131', '151', '181', '191',
'211', '241', '251', '271', '281', '311', '331', '401', '421', '431',
'461', '491', '521', '541', '571', '601', '631', '641', '661', '691',
'701', '751', '761', '811', '821', '881', '911', '941', '971', '991',
'1021', '1031', '1051', '1061', '1091', '1151', '1171', '1181', '1201',
'1231', '1291', '1301', '1321', '1361', '1381']
print(' '.join(l[:int(input())]))

Measured memory_bytes: 61916
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N, K;
	cin >> N >> K;
	set<int>s;
	map<int, int>m;
	int num;
	rep(i, N) {
		cin >> num;
		s.insert(num);
		m[num]++;
	}
	if (s.size() <= K)cout << 0;
	else {
		priority_queue<int, vector<int>, greater<int>>q;
		for (auto i : m)q.push(i.second);
		int ans = 0;
		rep(i, s.size() - K) {
			ans += q.top();
			q.pop();
		}
		cout << ans;
	}
}

Measured memory_bytes: 24308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>>price(n);
    for(ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        price[i]=make_pair(a,b);
    }
    sort(price.begin(),price.end());
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(price[i].second<m){
            m-=price[i].second;
            ans+=price[i].first*price[i].second;
        }
        else{
            ans+=price[i].first*m;
            m=0;
        }

        if(m==0){
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4740
#include<iostream>
using namespace std;
int main()
{
    int k,n;
    cin>>k>>n;
    int a[n];
    cin>>a[0];
    int max=0;
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(a[i]-a[i-1]>max)
            max=a[i]-a[i-1];
    }
    if(k-a[n-1]+a[0]>max)
        max=k-a[n-1]+a[0];
    cout<<k-max<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll g[61][51][51]={};

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

    ll N,K;cin>>N>>K;
    rep(i,N){
        rep(j,N){
            cin>>g[0][i][j];
        }
    }

    for(int d=0;d<60;d++){
        rep(i,N){
            rep(j,N){
                rep(k,N){
                    // if(g[d][i][k]==1 and g[d][k][j]==1) g[d+1][i][j]=1;

                    g[d+1][i][j]+=g[d][i][k]*g[d][k][j]%mod;
                    g[d+1][i][j]%=mod;
                }
            }
        }
    }

    // rep(d,4){
    //     cout<<(1<<d)<<" kaime ----"<<endl;
    //     rep(i,N){
    //         rep(j,N){
    //             cout<<g[d][i][j]<<' ';
    //         }cout<<endl;
    //     }
    // }

    ll dp[N];
    rep(i,N) dp[i]=1;
    rep(d,61){
        if((K>>d)&1){
            ll dp_new[N]={};
            rep(i,N){
                rep(j,N){
                    // if(g[d][i][j]){
                    //     dp_new[j]+=dp[i];
                    //     dp_new[j]%=mod;
                    // }

                    dp_new[j]+=dp[i]*g[d][i][j]%mod;
                    dp_new[j]%=mod;
                }
            }
            rep(i,N) dp[i]=dp_new[i];
        }
    }
    ll ans=0;
    rep(i,N){
        ans+=dp[i];
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> card(n);
  for (int i = 0; i < n; i++)
  {
    cin >> card.at(i);
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    if (i % 2 == 0)
    {
      sum += card[i];
    }
    else
    {
      sum -= card[i];
    }
  }
  cout << sum << endl;

  return 0;
}

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

int dfs(int currentnode,vector<vector<int>> &g,unordered_set<int> &visited,unordered_set<int> &currentvisit,int dp[],int &ans)
{
    
     
        if(visited.find(currentnode)==visited.end()) //already visited this,dp array has the answer
        {
            return dp[currentnode];
        }
    
    visited.erase(currentnode); //visited
    currentvisit.erase(currentnode); // visited in local visited
    
    int currentlongest=0;
    
    for(int i=0;i<g[currentnode].size();i++)
    {
        int neighbour=g[currentnode][i];
        
        if(currentvisit.find(neighbour)!=currentvisit.end()) //neighbour is not visited
        
        {
            currentlongest=max(currentlongest,1+dfs(neighbour,g,visited,currentvisit,dp,ans));
        }
     
    }
    currentvisit.insert(currentnode);
    dp[currentnode]=currentlongest;
    ans=max(ans,currentlongest);
    return currentlongest;
    
}

void findit(vector<vector<int>> &g,int n,int e)
{
    unordered_set<int> visited;
    unordered_set<int> currentvisit;
    int dp[n+1];
    

    for(int i=1;i<=n;i++)
    {
        visited.insert(i);
        currentvisit.insert(i);
        dp[i]=0; //not solved yet
    }
    
    int ans=0;
    
    for(int i=1;i<=n;i++)
    {
        if(visited.find(i)!=visited.end()) //this node is never visited
        {
         dfs(i,g,visited,currentvisit,dp,ans);   
        }
    }
    
    
    cout<<ans;
    
    
}

int main() 
{

    int n;
    cin>>n;
    int e;
    cin>>e;
    
    vector<vector<int>> g(n+1);
    
    for(int i=0;i<e;i++)
    {
        int e1; int e2;
        cin>>e1; cin>>e2;
        g[e1].push_back(e2);
    }
    
    findit(g,n,e);

	return 0;
}


Measured memory_bytes: 19784
#include "bits/stdc++.h"
using namespace std;

int main()
{
    stack<int> a;
    int b, c;
    for (string d; cin >> d; )
    {
        switch (d[0])
        {
            case '+':
                b = a.top();
                a.pop();
                c = a.top();
                a.pop();
                a.push(c + b);
                break;
            case '-':
                b = a.top();
                a.pop();
                c = a.top();
                a.pop();
                a.push(c - b);
                break;
            case '*':
                b = a.top();
                a.pop();
                c = a.top();
                a.pop();
                a.push(c * b);
                break;
            default:
                a.push(stoi(d));
                break;
        }
    }
    cout << a.top() << "\n";
}


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

using namespace std;

long long arr[200005];
long long target[200005];

long long n;

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	
	cin >> n;
	for(int i = 0;i < n;i++) cin >> target[i];
	for(int i = 0;i < n;i++) cin >> arr[i];
	
	
	queue<int> things;
	
	long long ans = 0;
	
	for(int i = 0;i < n;i++) things.push(i);
	
	while(!things.empty()){
		int u = things.front(); things.pop();
		
		long long A, B, C;
		B = arr[u];
		
		if(u == 0) A = arr[n-1];
		else A = arr[u-1];
		
		if(u == n-1) C = arr[0];
		else C = arr[u+1];
		
		//cout << u << " " << A << " " << B << " " << C << endl;
		
		if(B <= A + C) continue;
		
		//cout << u << "F" << endl;
		
		long long newB = target[u]; ///the lowest possible value it should go to
		long long times = (B - newB) / (A + C); ///how many times to subtract
		
		ans += times;
		arr[u] = B - times * (A + C);
		
		if(u == 0) things.push(n-1);
		else things.push(u-1);
		
		if(u == n-1) things.push(0);
		else things.push(u+1);
	}
	
	for(int i = 0;i < n;i++) if(arr[i] != target[i]) ans = -1;
	cout << ans;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int score = 9999999;
  for (int i = 0; i < a.size(); i++) {
    if (i == 0) {
      score = min(score, a[n-1] - a[i]);
    }
    else {
      score = min(score, k - (a[i] - a[i-1]));
    }
  }
  cout << score;
}

Measured memory_bytes: 1024
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    word = "ACL"
    k = I()
    print(word*k)

main()





Measured memory_bytes: 68460
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;


int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	auto c = vector<long long int>(n);
	auto a = vector<vector<long long int>>(n, vector<long long int>(m));
	for(int i = 0; i < n; ++i){
		cin >> c[i];
		for(auto&& aa : a[i]){
			cin >> aa;
		}
	}
	long long int ans = 1LL << 60;
	auto ct = map<int, long long int>();
	auto at = vector<map<int, vector<long long int>>>(1 << n);
	at[0][0] = vector<long long int>(m);
	for(int i = 0; i < n; ++i){
		int f = 1 << i;
		for(int k = 0; k <= i; ++k){
			for(auto r : at[k]){
				int e = f | r.first;
				at[i + 1][e] = vector<long long int>(m);
				long long int l = 1LL << 60;
				for(int j = 0; j < m; ++j){
					at[i + 1][e][j] = a[i][j] + r.second[j];
					l = min(l, at[i + 1][e][j]);
				}
				ct[e] = c[i] + ct[r.first];
				if(l >= x) ans = min(ans, ct[e]);
			}
		}
	}
	cout << (ans != 1LL << 60 ? ans : -1) << endl;
	return 0;
}

Measured memory_bytes: 4604
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
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 long long MOD = 1000000007;
const long long INF = (1LL << 60);
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n), b(n), c(n + 1); rep(i, n)cin >> a[i];
	b[0] = a[0];
	for (int i = 1; i < n; i++) {
		b[i] = gcd(b[i - 1], a[i]);
	}
	c[n - 1] = a[n - 1];
	for (int i = n - 1; i >= 0; i--) {
		c[i] = gcd(c[i + 1], a[i]);
	}
	int ans = c[1];
	for (int i = 1; i < n - 1; i++) {
	
		ans = max(ans, gcd(b[i - 1], c[i + 1]));
	}
	ans = max(ans, b[n - 2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
long gcd(long a,long b){
  if (a==b) return a;
  if(min(a,b)==0) return max(a,b);
  return gcd(min(a,b),max(a,b)%min(a,b));
}

int main() {
  int n;
  cin>>n;
  vector<long> a(n);
  for (size_t i = 0; i < n; i++) {
    cin>>a[i];
  }
  vector<long> l(n),r(n);
  l[0]=a[0];r[n-1]=a[n-1];
  for (size_t i = 1; i < n; i++) {
    l[i]=gcd(l[i-1],a[i]);
    r[n-1-i]=gcd(r[n-i],a[n-i-1]);
  }
  long mx=max(l[n-2],r[1]);
  for (size_t i = 0; i < n-2; i++) {
    mx=max(mx,gcd(l[i],r[i+2]));
  }
  cout<<mx;
}

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

int main()
{
long long int sum=0;
long long int a,b,c,k;
cin>>a>>b>>c>>k;
if(k<=a)
cout<<k;
else
{
sum+=a;
k=k-a;
k=k-b;
if(k>0)
sum-=k;
cout<<sum;
}

return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ld long double
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define INFINITE 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	#define precision(a) cout<<fixed<<setprecision(a);
	#define INF (1e18+5)
	#define inf (1e9+5)
	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };
	// 8-directions
	//int dx[]={1,1,1,0,0,-1,-1,-1};
	//int dy[]={-1,0,1,-1,1,-1,0,1};
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	int begtime = clock();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll a,b,c,k;
		cin>>a>>b>>c>>k;
		if(k<a+b)
		{
			cout<<k<<endl;
		}	
		else if(k>a+b)
		{
			cout<<-1*(k-(a+b))+(a)<<endl;
		}
		else	
			cout<<a<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		#ifndef ONLINE_JUDGE
    		cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    		#endif
		return 0;
	}

	
	
	
	

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??°????????????
		int x = sc.nextInt();
		//??°??????3?????????
		int Ansewer = x * x * x;
		//???????????¨???
		System.out.println(Ansewer);
	}
}

Measured memory_bytes: 26212
a,b,c = map(int,input().split())

if a >= b and a >= c :
    s = str(a)+str(b)
    total = int(s)+c
    print(total)

elif b >= a and b >= c:
    s = str(b)+str(a)
    total = int(s)+c
    print(total) 

elif c >= a and c >= b:
    s = str(c)+str(a)
    total = int(s)+b
    print(total) 

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// n
			scanner.nextInt();
			int q = scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			List<Integer> countList = new ArrayList<>();
			char previous = ' ';
			int count = 0;
			for (char c : s) {
				if (('A' == previous) && ('C' == c)) {
					count++;
				}
				previous = c;
				countList.add(count);
			}
			IntStream.range(0, q).forEach(i -> {
				int l = scanner.nextInt() - 1, r = scanner.nextInt() - 1;
				System.out.println(countList.get(r) - countList.get(l));
			});
		}
	}
}


Measured memory_bytes: 74676
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort)

main :: IO ()
main = do
  let
    f :: Rational -> [Rational] -> Rational
    f = foldl step
      where
        step :: Rational -> Rational -> Rational
        step v v' = (v + v') / 2
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  v0 : vs <- sort . map unsafeTextToRational . T.words <$> T.getLine :: IO [Rational]
  print . (fromRational :: Rational -> Double) . f v0 $ vs

unsafeTextToRational :: T.Text -> Rational
unsafeTextToRational s = case T.rational s of
  Right (x, _) -> x
{-# INLINE unsafeTextToRational #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 4080
def solve(i, al, bl, cl, nu):
    if i == N:
        lal, lbl, lcl = len(al), len(bl), len(cl)
        if lal == 0 or lbl == 0 or lcl == 0:
            return
        mp = 0
        mp += 10*(len(al)-1) if len(al) > 1 else 0
        mp += 10*(len(bl)-1) if len(bl) > 1 else 0
        mp += 10*(len(cl)-1) if len(cl) > 1 else 0
        mp += abs(sum(al)-A)
        mp += abs(sum(bl)-B)
        mp += abs(sum(cl)-C)
        global min_mp
        min_mp = min(min_mp, mp)
        return
    solve(i+1, al+[L[i]], bl, cl, nu)
    solve(i+1, al, bl+[L[i]], cl, nu)
    solve(i+1, al, bl, cl+[L[i]], nu)
    solve(i+1, al, bl, cl, nu+[L[i]])


N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
min_mp = 10**10
solve(0, [], [], [], [])
print(min_mp)

Measured memory_bytes: 3064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Set<Integer> c = new HashSet<>();
		Set<Integer> d = new HashSet<>();
		for(int i = 0; i < M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 1)
				c.add(b);
			if(b == N)
				d.add(a);
		}
		for(int i : c) {
			if(d.contains(i)) {
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}

}

Measured memory_bytes: 109076
import sys
sys.setrecursionlimit(400000000)
def main():
    n,k=map(int,input().split())
    h=tuple(map(int,input().split()))
    flog=[-1]*n
    for i in range(n):#dest=i 0が１
        if i<k+1:#0~k
            flog[i]=abs(h[i]-h[0])
        else:
            min=10**9
            for j in range(1,k+1):#1~k
                tmp=flog[i-j]+abs(h[i]-h[i-j])
                if tmp<min:
                    min=tmp
            flog[i]=min
    print(flog[n-1])
   # print(flog)
if __name__=="__main__":
    main()

Measured memory_bytes: 54496
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include <bits/stdc++.h>
#include <ext/rope> 
using namespace __gnu_cxx;
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007

const int INF = (int)1e8;
const int N = 500005;
int A[N];

int main()
{
    int n;
    si(n);
    string st, tmp="";
    cin>>st;
    int fr = 0, bk = 0;
    for(int i=0;i<st.length();i++){
        if(st[i]=='(')fr++;
        if(st[i]==')')bk++;

        if(st[i]==')' && bk<=fr)continue;

        if(st[i] == ')' && bk>fr){
            tmp+="(";
            fr++;
        }
    }
    while(fr>bk){
        fr--;
        st+=")";
    }
    st = tmp+st;

    cout<<st<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define I_O		ios::sync_with_stdio(false),cin.tie(0)
#define ll		long long
#define mod 	1000000007
#define rep(i,n)	for(int i=1;i<=n;i++)
#define pb 		push_back
int main()
{
	I_O;
	int n;	cin>>n;
	n%=10;
	if(n==2 || n==4 || n==5 || n==7 || n==9) 	cout<<"hon";
	else if(n==0 || n==1 || n==6 || n==8)		cout<<"pon";
	else										cout<<"bon";				
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>

using namespace std;

int a[5];

int main() {
    while (scanf("%d%d%d", &a[0], &a[1], &a[2]) != EOF) {
        sort(a, a + 3);
        printf("%d\n", a[2] * 10 + a[1] + a[0]);
    }
    return 0;
}


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

int main(){
    int h, n, sum = 0;
    cin >> h >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        sum += a;
    }
    cout << (h <= sum ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    ll n,t;
    cin >> n >> t;
    ll ans = 0;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    vector<ll> b(n,0);
    for(int i = 0; i < n-1; i++) b[i+1] = a[i+1]-a[i];
    
    for(int i = 0; i < n-1; i++){
        ans += min(t,b[i+1]);
        //cout << ans << endl;
    }
    ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6316
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	long long X;
	cin >> X;
	for (long long A = 0; A <= 1000; A++)
	{
		for (long long B = 0; B <= 1000; B++)
		{
			if (pow(A, 5) - pow(B, 5) == X)
			{
				cout << A << " " << B << endl;
				return 0;
			}
			else if (pow(A, 5) + pow(B, 5) == X)
			{
				cout << A << " " << (-1)*B << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
#define MN 500000
#define N 524288
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,K,a[MN+5],t[N*2+5],b[MN+5],c[MN+5];
struct Tree{int l,r,val,x;}T[MN*3+5];
inline void Renew(int x,int v){for(t[x+=N]+=v;x>>=1;)t[x]=t[x<<1]+t[x<<1|1];}
inline int Query(int l,int r)
{
	int res=0;
	for(l+=N-1,r+=N+1;l^r^1;l>>=1,r>>=1)
	{
		if(~l&1) res+=t[l+1];
		if( r&1) res+=t[r-1]; 
	}
	return res;
}
void Build(int x,int l,int r)
{
	if((T[x].l=l)==(T[x].r=r)) {T[x].x=b[l];return;}
	int mid=l+r>>1;
	Build(x<<1,l,mid);Build(x<<1|1,mid+1,r);
	T[x].x=min(T[x<<1].x,T[x<<1|1].x);
}
inline void Mark(int x,int v){T[x].x+=v;T[x].val+=v;}
inline void pushdown(int x){if(T[x].val)Mark(x<<1,T[x].val),Mark(x<<1|1,T[x].val),T[x].val=0;}
int Find(int x)
{
	if(T[x].l==T[x].r) return T[x].l;
	pushdown(x);
	return Find(x<<1|(T[x<<1|1].x<=0));	
}
void Mod(int x,int l,int r,int v)
{
	if(T[x].l==l&&T[x].r==r) return Mark(x,v);
	int mid=T[x].l+T[x].r>>1;
	pushdown(x);
	if(r<=mid) Mod(x<<1,l,r,v);
	else if(l>mid) Mod(x<<1|1,l,r,v);
	else Mod(x<<1,l,mid,v),Mod(x<<1|1,mid+1,r,v);
	T[x].x=min(T[x<<1].x,T[x<<1|1].x);	
}
int main()
{
	n=read();K=read();
	for(int i=1;i<=n;++i) a[read()]=i;
	for(int i=n;i;--i) b[a[i]]=Query(max(1,a[i]-K+1),min(n,a[i]+K-1)),Renew(a[i],1);
	Build(1,1,n);
	for(int i=n;i;--i)
	{
		int x=Find(1);c[x]=i;
		Mod(1,x,x,1e6);Mod(1,max(1,x-K+1),min(n,x+K-1),-1);
	}
	for(int i=1;i<=n;++i) printf("%d\n",c[i]);
	return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N;
    cin >> N;

    vi a(N);
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        ai--;
        a[i] = ai;
    }
    
    int ans=0;
    for (int i = 0; i < N; i++) {
        if (i == a[a[i]]) {
            ans++;
        }
    }
    ans /= 2;
    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 640
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = len(set(list(map(int, input().split()))))
    print('YES') if n == a else print('NO')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 76292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
    ll N;
  cin >>N;
  ll h[N];
  for(ll i=0;i<N;i++){
  cin >>h[i];
  }
ll dp[N];
  for(ll i=1;i<N;i++){dp[i]=INF;}
  dp[0]=0;

  for(ll i=0;i<N;i++){
    for(ll j=1;j<3;j++){
	dp[min(i+j,N)]=min(dp[min(i+j,N)],dp[i]+abs(h[min(i+j,N)]-h[min(i,N)]));
    }
 // cout<<i<<";"<<dp[i]<<endl;
  }
  //  cout<<dp[i]<<endl;
    
  
  cout<<dp[N-1]<<endl;
  
}


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

using namespace std; 

int main(){ 
  int h,w;
  cin>>h>>w;
  vector<vector<char>> data(h, vector<char>(w)); 
  for(int  i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> data.at(i).at(j); 
    }
  }
  for(int i=0;i<w+2;i++){
    cout<<'#';
    if(i==w+1) cout<<endl;
  }
  for (int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j==0) cout<<'#';
      cout<<data.at(i).at(j);
      if(j==w-1) cout<<'#'<<endl;
    }
  }
  for(int i=0;i<w+2;i++) {
    cout<<'#';
    if(i==w+1) cout<<endl;
  }
}

Measured memory_bytes: 256
//
//  M.cpp
//  main
//
//  Created by 田村雄太 on 2016/10/23.
//  Copyright © 2016年 田村雄太. All rights reserved.
//
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision

typedef long long ll;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

using namespace std;
void omajinai() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}

int main(){
    omajinai();
    
    int K,T;
    cin>>K>>T;
    int* x = new int[T];
    for_each(x, x+T, [](int &i){cin>>i;});
    cout<<max(2 * *max_element(x, x + T) - K - 1,0)<<endl;
    
    
}

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

if a[0] == c:
    b[0] = b[0] - 1
else:
    b[1] = b[1] - 1

i = 0
while i <= 1:
    print(b[i], end =' ')
    i = i +1

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

int main()
{
	int n,i=0,count=0;
	char S[100000];

	scanf("%d", &n);
	scanf("%s", &S);

	do{
		if (S[i] != S[i + 1] && S[i+1] != NULL) {
			count++;
			i++;
		}
		i++;
	} while (i < n);

	cout << count<<endl;


}


Measured memory_bytes: 3324
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
using namespace std;

#define bll long long
#define dou double
#define For(i,a,b) for (int i=(a),_##i=(b); i<=_##i; ++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; --i)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Cpy(a,b) memcpy(a,b,sizeof(b))

const int maxn=1e5+100;
int N;
char s[maxn];
int A[maxn];
int pre[maxn],nex[maxn];

void Prepare()
{
    For(i,1,N) A[i]=(s[i]=='1');
    A[0]=A[N+1]=-1;
    For(i,1,N)
    {
        pre[i]=(A[i]==A[i-1] ? pre[i-1] : i);
    }
    Rof(i,N,1)
    {
        nex[i]=(A[i]==A[i+1] ? nex[i+1] : i);
    }
}

bool can_change(int x,int y,int k)
{
    if (nex[x]>=k) return 1;
    if (N-pre[y]+1>=k) return 1;
    return 0;
}

bool check(int k)
{
    For(i,1,N-k+1)
    {
        int j=i+k-1;
        if (nex[i]>=j) return 1;
        if (can_change(i,j,k)) return 1;
    }
    return 0;
}

int main()
{
    for (; scanf("%s",s+1)!=EOF; )
    {
        N=strlen(s+1);
        Prepare();
        int le=0,ri=N+1;
        while(le+1<ri)
        {
            int mid=(le+ri)>>1;
            check(mid) ? le=mid : ri=mid;
        }
        printf("%d\n",le);
    }
    return 0;
}



Measured memory_bytes: 1536