akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define F first
#define S second
#define X real()
#define Y imag()
#define PB push_back 
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef complex<int> cld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut,pr> ppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
typedef vector<ppr> Vppr;
const int SIZE=100+9*1e+5;
const int INF=1<<30;
int dist[SIZE];
Vpr edge;
PQ qu;
int point[16][3];
LL cost[16][16];
int isUselly[SIZE];
int DP[SIZE];
int SDP[16][1<<16];
int N,M,d[16],c;
int BIT[SIZE];
void add(int x,int p){
	while(x<=SIZE){
		BIT[x]+=p;
		x+=x&-x;
	}
}
int sum(int x){
	int sum=0;
	while(x>0){
		sum+=BIT[x];
		x-=x&-x;
	}
	return sum;
}
int calc(int x){
    if(x>=SIZE) return INF;
    if(isUselly[x] && x%2==0) return 2;
    if(DP[x]) return DP[x];
    return DP[x]=min(max(3,dist[x]),calc(x+2)); 
}
void calc(){
    REP(i,SIZE){
        int k=SIZE-i-1;
        calc(k);
    }
}
int distances(int a,int b){
    int dif=0;
    REP(i,3)
        dif+=abs(point[b][i]-point[a][i]);
    int minium=min(dist[dif],calc(dif));
    if(sum(dif)>0 && dif%2)
    	minium=min(minium,2);
    //cout << dif <<" " <<a<< " " <<b <<" " << minium << endl;
    return minium;
}
LL sells(int now,int need){
    if(need==0) return 0;
    if(SDP[now][need]) return SDP[now][need];
    LL minium=INF;
    REP(i,M)
        if(need&(1<<i))
            minium=min(minium,sells(i,need^(1<<i))+cost[now][i]);
    return SDP[now][need]=minium;
}
int main(){
    FOR(i,1,SIZE)
        dist[i]=INF;
    cin >> N>> M;
    REP(i,N){
        cin >> d[i];
        edge.PB(pr(d[i],1));
        edge.PB(pr(-d[i],1));
    }
    qu.push(pr(0,0));
    while(!qu.empty()){
        int now=qu.top().S;
        int d=qu.top().F;
        qu.pop();
        if(d!=dist[now]) continue;
        REP(i,N*2){
            int next=now+edge[i].F;
            int nd=d+edge[i].S;
            if(next>0 && next<SIZE){
                if(nd==2)
                    isUselly[next]=true;
                if(dist[next]>nd){
                    dist[next]=nd;
                    qu.push(pr(nd,next));
                }
            }
        }
    }

    REP(i,N)
    	REP(j,N)
    		if((d[i]^d[j])&1){
    			add(abs(d[i]-d[j]),1);
    			add(abs(d[i]+d[j]+1),-1);
    		}
    REP(i,M){
        REP(j,3)
            cin >> point[i][j];
    }
    calc();
    REP(i,M+1)
        REP(j,M+1)
            cost[i][j]=distances(i,j);
 
    LL ans=sells(M,(1<<M)-1);
    if(ans==INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
}


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int ans;
string s;

main() {
    cin >> s;
    rep(i,s.size()) {
        if (s[i]=='g') ans++;
        else ans--;
    }
    ct(ans/2)
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define endl '\n'
#define sz(x) ((int)x.size())
#define reset(n, m) memset(n, m, sizeof(n))

const int N = 705;
int w, b, n, m;
vector<pair<int, int>> idx;
vvi node;

int col[N];
bool mp[N][N];

void dfs(int v, int c)
{
	if (c == 1)
		w++;
	else
		b++;

	col[v] = c;

	for (int i = 1; i <= n; i++)
	{
		if (mp[v][i])
			continue;
		if (!col[i])
			dfs(i, (c == 1) ? 2 : 1);
		else if (col[i] == col[v])
		{
			cout << -1 << endl;
			exit(0);
		}
	}
}

ll memo[N][N];

ll solve(int curr, int W, int B)
{
	if (curr >= sz(idx))
		return (W * (W - 1ll) + B * (B - 1ll)) / 2ll;

	ll &ret = memo[curr][W];

	if (~ret)
		return ret;
	ret = min(solve(curr + 1, W + idx[curr].first, B + idx[curr].second),
			solve(curr + 1, W + idx[curr].second, B + idx[curr].first));
	return ret;
}

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

	cin >> n >> m;

	while (m--)
	{
		int u, v;
		cin >> u >> v;
		mp[u][v] = mp[v][u] = 1;
	}

	for (int i = 1; i <= n; i++)
		mp[i][i] = 1;

	for (int i = 1; i <= n; i++)
	{
		if (!col[i])
		{
			w = b = 0;
			dfs(i, 1);
			idx.push_back(
			{ w, b });
		}
	}
	reset(memo, -1);
	cout << solve(0, 0, 0) << endl;

	return 0;
}


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

int main() {
	vector<char> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a[0] == 'a' && a[1] == 'b' && a[2] == 'c') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

constexpr size_t MOD = 1'000'000'007;

using Graph = std::vector<std::vector<size_t>>;

size_t dfs(const Graph& g, size_t k, size_t vc, size_t vp) {
  auto count = g[vc].size();

  size_t answer = 1;

  if (vc == 0) {
    answer *= k;
    for (size_t i = 0; i < count; ++i) {
      answer *= k - 1 - i;
      answer %= MOD;
    }
  } else {
    for (size_t i = 0; i < count - 1; ++i) {
      answer *= k - 2 - i;
      answer %= MOD;
    }
  }

  for (auto&& vi : g[vc]) {
    if (vi != vp) {
      answer *= dfs(g, k, vi, vc);
      answer %= MOD;
    }
  }

  return answer;
}

int main() {
  size_t n, k;
  std::cin >> n >> k;

  Graph g(n);
  for (size_t i = 0; i < n - 1; ++i) {
    size_t a, b;
    std::cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }

  std::cout << dfs(g, k, 0, -1) << std::endl;
}

Measured memory_bytes: 11520
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    string n;
    while( 1 ){
        cin >> n;
        if( n == "0" ) break;
        int sum = 0;
        rep(i, n.size()){
            sum += (int)(n[i]-'0');
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 1192
//============================================================================
// Name        : testcpp2.cpp
// Author      : luyikei
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

	while(true){
	int n=0;
	cin >> n;
	if(!n)
			break;
	vector< vector<int> >list;
	for (int i=0;i<n;i++){
		vector<int>tmp_v;
		for (int i2=0;i2<n;i2++){
			int tmp;
			cin >> tmp;
			tmp_v.push_back(tmp);
		}
		list.push_back(tmp_v);
	}
	vector<int> r_max_list;
	for (int i=0;i<n;i++){
		int r_max=100;
		for (int i2=0;i2<n;i2++){
			if(r_max > list[i][i2] ){
				r_max = list[i][i2];
			}
		}
		r_max_list.push_back(r_max);
	}
	vector<int> c_max_list;
		for (int i=0;i<n;i++){
			int c_max=0;
			for (int i2=0;i2<n;i2++){
				if(c_max < list[i2][i] ){
					c_max = list[i2][i];
				}
			}
			c_max_list.push_back(c_max);
		}
	int max=0;
	for (int i=0;i<n;i++){
		for (int i2=0;i2<n;i2++){
			if(r_max_list[i]==c_max_list[i2]){
				max = r_max_list[i];
			}
		}
	}
	cout << max << endl;
	}
	return 0;
}

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

int func(long long n, bool f3, bool f5, bool f7, int N, long long *presult)
{
	if (n > N)
	{
		// cout << n << ":"
		// 	 << "0"
		// 	 << "\n";
		return 0;
	}
	else
	{
		if (f3 && f5 && f7)
		{
			(*presult)++;
		}
		func(n * 10 + 3, true, f5, f7, N, presult);
		func(n * 10 + 5, f3, true, f7, N, presult);
		func(n * 10 + 7, f3, f5, true, N, presult);
		// cout << n << ":" << ret << "\n";
		return 0;
	}
}

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

	long long N;
	scanf("%lld", &N);
	long long result = 0;
	func(0, false, false, false, N, &result);
	cout << result;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N = 0;

    scanf("%d", &N);

    if (999 >= N){
        printf("ABC");
    }
    else{
        printf("ABD");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 100002
using namespace std;
struct node{
	int a,b;
	bool operator<(const node &_)const{
		return b>_.b;
	}
}t[N];
int n,m,fa[N],ans;
int getfa(int x){
	return x==fa[x]?fa[x]:fa[x]=getfa(fa[x]);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&t[i].a,&t[i].b);
	for(int i=1;i<=m;i++)fa[i]=i;
	sort(t+1,t+n+1);
	for(int i=1;i<=n;i++){
		if(t[i].a<=m){
			int ga=getfa(m-t[i].a+1);
			if(ga==0)continue;
			fa[ga]=ga-1;
			ans+=t[i].b;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
  long n, k;
  cin >> n >> k;
  
  if (n%k == 0) cout << 0 << endl;
  else if (n%k > abs(n%k-k)) cout << abs(n%k-k) << endl;
  else cout << n%k << endl;
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>

using namespace std;

class Dice{
	int face[6] ;
	map<string,int> dir;
	
public:
	Dice(int sai[6]){
		for(int i=0 ; i<6 ; i++){
			face[i] = sai[i] ;
		}
		dir["top"]    = 1 ;
		dir["south"]  = 2 ;
		dir["east"]   = 3 ;
		dir["west"]   = 4 ;
		dir["north"]  = 5 ;
		dir["bottom"] = 6 ;
	}
	void show(string d){
		if(d == "all"){
			for(int i=0 ; i<6 ; i++){
				cout << face[i] << " " ;
			}
			cout << endl;
			return ;
		}else{
			cout << face[dir[d]-1] << endl;
		}
	}
	int get(string d){
		return face[dir[d]-1] ;
	}
	void move(const string str){//動かす
		for(int i=0 ; i<str.size() ; i++){
			turn(str[i]);//char
		}
	}
	void turn(char d){//回す//direction:方向
		map<char, int> mp;
		mp['S'] = 0 ;
		mp['E'] = 1 ;
		mp['W'] = 2 ;
		mp['N'] = 3 ;
		
		static const int index[4][6] ={
			{5,1,3,4,6,2},//south
			{4,2,1,6,5,3},//east
			{3,2,6,1,5,4},//west
			{2,6,3,4,1,5},//north
		};
		
		int copy[6] ;
		for(int i=0 ; i<6 ; i++){
			copy[i] = face[i] ;
		}
		//これは止めて、代入演算子＝をオーバーライドしてもいいかもしれない。しかして、それをやると実行時のメモリが微増するはずだ。
		
		for(int i=0 ; i<6 ; i++){//permutation:置換
			face[i] = copy[index[mp[d]][i]-1] ;
		}
		
		//show("all");//check
	}
	void rotate(void){//回転//SWNの操作で、上から見てCCW:counter clock wise：反時計回りでの90度回転。
		turn('S');
		turn('W');
		turn('N');
	}
	bool adjust(int top,int south){//位置合わせ
		for(int i=0;i<6;i++){
			if(get("top") == top){
				break;
			}
			//cout << "zigzag:" << i << endl ;//check
			turn(i%2==0 ? 'S' : 'E');//三項演算子
		}
		for(int i=0;i<4;i++){
			//cout << "rotate:" << i << endl ;//check
			rotate();
			if(get("south") == south){
				return true ;
			}
		}
		
		return false ;
	}
	bool operator == (Dice obj){//演算子のオーバーライド
		if(obj.adjust(this->get("top"),this->get("south"))){
			for(int i=0 ; i<6 ; i++){
				if(this->face[i] != obj.face[i]){
					return false ;
				}
			}
			return true ;
		}
		
		return false ;
	}
};

int main(void){
	// ITP1_11_A　転がす
	int sai[6] ;
	cin >> sai[0] >> sai[1] >> sai[2] >> sai[3] >> sai[4] >> sai[5] ;
	Dice d(sai) ;
	
	string str ;
	cin >> str ;
	
	d.move(str) ;
	d.show("top") ;
}

Measured memory_bytes: 1224
object Main {
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNext){
	        val n = sc.nextInt
	        var count = 0
	        for(a <- 0 to 9; b <- 0 to 9; c <- 0 to 9; d <- 0 to 9){
	           if(a+b+c+d == n) count+=1
	        }
	        println(count)
    	}
    }
}

Measured memory_bytes: 47764
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n,k;
    long long int s;
      cin>>n>>k>>s;

       long long int arr[n];

        if(k!=0)
        {
            for(int i=0;i<n;i++)
            {
               if(i<k)
                arr[i]=s;

                else{
                   arr[i]=s/2 +1;
                     if(arr[i]==s)
                     arr[i]=s/2 +2;
                }
            }
        }
        else
        {
           for(int i=0;i<n;i++)
            {
               arr[i]=s/2 +1;
               if(arr[i]==s)
               arr[i]=s/2 +2;
             }
        }
      for(int i=0;i<n;i++)
       cout<<arr[i]<<" ";
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

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

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

    int operation = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = n-1; j > i; --j) {
            if (a[j] < a[j-1]) {
                std::swap(a[j], a[j-1]);
                operation++;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        std::cout << a[i];
        if (i == (n-1)) {
            std::cout << std::endl;
        } else {
            std::cout << " ";
        }
    }

    std::cout << operation << std::endl;

    return 0;
}


Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int D = scan.nextInt();
        int[][] X = new int[N][D];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                X[i][j] = scan.nextInt();
            }
        }
        double distance = 0.0;
        int count=0;
        for (int i = 0; i < N; i++) {
          for (int k = i+1; k < N; k++) {
            distance = 0.0;
            for (int j = 0; j < D; j++) {
                    distance += Math.pow(Math.abs(X[i][j] - X[k][j]),2.0);
                }            
            	int distanceT= (int)Math.sqrt(distance);
            	if (distance==Math.pow(distanceT,2.0)) {
               		count++;
            	}
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23636
n,k=map(int,input().split())
c=0
if k==0:
 print(n**2)
else:
  for b in range(k,n+1):
    p=int(n/b)
    r=n%b
    c+=(b-k)*p
    if r>=k:
      c+=r-k+1
  print(c)

Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
XY = zip(m,m)

MOD = 10**9 + 7

graph = [[] for _ in range(N+1)]
for x,y in XY:
    graph[x].append(y)
    graph[y].append(x)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

dp_w = [1] * (N+1) # 根が白
dp_b = [1] * (N+1)

for x in order[::-1]:
    w = dp_w[x]; b = dp_b[x]
    p = parent[x]
    dp_w[p] *= (b+w); dp_w[p] %= MOD
    dp_b[p] *= w; dp_b[p] %= MOD

answer = (dp_w[1] + dp_b[1]) % MOD
print(answer)

Measured memory_bytes: 31600
#include <stdio.h>
int main()
{
	int i,H,W,flag=0;
	while(scanf("%d%d",&H,&W)!=EOF&&H!=0)
	{
		for(i=0;i<W;i++)printf("#");
		printf("\n");
		for(i=1;i<H-1;i++)
		{
			for(int j=0;j<W;j++)
			{
				if(j==0||j==W-1)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		for(i=0;i<W;i++)printf("#");
		printf("\n\n");
	}	
	return 0;
}


Measured memory_bytes: 2104
class UnionFind:
    """
    sizeによる実装
    """

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        """
        x: child
        ret-> node
        xのグループの代表を見つける
        """
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        """
        union (x ,y)
        x,y: node
        ret->None
        """
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size[px] < self.size[py]:
            self.parent[px] = py
            self.size[py] += self.size[px]
        else:
            self.parent[py] = px
            self.size[px] += self.size[py]

    def same(self, x, y):
        """
        return true if x and y are in same group
        """
        return self.find(x) == self.find(y)

    def connectedNum(self, x):
        """
        return size of the group x belong to
        """
        return self.size[self.find(x)]

    def is_connected(self):
        """
        return true is all node is in one group
        """
        return self.connectedNum(0) == len(self.parent)


N, M, K = map(int, input().split())
F = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
B = [list(map(lambda x:int(x)-1, input().split())) for _ in range(K)]

B_set = [set() for _ in range(N)]
F_set = [set() for _ in range(N)]
for a, b in B:
    B_set[a].add(b)
    B_set[b].add(a)
for a, b in F:
    F_set[a].add(b)
    F_set[b].add(a)

Un = UnionFind(N)
for a, b in F:
    Un.union(a, b)

ans = [0]*N
for i in range(N):
    in_group_B = 0
    for b in B_set[i]:
        if Un.same(b, i):
            in_group_B += 1
    ans[i] = Un.connectedNum(i) - len(F_set[i])-in_group_B-1
print(*ans)


Measured memory_bytes: 146220
N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list( map(int, input().split()) )

A.insert(0, 0)
B.insert(0,0)

# convert to the cumulative/prefix sum
for i in range(1, len(A)):
    A[i] += A[i-1]

for i in range(1, len(B)):
    B[i] += B[i-1]

# print(A)
# print(B)

books_stack_a = 0

books_stack_b = M

cur_max = 0

for books_stack_a in range(0, N + 1):
    if A[books_stack_a] > K:
        break
    diff = K - A[books_stack_a]
    while diff < B[books_stack_b]:
        books_stack_b -= 1

    cur_max = max(cur_max, books_stack_b + books_stack_a)

print(cur_max)

Measured memory_bytes: 117980
using System;
using System.Collections.Generic;
using System.Text;

namespace AtcoderTest.BeginnerContest124
{
    class B
    {
        public static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var Hi = Console.ReadLine().Split(' ');

            int high = 0;
            int num = 0;
            foreach(var inn in Hi)
            {
                int innHigh = int.Parse(inn);
                if (high <= innHigh)
                {
                    high = innHigh;
                    num++;
                }
            }
            Console.WriteLine(num);
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String str = sc.next();
        int count = 0;
        for (char c : str.toCharArray()) {
            if (c == '-') {
                count--;
            } else {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21588
#include <iostream>

int main() {
	int a,b,k;
  	std::cin >> a >> b >> k;
    for (int i=((a>b)?b:a);; i--){
        if ((a%i==0)&&(b%i==0)) k--;
        if (k==0) {
            std::cout << i << std::endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define lli long long int
int main(){
  lli i=1,n,m,k,u=0;
  cin>>n>>m>>k;
  //lli z=min(n,m);
  for(i=min(n,m);i>=1;i--){
    if(n%i==0 and m%i==0){
      u++;
    }
    if(u==k){
      cout<<i;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(a,b)=input.split(" ").map(_.toInt)
    if(a%3==0 || b%3==0 || (a+b)%3==0){
      "Possible"
    }else{
      "Impossible"
    }
  }
}


Measured memory_bytes: 25532
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();


        char c = s.charAt(k-1);


        StringBuilder sb = new StringBuilder();
        for(char t: s.toCharArray()) {
            if(t == c) sb.append(t);
            else sb.append('*');
        }

        System.out.println(sb);


    }


}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int k,x;
int main(){
	cin >> k >> x;
	for(int i=x-k+1;i<x+k;i++) cout << i << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int H, W, K; cin >> H >> W >> K;
  string a[H]; rep(i,H) cin >> a[i];

  int top = 0, count = 1;
  vector<int> st[H];
  int result[H][W] = {};
  rep(i,H) {
    rep(j,W) if (a[i][j]=='#') st[i].push_back(j);
    if (st[i].empty()) {
      if (i!=H-1) continue;
      for (auto j=st[top-1].begin(); j<st[top-1].end(); j++) {
        int l = (j==st[top-1].begin()) ? 0 : *j;
        int r = (j==st[top-1].end()-1) ? W-1 : *(j+1)-1;
        for (int k=top; k<=i; k++) for (int d=l; d<=r; d++) {
          result[k][d] = result[top-1][d];
        }
      }
    }
    else {
      for (auto j=st[i].begin(); j<st[i].end(); j++) {
        int l = (j==st[i].begin()) ? 0 : *j;
        int r = (j==st[i].end()-1) ? W-1 : *(j+1)-1;
        for (int k=top; k<=i; k++) for (int d=l; d<=r; d++) {
          result[k][d] = count;
        }
        count++;
      }
      top = i+1;
    }
  }
  rep(i,H) {
    rep(j,W) cout << result[i][j] << " ";
    cout << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>f,s,th;
    for(int i=0;i<n;i++){
        int tf,ts,tth;
        cin>>tf>>ts>>tth;
        f.push_back(tf);
        s.push_back(ts);
        th.push_back(tth);
    }
    vector<int>dpf,dps,dpth;
    dpf.push_back(f[0]);
    dps.push_back(s[0]);
    dpth.push_back(th[0]);
    for(int i=1;i<n;i++){
        dpf.push_back(f[i]+max(dps[i-1],dpth[i-1]));
        dps.push_back(s[i]+max(dpf[i-1],dpth[i-1]));
        dpth.push_back(th[i]+max(dps[i-1],dpf[i-1]));
    }
    cout << max(dpf[n-1],max(dps[n-1],dpth[n-1])) << endl;
    return 0;
}


Measured memory_bytes: 2924
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();

        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (n == i * j) {
                    System.out.println("Yes");
                    return;
                }

            }
        }
        System.out.println("No");
    }
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}



int32_t main() {
	

	int n; 
	cin>>n;

	int val = n / 1000;
	int v = n % 1000;
	if(v==0){
		cout << 0;
	}
	else{
		cout <<  ((val+1) * 1000) - n;
	}
	// cout <<  ((val+1) * 1000) - n;

	return 0;
}

Measured memory_bytes: 3632
arr = []
for i in range(3):
	te = list(map(int,input().split()))
	arr.append(te)
n = int(input())
check = []
for i in range(n):
	x = int(input())
	for j in range(3):
		for k in range(3):
			if arr[j][k]==x:
				arr[j][k] = 0
yes = False
for j in range(3):
	c = 0
	for k in range(3):
		if arr[j][k]==0:
			c+=1
	if c==3:
		yes = True
		break
	
if yes==False:
	for j in range(3):
		c = 0
		for k in range(3):
			if arr[k][j]==0:
				c+=1
		if c==3:
			yes = True
			break
if yes==False:
	c = 0
	for j in range(3):		
		if arr[j][j]==0:
			c+=1
	if c==3:
		yes = True
if yes==False:
	c = 0
	for j in range(3):		
		if arr[j][2-j]==0:
			c+=1
	if c==3:
		yes = True
if yes:
	print("Yes")
else:
	print("No")					

Measured memory_bytes: 3064
h, w, d = map(int, input().split())

a = [list(map(int, input().split())) for i in range(h)]

dic = [0] * (h * w)

for i in range(h):
    for j in range(w):
        dic[a[i][j] - 1] = i, j

s = [[0] * (h * w // d + (i < h * w % d)) for i in range(d)]

for i in range(d):
    for j in range(1, len(s[i])):
        b = i + d * (j - 1)
        c = i + d * j

        y, x = dic[b]
        ny, nx = dic[c]
        s[i][j] = s[i][j - 1] + abs(ny - y) + abs(nx - x)

q = int(input())

for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    print(s[l % d][r // d] - s[l % d][l // d])


Measured memory_bytes: 22892
#include <iostream>
#include<string>
#include<math.h>
using namespace std;


int main(){
    int X;
    
    cin >> X;
    if(X==1){
        int ans=1;
        cout<<ans;
        return 0;
    }
    int max=0;
    for(int i=1;i<X;i++){
        for(int k=2;k<11;k++){
            int tmp=pow(i,k);
            if(X>=tmp){
                if(max<tmp){
                    max=tmp;
                }
            }
        }    
    }
        
    cout << max;
    return 0;
}

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

using namespace std;

int main()
{
  int N;
  int conp = 0;
  string S;

  cin >> N;
  cin >> S;

  while(conp < S.size()){
    int num = 0;
    int i = conp + 1;

    while(S[conp] == S[i] && S.size() > i){
      num++;
      i++;
    }

    if(num != 0){                                                                                                                             
      S.erase(S.begin() + conp, S.begin() + i-1);
    }
    conp++;
  }

  cout << S.size() << endl;

  return 0;
}

Measured memory_bytes: 512
W=[]
K=[]

for i in range(10):
    W.append(int(input()))
for i in range(10):
    K.append(int(input()))
  
W.sort(reverse=True)
K.sort(reverse=True)
   
print(W[0]+W[1]+W[2],K[0]+K[1]+K[2])


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MAX_H 2200
#define MAX_W 2200

int main() {
  int H, W;
  cin >> H >> W;
  string S[MAX_H];
  vector<vector<int> > vert(MAX_H, vector<int>(MAX_W));
  vector<vector<int> > hori(MAX_H, vector<int>(MAX_W));

  REP(i, H) cin >> S[i];

  REP(i, H) {
    int cnt = 0, start = 0;
    REP(j, W) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        REP2(k, start, j) hori[i][k] = cnt;
        cnt = 0;
        start = j;
      }
      if (j == W - 1) REP2(k, start, j + 1) hori[i][k] = cnt;
    }
  }

  REP(j, W) {
    int cnt = 0, start = 0;
    REP(i, H) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        REP2(k, start, i) vert[k][j] = cnt;
        cnt = 0;
        start = i;
      }
      if (i == H - 1) REP2(k, start, i + 1) vert[k][j] = cnt;
    }
  }


  vector<vector<int> > ans(H, vector<int>(W));
  int answer = 0;
  REP(i, H) {
    REP(j, W) {
      if (S[i][j] != '#') {
        ans[i][j] = vert[i][j] + hori[i][j];
        answer = max(answer, ans[i][j]);
      }
    }
  }

  cout << answer - 1 << endl;
  return 0;
}


Measured memory_bytes: 58112
#include <stdio.h>

int main(void){
    int n,k,i,d[1000],a[1000],b[1000],j,l,c=0,x,y[1000];

    scanf("%d %d",&n,&k);

    for(l=1;l<=n;l++){
        b[l]=1;
    }

    for(l=1;l<=n;l++){
        y[l]=l;
    }

    for(i=1;i<=k;i++){
        scanf("%d",&d[i]);
        x=d[i];
        j=1;
        while(x!=0){
            scanf(" %d",&a[j]);
            x--;
            j++;
        }
        for(l=1;l<=d[i];l++){
            if(a[l]==y[a[l]]){
                b[a[l]]--;
            }
        }
        int a[1000]={0};
    }

    for(i=1;i<=n;i++){
        if(b[i]==1){
            c++;
        }
    }


    printf("%d\n",c);

    return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll n;
  cin >> n;
  vll b(n-1);
  for (ll i = 0; i < n; i++) {
    cin >> b[i];
  }
  b.push_back(100001);
  ll ans = b[0];
  for (ll i = 0; i < n; i++) {
    if (b[i] < b[i+1]) {
      ans += b[i];
    }
    else {
      ans += b[i+1];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(x+y*1j)
 
print(abs(area_polygon(p)))

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

const long long int DENOMI = 1000000007;

int main()
{
	int n;
	cin >> n;
	auto f = vector<int>(n + 1);
	for(auto i = 2; i <= n; ++i){
		int t = i;
		for(auto j = 2; j <= t; ++j){
			while(t % j == 0){
				++f[j];
				t /= j;
			}
		}
	}
	long long int ans = 1;
	for(auto i = 2; i <= n; ++i){
		ans = (ans * (f[i] + 1)) % DENOMI;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,s,e) for(ll i=(s);(s>e)?i>e:i<e;(s>e)?i--:i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll k,a,b;
    cin>>k>>a>>b;
    for(ll i = a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
from math import ceil

n = int(input())
cs = []
ss = []
fs = []

for _ in range(n-1):
    c, s, f = map(int, input().split())
    cs.append(c)
    ss.append(s)
    fs.append(f)

for i in range(n):
    t = 0
    for j in range(i, n-1):
        if t < ss[j]:
            t = ss[j]
        t = ceil(t / fs[j]) * fs[j]
        t += cs[j]
    print(t)

Measured memory_bytes: 9032
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
  int N, m=0;
  cin >> N;
  vector<int> A(N);
  for (int j=0; j < N; ++j) {
  	cin >> A[j];
  }
  for (int j=0; j < N-1; ++j) {
    for (int k=j+1; k < N; ++k) {
  		m = max(m, abs(A[j]-A[k]));
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

//The Two Men of the Japanese Alps
public class Main{

	int INF = 1<<29;
	Map<Integer, Double>[] map;
	
	double calc(double x1, double y1, double x2, double y2){
		return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		int[] xs = new int[100], ys = new int[100], y = new int[6000];
		double[] x = new double[6000];
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			Set<Integer> yset = new HashSet<Integer>();
			for(int i=0;i<n;i++){
				xs[i] = sc.nextInt();
				yset.add(ys[i]=sc.nextInt());
			}
			int[] Y = new int[yset.size()];
			int id = 0;
			for(int yy:yset)Y[id++]=yy;
			Arrays.sort(Y);
			id = 0;
			for(int i=0;i+1<n;i++){
				if(ys[i]==ys[i+1]){
					x[id] = xs[i];
					y[id++] = ys[i];
				}
				else if(ys[i]<ys[i+1]){
					for(int j=0;j<Y.length&&Y[j]<ys[i+1];j++){
						if(Y[j]<ys[i])continue;
						x[id] = (xs[i+1]-xs[i])*(Y[j]-ys[i]+0.)/(ys[i+1]-ys[i]) + xs[i];
						y[id++] = Y[j];
					}
				}
				else{
					for(int j=Y.length-1;j>=0&&Y[j]>ys[i+1];j--){
						if(Y[j]>ys[i])continue;
						x[id] = (xs[i+1]-xs[i])*(Y[j]-ys[i]+0.)/(ys[i+1]-ys[i]) + xs[i];
						y[id++] = Y[j];
					}
				}
			}
			x[id] = xs[n-1];
			y[id++] = 0;
			map = new Map[id];
			for(int i=0;i<id;i++)map[i]=new HashMap<Integer, Double>();
			map[0].put(id-1, 0.);
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(id, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return (int)Math.signum(map[o1[0]].get(o1[1]) - map[o2[0]].get(o2[1]));
				}
			});
			q.add(new int[]{0, id-1});
			double res = INF;
			while(!q.isEmpty()){
				int[] V = q.poll();
				int i = V[0], j = V[1];
				if(i==j){
					res = Math.min(res, map[i].get(j)); continue;
				}
				for(int di=-1;di<=1;di++){
					int ni = i+di;
					if(ni<0 || id<=ni)continue;
					for(int dj=-1;dj<=1;dj++){
						int nj = j+dj;
						if(nj<0 || id<=nj || nj < ni || y[ni]!=y[nj])continue;
						double w = map[i].get(j) + calc(x[i], y[i], x[ni], y[ni]) + calc(x[j], y[j], x[nj], y[nj]);
						if(!map[ni].containsKey(nj) || w < map[ni].get(nj)){
							map[ni].put(nj, w);
							q.add(new int[]{ni, nj});
						}
					}
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val p = sc.asSequence().take(n).map { it.toInt() }.joinToString("")
    val q = sc.asSequence().take(n).map { it.toInt() }.joinToString("")

    val s = (1..n).map { it.toString() }.joinToString("")
    val all = mutableListOf<String>()
    permutation(s, "", all)
    all.sort()
//    println(p)
//    println(q)
//    println(all)
    print(Math.abs(all.indexOf(q) - all.indexOf(p)))
}

fun permutation(q: String, ans: String, all: MutableList<String>) {
    // Base Case
    if (q.length <= 1) {
        all.add(ans + q)
    } else {
        for (i in 0 until q.length) {
            permutation(
                q.substring(0, i) + q.substring(i + 1),
                ans + q[i],
                all
            )
        }
    }// General Case
}

Measured memory_bytes: 56404
#include<cstdio>
#include<cmath>
int main(){
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
	int sum=0;
	int j=i;
		while(j>0){
			j/=10;
			sum++;
		}
	if(sum%2==1)
	ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int x,y,s,a,b,l;
    scanf("%d %d %d",&x,&y,&s);
    while (!(x==0&&y==0&&s==0)) {
    
        l=0;
        for (a=1;a<s;a++) {
            for (b=a;b<s;b++) {
                int u,t,c,d,e,f;
                c=a*(100+x)/100;
                d=b*(100+x)/100;
                e=a*(100+y)/100;
                f=b*(100+y)/100;
                u=c+d;
                t=e+f;
                if (u==s) {
                    if (l<t) {
                        l=t;
                    }
                }
            }
        }
        printf("%d\n",l);
        scanf("%d %d %d",&x,&y,&s);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>

int main(void) {
	int n,i;
	int l[100];
	int max = 0,sum = 0;
	
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		scanf("%d", &l[i]);
		if (max < l[i]) max = l[i];
		sum += l[i];
	}
	sum -= max;
	if (max < sum) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
int main(void){
  char str[100005];
  cin>>str;
  int N=strlen(str);
  int count1=0;
  int count0=0;
  int ans=0;
  for(int i=0;i<N;i++){
      if(str[i]=='1'){count1++;}
      else {count0++;}
      if(count1>=1&&count0>=1){count1--; count0--; ans+=2;}
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int n,k;
int a[1001010];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>k;
    rep(i,1,n+1){
    	cin>>a[i];
	}
	sort(a+1,a+1+n);
	int sum=0;
	rep(i,1,k+1){
		sum+=a[i];
	}
	cout<<sum;
    return 0;
}



Measured memory_bytes: 3592
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for ( int i = 0; i < n; i++ ) {
			d[i] = in.nextInt();
			sum += d[i];
		}

		int ans = 0;
		for ( int i = 0; i < n; i++ ) {
			sum -= d[i];
			ans += sum*d[i];
			sum += d[i];
		}
		System.out.println(ans/2);
		in.close();
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints


if A <= 5
  puts '0'
elsif A <= 12
  puts B / 2
else
  puts B
end


Measured memory_bytes: 14236
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
using namespace std;

class Dictionary {
private:
	int size;
	vector<string> table;
	const int P;
public:
	Dictionary(int n);
	int hash(string str);
	void insert(string str);
	bool find(string str);
};

Dictionary::Dictionary(int n) : table(n), P(7916843) {
	size = n;
}

int Dictionary::hash(string str) {
	int S = 0;
	for (int i = 0; i < str.size(); i++) {
		int k = str[i] - 'A';
		S = S * 5 + k;
	}
	S = (S ^ P) % size;
	if (table[S].empty() || table[S] == str) {
		return S;
	}
	else {
		for (int i = 1;; i++) {
			int t = (S + i) % size;
			if (table[t].empty() || table[t] == str) {
				return t;
			}
		}
	}
}

void Dictionary::insert(string str) {
	int h = this->hash(str);
	if (table[h].empty()) {
		table[h] = str;
		return;
	}
}

bool Dictionary::find(string str) {
	int h = this->hash(str);
	if (table[h].empty())
		return false;
	else {
		assert(table[h] == str);
		return true;
	}
}

int main() {
	int n;
	cin >> n;
	Dictionary dic(1000000);
	for (int i = 0; i < n; i++) {
		string command, str;
		cin >> command >> str;
		//cout << i << endl;
		if (command == "insert")
			dic.insert(str);
		else if (command == "find") {
			if (dic.find(str))
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 26608
from collections import deque


n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]
c = list(map(int, input().split()))
c = sorted(c, reverse=True)

tree = [[] for i in range(n)]
cnt = [0] * n
for i in range(n - 1):
    a, b = info[i]
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
    cnt[a] += 1
    cnt[b] += 1

for i in range(n):
    if len(tree[i]) == 1:
        root = i
        break
        
q = deque([root])
visited = [False] * n
visited[root] = True
ind = 0
ans = 0
res = [0] * n
while q:
    v= q.pop()
    tmp_cnt = 0
    for nxt_v in tree[v]:
        if visited[nxt_v]:
            tmp_cnt += 1
    ans += c[ind] * tmp_cnt
    res[v] = c[ind]
    ind += 1
    for nxt_v in tree[v]:
        if visited[nxt_v]:
            continue
        visited[nxt_v] = True
        q.append(nxt_v)
    
print(ans)
print(*res)

Measured memory_bytes: 53720
#include<stdio.h>

int main(){
	char S[11];
	scanf("%s",S);
	int len=0,flag=1,C_flag=0;
	
	for(int i=0;S[i]!='\0';i++)len++;
	
	if(S[0]!='A')flag=0;
	if(S[1]-'A'<26)flag=0;
	
	for(int i=2;i<len-1;i++){
		if(S[i]-'A'<26){
			if(S[i]=='C' && C_flag==0)C_flag=1;
			else if(S[i]=='C' && C_flag==1)flag=0;
			else flag=0;
		}
	}
	if(S[len-1]-'A'<26)flag=0;
	if(C_flag==0)flag=0;
		
	if(flag==1)printf("AC\n");
	else printf("WA\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <map>

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

int main() {
	int m, n;
	cin >> n >> m;
	float border = 0;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		border += a[i];
	}
	border /= (float)(4 * m);
	sort(a.begin(), a.end());
	if (a[n - m] >= border) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

const int N = 2e5 + 10;
int neg, t[N], cnt[N], ans, a[N], n, m;

void add(int i){
	if(i - t[i] <= 0){
		t[i]++;
		return;
	}
	
	cnt[i - t[i]]++;
	if(cnt[i - t[i]] == 1)
		ans--;
	t[i]++;
}
void del(int i){
	//t[i]--;
	
	if(i - t[i] <= 0)
		return;
	
	cnt[i - t[i]]--;
	if(!cnt[i - t[i]])
		ans++;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n >> m;
	ans = n;
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		add(a[i]);
	}
	
	for (int i = 0; i < m; i++){
		int ind, x;
		cin >> ind >> x;
		ind--;
		
		t[a[ind]]--;
		del(a[ind]);
		a[ind] = x;
		add(a[ind]);
		
		cout << ans << '\n';
	}
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        int d,t,s;
        cin>>d>>t>>s;
        if(d<=(t*s))
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
        
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


    int t = 1;
    //    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	vector <ll> h;
	h.resize(n+1);
	vector <bool> v;
	v.resize(n + 1, true);
	for (ll i = 1; i <= n; i++) {
		ll tmp;
		cin >> tmp;
		h[i] = tmp;
	}
	for (ll i = 0; i < m; i++) {
		ll a, b;
		cin >> a >> b;
		if (h[a] <= h[b]) {
			v[a] = false;
		}
		if (h[b] <= h[a]) {
			v[b] = false;
		}
	}
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		if (v[i] == true) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false;
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  lli age;
  cin >> age;
  if (age==1) {
    cout << "Hello World\n";
  } else {
    lli x, y;
    cin >> x >> y;
    cout << x+y << '\n';
  }
  return 0;
}


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

typedef long long ll;

bool is_palindrome(string str) {
    int len = str.length();
    for (int i = 0; i < len; i++) {
        if (str[i] != str[len-i-1]) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.length();
    string s1 = s.substr(0, (n-1)/2);
    string s2 = s.substr((n+3)/2-1, (n-1)/2);
    if (is_palindrome(s) && is_palindrome(s1) && is_palindrome(s2)) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

Measured memory_bytes: 256