akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
int n,m,i;
  scanf("%d %d",&n,&m);
int road[n+1],point[2*m];
  for(i=0;i<n+1;++i)
  {
  road[i]=0;
  }

  for(i=0;i<m;++i)
  {
  scanf("%d %d",&point[2*i],&point[2*i+1]);

  road[point[2*i]]++;
  road[point[2*i+1]]++;
  }
  
  for(i=1;i<n+1;++i)
  {  printf("%d\n",road[i]);
  }

return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
	for(int i=0;i<M;i++){
		int a;
		cin >> a;
		N-=a;
	}
	if (N<0){
		cout << -1 << endl;
	}else{
		cout << N << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
	char b;
	cin>>b;
	if(b=='A')cout<<'T'<<endl;
	if(b=='T')cout<<'A'<<endl;
	if(b=='C')cout<<'G'<<endl;
	if(b=='G')cout<<'C'<<endl;
	return 0;
}


Measured memory_bytes: 256
#121_B
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
def F(A):
    return sum([A[i]*B[i] for i in range(M)])+C

cnt=0
for _ in range(N):
    A=list(map(int,input().split()))
    if F(A)>0:
        cnt+=1

print(cnt)

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

using namespace std;
int x, y, z;


int main() {
    scanf(" %d %d %d", &x, &y, &z);
    printf("%d %d %d\n", z, x, y);
    return 0;
}

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

void InsertionSort(int num[], int N);
void showArray(int num[], int N);

int main()
{
	int n;
	cin >> n;
	int *num = new int [n];
	for(int i = 0; i < n; i++)
		cin >> num[i];
	InsertionSort(num, n);
	return 0;
}

void InsertionSort(int num[], int N)
{
	for(int i = 1; i<N; i++)
	{
		int temp = num[i];
		int j;
		showArray(num, N);
		for(j = i; j > 0 && num[j-1] > temp; j--)
			num[j] = num[j-1];
		num[j] = temp;
	}
	showArray(num, N);
}

void showArray(int num[], int N)
{
	cout << num[0];
	for(int i = 1; i < N; i++)
		cout << ' ' << num[i];
	cout << endl;
}

Measured memory_bytes: 1192
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W, n = map(int, input().split())
    AB = set(tuple(tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(n)))

    d = ((1, 1), (1, 0), (1, -1), (0, 1), (0, 0), (0, -1), (-1, 1), (-1, 0), (-1, -1))
    target = set()
    res = [0] * 10
    for h, w in AB:
        cnt = 0
        flg = True
        for dh, dw in d:
            next_h, next_w = h + dh, w + dw
            if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                flg = False
            if (next_h, next_w) in AB:
                cnt += 1
            else:
                if (next_h, next_w) != (h, w):
                    target.add((next_h, next_w))
        if flg:
            res[cnt] += 1

    for h, w in target:
        cnt = 0
        for dh, dw in d:
            next_h, next_w = h + dh, w + dw
            if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                break
            if (next_h, next_w) in AB:
                cnt += 1
        else:
            res[cnt] += 1

    total = (H - 2) * (W - 2)
    res[0] = total - sum(res)
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 162744
A,B=map(int,input().split())
if A==2 or B==2:
	print("No")
elif A==4 or A==6 or A==9 or A==11:
	if B==4 or B==6 or B==9 or B==11:
		print("Yes")
	else:
		print("No")
else:
	if B==4 or B==6 or B==9 or B==11:
		print("No")
	else:
		print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	double d;
	cin >> d;
	int ans = 0;
	while (n--)
	{
		int a, b;
		cin >> a >> b;
		double d1 = sqrt(a * a + b * b);
		if (d1 <= d)
		{
			ans++;
		}
	}
	cout << ans << endl;

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 3792
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
students = []
cps = []
for _ in range(N):
    students.append(list(map(int, input().split())))
for _ in range(M):
    cps.append(list(map(int, input().split())))

for std in students:
    cp_idx = 0
    dist = abs(std[0] - cps[0][0]) + abs(std[1] - cps[0][1])
    for i in range(1, M):
        new_dist = abs(std[0] - cps[i][0]) + abs(std[1] - cps[i][1])
        if new_dist < dist:
            cp_idx = i
            dist = new_dist
    print(cp_idx + 1)


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

int main() {
    int a, b,imax=0,imin=0;
    cin >> a >> b;
    imin = min(a,b);
    imax = max(a,b);
    for (int i = 0; i < imax; i++) cout << imin;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp106 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = st[0];
            int M = st[1];

            var a = new int[M];
            var b = new int[M];

            var tupleList = new List<Tuple<int, int>>();

            var candList_START = new List<int>();
            var candList_GOAL = new List<int>();

            for (int i = 0; i < M; i++) {
                var x = Console.ReadLine().Split().Select(int.Parse).ToArray();

                a[i] = Math.Min(x[0], x[1]);
                b[i] = Math.Max(x[0], x[1]);

                tupleList.Add(new Tuple<int, int>(a[i], b[i]));

                if (a[i] == 1) {
                    candList_START.Add(b[i]);
                }

                if (b[i] == N) {
                    candList_GOAL.Add(a[i]);
                }
            }

            if (tupleList.Count() == 0) {
                Console.WriteLine("IMPOSSIBLE");
                return;
            }

            if (candList_START.Intersect(candList_GOAL).Count() >= 1) {
                Console.WriteLine("POSSIBLE");
            } else {
                Console.WriteLine("IMPOSSIBLE");
            }

            


        }
    }
}


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

int main() {
  int n, m, allvotes = 0, count = 0;
  cin >> n >> m;
  vector<int> a(n + 10);
  for (int i = 0; i < n; i++)  {
    cin >> a[i];
    allvotes += a[i];
  }
 
  
  double boundary = (double)allvotes /(double)(4*m);
  for (int i = 0; i < n; i++)
  {
    if (a[i] >= boundary)  count++;
  }
  if (count >= m)  cout << "Yes";
  else  cout << "No";
  return 0;
  
}

Measured memory_bytes: 384
/*#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>
#include <numeric>*/
#include<bits/stdc++.h>

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>=(n);(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 vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll 	n;
	string s;
	cin >> n >> s;
	ll ans = 0,x=0;
	rep(i,n){
		if(s[i] == 'I') x++;
		else x--;
		ans = max(ans,x);
	}
	cout << ans << endl;
	return 0;
}  


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

r,g,b = LI()
s = str(r)+str(g)+str(b)
if int(s) % 4 == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll X,Y;
    cin>>X>>Y;
    if(X%Y==0) cout<<-1<<endl;
    else cout<<X<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
typedef struct{
  char shcd;
  int value;
} Data;

bool isStable(int N, Data C1[] , Data C2[])
{
  for(int i = 0;i < N;i++)
    {
      if(C1[i].shcd != C2[i].shcd) return false;
    }
  return true;
}

int main()
{
  int N,i,j,minj;
  Data C[36],C1[36],C2[36],X;

  scanf("%d",&N);
  
  for(i = 0;i <= N - 1;i++)
    scanf(" %c%d",&C[i].shcd,&C[i].value);

  for(i = 0;i <= N - 1;i++)
    {
      C1[i] = C[i];
      C2[i] = C[i];
    }

  for(i = 0;i <= N - 1;i++)
    {
      for(j = N - 1;j >= i + 1;j--)
	{
	  if(C1[j].value < C1[j - 1].value)
	    {
	      X = C1[j];
	      C1[j] = C1[j - 1];
	      C1[j - 1] = X;
	    }
	}
    }
  for(i = 0;i < N - 1;i++)
     printf("%c%d ",C1[i].shcd,C1[i].value);
  printf("%c%d",C1[N - 1].shcd,C1[N - 1].value);
  printf("\n");
  
    printf("Stable\n");
 
  for(i = 0;i <= N - 1;i++)
    {
      minj = i;
      for(j = i;j <= N - 1;j++)
	{
	  if(C2[j].value < C2[minj].value)
	    minj = j;
	}
      X = C2[i];
      C2[i] = C2[minj];
      C2[minj] = X;
    }
  
   for(i = 0;i < N - 1;i++)
     printf("%c%d ",C2[i].shcd,C2[i].value);
   printf("%c%d",C2[N - 1].shcd,C2[N - 1].value);
   printf("\n");
   
   if(isStable(N,C1,C2))
     {
     printf("Stable\n");
     }
   else printf("Not stable\n");
  return 0;
}  
      



Measured memory_bytes: 2108
import java.util.*;

public class Main {
    public static void main(String[] arg) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if (Math.abs(a - c) <= d) {
            System.out.println("Yes");
        } else {
            if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
typedef long long ll;
int N;

int main(){
	cin >> N;
	vector<ll> A(N+1,-1),B(N+1,-1),v;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	for(int i=1;i<=N;i++){
		cin >> B[i];
	}
	ll ans = 0;
	for(int k=0;k<=29;k++){
		ll mod = (1<<(k+1));
		v.push_back(-1);
		for(int i=1;i<=N;i++) v.push_back(B[i]%mod);
		sort(v.begin(),v.end());
		ll cnt = 0,t = (1<<k);
		for(int i=1;i<=N;i++){
			int id1 = lower_bound(v.begin(),v.end(),t-A[i]%mod)-v.begin();
			int id2 = lower_bound(v.begin(),v.end(),2*t-A[i]%mod)-v.begin();
			int id3 = lower_bound(v.begin(),v.end(),3*t-A[i]%mod)-v.begin();
			int id4 = lower_bound(v.begin(),v.end(),4*t-A[i]%mod)-v.begin();
			cnt += (id2-id1) + (id4-id3);
			if(id1==0 && id2!=0) cnt--;
			if(id3==0 && id4!=0) cnt--;
		}
		if(cnt>=0 && cnt%2==1) ans += (1<<k);
		v.clear();
	}
	cout << ans << endl;
}

Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a, b;
	cin >> a >> b;
	long long arr[a + 5][2];
	for(int i=0; i<a; i++)
		cin >> arr[i][0] >> arr[i][1];
	long long dp[200050];
	memset(dp, 0, sizeof(dp));
	for(int i=0; i<a; i++)
	{
		for(int j=100050; j>=arr[i][1]; j--)
		{
			if(dp[j - arr[i][1]])
			{
				if(!dp[j]) dp[j] = dp[j - arr[i][1]] + arr[i][0];
				else       dp[j] = min(dp[j], dp[j - arr[i][1]] + arr[i][0]);
			}
			if(j == arr[i][1])
			{
				if(!dp[j]) dp[j] = arr[i][0];
				else       dp[j] = min(dp[j], arr[i][0]);
			}
		}
	}
	int ans = 0;
	for(int i=0; i<100050; i++)
	{
		if(dp[i] <= b && dp[i]) ans = i;
	}	
	printf("%d\n",ans);
	return 0;
} 

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

#define pb push_back
#define mp make_pair
#define up upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define ll long long
#define vi vector < ll > 
#define pi pair < ll , ll > 
#define ld long double
#define iPair pair< ll , ll >

#define lp(n,i) for(ll i=0;i<n;i++)
#define rlp(n) for(ll i=n-1;i>=0;i--)
//#define e 1000000009
//#define e  998244353
#define inf 9999999999999999
#define pri1 1000000007
#define pri2 1000001001
#define PI 3.14159265
 /*
ll pw(ll a, ll b)
{
    ll t=1;
    
    if(b==0)return t;
    if(b%2)
    {
        t=t*a;
    }
   t%=e;
    ll x=pw(a,b/2);
    x=x*x;
    x%=e;
    t*=x;
    t%=e;
    return t;
}/*
vector < ll > pr;
ll vis[10000005]={0};
void seive ( ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(vis[i]==0)
        {
            
            for(ll j=i*i;j<=n;j+=i)vis[j]=1;
        }
    } 
    
    for(ll i=2;i<=n;i++)
    {
        if(vis[i]==0)pr.pb(i);
    }
}
 
#define N 100005
ll z[N];
vector < ll > v;
void getz(string s)
{
    ll n=s.length();
    ll l=0,r=0;
    for(ll i=1;i<n;i++)
    {
        if(i<=r)
        {
            z[i]=min(r-i+1,z[i-l]);
        }
        
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]])z[i]++;
        
        if((i+z[i]-1)>r)
        {
            l=i;
            r=i+z[i]-1;
        }
    }
    
   for(ll i=0;i<n;i++)
   {
       v.pb(z[i]);
   }
  
    sort(v.begin(),v.end());
    
}
*/
 

 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
 
   
 ll ti=1;
//cin>>ti;
 
 for (ll io=0;io<ti;io++)
 {
ll k;
cin>>k;
string s;
cin>>s;
if(s.length()<=k)cout<<s<<endl;
else cout<<s.substr(0,k)<<"..."<<endl;
    
 }
 return 0;	
}

Measured memory_bytes: 3656
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! { n: usize, mut p: [i32; n] }
    p.sort();
    let mut ret:i32 = p.iter().take(n-1).sum();
    ret += p[n-1]/2;
    println!("{}", ret);
}

Measured memory_bytes: 4352
j = 0

def attack(x):
    global j
    if x == 1:
        j += 1
        return
    elif x % 2 == 1:
        x = x // 2
        j += 1
    else:
        x = int(x / 2)
        j += 1
    attack(x)

if __name__ == "__main__":
    h = int(input())
    attack(h)
    print(2 ** j - 1)

Measured memory_bytes: 3060
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = map(int, input().split())
n = [True for _ in range(N+1)]
for _ in range(M):
	n[int(input())] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1

for i in range(N+1):
	if not n[i]:
		continue
	for j in [1, 2]:
		if i - j >= 0:
			dp[i] += dp[i-j]
print(dp[-1]%1000000007)

Measured memory_bytes: 465716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int T[26][100002] = {0};
static char C[27] = "abcdefghijklmnopqrstuvwxyz";

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	for(int i=0; i<26; i++){
		char c = C[i];
		for(int j=0; j<S.size(); j++){
			if(c == S[j]){
				T[i][j] = 1;
			}
			else{
				T[i][j] = 0;
			}
		}
	}

	int found = 0;
	int s, e;
	
	for(int i=0; i<26; i++){
		s = -1;
		e = -1;
		for(int j=0; j<S.size(); j++){
			if(T[i][j] == 0){
				continue;
			}
			e = j;
			if(s == -1){
				s = j;
				continue;
			}
			else{
				if(e - s + 1 < 4){
					found = 1;
					break;
				}
				s = e;
			}
		}
		if(found == 1){
			break;
		}
	}
	if(found == 0){
		printf("-1 -1\n");
	}
	else{
		printf("%d %d\n", s+1, e+1);
	}
	return 0;
}

Measured memory_bytes: 13952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        List<char> s = new List<char>();
        for (int i = 0; i < n; i++)
        {
            s.Add(sc.NextChar());
        }

        int count = s.Distinct().Count();

        string answer = count == 3 ? "Three" : "Four";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min({a + c, a + d, b + c, b + d}) << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt64()
	mm := make([]int64, 0, n)

	start := nextInt64()
	var result int64
	for index := int64(1); index < n; index++ {
		now := nextInt64()
		if start >= now {
			result++
		} else {
			mm = append(mm, result)
			result = 0
		}
		start = now
	}

	if result > 0 {
		mm = append(mm, result)
	}

	if len(mm) == 0 {
		fmt.Println(0)
		return
	}

	fmt.Println(Max(mm...))
}

func Max(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int A, B, C, D; std::cin >> A >> B >> C >> D;
    int x((A+D-1) / D), y((C+B-1) / B);
    std::cout << ((x >= y) ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;cin>>a>>b;
	ll ans = (a*b)/__gcd(a,b);
	cout<<ans<<endl;































	
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans;
    string a="";
    for(int i=0;i<3;i++){
        string b;
        cin >>b;
        a+=b[0];
    }

    dbg{
    if(true)cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
    }

    cout <<a<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<vector<int>> V;
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    V.emplace_back(vector<int>{a, b});
  }
  sort(V.begin(), V.end());
  ll cnt = 0;
  int res = 0;
  for (auto &v : V) {
    cnt += v[1];
    if (cnt >= K) {
      printf("%d\n", v[0]);
      return 0;
    }
  }
}

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

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

int main() {
  int64_t N, s=0;
  cin >> N;
  vector<int64_t> A(N), V(N+1), W(N+1);
  rep(i,N) {
    cin >> A.at(i);
    V.at(A.at(i))+=1;
    W.at(A.at(i))+=1;
  }
  sort(W.begin(),W.end());
  reverse(W.begin(),W.end());
  int j=0;
  while(W.at(j)>0) {
    W.at(j)=W.at(j)*(W.at(j)-1)/2;
    s+=W.at(j);
    j++;
  }
  rep(i,N) {
    cout << s-V.at(A.at(i))+1 << endl;
  }
}

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

int main(){
  int N;
  string c;
  cin >>N;
  
  for(int i=0; i < N; i++){
    cin >> c;
    if(c == "Y"){
      cout << "Four";
      break;
    }
    else if(i == N -1){
      if(c == "Y"){
        cout << "Four" << endl;
      }
      else{
        cout << "Three" << endl;
      }
    }
  }
}

 
    

Measured memory_bytes: 256
from itertools import accumulate
import sys
sys.setrecursionlimit(10**8)
class BIT():
    def __init__(self,number):
        self.n=number
        self.list=[0]*(number+1)
        
    def add(self,i,x):#ith added x  1indexed
        while i<=self.n:
            self.list[i]+=x
            i+=i&-i
            
    def search(self,i):#1-i sum
        s=0
        while i>0:
            s+=self.list[i]
            i-=i&-i
        return s
    
    def suma(self,i,j):#i,i+1,..j sum
        return self.search(j)-self.search(i-1)

N,K=map(int,input().split())
A=[int(input()) for i in range(N)]
B=list(accumulate([0]+A))
for i in range(N+1):
    B[i]-=K*i
C=sorted(set(B))
t=len(C)
D={ C[i]:i for i in range(t)}
tree=BIT(t)
ans=0
for i in range(N+1):
    ans+=tree.search(D[B[i]]+1)
    tree.add(D[B[i]]+1,1)
print(ans)

Measured memory_bytes: 90372
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, M;
    cin >> N >> M;
    ll count = 1;
    double expected_time = 0;
    expected_time = (1900 * M + 100 * (N-M));
    cout << ll(expected_time*pow(2,M)) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 4100
H,W,A,B=gets.split.map(&:to_i)
H.times do |i|
    if i<=B-1
        s="0"*W
    else
        s="1"*W
    end
    A.times do |j|
        s[j]=s[j]=="0" ? "1" : "0"
    end
    puts s
end


Measured memory_bytes: 3708
while True:
    m,f,r =map(int,input().split())
    a = m+f
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif a >= 80:
        print("A")
    elif a < 80 and a >= 65:
        print("B")
    elif a < 65 and a >= 50:
        print("C")
    elif a < 50 and a >= 30 :
        if r < 50:
            print("D")
        if r >= 50:
            print("C")
    elif a < 30:
        print("F")
    
        


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

#define ll long long

int main()
{
    int n,w;
    cin>>n>>w;
    int wt[n+5],vl[n+5];
    for(int i=1; i<=n; i++)
        cin>>wt[i]>>vl[i];
    ll dp[n+5][w+5];
    memset(dp,0,sizeof(dp));
    //for(int i=1; i<=w; i++)
        //dp[1][i]=1;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=w; j++)
        {
            if(wt[i]<=j)
                dp[i][j]=max(dp[i-1][j],vl[i]+dp[i-1][j-wt[i]]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 82304
# Problem: https://atcoder.jp/contests/abc085/tasks/abc085_c
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


# Const
MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1
YES = "YES"
NO = "NO"

def solver(totalSheet, sum):
    result = [-1, -1, -1]
    # algorithm
    for sheet_10000 in range(0, totalSheet+1, +1):
        for sheet_5000 in range(0, totalSheet + 1 - sheet_10000, +1):
            sheet_1000 = totalSheet - sheet_10000 - sheet_5000
            nowSum = sheet_10000 * 10000 + sheet_5000 * 5000 + sheet_1000 * 1000
            if nowSum == sum:
                result = [sheet_10000 ,sheet_5000, sheet_1000]
    return result


if __name__ == "__main__":
    N, Y = MI()
    answer = solver(N, Y)
    print("{} {} {}".format(answer[0], answer[1], answer[2]))


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

int main() {
    int A, B;
    std::cin >> A >> B;

    if ((A + B) % 2 != 0) {
        std::cout << "IMPOSSIBLE\n";
    } else {
        std::cout << (A + B) / 2 << std::endl;
    } 

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int m;
    m=a;
    int cnt;
    cnt=1;
    if(b==1)
        cout<<"0"<<endl;
    else
    {
    for(;;)
    {
        if(a<b)
            {
                cnt++;
                a=a+(m-1);
            }
        else
            break;
    }
    cout<<cnt<<endl;}
}


Measured memory_bytes: 256
s = input()
n = len(s)

l = 0
r = n//2 + 1

while r - l > 1:
    m = l + (r-l)//2
    d = n//2 - m
    if s[d:n-d].count("0") == 0 or s[d:n-d].count("1") == 0:
        l = m
    else:
        r = m

if n % 2 == 0:
    print(n//2+l)
else:
    print(n//2+l+1)


Measured memory_bytes: 3188
fun main(args: Array<String>) {
    abc068c()
}

fun abc068c() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val abList = (1..m).map { readLine()!!.split(' ').map { it.toInt() - 1 } }
        .map { Pair(it[0], it[1]) }
    val paths = Array(n) { mutableSetOf<Int>() }

    abList.forEach {
        paths[it.first].add(it.second)
        paths[it.second].add(it.first)
    }

    var list = mutableSetOf(0)
    repeat(2) {
        val curr = list.map { paths[it] }.flatten().toSet()
        if (curr.contains(n - 1)) return println("POSSIBLE")
        list = curr.toMutableSet()
    }

    return println("IMPOSSIBLE")
}


Measured memory_bytes: 131140
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f

const int N = 66;
int x[N], y[N], a[N], b[N];
int main()
{
  // freopen("in.txt","r",stdin); 
   int n, m;
   while (~scanf("%d%d", &n, &m))
   {
      for (int i = 1; i <= n; i++)
        scanf("%d%d", x + i, y + i);
      for (int i = 1; i <= m; i++)
        scanf("%d%d", a + i, b + i);
      for (int i = 1; i <= n; i++)
      {
        int ans = INF, id;
        for (int j = 1; j <= m; j++)
        {
          int t = (abs(y[i] - b[j]) + abs(x[i] - a[j]));
          if (ans > t)
          {
            ans = t;
            id = j;
          }
        }
      printf("%d\n", id);
      }
   }
   return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
a = [tuple(map(int,input().split())) for i in range(2)]
b = [list(accumulate(a[0])), [0] * n]
for i in range(n):
  if i == 0:
    b[1][0] = a[0][0] + a[1][0]
  else:
    b[1][i] = max(b[0][i],b[1][i-1]) + a[1][i]
print(b[1][n-1])

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

map<ll,int> primeFact(ll n) {
	map<ll,int> r;
	for(ll i=2; i*i<=n; i++)
		while(n%i == 0) {
		r[i]++;
		n /= i;
		}
	if(n != 1)
		r[n] = 1;
	return r;
}

int main() {
	ll N,P,r=1;
	map<ll,int> m;

	cin >> N >> P;
	m = primeFact(P);

	for(auto x : m)
		r *= pow(x.first, x.second/N);
	cout << r << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int n;
    while(true){
        int b;
        cin>>n;
        if(n==0)break;
vector<int> m(n);
vector<int> p,ans;
for(int i=0;i<n;i++){
    cin>>m[i];
    for(int j=0;j<m[i];j++){
int a;
cin>>a;
p.push_back(a);
    }
    
}
int k;
cin>>k;
vector<int> l(k);
for(int i=0;i<k;i++)
cin>>l[i];
int sum=0;
for(int i=0;i<n;i++){
    sum+=m[i];
    b=0;
    for(int j=0;j<k;j++){
        int t=0;
        for(int q=sum-m[i];q<sum;q++){
            if(l[j]==p[q])
            t++;
        }
        if(t==0)break;
        else b++;
    }
if(b==k) ans.push_back(i+1);
}
if(ans.size()==1){
    cout<<ans[0]<<endl;
}else{
    cout<<-1<<endl;
        
}
    }
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#define ll long long

using namespace std;
ll a[110],b[110],dp[110][110][330];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            for(int k=0;k<=3*j;k++){
                dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+1][k+a[i]-a[1]] = max(dp[i+1][j+1][k+a[i]-a[1]],dp[i][j][k] + b[i]);
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=3*i;j++){
            ll w = a[1]*i + j;
            if(w <= m)
                ans = max(ans,dp[n+1][i][j]);
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 29056
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node
{
	int parent;
	int left;
	int right;
};

struct Node T[MAX];
int n;

void preParse(int u)
{
	if (u == NIL) return;
	printf(" %d", u);
	preParse(T[u].left);
	preParse(T[u].right);
}

void inParse(int u)
{
	if (u == NIL) return;
	inParse(T[u].left);
	printf(" %d", u);
	inParse(T[u].right);
}

void postParse(int u)
{
	if (u == NIL) return;
	postParse(T[u].left);
	postParse(T[u].right);
	printf(" %d", u);
}

int main()
{
	int v, l, r, root = 0;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		T[i].parent = NIL;
	}

	for (int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &v, &l, &r);

		T[v].left = l;
		T[v].right = r;
		if (l != NIL) T[l].parent = v;
		if (r != NIL) T[r].parent = v;
	}

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

	printf("Preorder\n");
	preParse(root);
	printf("\n");

	printf("Inorder\n");
	inParse(root);             
	printf("\n");

	printf("Postorder\n");
	postParse(root);
	printf("\n");

	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X ;
  int count =0;
  for (int i=0;i<=A;++i){
    for (int j=0;j<=B;++j){
      for (int k=0;k<=C;++k){
        if(500*i+100*j+50*k == X) ++count;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;

int solve() {
  int A, B;
  cin >> A >> B;
  if(A <= 5) return 0;
  else if(A <= 12) return B/2;
  else return B;
}

int main() {
  cout << solve() << endl;
  return 0;
}


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

int main(){
  vector<char> v1(3),v2(3);
  cin >> v1.at(0) >> v1.at(1) >> v1.at(2) >> v2.at(0) >> v2.at(1) >> v2.at(2);
  int i = 0;
  if(v1.at(0) == v2.at(0))
    i++;
  if(v1.at(1) == v2.at(1))
    i++;
  if(v1.at(2) == v2.at(2))
    i++;
  cout << i;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-26 20:28:21
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

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

  int64 h; cin >> h;

  int cnt = 0;

  while (h > 0) {
    h >>= 1;
    ++cnt;
  }

  debug(cnt);

  int64 ans = 1;

  for (int i = 0; i < cnt; ++i) {
    ans <<= 1;
  }

  cout << ans - 1 << endl;

  return 0;
}

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

int main() {
    int n,k;
    string s;
    cin >> n >> s >> k;
    char c = s[k-1];
    rep(i,n) {
        if(s[i] != c) {
            s[i] = '*';
        }
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll N;

int main(){
	map<string, ll> memo;
	cin >> N;

	ll ans = 0;
	rep(i, N) {
		string S;
		cin >> S;
		sort(S.begin(), S.end());
		ans += memo[S];
		memo[S]++;
	}
	cout << ans << endl;
}


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

int n;
string a[3];
int ada[30];

int main(){
   cin >> n;
   cin >> a[0] >> a[1] >> a[2];
   int ans = 0;
   for(int i=0;i<n;i++){
      memset(ada,0,sizeof(ada));
      int tmp = 0;
      for(int j=0;j<3;j++){
         ada[a[j][i]-'a']++;
         tmp = max(tmp,ada[a[j][i]-'a']);
      }
      ans+=3-tmp;
   }
   cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 10000
#define NIL -1

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

void preorder(int u) {
  if (u == NIL) return;
  cout << " " << u;
  preorder(T[u].left);
  preorder(T[u].right);
}

void inorder(int u) {
  if (u == NIL) return;
  inorder(T[u].left);
  cout << " " << u;
  inorder(T[u].right);
}

void postorder(int u) {
  if (u == NIL) return;
  postorder(T[u].left);
  postorder(T[u].right);
  cout << " " << u;
}

int main() {
  int v, l, r, root = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) T[i].parent = NIL;
  for (int i = 0; i < n; ++i) {
    cin >> v >> l >> r;
    T[v].left = l;
    T[v].right = r;
    if (l != NIL) T[l].parent = v;
    if (r != NIL) T[r].parent = r;
  }
  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }
  cout << "Preorder" << endl;
  preorder(root);
  cout << endl;
  cout << "Inorder" << endl;
  inorder(root);
  cout << endl;
  cout << "Postorder" << endl;
  postorder(root);
  cout << endl;
}



Measured memory_bytes: 3096
//???1:AC?????????
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

ll N;
ll* BIT;
ll* table;
ll* weight;
ll* hanten_num;
ll* mult;

void add(ll loc,ll value){

	BIT[loc] += value;

	loc += loc & -loc;

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

ll getSum(ll loc){

	ll sum = BIT[loc];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

void func(){

	for(ll i = 0; i <= N; i++){
		BIT[i] = 0;
	}

	for(ll i = 1; i <= N; i++){
		table[i] = (ll)i;
	}

	weight[N] = 0;
	weight[N-1] = 1;
	for(int digit = N-2; digit >= 1; digit--){
		weight[digit] = mult[N-(digit)];
	}

	int R;
	scanf("%d",&R);

	int left,right;
	for(int loop = 0; loop < R; loop++){
		scanf("%d %d",&left,&right);
		swap(table[left],table[right]);
	}

	for(int digit = N; digit >= 1; digit--){
		hanten_num[digit] = getSum(table[digit]);
		add(table[digit],1);
	}

	ll ans = 0;

	for(int digit = 1; digit <= N-1; digit++){
		ans += (weight[digit]*hanten_num[digit])%MOD;
		ans %= MOD;
	}

	printf("%lld\n",ans%MOD);
}



int main(){

	BIT = new ll[100001];
	table = new ll[100001];
	weight = new ll[100001];
	hanten_num = new ll[100001];
	mult = new ll[100001];

	mult[1] = 1;

	for(int i = 2; i <= 100000; i++){
		mult[i] = mult[i-1]*i;
		mult[i] %= MOD;
	}

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 7128
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0
for a in range(0,A + 1):
    for b in range(0,B + 1):
        for c in range(0,C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                counter += 1

print(counter)

Measured memory_bytes: 3060
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {

	long res = 0;
	long n; cin >> n;
	long p[100009]; for (int i = 1; i <= n; i++) cin >> p[i];

	for (int i = 2; i <= n - 1; i++) if (p[i - 1] + p[i] + p[i + 1] - max(p[i - 1], max(p[i], p[i + 1])) - min(p[i - 1], min(p[i], p[i + 1])) == p[i]) res++;

	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int w, h;
int c[51][51];

void dfs( int i, int j )
{
  c[i][j] = 0;

  for( int dx = -1; dx <= 1; ++dx ) for( int dy = -1; dy <= 1; ++dy )
  {
    int ni = i+dy, nj = j+dx;

    if( ni >= 0 && ni < h && nj >= 0 && nj < w && c[ni][nj] == 1 )
      dfs( ni, nj );
  }

  return;
}

int main()
{
  while( scanf( "%d%d", &w, &h ), w|h )
  {
    rep( i, h ) rep( j, w )
      scanf( "%d", &c[i][j] );

    int cnt = 0;
    rep( i, h ) rep( j, w ) if( c[i][j] == 1 )
      dfs( i, j ), ++cnt;    

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


Measured memory_bytes: 2780
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))
 
 
using namespace std;
 
 
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;
 
const long MOD = 998244353;



int main(){
	std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	string s;
	cin>>s;
	cout<<s.substr(0,s.find_last_of("F"))<<endl;
	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

su = A+B
a = 0
b = 0


for i in range(N):
    f = 0
    if S[i] == "a":
        if su > a + b:
            f = 1
            a += 1
    elif S[i] == "b":
        if su > a+b and B > b:
            f = 1
            b += 1
    if f:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4016
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end


long long a[100005]={0};
long long minus1[100005]={0};
long long plus1[100005]={0};
long long ans[100005]={0};

int main() {
    long long N;
    long long ansnum=0;

    cin >> N;
    rep(i,N){
        long long x;
        cin >> x;
        minus1[x]++;
        x++;
        a[x]++;
        x++;
        plus1[x]++;
    }

    rep(i,100005){
        ansnum=max(ansnum, minus1[i]+a[i]+plus1[i]);
    }

    cout << ansnum << endl;
    return 0;
}



Measured memory_bytes: 2560