akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i*i <= n; i++) {
    if (n%i != 0) continue;
    res.eb(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().se++;
    }
  }
  if (n != 1) res.eb(n,1);
  return res;
}

int main () {
  ll n;
  cin >> n;
  
  vi cnt(n+1);
  for (ll i = 1; i <= n; i++) {
    for(auto p : factorize(i)) {
      //show3(i, p.fi, p.se);
      cnt[p.fi] += p.se;
    }
  }
  
  ll ans = 1;
  for (ll i = 2; i <= n; i++) {
    ans *= (cnt[i]+1);
    ans %= mod;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print("hon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print("pon")
elif N%10==3:
    print("bon")

Measured memory_bytes: 8856
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main(){
	int x, y, sum, sum2;
	cin >> y >> x;
	vector< vector<int> > v;
	vector<int> row, column;
	for(int i = 0; i < y; i++){
		vector<int> tmp;
		for(int j = 0; j < x; j++){
			int num;
			cin >> num;
			tmp.push_back(num);
		}
		v.push_back(tmp);
	}
	for(int i = 0; i < y; i++){
		sum = accumulate(v[i].begin(), v[i].end(), 0);
		row.push_back(sum);
	}
	for(int i = 0; i < x; i++){
		sum2 = 0;
		for(int j = 0; j < y; j++){
			sum2 += v[j][i];
		}
		column.push_back(sum2);
	}
	for(int i = 0; i < y; i++){
		for(int j = 0; j < x; j++){
			cout << v[i][j] << ' ';	
		}
		cout << row[i] << '\n';
	}
	for(int i = 0; i < x; i++){
		cout << column[i] << ' ';
	}
	cout << accumulate(row.begin(), row.end(), 0) << endl;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

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

  vector<int> S(N);
  REP(i, N){
    cin >> S[i];
  }

  sort(ALL(S));

  vector<vector<ll>> dp(N+1, vector<ll>(X+1));

  REP(j, X+1){
    dp[1][j] = j % S[0];
  }

  FOR(i, 2, N+1){
    REP(j, X+1){
      dp[i][j] = ((i-1) * dp[i-1][j] % MOD + dp[i-1][j%S[i-1]] )%MOD;
    }
  }

  cout << dp[N][X]%MOD << endl;
}

Measured memory_bytes: 158592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000005,p=998244353,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,g[N],ans;
char ch[N];
int work(int R){
	int ta=0,tb=0,cur=0;
	for (int i=1;i<=n;i++){
		if (ch[i]!='?') cur+=(ch[i]=='1') ? 1 : -1;
		else cur+=(cur+1+g[i+1]<=R) ? 1 : -1;
		ta=max(ta,cur);tb=min(tb,cur);
	}
	return ta-tb;
}
int main(){
//	freopen("a.txt","r",stdin);
	scanf("%s",ch+1);
	n=strlen(ch+1);
	for (int i=n;i;i--)	g[i]=max(0,g[i+1]+((ch[i]=='1') ? 1 : -1));
	ans=min(work(g[1]),work(g[1]+1));
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

string ans;
string s;

void dfs(string t, int &K) {
  // cout << s << " " << t << " " << K << endl;
  if (s.find(t) != string::npos) {
    K--;
    if (K == 0) {
      ans = t;
      throw 1;
    }
    for (char c = 'a'; c <= 'z'; c++) {
      dfs(t + c, K);
    }
  }

}

int main2() {
  cin >> s;
  int K; cin >> K;
  K++;
  ans = "";
  try {
    dfs("", K);
  } catch (int e) {

  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
work_ls = [0] * n
for i in range(n):
    a,b = map(int,input().split())
    work_ls[i] = [a,b]
work_ls.sort(key = lambda x:x[1])
time = 0
res = 'Yes'
for cost, dline in work_ls:
    time += cost
    if time > dline:
        res = 'No'
print(res)

Measured memory_bytes: 38044
#include<bits/stdc++.h>
#define ll  int
#define db long double 
#define ull unsigned long long int
// #define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
// #define INF 10000000000000
#define MOD 1000000007
#define MAXN 200005
 
using namespace std;


int main()
{
        ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tests=1;
    // cin>>tests;    
    while(tests--)
    {
    	ll x;
    	cin>>x;
    	if(x==0) cout<<1;
    	else cout<<0;
    }

    return 0;
}
    

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

const int64_t MOD = 2019;

//繰り返し二乗法
int64_t pown(int64_t x, int64_t n) { 
  int64_t ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x;
      ans %= MOD;
    }
    x = x * x;//一周する度にx, x^2, x^4, x^8となる
    x %= MOD;
    n >>= 1; //桁をずらす n = n >> 1
  }
  return ans;
}


int main(){
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  int N = S.size();
  int dp[N+1];
  int K = 2019;
  for(int i=0; i<N+1; i++){
    dp[i] = 0;
  }
  for(int i=0; i<N; i++){
    int x = S.at(i) - '0';
    dp[i+1] = (dp[i] + x*pown(10,i))%K;
    //cout << dp[i+1] << endl;
  }
  
  map<int,int> mp;
  for(int i=0; i<N+1; i++){
    if(mp.count(dp[i])){
      mp[dp[i]]++;
    }
    else{
      mp[dp[i]] = 1;
    }
  }
  
  int ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    ans += (itr->second)*(itr->second-1)/2;
  } 
  cout << ans << endl;
}

Measured memory_bytes: 4540
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int k = s.length();
  int cnt = 0;
  for(int i = 0; i < k; i++){
    if(s[i] == 'o') cnt++;
  }
  if(8-cnt <= 15-k) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int n,m;
bool vi[100100];
vector<int> ed[100100];
queue<int> ans;
stack<int> ans2;

void dfs(int nw)
{
	vi[nw]=true;
	ans.push(nw);
	for(int i=0;i<ed[nw].size();i++)
	{
		if(vi[ed[nw][i]]==false)
		{
			dfs(ed[nw][i]);
			break;
		}
	}
}

void dfs2(int nw)
{
	vi[nw]=true;
	ans2.push(nw);
	for(int i=0;i<ed[nw].size();i++)
	{
		if(vi[ed[nw][i]]==false)
		{
			dfs2(ed[nw][i]);
			break;
		}
	}
}

main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		ed[a].push_back(b);
		ed[b].push_back(a);
	}
	dfs(1);
	for(int i=0;i<ed[1].size();i++)
	{
		if(vi[ed[1][i]]==false)
		{
			dfs2(ed[1][i]);
			break;
		}
	}
	printf("%d\n",ans.size()+ans2.size());
	while(!ans2.empty())
	{
		printf("%d ",ans2.top());
		ans2.pop();
	}
	while(!ans.empty())
	{
		printf("%d ",ans.front());
		ans.pop();
	}
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var s = CRL();

        var west = new int[n];
        var east = new int[n];

        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'W')
            {
                west[i]++;
            }
            else
            {
                east[i]++;
            }

            if (i!=0)
            {
                west[i] += west[i - 1];
                east[i] += east[i - 1];
            }
        }

        var min = int.MaxValue;
        for (int i = 0; i < n; i++)
        {
            var val = east.Last() - east[i] + west[i];
            if (s[i] == 'W')
            {
                val--;
            }
            min = Math.Min(min, val);
        }

        CWL(min);
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();

    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();

    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}


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

int main(){
	int n,i,max=0,count=0;
	vector<char> s(3);
	for(i=0;i<3;i++)
	cin >> s.at(i);
	
	for(i=0;i<3;i++){
		if(s.at(i)=='R'){
			count++;
			if(max<count)max=count;
		}
		else
			count=0;
	}

	cout << max <<endl;
	
	return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

vector<piii> ans;
int main() {
	int l, t, n;
	scanf("%d", &l);
	for (int i = 25; ; i--) {
		if((1<<i) <= l) {
			t = i;
			n = t+1;
			break;
		}
	}
	for (int i = 1; i <= t; i++) {
		ans.pb({{i, i+1}, 1<<i-1});
		ans.pb({{i, i+1}, 0});
	}
	int res = l - (1<<t), now = (1<<t);
	for (int i = n-1; i >= 1; i--) {
		if((1<<i-1) <= res) {
			res -= 1<<i-1;
			ans.pb({{i, n}, now});
			now += 1<<i-1;
		}
	}
	printf("%d %d\n", n, (int)ans.size());
	for (int i = 0; i < ans.size(); i++) printf("%d %d %d\n", ans[i].fi.fi, ans[i].fi.se, ans[i].se);
	return 0;
} 

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

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

    vector<int> numbers;
    int x = 0, sum = 0;
    do {
        x++;
        sum += x;
    } while (sum < N);

    for (int i = 1; i <= x; i++) {
        if (i == sum - N) continue;
        cout << i << endl;
    }

    return 0;
}

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


int main()
{
 
 int n,k,num=0;
 cin>>n>>k;
 for(int i=0;i<n;i++)
 {
     int x;
     cin>>x;
     if(x>=k) num++;
 }
 cout<<num;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 2000;
const int M = 1000000007;

int n, nK;
int f[MaxN + 2][MaxN + 2][2];

int main()
{
	cin >> n >> nK;

	f[n + 1][0][1] = 1;
	for (int i = n; i; --i)
	{
		int l = i + 1;
		for (int j = n; j >= 0; --j)
			f[l][j][0] = (f[l][j][0] + f[l][j + 1][0]) % M;

		for (int j = 0; j <= n; ++j)
			for (int k = 0; k < 2; ++k)
			{
				int cur = f[l][j][k];
				f[i][j + 1][1] = (f[i][j + 1][1] + cur) % M;
				f[i][j + 0][0] = (f[i][j + 0][0] + cur) % M;
			}
	}

	int res = f[1][n - nK][0];
	for (int i = 0; i < n - nK - 1; ++i)
		res = (s64)res * 2 % M;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using  namespace std;
#define    ll  long long int
int main( )
{
    int n, i, x, k, mx = -1;
    map<int, int> mp;
    map<int, int> ::iterator it;
    vector<int> v;
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> x;
        mp[x-1]++;
        mp[x+1]++;
        mp[x]++;

    }
    for(it=mp.begin(); it!=mp.end(); it++)
    {
        mx=max(mx,it->second);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define eb emplace_back
#define pb pop_back
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define sz(x) (int)x.size()
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define itn int
#define vpii vector<pii>
#define pdd pair<double,double>
#define vll vector<ll>

typedef long long ll;

using namespace std;

const int MAXN = 2000;
vi g[MAXN];

int color[MAXN];

vector <int> visited;

vector <int> cycle;


int nxt[MAXN];


void gfs(int v) {
	color[v] = 1;
	visited.eb(v);
	for (auto u : g[v]) {
		if (color[u] == 1 && cycle.empty()) {
			vector <int> path = visited;
			while (path.back() != u) {
				cycle.eb(path.back());
				path.pb();
			}
			cycle.eb(u);
			reverse(all(cycle));
		}
		if (color[u] == 0) {
			gfs(u);
		}
	}
	visited.pb();
	color[v] = 2;
}

bool check(int a, int b) {
	int cur = a;
	if (nxt[a] == b) return false;
	while (nxt[cur] != a) {
		if (b == cur) return true;
		cur = nxt[cur];
	}
	return false;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].eb(b);
		//~ g[b].eb(a);
	}
	for (int i = 1; i <= n; i++) {
		if (!color[i]) {
			gfs(i);
		}
	}
	if (cycle.empty()) {
		cout << -1;
		return 0;
	}
	//~ for (auto v : cycle) {
		//~ cout << v << " ";
	//~ }
	//~ cout << endl;
	for (int i = 0; i < sz(cycle); i++) {
		int a = cycle[i];
		int b = cycle[(i + 1) % sz(cycle)];
		nxt[a] = b;
	}
	//~ for (int i = 1; i <= n; i++) {
		//~ cout << i << " " << nxt[i] << endl;
	//~ }
	int cur = cycle[0];
	for (int i = 0; i < 1e5; i++) {
		while (sz(g[cur])) {
			int v = g[cur].back();
			if (check(cur, v)) {
				nxt[cur] = v;
			}
			g[cur].pop_back();
		}
		cur = nxt[cur];
	}
	vector <int> ans;
	int start = cur;
	do {
		ans.eb(cur);
		cur = nxt[cur];
	} while(cur != start);
	cout << sz(ans) << endl;
	sort(all(ans));
	for (auto x : ans) cout << x << "\n";
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
  int j,k,l,f,d,s;
  scanf("%d %d %d",&j,&k,&l);
  if(j > k)
    { f=k;
  k=j;
  j=f;}
  if(k > l)
    {d=l;
  l=k;
  k=d;}
  if(j > k)
    {s=k;
  k=j;
  j=s;}
  printf("%d %d %d\n",j,k,l);
  return 0;
}

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

int main() {

    int H, W;
    cin >> H >> W;

    vector<vector<string>> table(H, vector<string>(W));

    vector<int> del_i;
    vector<int> del_j;


    for (int i = 0; i < H; i++) {
        //cin >> A.at(i) >> B.at(i);
        string line;
        cin >> line;

        for (int j = 0; j < line.size(); j++) {
            table.at(i).at(j) = line.substr(j,1);
        }

    }
    ///////////////////////////////
    for (int i = 0; i < H; i++) {
        bool flg = true;
        for (int j = 0; j < W; j++) {
            if(table.at(i).at(j) == "#"){
                flg = false;
            }
        }
        if(flg){
            // del i idx
            //cout << "del i: " << i <<endl;
            del_i.push_back(i);
        }
    }

    ///////////////////////////////
    for (int j = 0; j < W; j++) {
        bool flg = true;
        for (int i = 0; i < H; i++) {

            if(table.at(i).at(j) == "#"){
                flg = false;
            }
        }
        if(flg){
            // del j idx
            //cout << "del j: " << j <<endl;
            del_j.push_back(j);     
        }
    }

    vector<vector<string>> new_table(vector<string>);

    for (int i = 0; i < H; i++) {

        bool di_flg = false;
        for (int di = 0; di < del_i.size(); di++) {
            if(i == del_i.at(di)){
                di_flg = true;
                break;
            }
        }
        if (di_flg){
            continue;
        }

        

         for (int j = 0; j < W; j++) {
             //cout << table.at(i).at(j);

            bool dj_flg = false;
            for (int dj = 0; dj < del_j.size(); dj++) {
                if(j == del_j.at(dj)){
                    dj_flg = true;
                    break;
                }
            }
            if (dj_flg){
                continue;
            }

            cout << table.at(i).at(j);


         }
         cout << endl;
    }






    // for (int i = 0; i < M; i++) {
    //     //cin >> A.at(i) >> B.at(i);
    //     int kachi = A.at(i) - 1;
    //     int make  = B.at(i) - 1; 

    //     table.at(kachi).at(make) = "o";
    //     table.at(make).at(kachi) = "x";
    // }

    // for (int i = 0; i < H; i++) {
    //     for (int j = 0; j < W; j++) {
    //         cout << table.at(i).at(j);
    //     }
    //     cout << endl;
    // }

}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
long long n,k,q;
long long a[200005],cnt[200005];
int main()
{
    scanf("%lld%lld%lld",&n,&k,&q);	
    for(int i=1;i<=q;++i)
        scanf("%lld",&a[i]),cnt[a[i]] ++;
    for(int i=1;i<=n;++i)
    {
    	if(k-(q-cnt[i]) <= 0) printf("No\n");
    	else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 5220
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

//#define int long long

using namespace std;

void Main()
{
	int A, B;
	cin >> A >> B;

	int sum = A + B;
	if (sum % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << sum / 2 << endl;
	}
}

int32_t main()
{
	Main();
	return 0;
}

/*
void sample()
{
	vector<int> v;
	sort(v.begin(), v.end());
	sort(v.begin(), v.end(), greater<int>());

}
*/



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

const ll mod=998244353;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  ll n,k;
  cin >> n >> k;
  vll a(n);
  rep(i,0,n) {
    cin >> a[i];
    --a[i];
  }
  vll f(n,0);
  f[0]=1;
  ll now=a[0];
  queue<ll> que;
  que.push(0);
  while(1){
   if(f[now]) break;
   que.push(now); 
   f[now]=1;
   now=a[now]; 
  }
  
  while(k>0&&que.front()!=now){
   que.pop(); 
   --k; 
  }
  k%=que.size();
  while(k>0){
   que.pop();
   --k; 
  }
  cout << que.front()+1 << endl;
  
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  


Measured memory_bytes: 7960
/**
*    author:  souzai32
*    created: 02.08.2020 21:18:08
**/

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

int main() {

    int n;
    cin >> n;
    int countR=0,countW=0;
    string a;
    cin >> a;

    rep(i,n){
        if(a.at(i)=='W') countW++;
        if(a.at(i)=='R') countR++;
    }

    int ans=0;

    rep(i,countR){
        if(a.at(i)=='W') ans++;
    }

    cout << ans << ' ' ;
    return 0;
}

Measured memory_bytes: 3752
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N);readl(M);

  ll a = 1900 * M + 100 * (N - M);
  ll pinv = 1;
  rep1(i, M + 1){
    pinv *= 2;
  }

  cout << a * pinv;
}
#endif


Measured memory_bytes: 384
n = int(input())
 
if n == 111:
    print(999)
elif n == 119:
    print(991)
elif n == 191:
    print(919)
elif n == 199:
    print(911)
elif n == 911:
    print(199)
elif n == 919:
    print(191)
elif n == 991:
    print(119)
elif n == 999:
    print(111)

Measured memory_bytes: 9076
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 998244353;
 
vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//abcのbed乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];
char s[500005];
ll dp[800005];
bool deleted[500005];
bool update;


int main(){	
	cin >> n >> m;
	cin >> s;
	d = n;
	for(i=0;i<m;i++){
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	//両方がない点を探すよ
	for(i=1;i<=n;i++){
		a = 0;
		b = 0;
		for(j=0;j<G[i].size();j++){
			if(s[G[i][j]-1]=='A')a=1;
			if(s[G[i][j]-1]=='B')b=1;
		}
		if(a*b==0){
			pql.push(i);
			deleted[i] = true;
			d--;
			//i番目の頂点には両方ないよ
		}
	}
	update = true;
	while(!pql.empty() && d>=0){
		ll v = pql.top();
		pql.pop();
		for(i=0;i<G[v].size();i++){
			if(deleted[G[v][i]])continue;
			//v番目の頂点につながってる頂点を全部見る
			c = G[v][i];
			a = 0;
			b = 0;
			for(j=0;j<G[c].size();j++){
				if(deleted[G[c][j]])continue;	
				if(s[G[c][j]-1]=='A')a = 1;
				if(s[G[c][j]-1]=='B')b = 1;
			}
			if(a*b==0){
				pql.push(c);
				deleted[c] = true;
				d--;
			}
		}
	}

	if(d<=0){
		p("No");
	}else{
		p("Yes");
	}

		
	return 0;
}

Measured memory_bytes: 33788
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n;
	    cin>>n;
	    int maxi=0,ans;
	    for (int i = 0; i < n; ++i)
	    {
	    	int za,zb;
	    	cin>>za>>zb;
	    	if(maxi < za){
	    		maxi= za;
	    		ans = za + zb;
	    	}
	    }
	    cout<<ans<<endl;
	    return 0;
	  }


Measured memory_bytes: 256
#
n=int(input())

c=[]
s=[]
f=[]
for i in range(n-1):
    c_,s_,f_ = map(int, input().split())
    c.append(c_)
    s.append(s_)
    f.append(f_)

for i in range(n):
    ans = 0
    for j in range(i,n-1):
        ans = max(s[j],(ans+f[j]-1)//f[j]*f[j])
        ans +=c[j]
    print(ans)

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

int  main()
{
	int n;
	cin >> n;
	vector <pair<int, int>> d(n);
	int cnt = 0;
	int flag = 0;
	rep(i, n)
	{
		cin >> d[i].first >> d[i].second;
		if (d[i].first == d[i].second)
			cnt++;
		else
			cnt = 0;
		if (cnt == 3)
			flag = 1;
	}
	if (flag)
		cout << "Yes\n";
	else
		cout << "No\n";
	return (0);
}

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

int t,c,n,mn,mx;
string s,q;
int main(){
    cin>>s;
    n=s.size();
    if (true){
        for (int i=0; i<n/2; i++){
            if (s[i]!=s[n-i-1]){
                c++;
            }
        }
        cout<<c<<endl;
    }
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long k;
    cin>>k;

    long long tens[1000010];

    tens[0]=1%k;
    rep2(i,k){
        tens[i]=(tens[i-1]*10)%k;
    }
    long long cnt=1;
    long long seven=7;
    long long ans=-1;
    while(cnt<=k){
        if(seven%k==0){
            ans=cnt;
            break;
        }
        seven=seven+7*tens[cnt];
        seven%=k;
        cnt++;
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


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

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    sum += A[i];
  }
  int border = (sum - 1) / (4 * M);
  int candidate = 0;
  for (int i = 0; i < N; i++){
    if (A[i] > border){
      candidate++;
    }
  }
  if (candidate < M){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
h, n = list(map(int,(input().split())))
a = list(map(int,(input().split())))
import sys
sys.setrecursionlimit(10 ** 9) #再帰用

a.sort(reverse=True)

if h >= n and n !=0 :
  a = a[n:]
  ans = sum(a)
elif n ==0:
  ans = sum(a)
else:
  ans = 0
  
print(ans)

Measured memory_bytes: 26024
#include <stdio.h>


int main(void){
    int H,W;
    scanf("%d %d",&H,&W);
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    char po[100][100];
    for(int i=0;i<100;i++){po[0][i]='.';po[H+1][i]='.';}
    for(int i=1;i<=H;i++)scanf("%s",po[i]);
    for(int i=1;i<=H;i++)for(int j=0;j<W;j++){
        if(po[i][j]=='#'){
            int flag=0;
            for(int k=0;k<4;k++){
                if(j+dx[k]>=0&&j+dx[k]<W&&po[i+dy[k]][j+dx[k]]=='#')flag=1;
            }
            if(flag==0){printf("No");return 0;}
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final int c = sc.nextInt();
			
			final int size = a + b + c;
			
			if(size == 0){
				break;
			}
			
			final int N = sc.nextInt();
			
			int[] answer = new int[size];
			Arrays.fill(answer, 2);
			
			LinkedList<Integer> a_list = new LinkedList<Integer>();
			LinkedList<Integer> b_list = new LinkedList<Integer>();
			LinkedList<Integer> c_list = new LinkedList<Integer>();
			LinkedList<Integer> answers = new LinkedList<Integer>();
			
			for(int i = 0; i < N; i++){
				final int a_part = sc.nextInt() - 1;
				final int b_part = sc.nextInt() - 1;
				final int c_part = sc.nextInt() - 1;
				
				final int ans = sc.nextInt();
				
				if(ans == 1){
					a_list.addFirst(a_part);
					b_list.addFirst(b_part);
					c_list.addFirst(c_part);
					answers.addFirst(ans);
				}else{
					a_list.addLast(a_part);
					b_list.addLast(b_part);
					c_list.addLast(c_part);
					answers.addLast(ans);
				}
			}
			
			while(!answers.isEmpty()){
				final int a_part = a_list.poll();
				final int b_part = b_list.poll();
				final int c_part = c_list.poll();
				
				final int ans = answers.poll();
				
				if(ans == 1){
					answer[a_part] = ans;
					answer[b_part] = ans;
					answer[c_part] = ans;
				}else{
					if(answer[a_part] == 1 && answer[b_part] == 1 && answer[c_part] == 2){
						answer[c_part] = 0;
					}else if(answer[a_part] == 1 && answer[b_part] == 2 && answer[c_part] == 1){
						answer[b_part] = 0;
					}else if(answer[a_part] == 2 && answer[b_part] == 1 && answer[c_part] == 1){
						answer[a_part] = 0;
					}
				}
			}
			
			for(int i = 0; i < size; i++){
				System.out.println(answer[i]);
			}
		}
		
	}
}

Measured memory_bytes: 28256
#include <cstdio>

int A, B, N;

int solve() {
  int t = A % B;
  int ans = 0;

  for (int z = 0; z <= N; ++z) {
    ans += t / B;
    t %= B;
    if (B >= t)
      t *= 10;
  }
  return ans;
}

int main() {
  while (scanf("%d%d%d", &A, &B, &N) != -1) {
    printf("%d\n", solve());
  }
  return 0;
}

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

int main()
{
	ll n,f=0;
	ll xx=1000000000000000000;
	ll ans=1;
	ll a;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a==0)
		{
			f=2;
		}
		else if(f==0&&a>xx/ans)
		{
			f=1;
		}
		else if(f==0&&a<=xx/ans)
		{
			ans*=a;
		}
	}
	if(f==2)
	cout<<0<<endl;
	else if(f==1)
	cout<<-1<<endl;
	else
	{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
    #define rep(i,a,b) for(int i=int(a);i<int(b);++i)
    using namespace std;
    typedef long long ll;
    int INF = (1LL << 30) - 1;
    int MOD = 1e9+7;
    main(){
        string S;
        cin >> S;
        int X,Y;
        cin >> X >> Y;
        vector<int> V(1);
        int idx = 0;
        for(auto c:S){
            if(c == 'F')V[idx]++;
            else {
                V.push_back(0);
                idx++;
            }
        }
        //for(auto i:V)cout << i << " ";cout << endl;
        map<int,int> mpx, mpy;
        mpx[V[0]] = 0;
        mpy[0] = -1;
        rep(i,1,V.size()){
            if(i % 2 == 0){
                vector<int> v;
                for(auto p:mpx){
                    if(p.second == i-2)v.push_back(p.first);
                }
                for(auto j:v){
                    mpx[j + V[i]] = i;
                    mpx[j - V[i]] = i;
                }
            }else{
                vector<int> v;
                for(auto p:mpy){
                    if(p.second == i-2)v.push_back(p.first);
                }
                for(auto j:v){
                    mpy[j + V[i]] = i;
                    mpy[j - V[i]] = i;
                }
            }
        }
        bool findx = 0, findy = 0;
        for(auto p:mpx){
            //cout  << p.first << "," << p.second << " ";
            if(p.second == V.size() - (V.size() % 2 ? 1 : 2)){
                if(p.first == X)findx = 1;
            }
        }//cout << endl;
        for(auto p:mpy){
            //cout  << p.first << "," << p.second << " ";
            if(p.second == V.size() - (V.size() % 2 ? 2 : 1)){
                if(p.first == Y)findy = 1;
            }
        }//cout << endl;
        if(findx && findy)cout << "Yes" << endl;
        else cout << "No" << endl;
    }


Measured memory_bytes: 1024
from collections import deque
import heapq
k = int(input())
s =[1,2,3,4,5,6,7,8,9,10]
heapq.heapify(s)
li = set()
for val in range(1,2**11):
    v = int(str(bin(val)[2:]))
    li.add(v)
while len(li)<=301000:
    val = heapq.heappop(s)
    li.add(val)
    if str(val)[-1]=='0':
        heapq.heappush(s,10*val)
        heapq.heappush(s,10*val + 1)
    elif str(val)[-1]=='9':
        heapq.heappush(s,10*val + 8)
        heapq.heappush(s,10*val + 9)
    else:
        heapq.heappush(s,10*val + int(str(val)[-1]))
        heapq.heappush(s,10*val + int(str(val)[-1])+1)
        heapq.heappush(s,10*val + int(str(val)[-1])-1)
L = list(li)
L.sort()
print(L[k-1])



Measured memory_bytes: 157780
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int H, W, K;
	scanf("%d%d%d", &H, &W, &K);
	char* str = new char[W * 100];
	str[0] = 0;
	vector<string> s(H);
	vector<int> f(H, 0);
	rep(i, 0, H) {
		cin >> s[i];
		rep(i2, 0, W) {
			if (s[i][i2] == '#') {
				f[i] = 1;
				break;
			}
		}
	}
	int p = 0, n = 0, c, t;
	if (f[0] == 0) {
		while (!f[p])p++;
		n++;
		str[0] = c = 0;
		rep(i, 0, W) {
			if (s[p][i] == '#')c++;
		}
		t = n;
		rep(i, 0, W) {
			sprintf(str, i == W - 1 ? "%s%d" : "%s%d ", str, n);
			if (s[p][i] == '#')n++;
			if (n - t == c)n--;
		}
		rep(i, 0, p + 1)puts(str);
		p++;
	}
	while (p < H) {
		if (f[p] == 0)puts(str);
		else {
			n++;
			str[0] = c = 0;
			rep(i, 0, W) {
				if (s[p][i] == '#')c++;
			}
			t = n;
			rep(i, 0, W) {
				sprintf(str, i == W - 1 ? "%s%d" : "%s%d ", str, n);
				if (s[p][i] == '#')n++;
				if (n - t == c)n--;
			}
			puts(str);
		}
		p++;
	}
	return 0;
}

Measured memory_bytes: 896
while True:
    n = input()
    tmp = ''
    if n == '-':
        break
    m = int(input())
    for i in range(m):
        h = int(input())
        if i == 0:
            tmp = n[h:]+n[:h]
        else:
            tmp = tmp[h:]+tmp[:h]
    print(tmp)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
struct point {
	ld x, y;
	ld dist(const point& b) {
		return sqrtl((x - b.x) * (x - b.x) + (y - b.y) * (y - b.y));
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<point> a(n);
	vector<int> ind(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i].x >> a[i].y;
		ind[i] = i;
	}
	ld sum = 0;
	do {
		vector<point> b(n);
		for (int i = 0; i < n; ++i) {
			b[i] = a[ind[i]];
		}
		for (int i = 0; i < n - 1; ++i) {
			sum += b[i].dist(b[i + 1]);
		}
	} while(next_permutation(ind.begin(), ind.end()));
	ld p = 1;
	for (int i = 1; i <= n; ++i) {
		p *= i;
	}
	cout << sum / p << '\n';
	return 0;
}


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

int main() {
  int64_t n, a, b, p, c = 0;
  cin >> n >> a >> b;
  a--;
  b--;
  n--;
  if(a < b){
    p = a;
    a = b;
    b = p;
  }
  if((a - b) % 2 == 0){
    cout << (a - b) / 2 << endl;
  }
  else if(a < n - b) cout << (a + b + 1) / 2 << endl;
  else cout << (2 * n - a - b + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll> >
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9 + 7;

int main()
{
	fast;
	ll n,m;
	cin>>n>>m;
	map<ll,ll> p;
	map<ll,ll> g;
	ll ans=0,ans2=0;
	for(ll i=0;i<m;i++)
	{
		ll x;
		string y;
		cin>>x>>y;
		if(p[x]==1)
		{
			continue;
		}
		else
		{
			if(y=="AC")
			{
				ans2++;
				ans += g[x];
				p[x]++;
			}
			else
			{
				g[x]++;
			}
		}
	}
	cout<<ans2<<" "<<ans;
	
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	string W;
	string T;
	int ans = 0;
	cin >> W;
	cin >> T;
	while (T != "END_OF_TEXT")
	{
		transform(T.begin(), T.end(), T.begin(),::tolower);
		if (T == W)
		{
			ans++;
		}
		cin >> T;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n)cin>>p[i];
    int cnt = 0;
    for(int i = 1; i < n; i++){
        if(i+1==n)break;
        if(p[i-1]>p[i]&&p[i]>p[i+1])cnt++;
        if(p[i-1]<p[i]&&p[i]<p[i+1])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())

a=0
b=0
c=0

for _ in range(n):
  aa,bb,cc=map(int,input().split())
  
  a1=max(b,c)+aa
  b1=max(a,c)+bb
  c1=max(b,a)+cc
  a=a1
  b=b1
  c=c1
  #print(a,b,c)
  
print(max(a,b,c))

Measured memory_bytes: 49148
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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 (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N-1) cin >> A[i];
    vector<ll> cnt(N, 0);
    REP(i, N-1) cnt[A[i]-1]++;

    REP(i, N){
        cout << cnt[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6352
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    rep(i, n){
        if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    if(s.charAt(0)!=s.charAt(1)&&s.charAt(1)!=s.charAt(2)&&s.charAt(2)!=s.charAt(3)){
      System.out.println("Good");
    }else{
      System.out.println("Bad");
    }
  }
}


Measured memory_bytes: 21716
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <ios>
 
#include <iostream>
#include <cstdio>
 
using namespace std;
int main(void)
{
 
    long double W, H, x, y;
    cin >> W >> H >> x >> y;
 	cout << (W*H) / 2 << " " << (W/2 == x && H/2 == y) << endl;   
    
}

Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int n;cin>>n;
    string s;cin>>s;
    int cnt=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]) cnt++;
    }
    cout<<cnt<<endl;
}

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

int main(){
  int A1,A2,A3;
  cin >>A1>>A2>>A3;
  
  string ans;
  if(A1+A2+A3>21) ans = "bust";
  else ans = "win";
  
  cout << ans<< endl;
}

Measured memory_bytes: 256
n,k = map(int, input().split())

al = list(map(int, input().split())) 

if n==k:
    print(1)
    exit()
    
x = 1+(n-k)//(k-1)
y = (n-k)%(k-1)

if y >0:
    print(x+1)
else:
    print(x)

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

ans = 0
for i in range(1, N+1, 2):
    cnt = 0
    for j in range(1, i+1):
        if i%j == 0:
            cnt += 1
        else:
            cnt = cnt
    if cnt == 8:
        ans += 1
    else:
        ans = ans

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	string s;
	cin>>s;
	if (s[sz(s)-1]=='3')  cout<<"bon";
	else if (s[sz(s)-1]=='0' || s[sz(s)-1]=='1' || s[sz(s)-1]=='6' || s[sz(s)-1]=='8')  cout<<"pon";
	else  cout<<"hon";
	re 0;
}

Measured memory_bytes: 3628
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
  t_sum=a[i]+a[i-1]
  tt=0
  if t_sum>x:
    tt=t_sum-x
    tmp1=min(a[i],tt)
    ans+=tmp1
    a[i]-=tmp1
    tt-=tmp1
    if tt>0:
    # if i!=0:
      tmp2=min(a[i-1],tt)
      ans+=tmp2
      a[i-1]-=tmp2
print(ans)

Measured memory_bytes: 14068