akhauriyash/Code-Regression huggingface dataset:
// B - Picking Up
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<pair<int, int> > a(n);
	for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

	map<pair<int, int>, int> c;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			c[make_pair(a[j].first - a[i].first, a[j].second - a[i].second)]++;
	int m = 0;
	c.erase(make_pair(0, 0));
	for (map<pair<int, int>, int>::iterator it = c.begin(); it != c.end(); ++it)
		m = max(m, it->second);
	cout << (n - m) << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))
#define pi acos(-1);

typedef long long ll;
const ll M = 1e9+7;
const int sz = 500010;


int main(){
    int n,x; cin >> n;
    unordered_map<int,int> mp;
    for(int i=0;i<n-1;i++){
        cin >> x;
        mp[x]++;
    }
    for(int i=1;i<=n;i++) cout << mp[i] << endl;
    return 0;
}


Measured memory_bytes: 11472
N = int(input())
A = [int(_) for _ in input().split()]

ma = sorted(x for x in A if x < 0)
pa = sorted(x for x in A if x >= 0)

# print(ma, pa)

if len(ma) % 2 == 0:
    result = -sum(ma) + sum(pa)
else:
    x = -ma[-1]
    if len(pa):
        x = min(x, pa[0])
    result = -sum(ma) + sum(pa) - x * 2

print(result)
   

Measured memory_bytes: 14252
A, B, C = [input() for _ in range(3)]

x = A[0]
cnt_a = 0
cnt_b = 0
cnt_c = 0
for _ in range(len(A)+len(B)+len(C)):
    if x == "a":
        if cnt_a < len(A):
            x = A[cnt_a]
            cnt_a += 1
        else:
            print("A")
            break
    elif x == "b":
        if cnt_b < len(B):
            x = B[cnt_b]
            cnt_b += 1
        else:
            print("B")
            break
    else:
        if cnt_c < len(C):
            x = C[cnt_c]
            cnt_c += 1
        else:
            print("C")
            break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a=0,b=0,k,t,j;
    cin>>n>>m>>a;
    if(n+m+a>=22) cout<<"bust";
    else cout<<"win";
}

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

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

using namespace std;

const int INF=1<<29;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int ans=INF;
	rep(x,101){
		int sum=0;
		rep(i,n) sum+=(x-a[i])*(x-a[i]);
		ans=min(ans,sum);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double x[20],y[20];
double t[20];
double S=0;
int n;
double Abs(double a){return a<0.0?-a:a;}
double f(double m){
	int count=-1;
	double oneX=0;
	double oneY=0;
	for(int i=0;i<n;i++){
		int v=(i+1)%n;
		if(x[i]!=x[v]){
			double Y=m*x[i];
			if(min(y[i],y[v])<Y&&Y<max(y[i],y[v])){
				if(~count){
					double V=0;
					for(int j=count+1;j<i;j++){
						V+=x[j]*y[j+1]-x[j+1]*y[j];
					}
					V+=x[count+1]*oneY-oneX*y[count+1];
					V+=x[i]*Y-x[i]*x[i];
					V=Abs(V)/2;
					return -Abs(S-V-V);
				}else{
					count=i;
					oneX=x[i];
					oneY=Y;
				}
			}
		}else{
			if((y[i]-y[v])/(x[i]-x[v])!=m){
				double X=(x[i]*((y[v]-y[i])/(x[v]-x[i]))+y[i])/(m-(y[v]-y[i])/(x[v]-x[i]));
				double Y=m*X;
				if(min(x[i],x[v])<X&&X<max(x[i],x[v])){
					if(~count){
						double V=0;
						for(int j=count+1;j<i;j++){
							V+=x[j]*y[j+1]-x[j+1]*y[j];
						}
						V+=x[count+1]*oneY-oneX*y[count+1];
						V+=x[i]*Y-X*x[i];
						V=Abs(V)/2;
						return -Abs(S-V-V);
					}else{
						count=i;
						oneX=X;
						oneY=Y;
					}
				}
			}
		}
	}
}

int main(){
	int a;
	while(scanf("%d",&a),a){
		n=a;
		for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
		for(int i=0;i<a;i++){
			S+=x[i]*y[(i+1)%a]-x[(i+1)%a]*y[i];
		}
		int now=0;
		S=Abs(S)/2;
		for(int i=0;i<a;i++){
			if(Abs(x[i])>0.00001)t[now++]=y[i]/x[i];
		}
		t[now++]=9999999999999.99999;
		t[now++]=-9999999999999.99999;
		std::sort(t,t+now);
		for(int i=0;i<now;i++){
			double L=t[i];
			double R=t[i+1];
			for(int j=0;j<100;j++){
				double p1=(L*2+R)/3;
				double p2=(L+R*2)/3;
				if (f(p1) > f(p2)){
					R = p2;
				} else {
					L = p1;
				}
			}
			if(f(L)>-0.000000001||f(R)>-0.000000001){
				printf("%.15f %.15f\n",2.0,2.0*L);
				break;
			}
		}
	}
}

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

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;



signed main() {
	string s;
	cin>>s;
	cout<<s[0]<<s.size()-2<<s.back()<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,D,q;
ll d[500001];
ll pre[500001];
ll dp[500001];

int main(){
  cin>>n>>D;
  rep(i,n)cin>>d[i];
  dp[n]=1;
  for(ll i=n-1;i>=0;i--){
    if(dp[i+1]<=d[i]/2){
      dp[i]=dp[i+1];
    }else{
      dp[i]=dp[i+1]+d[i];
    }
  }
  rep(i,n){
    pre[i]=D;
    if(d[i]<=D){
      D-=d[i];
    }else if(d[i]<=2*D){
      D=d[i]-D;
    }
  }

  cin>>q;
  while(q--){
    ll t;
    cin>>t;
    t--;
    if(pre[t]<dp[t+1]){
      cout<<"NO"<<endl;
    }else{
      cout<<"YES"<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 13696
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include <utility>

using namespace std;


int main(){
	int dp[10100];
	
	int W,N;
	int v[1010],w[1010];
	
	int count=0;
	
	while(cin>>W,W){
		cin>>N;
		count++;
		for(int i=0;i<N;i++){
			scanf("%d,%d",&v[i],&w[i]);
		}
		
		for(int j=0;j<W+1;j++){
			if(j<w[0]){
				dp[j]=0;
			}else{
				dp[j]=v[0];
			}
		}
		
		for(int i=1;i<N;i++){
			for(int j=W;j;j--){
				if(j<w[i]){
					dp[j]=dp[j];
				}else{
					dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
				}
			}
		}
		cout<<"Case "<<count<<":"<<endl;
		cout<<dp[W]<<endl;
		while(dp[W]==dp[W-1])W--;
		cout<<W<<endl;
	}
	
	
	
	
	return 0;
	
}

Measured memory_bytes: 1260
s=list(raw_input())
l=len(s)-1
if len(s)<26:
    al = {}
    for i in s:
        al[i] = 1
    while (l >= 0):
        for i in range(97, 97 + 26):
            x = chr(i)
            if al.get(x, -1) == -1 :
                ans = s[:l + 1] + [x]
                if len(s) == 26:
                    ans[-2] = ''
                print ''.join(ans)
                exit()
        al[s[l]] = -1
        l -= 1
    print -1
else:
    al={}
    for i in s:
        al[i]=1
    while(l>=0):
        for i in range(97,97+26):
            x=chr(i)
            if al.get(x,-1)==-1 and x>s[l]:
                ans=s[:l+1] +[x]
                if len(s)==26:
                    ans[-2]=''
                print ''.join(ans)
                exit()
        al[s[l]]=-1
        l-=1
    print -1







Measured memory_bytes: 2696
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a, b;
	cin >> a >> b;
	a %= 500;
	if (a <= b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	string s,t;
	cin>>s>>t;
	ll siz = s.size();

	//possible impossible
	set<char> check;
	rep(i,siz)check.insert(s[i]);
	rep(i,t.size()){
		if(check.count(t[i]) == 0){
			cout<<-1<<endl;
			return 0;
		}
	}

	//solve
	string comp = s+s;
	ll ans = 0;
	vector<vector<int>> chcnt(26, vector<int> ());
	rep(i,comp.size()){
		chcnt[comp[i] - 'a'].push_back(i+1);
	}
	rep(i,t.size()){
		int ch = t[i] - 'a';
		int base = ans % siz;
		auto itr = upper_bound(all(chcnt[ch]), base);
		ans += *itr-base;
	}
	cout<<ans<<endl;
}

// vector<vector<ll>> chcnt(26, vector<ll> ());
// vector<ll> naxs(26);

// bool isOK(ll chnum, ll k, ll index, ll key){
//     if(chcnt[chnum][index] + k > key) return true;
//     else return false;
// }

// ll binary_search(ll chnum, ll k, ll nax, ll key){
//     ll ng = -1;
//     ll ok =nax;
//     while(abs(ok-ng) > 1){
//         ll mid = (ok + ng)/2;
//         if(isOK(chnum, k, mid, key))ok = mid;
//         else ng = mid;
//     }
//     return ok;
// }

// int main(){
// 	string s,t; cin>>s>>t;
// 	set<char> cnt;
// 	rep(i,s.size())cnt.insert(s[i]);
// 	bool ok = true;
// 	rep(i,t.size())if(cnt.count(t[i]) == 0)ok = false;
// 	if(!ok){cout<<-1<<endl; return 0;}

// 	rep(i,s.size()){
// 		ll ind = s[i] - 'a';
// 		chcnt[ind].push_back(i+1);
// 		naxs[ind] = i+1;
// 	}
// 	ll ans = 0;
// 	ll bfans = -1;
// 	rep(i,t.size()){
// 		ll ind = t[i] - 'a';
// 		ll tmp = max(ans-naxs[ind], 0LL);
// 		ll k = (ll)(tmp/s.size() + (tmp%s.size() != 0)) * (ll)s.size();
// 		// ll k = ceil(max(ans-naxs[ind], 0LL)/(double)s.size()) * (ll)s.size();
// 		ll e_ans = binary_search(ind, k, chcnt[ind].size(), ans);
// 		ans = k+chcnt[ind][e_ans];
// 		if(ans == bfans){
// 			k+=(ll)s.size();
// 			e_ans = binary_search(ind, k, chcnt[ind].size(), ans);
// 			ans = k+chcnt[ind][e_ans];
// 		}
// 		bfans = ans;
// 		// printf("%c is %lld [k = %lld, e_ans = %lld, add = %lld]\n", 
// 		// 	(char)('a'+ind), ans, k, e_ans, chcnt[ind][e_ans]);
// 	}
// 	cout<<ans<<endl;
// 	return 0;
// }

Measured memory_bytes: 4796
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 81;
const int inf = 1e9 + 5;
int a[nax][nax], b[nax][nax];
bool f[nax][nax][2 * nax * nax];

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

	int n, m;
	scanf("%d %d",&n, &m);
	rep(i,0,n) {
		rep(j, 0, m) {
			scanf("%d", &a[i][j]);
		}
	}
	rep(i,0,n) {
		rep(j, 0, m) {
			scanf("%d", &b[i][j]);
		}
	}
	f[0][0][nax * nax + (a[0][0] - b[0][0])] = true;
	f[0][0][nax * nax - (a[0][0] - b[0][0])] = true;
	// printf("f[0][0][%d] = f[0][0][%d] = true\n", (a[0][0] - b[0][0]), -(a[0][0] - b[0][0]));
	rep(i,0,n)rep(j,0,m) {
		if (i == j && i == 0) continue;
		// printf(" i: %d, j: %d\n", i, j);
		for (auto mydiff : {a[i][j] - b[i][j], -(a[i][j] - b[i][j])}) {
			// printf("mydiff: %d\n", mydiff);
			rep(k,mydiff,2*nax*nax) {
				if (i > 0) {
					f[i][j][k] |= f[i-1][j][k-mydiff];
				}
				if (j > 0) {
					f[i][j][k] |= f[i][j-1][k-mydiff];
				}
				// if (f[i][j][k]) printf("f[%d][%d][%d]=true\n", i, j, k - nax*nax);
			}
		}
	}
	int res = 0;
	while (!f[n-1][m-1][nax*nax + res] && !f[n-1][m-1][nax*nax - res]) {
		++res;
	}
	printf("%d\n", res);
}

Measured memory_bytes: 84224
import java.util.Scanner;
	public class Main{
		public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			int count = 0;
			while(sc.hasNext()){
				String str = sc.nextLine();
				String reverse =  new StringBuffer(str).reverse().toString();
				if(str.equals(reverse))count++;
			}
			System.out.println(count);
	}
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, x, y;
	cin>>n>>m;
	vector<int> h(n+1);
	for(int i = 1; i <= n; i++)
	{
		cin>>h[i];
	}
	vector<int> a[n+1];
	for(int i = 0; i < m; i++)
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
		// for(int i = 1; i <=n; i++)
		// {
		// 	for(int j = 0; j<a[i].size(); j++)
		// 	{
		// 		cout<<a[i][j]<<" ";
		// 	}
		// 	cout<<endl;
		// }
	int ct = 0, f  = 0;
	for(int i = 1; i <= n; i++)
	{
		f=0;
		// cout<<"h[i] "<<h[i]<<endl;
		for(int j = 0; j < a[i].size(); j++)
		{
			// cout<<"h[a[i][j] "<<h[a[i][j]]<<"  ";
			if(h[i]<=h[a[i][j]])
			{
				f=1;
				break;
				f = 1;
			}
		}
		// cout<<"f "<<f<<endl;
		if(!f) ct++;
	}
	cout<<ct;
}

Measured memory_bytes: 8772
import sys
N, = map(int, input().split())
X = list(map(int, input().split()))
S = X[0]+X[1]
T = 0
for i in range(2, N):
    T ^= X[i]
if S<T or (S-T)%2:
    print(-1)
    sys.exit()
D = (S-T)//2
if D&T:
    print(-1)
    sys.exit()
M = T.bit_length()+1
if D > X[0]:
    print(-1)
    sys.exit()
Y = 0
for i in range(M, -1, -1):
    if T & (1<<i) and ((1<<i)|Y)^D <= X[0]:
        Y = (1<<i)|Y
if Y^D == 0:
    print(-1)
else:
    print(X[0]-(Y^D))


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}


signed main(){
    int n, a, b;
    cin >> n >> a >> b;

    if(a + b - 1 > n){
        cout << -1 << endl;
        return 0;
    }

    vector<int> inc, dec;
    REP(i, a){
        inc.push_back(n - i);
    }
    for(int i=n-a; i>0; i--){
        dec.push_back(i);
    }

    vector<int> ans;

    REP(i, a){
        ans.push_back(inc.back());
        inc.pop_back();

        vector<int> v;
        REP(i, b-1){
            if(dec.empty()) break;
            v.push_back(dec.back());
            dec.pop_back();
        }
        RREP(i, v.size()){
            ans.push_back(v[i]);
        }
    }

    if(dec.empty()){
        for(auto i : ans){
            cout << i << " ";
        }
        cout << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;

}

Measured memory_bytes: 5104
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ios;
	int n;cin>>n;
	int dp[n+1][4],a[n+1][4];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	}
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	dp[1][3]=a[1][3];
	for(int i=2;i<=n;i++){
		for(int j=1;j<=3;j++){
			for(int k=1;k<=3;k++){
				if(j!=k){
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
				}
			}
		}
	}
	int ans=0;
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
}

Measured memory_bytes: 3328
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = cin.nextInt();
            y[i] = cin.nextInt();
        }

        long ans = long.MaxValue;

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                for (int k = 0; k < N; k++)
                {
                    for (int l = 0; l < N; l++)
                    {
                        int minx = x[i];
                        int miny = y[j];
                        int maxx = x[k];
                        int maxy = y[l];
                        if (minx > maxx) continue;
                        if (miny > maxy) continue;
                        long S = (long)(maxx - minx) * (long)(maxy - miny);
                        if (ans <= S) continue;

                        int tmp = 0;
                        for (int p = 0; p < N; p++)
                        {
                            if (x[p] <= maxx && x[p] >= minx && y[p] <= maxy && y[p] >= miny) tmp++;
                        }
                        if (tmp >= K) ans = S;
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
n, k=list(map(int, input().split()))
 
a=list(map(int, input().split()))
 
if n<3:
    print(abs(a[0]-a[-1]))
    exit()
 
c=[0]*n
c[-1]=0
mini=1000000
 
for i in reversed(range(n-k, n-1)):
    # print(i)
    c[i]=abs(a[i]-a[n-1])
    mini=min(mini, c[i])
 
 
for i in reversed(range(n-k)):
    c[i]=min([c[t]+abs(a[i]-a[t]) for t in range(i+1, i+k+1)])
 
# print("?", c)
 
print(c[0])

Measured memory_bytes: 52448
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

long long int N, M, K, W, H, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin >> M >> L >> R;
	if (abs(M - L) > abs(M - R)) {
		cout << "B\n";
	}
	else {
		cout << "A\n";
	}
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toLong)
    val bList = readLine()!!.split(" ").map(String::toLong)
    val aSum = aList.sum()
    val bSum = bList.sum()
    var e = 0L
    for (i in 0 until n) {
        val sub = bList[i] - aList[i]
        if (sub > 0) e += (sub + 1) / 2
    }
    if (bSum - aSum < e) {
        println("No")
    } else {
        println("Yes")
    }
}

Measured memory_bytes: 41736
#include <stdio.h>

int main(void) {
  int A,B,M;
  int a[100000];
  int b[100000];
  int x,y,c;

  int i;
  int tmp;
  int cost;
  int min_a;
  int min_b;

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

  for (i = 0; i < A; i++) {
    scanf("%d", &a[i]);
    if ((i == 0) || (a[i] < min_a)) min_a = a[i];
  }
  for (i = 0; i < B; i++) {
    scanf("%d", &b[i]);
    if ((i == 0) || (b[i] < min_b)) min_b = b[i];
  }
  cost = min_a + min_b;

  for (i = 0; i < M; i++) {
    scanf("%d %d %d", &x, &y, &c);
    tmp = a[x - 1] + b[y - 1] - c;
    if (tmp < cost) cost = tmp;
  }

  printf("%d\n", cost);
  return (0);
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;

int main(){
  ll N;
  std::cin >> N;
  ll C0 = 0;
  ll C1 = 0;
  ll C2 = 0;
  ll C3 = 0;
  for(int i = 0 ; i < N ; i++){
    std::string str;
    std::cin >> str;
    if(str == "AC"){
      C0++;
      continue;
    }
    if(str == "WA"){
      C1++;
      continue;
    }
    if(str == "TLE"){
      C2++;
      continue;
    }
    if(str == "RE"){
      C3++;
      continue;
    }
  }
  std::cout << "AC x " << C0 << std::endl;
  std::cout << "WA x " << C1 << std::endl;
  std::cout << "TLE x " << C2 << std::endl;
  std::cout << "RE x " << C3 << std::endl;
  return 0;
}


Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

from functools import lru_cache


def main(): 
    S = SI()

    print('vowel' if S in 'aeiou' else 'consonant')


main()

Measured memory_bytes: 3572
#include<stdio.h>
#include<algorithm>
using namespace std;
#define NIL -1
#define MAX 25

struct Node { int parent, left, right; };
struct Node T[MAX];
int D[MAX], H[MAX];

void setDepth(int u, int d) {
  D[u] = d;
  if (T[u].left != NIL) setDepth(T[u].left, d+1);
  if (T[u].right != NIL) setDepth(T[u].right, d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL) h1 = setHeight(T[u].left)+1;
  if (T[u].right != NIL) h2 = setHeight(T[u].right)+1;
  H[u] = max(h1, h2);
  return H[u];
}

int main() {
	int n;
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  int id, left, right;
  for ( int i = 0; i < n; i++ ) {
    scanf("%d %d %d", &id, &left, &right);
    T[id].left = left;
    T[id].right = right;
    if (left != NIL) T[left].parent = id;
    if (right != NIL) T[right].parent = id;
  }

  for ( int i = 0; i < n; i++ ) {
    if (T[i].parent == NIL) {
      setDepth(i, 0);
      setHeight(i);
      break;
    }
  }

  for ( int i = 0; i < n; i++ ) {
    printf("node %d: parent = %d, ", i, T[i].parent);
    if (T[i].parent == -1) {
      printf("sibling = -1, ");
    } else if (T[T[i].parent].left == i) {
      printf("sibling = %d, ", T[T[i].parent].right);
    } else if (T[T[i].parent].right == i) {
      printf("sibling = %d, ", T[T[i].parent].left);
    } else {
      printf("sibling = -1, ");
    }
    int deg = 0;
    if (T[i].left != NIL) deg++;
    if (T[i].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);
    if (T[i].parent == NIL) {
      printf("root\n");
    } else if (T[i].left == NIL && T[i].right == NIL) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2684
from collections import Counter
n = int(input())
count_list = []
for i in range(n):
    s = input()
    c = sorted(Counter(s).items(), key = lambda x:x[0])
    tmp = ""
    for j in range(len(c)):
        tmp += c[j][0]
        tmp += str(c[j][1])
    count_list.append(tmp)

c = Counter(count_list)
ans = 0
for i in c.values():
    if i >= 2:
        ans += i * (i - 1) // 2

print(ans)


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

int main(){
  double r;
  cin >> r;
  cout << fixed << setprecision(20) << r * 2.0 * M_PI << endl;

}

Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
using namespace std;
int n;

int main()
{
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2){
        int num = 0;
        for (int j = 1; j <= i; j++)
            num += (i%j == 0);
        ans += (num == 8);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int change(string tmp)
{
    int ret=0,val=1;
    for(int i=tmp.length()-1; i>=0; i--)
        ret+=(tmp[i]-'0')*val,val*=10;
    return ret;
}
int main()
{
    string a,b;
    while(cin>>a>>b)
    {
        string c=a+b;
        int ret=change(c);
        int val=sqrt(ret);
        if(val*val==ret) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define R register int
#define G if(++ip==ie)if(fread(ip=buf,1,SZ,stdin))
using namespace std;
const int SZ=1<<19,N=2e5+9;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
inline int in(){
	G;while(*ip<'-')G;
	R x=*ip&15;G;
	while(*ip>'-'){x*=10;x+=*ip&15;G;}
	return x;
}
int a[N],f[N];
struct Edge{
	int u,v,w;
	inline bool operator<(const Edge&x)const{
		return w<x.w;
	}
}e[2*N];
inline void Cmn(R&x,R y){
	if(x>y)x=y;
}
int Getf(R x){
	return x==f[x]?x:f[x]=Getf(f[x]);
}
int main(){
	R n=in(),q=in();
	memset(a,63,4*n);
	for(R i=1;i<=q;++i){
		e[i].u=in(),e[i].v=in(),e[i].w=in();
		Cmn(a[e[i].u],e[i].w+1);
		Cmn(a[e[i].v],e[i].w+2);
	}
	R pos=min_element(a,a+n)-a;
	for(R i=pos+1;i!=pos;++i%=n)
		Cmn(a[i],a[i?i-1:n-1]+2);
	for(R i=0;i<n;++i)
		e[++q]=(Edge){i,(i+1)%n,a[i]},f[i]=i;
	sort(e+1,e+q+1);
	LL ans=0;
	for(R i=1;i<=q;++i){
		R x=Getf(e[i].u),y=Getf(e[i].v);
		if(x!=y)f[x]=y,ans+=e[i].w;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int a, s1, s2, s3;
  cin >> a;

  s1 = a / 100;
  s2 = (a - s1*100) / 10;
  s3 = (a - s1*100 - s2*10);

  cout << s1 + s2 + s3 << endl;
}


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

using namespace std;

int n,num[200010],bj[200010];

int main()
{
	scanf("%d",&n);
	int num_max=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
		bj[num[i]]++;
		num_max=max(num_max,num[i]);
	}
	if(bj[num_max]>=2)
	{
		for(int i=1;i<=n;i++)
		    printf("%d\n",num_max);
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			if(num[i]!=num_max)
			    printf("%d\n",num_max);
			else
			{
				for(int i=num_max-1;i>=1;i--)
				{
					if(bj[i]>0)
					{
						printf("%d\n",i);
						break;
					}
				}
			}
		}
	}
	return 0;
} 

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

int main()
{
	for(string s;cin>>s;){
		set<char> cs(begin(s),end(s));
		if(cs.size()==26){
			cout<<"None"<<endl;
			continue;
		}
		for(int i=0;i<26;i++)
			if(cs.count('a'+i)==0){
				cout<<char('a'+i)<<endl;
				break;
			}
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n,k,a[100005];
vector <int> v,av;

int main(void){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%1d",&a[i]);
	if(a[1]==0)v.push_back(0);
	int len=0;
	for(int i=1;i<=n;i++){
		if(i>1&&a[i]!=a[i-1]){
			v.push_back(len);
			len=1;
		}
		else
		len++;
	}
	v.push_back(len);
	av.resize(v.size()+1);
	av[0]=0;
	for(int i=0;i<v.size();i++)
	av[i+1]=av[i]+v[i];
	int ans=0;
	for(int i=0;i<av.size();i+=2){
		int ss=av[min((int)v.size(),i+2*k+1)]-av[i];
		ans=max(ans,ss);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main(){
	string s[3];
	rep(i, 3) cin >> s[i];

	rep(i, 3) cout << s[i][0];
	cout << endl;

	return 0;
}



Measured memory_bytes: 384
#include<iostream>

int main(){
  int a[26];
  for(int i = 0; i < 26; i++) a[i] = 0;

  std::string str;
  while(std::cin >> str){

    for(int i = 0; i < str.size(); i++){
      if('a' <= str[i] && str[i] <= 'z'){
	a[str[i] - 'a']++;
      }else if('A' <= str[i] && str[i] <= 'Z'){
	a[str[i] - 'A']++;
      }
    }
  }
  
  for(int i = 0; i < 26; i++){
    std::cout << (char)('a' + i) << " : " << a[i] << std::endl;
  }
  
  return 0;
}



Measured memory_bytes: 3152
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    ll h,a; cin >> h >> a;
    cout << ceil(h,a) << endl;
}



Measured memory_bytes: 3592
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

bool went[100000]={};

void dfs(int i,std::vector<std::vector<int>> &connected) {
  went[i] = 1;
  _for(j,connected[i].size()) {
    if(went[connected[i][j]]==0)dfs(connected[i][j],connected);
  }
}

int main() {
  int n,m;
  std::cin >> n >> m;
  int x[m][2];
  int z[m];
  std::vector<std::vector<int>> connected(n,std::vector<int>());
  _for(i,m) {
    std::cin >> x[i][0] >> x[i][1] >> z[i];
    _for(j,2) x[i][j]--;
    connected[x[i][0]].emplace_back(x[i][1]);
    connected[x[i][1]].emplace_back(x[i][0]);
  }
  int count = 0;

  _for(i,n) {
    if(went[i]==0) {
      count ++;
      std::queue<int> que;
      que.emplace(i);
      while(que.size()) {
        _for(k,connected[que.front()].size()) {
          if(went[connected[que.front()][k]]==0){
            que.emplace(connected[que.front()][k]);
            went[connected[que.front()][k]] = 1;
          }
        }
        que.pop();
      }
    }
  }
  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 7800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;
    int r = 0;
    REP(i, s.size())
    {
        if (s[i] == 'o')
            r++;
    }

    if ((15 - s.size()) + r >= 8)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq
from typing import List, Any, Tuple


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    K, T = read_ints()
    A = read_ints()
    cakes: List[List[int]] = [[-A[i], i] for i in range(T)]
    heapq.heapify(cakes)
    last_eaten = -1
    count = 0
    while cakes:
        frequent0 = heapq.heappop(cakes)
        if frequent0[1] == last_eaten:
            if cakes:
                frequent1 = heapq.heappop(cakes)
                last_eaten = frequent1[1]
                frequent1[0] += 1
                if frequent1[0] != 0:
                    heapq.heappush(cakes, frequent1)
            else:
                count += 1
                last_eaten = frequent0[1]
                frequent0[0] += 1
        else:
            frequent0[0] += 1
            last_eaten = frequent0[1]
        if frequent0[0] != 0:
            heapq.heappush(cakes, frequent0)
    return count


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 75604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n ,k;
	char s[10];
	cin >> n;
	REP(i, n)
		cin >> s[i];
	cin >> k;
	char c = s[k-1];
	REP(i, n){
		if(s[i] == c)
			cout << c;
		else
			cout << '*';
	}
	
	cout << '\n';
 
	return 0;
}

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

double f(double x){
  if(x < 0){x *= (-1);}
  return x;
}

int main(){
  int n;
  cin >> n;
  int a = 0;
  int b = 0;
  int c = 0;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    if(x % 4 == 0){a++;}
    else if(x % 2 == 0){b++;}
    else{c++;}
  }
  if(n % 2 == 0){
    if(a >= c || c == 0){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
  }
  else{
    if(b == 0){
      if(a >= c - 1){cout << "Yes" << endl;}
      else{cout << "No" << endl;}
    }
    else{
      if(a >= c){cout << "Yes" << endl;}
      else{cout << "No" << endl;}
    }
  }
}       

Measured memory_bytes: 256
import sys
raw_input = sys.stdin.readline
range = xrange
N, C = map(int, raw_input().split())
x = [None]*N
v = [None]*N
for i in range(N):
    x[i], v[i] = map(int, raw_input().split())
cw = [0]*(N+1)
ccw = [0]*(N+1)
for i in range(N):
    cw[i+1] = cw[i] + v[i]
    ccw[i+1] = ccw[i] + v[N-1-i]
for i in range(1, N+1):
    cw[i] -= x[i-1]
    ccw[i] -= (C - x[N-i])
maxccw = [0]*(N+1)
maxcw = [0]*(N+1)
for i in range(1, N+1):
    maxccw[i] = max(maxccw[i-1], ccw[i])
    maxcw[i] = max(maxcw[i-1], cw[i])
ans = max(0, maxcw[-1], maxccw[-1])
for i in range(1, N+1):
    ans = max(ans, cw[i] - x[i-1] + maxccw[N-i])
    ans = max(ans, ccw[i] - C + x[N-i] + maxcw[N-i])
print ans

Measured memory_bytes: 17028
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String moji = stdIn.next();
		stdIn.close();
		
		for (int i = (moji.length() - 1); i >= 0; i--) {
			System.out.print(moji.charAt(i));
		}
		System.out.println();
}
}

Measured memory_bytes: 17124
#include<bits/stdc++.h>
using namespace std;
long long a[100001], b[100001], sum = 0, n;
int main () {
    ios_base :: sync_with_stdio (0);
    cin.tie (nullptr);
    cout.tie (nullptr);
    cin >> n;
    for (int i = 1; i <= n + 1; ++ i) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 1; i <= n; ++ i) {
        cin >> b[i];
    }
    for (int i = 1; i <= n; ++ i) {
        if (b[i] > a[i]) {
            b[i] -= a[i];
            a[i] = 0;
        }
        else {
            a[i] -= b[i];
            b[i] = 0;
        }
        if (b[i] > a[i + 1]) {
            b[i] -= a[i + 1];
            a[i + 1] = 0;
        }
        else {
            a[i + 1] -= b[i];
            b[i] = 0;
        }
    }
    for (int i = 1; i <= n + 1; ++ i) {
        sum -= a[i];
    }
    cout << sum;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	int n; cin >> n;
	
	vector<int> a(n); rep(i,n) cin >> a[i];
	sort(all(a));
	
	for(int i=a[1];i>0;i--){
		int c=0;
		rep(j,n) if(a[j]%i==0) c++;
		if(c>=n-1){
			cout << i << endl;
			return 0;
		}
	}
	
	
	//cout << c << "\n";
	
	return 0;
}


Measured memory_bytes: 640
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int main() {
	string S;
	cin >> S;
	int win = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'o') win++;
	}
	if (win + 15 - S.size() >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
// AOJ 2018: Princess's Gamble
// 2017.9.30 bal4u@uu

#include <stdio.h>

int main()
{
	int n, m, p, x, i, sum, ans;

	while (scanf("%d%d%d", &n, &m, &p) && n > 0) {
		for (sum = ans = 0, i = 1; i <= n; i++){
			scanf("%d", &x); sum += x;
			if (i == m) ans = x;
		}
		if (ans > 0) ans = sum * (100 - p) / ans;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1812
def main():
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(1000000)
    n, *rem = map(int, open(0).read().split())
    t = 3 * (n - 1)
    abc = rem[:t]
    q, k = rem[t], rem[t + 1]
    xy = rem[t + 2:]

    dist = defaultdict(dict)
    for a, b, c in zip(*[iter(abc)] * 3):
        dist[a].update({b: c})
        dist[b].update({a: c})

    vis = [False] * (n + 1)
    cost = [0] * (n + 1)
    vis[k] = True

    def dfs(a, b):
        if vis[b]:
            return
        vis[b] = True
        cost[b] = cost[a] + dist[a][b]
        a = b
        for b in dist[a].keys():
            dfs(a, b)

    for b in dist[k].keys():
        dfs(k, b)

    tmp = []
    for x, y in zip(*[iter(xy)] * 2):
        tmp.append(cost[x] + cost[y])

    ans = "\n".join(map(str, tmp))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 184088
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const int maxn = 2e5;
int dp[maxn];
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int x ,n; cin>>x>>n;
vin A (n);
F (i,0,n,1) cin>>A[i];
int maxi=x;
int mk[102]={0};
F (i,0,n,1) mk[A[i]]=1;
F (i,1,102,1) {
  if (!mk[i]) maxi=min(maxi,abs(x-i));
}
if (!mk[x-maxi]) maxi=x-maxi;
else maxi=x+maxi;
cout<<maxi;


return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;
 
struct ToUpper {
    char operator()(char c) { return toupper(c); }
};
 
int main() {
    string st;
    getline(cin, st);
    transform(st.begin(), st.end(), st.begin(), ToUpper());
    cout <<st<< endl;
    return 0;
} 

Measured memory_bytes: 2992
use strict;
use warnings;
use utf8;

my @s = split(//, <>);
my $tmp = "a";
my $i;

if ($#s != 4) {
        print "Bad";
        exit 0;
}

for ($i=0; $i<4; $i++) {
        if ($tmp eq $s[$i]) {
                print "Bad";
                exit 0;
        }
        $tmp = $s[$i];
}
print "Good";

Measured memory_bytes: 640
/**
    __author__ : srv_twry
**/

#include<bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}

bool ge(const ll& a, const ll& b) { return a >= b; }
bool le(const ll& a, const ll& b) { return a <= b; }
bool eq(const ll& a, const ll& b) { return a == b; }
bool gt(const ll& a, const ll& b) { return a > b; }
bool lt(const ll& a, const ll& b) { return a < b; }
int sgn(const ll& x) { return le(x, 0) ? eq(x, 0) ? 0 : -1 : 1; }
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,k; cin>>n>>k;
    string s; cin>>s;
    vi arr;
    int prev = 0;
    FOR(i, 1, s.size()) {
    	if(s[i] != s[i-1]) {
    		arr.push_back(i-prev);
    		prev = i;
    	}
    }
    arr.push_back(n-prev);
    // debug_vi(arr); cout<<endl;
    int maxsz = 2 * k + 1, lo = 0, sm = 0, ans = 0, best = 0;
    FOR(i, 0, min((int)arr.size(), maxsz)) {
    	sm += arr[i];
    }
    best = sm;
    int hi = min((int)arr.size(), maxsz) - 1;
    int idx = hi + 1;
    while(idx < min((int) arr.size(), maxsz)) {
    	sm += arr[idx];
    	sm -= arr[idx - maxsz];
    	if(sm > best) {
    		best = sm;
    		lo = idx - maxsz + 1;
    		hi = idx;
    	}
    	idx++;
    }
    FOR(i, 0, arr.size()) {
    	if(i < lo || i > hi) ans += arr[i]-1;
    }
    ans += best-1;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 972