akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

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

  vector<int> sorted = A;
  sort(ALL(sorted), greater<int>());
  int max_v = sorted[0];
  int sec_v = sorted[1];

  REP(i, N) {
    if(A[i] == max_v) {
      cout << sec_v << endl;
    } else {
      cout << max_v << endl;
    }
  }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef multiset<ll> ssll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

const int INF = 1000000000;
const ll MOD = 1000000007;

vi st;
int N = 300010;

void build(vi &a, int v, int tl, int tr) {
	if (tl == tr)
		st[v] = a[tl];
	else {
		int tm = (tl + tr) / 2;
		build(a, v * 2, tl, tm);
		build(a, v * 2 + 1, tm + 1, tr);
		st[v] = max(st[v*2], st[v*2+1]);
	}
}

int maxVal(int v, int tl, int tr, int l, int r) {
	if (l > r)
		return 0;
	if (l == tl and r == tr)
		return st[v];
	int tm = (tl + tr) / 2;
	int rmax = maxVal(v * 2, tl, tm, l, min(r, tm));
	int lmax = maxVal(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
	return max(rmax, lmax);
}

void update(int v, int tl, int tr, int pos, int new_val) {
	if (tl == tr)
		st[v] = new_val;
	else {
		int tm = (tl + tr) / 2;
		if (pos <= tm)
			update(v * 2, tl, tm, pos, new_val);
		else
			update(v * 2 + 1, tm + 1, tr, pos, new_val);
		st[v] = max(st[v*2], st[v*2+1]);
	}
}

int main() {FIN
	
	int n, k, e, r, m = 0;
	cin >> n >> k;
	vi ns(N);
	
	st = vi(4*N+1);
	build(ns, 1, 0, N - 1);
	
	while (n--) {
		cin >> e;
		r = maxVal(1, 0, N-1, max(0, e-k), min(N-1, e+k));
		m = max(m, r+1);
		update(1, 0, N-1, e, r+1);
	}
	
	cout << m << "\n";
	
	return 0;
}

Measured memory_bytes: 9008
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner (System.in);
        
    String x=sc.nextLine();
    String y=sc.nextLine();
    
    int c=0;
    int z=0;
    
  for(int i=0;i<x.length();i++){
      char xx=x.charAt(i);
      char yy=y.charAt(i);
      
      if(xx!=yy){
        c++;
      }
      
      
  }
  System.out.println(c);
    
        
    
    }
}


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

int main(){
	string s, t;
	cin  >> s >> t;
	
	int num_s, num_t;
	cin >> num_s >> num_t;
	
	string u;
	cin >> u;
	
	if(u == s)
		num_s-= 1;
	else if(u == t)
		num_t-= 1;
  
  cout << num_s << " " << num_t; 
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int a[20], v[100];
	int b;
	int c;
	int d;
	int f;
	
	scanf("%d", &n);
	
	for (b = 0; b < n; b++){
		scanf("%d %d", &a[b], &v[b]);
	}
	
	c = 0;
	
	d = v[c] - v[1];
	
	if (d > 0){
		c = c;
	}
	else if (d < 0){
		c += 1;
	}
	else {
		f = a[c] - a[1];
		if (f < 0){
			c = c;
		}
		else {
			c = 1;
		}
	}
	
	for (b = 2; b < n; b++){
		d = v[c] - v[b];
		if (d < 0){
			c = b;
		}
		else if (d > 0){
			c = c;
		}
		else if (d == 0){
			f = a[c] - a[b];
			
			if (f < 0){
				c = c;
			}
			else {
				c = b;
			}
		}
	}
	
	printf("%d %d\n", a[c], v[c]);
	
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)

int main()
{
    int n,count=0,cannot=0,a[201];
    cin >> n;
    REP(i,n)
    {
        cin >> a[i];
    }
    while(cannot == 0)
    {
        REP(i,n)
        {
            if(a[i]%2 == 0)
            {
                a[i] /= 2;
            }
            else
            {
                cannot = 1;
                break;
            }
        }
        if(cannot != 1)
        {
            count++;
        }
    }
    cout << count << endl;
    
    return 0;
}

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

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

    int A[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    A[N] = 0;

    long long money = 1000;
    long long stocks = 0;
    for (int i = 0; i < N; ++i)
    {
        if (A[i] < A[i + 1])
        {
            stocks = money / A[i];
            money = money + ((A[i + 1] - A[i]) * stocks);
        }
    }
    cout << money << "\n";
}


Measured memory_bytes: 3192
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    Integer C[] = new Integer[N-1];
    Integer S[] = new Integer[N-1];
    Integer F[] = new Integer[N-1];
    for(int i=0; i<N-1; i++){
      C[i] = sc.nextInt();
      S[i] = sc.nextInt();
      F[i] = sc.nextInt();
    }
    for(int i=0; i<N-1; i++){
      int ans = S[i] + C[i];
      for(int j=i+1; j<N-1; j++){
        if(ans < S[j]) ans = S[j];
        else if(ans % F[j] != 0) ans = ans + F[j] - (ans % F[j]);
        ans += C[j];
      }
      out.println(ans);
    }
    out.println(0);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

int main(){
    ll N; cin >> N;
    int keta = 1;
    ll now = 26;
    ll z = 0;
    ll t[100];
    for (int i = 0; i < 100; i++)
    {
        t[i] = 1;
        for (int j = 0; j < i; j++)
        {
            t[i] *= 26;
        }
        
    }
    
    while(N > now){
        keta++;
        now += t[keta];
        z += t[keta-1];
    }
    N -= z + 1;
    int alp[100] = {0};
    for (int i = 0; i < keta; i++)
    {
        if(N >= t[keta-i-1]){
            alp[i] = N/t[keta-i-1];
            N -= alp[i]*t[keta-i-1];
        }
    }
    for (int i = 0; i < keta; i++)
    {
        char ans = 'a' + alp[i];
        cout << ans;
    }
    cout << endl;
}	


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];
    ll res=1000;
    rep(i, n-1){
        if(a[i]<a[i+1]){
            res = res/a[i]*a[i+1]+res%a[i];
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

string S;

int main()
{
    cin >> S;
    int ans = 1000000;
    for (int i = 0; i < S.length() - 2; i++) {
        string s = S.substr(i, 3);
        if (ans > abs(753 - stoi(s))) {
            ans = abs(753 - stoi(s));
        }
    }

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



Measured memory_bytes: 256
#include<cstdio>

int S[100000],T[1000];

bool linearSearch(int x,int n){
  int i = 0;
  int key = T[x];
  
  S[n] = key;

  while(S[i] != key){
    i++;

    if(i == n){
      return false;
    }
  }

  return true;
}

int main(){
  int n,q,cnt = 0;
  bool flag;
  std::scanf("%d",&n);

  for(int i = 0;i < n;i++){
    std::scanf("%d",&S[i]);
  }

  std::scanf("%d",&q);

  for(int i = 0;i < q;i++){
    std::scanf("%d",&T[i]);
  }

  for(int i = 0;i < q;i++){
    flag = linearSearch(i,n);
    if(flag){
      cnt++;
    }
  }
  
  std::printf("%d\n",cnt);

  return 0;
}



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

int main(void){
  int r0, w0, c, r, ans;
  double ratio;
  while(1){
    cin >> r0 >> w0 >> c >> r;
    if(r0 == 0) break;
    ratio = r0 / w0;
    ans = 0;
    while(ratio < c){
      r0 += r;
      ratio = r0 / w0;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<int, int>;
const double eps = 1e-10;
const int MOD = 1000000007;
const ll LINF = 1ll<<50;


template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

struct Edge {
  int from, to, cost;
  Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using P = std::pair<int, int>;
constexpr int INF = 1e9;

// 逆順にしているので注意
bool operator<(const Edge &e, const Edge &f)
{
    return e.cost > f.cost;
}

std::vector<int> dijkstra(const Graph &g, int s)
{
    std::vector<int> d((int)g.size(), INF);
    d[s] = 0;
    std::priority_queue<P, std::vector<P>, std::greater<P>> que;
    que.push(P(0, s)); // P(dis, pos)
    while (!que.empty())
    {
        int dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if (d[v] < dist)
            continue;
        for (const auto &e : g[v])
        {
            if (d[e.to] <= d[v] + e.cost)
                continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);

    int n, m; cin >> n >> m;
    Graph g(3*n);
    for(int i=0;i<m;++i) {
      int x, y; cin >> x >> y;
      x--; y--;
      g[x].push_back(Edge(x, y+n, 1));
      g[x+n].push_back(Edge(x+n, y+2*n, 1));
      g[x+2*n].push_back(Edge(x+2*n, y, 1));
    }

    int s, t; cin >> s >> t;
    s--; t--;
    vector<int> dist = dijkstra(g, s);
    if(dist[t] == INF) {
      cout << -1 << endl;
    } else {
      cout << dist[t]/3 << endl;
    }
}

Measured memory_bytes: 17792
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
mod = 1000000007
m = [(0, 1), (1, 0), (-1, 0), (0, -1)]
inf = float('INF')

#solve
def solve():
    n = II()
    p = LI()
    dp = [min(i, j, n - i - 1, n - j - 1) for i in range(n) for j in range(n)]
    c = [1 for i in range(n) for j in range(n)]
    d = defaultdict(tuple)
    for i in range(-1, n + 1):
        for j in range(n):
            d[i * n + j] = (i, j)
    q = [0] * (n ** 2)
    ans = 0
    for pi in p:
        pi -= 1
        ans += dp[pi]
        c[pi] = 0
        q[0] = pi
        p = 0
        l = 1
        while p != l:
            yx = q[p]
            p += 1
            score = dp[yx] + c[yx]
            y, x = d[yx]
            if 0 < y < n - 1:
                if 0 < x < n - 1:
                    myx = yx + n
                    if dp[myx] > score:
                        dp[myx] = score
                        q[l] = myx
                        l += 1
                    myx = yx - n
                    if dp[myx] > score:
                        dp[myx] = score
                        q[l] = myx
                        l += 1
                    myx = yx - 1
                    if dp[myx] > score:
                        dp[myx] = score
                        q[l] = myx
                        l += 1
                    myx = yx + 1
                    if dp[myx] > score:
                        dp[myx] = score
                        q[l] = myx
                        l += 1
                else:
                    if x == 0:
                        myx = yx + 1
                        if dp[myx] > score:
                            dp[myx] = score
                            q[l] = myx
                            l += 1
                    elif x == n - 1:
                        myx = yx - 1
                        if dp[myx] > score:
                            dp[myx] = score
                            q[l] = myx
                            l += 1
            else:
                if y == 0:
                    if 0 < x < n - 1:
                        myx = yx + n
                        if dp[myx] > score:
                            dp[myx] = score
                            q[l] = myx
                            l += 1
                elif y == n - 1:
                    if 0 < x < n - 1:
                        myx = yx - n
                        if dp[myx] > score:
                            dp[myx] = score
                            q[l] = myx
                            l += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 145340
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string s, t;
    cin >> s >> t;

    int ans = 0;
    rep(i, 3) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 504
n = int(input())
a = [int(n) for n in input().split()]


def calcSteps(sign):
    res = 0
    s = 0
    for i in range(n):
        if (s+a[i])*sign < 0:
            s += a[i]
        else:
            step = -s -sign -a[i]
            res +=  abs(step)
            s = -sign
        sign *= -1
    return res



print(min(calcSteps(-1),calcSteps(1)))




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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int i,j,k,x,y,z,n,m;
    cin>>n>>m;
    long long int dp[n+1]={0};
    stack<long long int>st;
    vector<long long int>vt[n+1];
    for(i=1;i<=m;i++){
        cin>>x>>y;
        vt[x].push_back(y);
    }
    long long int ans=0;
    bool visited[n+1]={false};
    for(i=1;i<=n;i++){
        if(visited[i]==true)
            continue;
        st.push(i);
        while(!st.empty()){
            x=st.top();
            visited[x]=true;
            for(j=0;j<vt[x].size();j++){
                if(visited[vt[x][j]]==false){
                    st.push(vt[x][j]);
                    break;
                }
                    dp[x]=max(dp[x],dp[vt[x][j]]+1);
            }
            if(j==vt[x].size())
                st.pop();
        }

    }
    for(i=1;i<=n;i++){
        ans=max(ans,dp[i]);
       // cout<<dp[i]<<endl;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 10140
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s,t = input().split()
a,b = inpl()
w = input()
if s == w:
    print(a-1,b)
else:
    print(a,b-1)

Measured memory_bytes: 66156
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    println(problem070b(a, b, c, d))
}

fun problem070b(a: Int, b: Int, c: Int, d: Int): Int {
    return Math.max(Math.min(b, d) - Math.max(a, c), 0)
}

Measured memory_bytes: 31140
import heapq


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

fa = A[:N]
max_l = [0] * (N + 1)
s = sum(fa)
max_l[0] = s
heapq.heapify(fa)
for i, a in enumerate(A[N:2*N]):
    if a > fa[0]:
        s -= heapq.heappop(fa)
        s += a
        heapq.heappush(fa, a)
    max_l[i+1] = s

la = [-i for i in A[2*N:]]
min_r = [0] * (N + 1)
s = sum(la)
min_r[N] = s
heapq.heapify(la)
for i, a in enumerate(reversed(A[N:2*N])):
    if a < -la[0]:
        s -= heapq.heappop(la)
        s += -a
        heapq.heappush(la, -a)
    min_r[N-i-1] = s

print(max([l + r for l, r in zip(max_l, min_r)]))


Measured memory_bytes: 37212
N,M = map(int,input().split())
H = [0]*N
H_top = [1]*N
H = list(map(int,input().split()))
for i in range(M):
    A,B = map(int,input().split())
    if H[A-1] >= H[B-1]:
        H_top[B-1] = 0
    if H[A-1] <= H[B-1]:
        H_top[A-1] = 0
print(sum(H_top))

Measured memory_bytes: 21600
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n : usize = sc.read();
    let mut ls: Vec<usize> = sc.vec(n);
    ls.sort();
    let sum = ls.iter().fold(0, |sum , &x| sum + x);
    if sum - ls[n - 1] > ls[n - 1] {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
    int a,b,c;
    int tmp;
    cin>>a>>b>>c;
    
    if(b<a){
        tmp=b;
        b=a;
        a=tmp;
    }
    if(c<b){
        tmp=c;
        c=b;
        b=tmp;
    }
    if(b<a){
        tmp=b;
        b=a;
        a=tmp;
    }
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    int c = S[S.size() - 1] - '0';
    if (c == 3)
    {
        cout << "bon" << endl;
    }
    else if (c == 0 || c == 1 || c == 6 || c == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
 int a,b,c,x,y,z;
 scanf("%d%d%d",&a,&b,&c);
  if(a > b){
  x = a;
  a = b;
  b = x;
  }
  if(b > c){
  y = b;
  b = c;
  c = y;
  }
  if(a > b){
  z = a;
  a = b;
  b = z;
}

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

 return 0;
}

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

struct UnionFind {
    // par[i]:iの親の番号　(例) par[3] = 99 : 3の親が99
    vector<int> par;

    UnionFind(int N) : par(N) {  // 初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {  // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(){
        int N = par.size();
        set<int> s;
        for (int i = 0; i < N; i++) {
            s.insert(root(i));
        }
        return s.size();
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    int ans = 0;

    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x,y);
    }
    
    cout << uf.size() << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
typedef long long ll;
#define M 1000000007
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    int ar[n][3];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }
    ll dp[n][3]={0};
    dp[0][0]=ar[0][0];
    dp[0][1]=ar[0][1];
    dp[0][2]=ar[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]=0;
            for(int k=0;k<3;k++)
            {
                if(k==j)
                {
                    continue;
                }
                dp[i][j]=max(dp[i][j],dp[i-1][k]+ar[i][j]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 3840
x, n = map(int, input().split())
p = set(map(int, input().split()))

i = 0

if n == 0:
    print(x)
else:
    near = 0
    while True:
        if not x - i in p:
            near = x - i
            break
        if not x + i in p:
            near = x + i
            break
        i += 1
    print(near)


Measured memory_bytes: 9184
import Control.Monad
main = do
  n <- readLn
  [d,x] <- map read . words <$> getLine
  a <- replicateM n readLn
  print $ x + sum (map (f d) a)

f p q = maximum [z | z <- [0..p], let w = q, z*q+1 <= p] + 1


Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main () {
   int N;
        cin >> N;
        int P=0;
        int X=0;
        for(int i=0;i<N;i++){
            int M; cin>>M;
            P=max(M,P);
            X+=M;
        }
        cout << X-(P/2);

    // enter your code here

    return 0;
}


Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
  
  const N = input - 0
  
  const dev = []
  
  for (let i = 1; i * i <= N; i++) {
    if (N % i === 0) {
      dev.push(i, N / i)
    }
  }
  
  dev.sort((a, b) => a - b)
    
  console.log(dev[dev.length / 2].toString().length)
  
})(input)


Measured memory_bytes: 33168
import math
from fractions import gcd
A,B = (int(i) for i in input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = gcd(A,B)
N_divisors = make_divisors(N)
prime_nums = []
for i in range(1,len(N_divisors)):
  if i == 1:
    prime_nums.append(N_divisors[i])
  else:
    for j in range(1,i):
      if N_divisors[i]%N_divisors[j] == 0:
        break
      if j == i-1:
        prime_nums.append(N_divisors[i])

ans = 1 + len(prime_nums)
print(ans)


Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
  cin >> a >> b;
  int ans = max(a+b, max(a-b, a*b));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
bool ok[7368791 + 1];
int main() {
	int m, n;
	while (cin >> m >> n, m) {
		int rest = n;
		memset(ok, 0, sizeof(ok));
		for (int i = m; i <= 7368791; i++) {
			if (ok[i]) continue;
			if (rest == 0) {
				cout << i << endl;
				break;
			}
			rest--;
			for (int j = i; j <= 7368791; j += i) ok[j] = 1;
		}
	}
}


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

using namespace std;

using ll = long long;

double dp[3000][3000];

int main() {

	int N;
	cin>>N;
	double p[N];
	for (int i = 1;i <= N;++i) {
		cin>>p[i];
	}

	dp[1][0] = 1 - p[1];
	dp[1][1] = p[1];
	for (int i = 2;i <= N;++i) {
		dp[i][0] = dp[i-1][0] * (1-p[i]);
		for (int j = 1;j <= i;++j) {
			dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1 - p[i]);
		}
	}

	cout<<setprecision(10);	
	double ans = 0;
	for (int i = N/2+1;i <= N;++i) {
		ans += dp[N][i];
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 68864
N = int(input())
li = list(map(int, input().split()))
money = 1000
kanum = 0

for i in range(N-1):
    if li[i] < li[i+1]:
        kanum += money // li[i]
        money = money % li[i]
    if li[i] > li[i+1]:
        money += kanum * li[i]
        kanum = 0

money += kanum * li[N-1]
print(money)


Measured memory_bytes: 61864
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 16;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

char in[55][55];
int main() {
	int N, M, i, j, k, l;
	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) scanf("%s", in[i]);

	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			if (in[i][j] == '#') {
				printf("#");
				continue;
			}
		
			int c = 0;
			for (k = i - 1; k <= i + 1; k++) {
				for (l = j - 1; l <= j + 1; l++) {
					if (k >= 0 && k < N && l >= 0 && l < M && in[k][l] == '#') c++;
				}
			}
			printf("%d", c);
		}
		printf("\n");
	}
	return 0;
}

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

int number_of_members(vector<vector<int>> &members, int boss);
int number_of_direct_members(vector<vector<int>> &members, int boss);

int main()
{
	int n;

	cin >> n;
	vector<vector<int>> members(n);
	for (int i=1;i<n;++i)
	{
		int member;
		cin >> member;
		members.at(member-1).push_back(i);
	}

	for (int i=0;i<n;++i)
	{
		cout << number_of_direct_members(members,i) << endl;
	}
	cout << endl;


}

int number_of_direct_members(vector<vector<int>> &members, int boss)
{
	return members.at(boss).size();
}


int number_of_members(vector<vector<int>> &members, int boss)
{
	int sum=1;

	for (int m: members.at(boss))
	{
		sum+=number_of_members(members,m);
	}
	return sum;
}





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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int n;cin>>n;
    vint x(n);vin(x);
    double ave=accumulate(all(x),0)/(double)n;
    int pos=ave;
    if(ave-pos>=0.5)pos++;

    int ans=0;
    rfor(m,x){
        int d=abs(m-pos);
        ans+=d*d;
    }
    cout << ans << endl;


    return 0;
}


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

using namespace std;

int read_int(){
    int a;
    scanf("%d",&a);
    return a;
}

int main(){
    int N = read_int();
    int M = read_int();
    int A[N];
    int total = 0;
    for(int i=0;i<N;i++){
        A[i] = read_int();
        total += A[i];
    }

    fprintf(stderr, "%d %d %d\n", N, M, total);

    int count = 0;
    for(int i=0;i<N;i++){
        if(A[i]*M*4>=total){
            count++;
        }
    }
    if(count>=M){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0; 

}

Measured memory_bytes: 128
function Main (input) {
  const inputs = input.split(/\s/g).map((num) => parseInt(num));
  const patterns = [
    inputs[0] + inputs[1],
    inputs[0] - inputs[1],
    inputs[0] * inputs[1]
  ];
  console.log('%s', Math.max(...patterns));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    string ans = s;
    rep(i, s.size()){
        if(ans[i] != 'a' && 'z' - ans[i] + 1 <= k){
            k -= 'z' - ans[i] + 1;
            ans[i] = 'a';
        }
    }
    if(k > 0){
        ans.back() += k % 26;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
package main

import (
  "fmt"
  "sort"
)

func main() {
  var N, K, i int
  fmt.Scan(&N, &K)
  h := make([]int, N)
  for i := range h {
    fmt.Scan(&h[i])
  }
  sort.Ints(h)
  for i = N-1; i >= 0 && K <= h[i]; i-- {}
  fmt.Println(N-(i+1))
}


Measured memory_bytes: 5504
MOD = 1000000007

def mod(n):         
  return n % MOD

def add(a, b):      #mod(a+b)を求める
  return mod(mod(a)+mod(b))

def subtract(a, b): #mod(a-b)を求める
  return mod(mod(a)-mod(b))

def multiply(a, b): #mod(a*b)を求める
  return mod(mod(a)*mod(b))

def divide(a, b):   #mod(a / b)を求める
  ans = mod(a) * inverse(b)
  return mod(ans)

def modpow(a, n):   #mod(a**n)を高速で求める
    res = 1  
    digit = len(str(bin(n))) - 2
    for i in range(digit):
      if (n >> i) & 1:
        res *= mod(a)
        res = mod(res)
      a = mod(a**2)
    return mod(res)

def inverse(a):     #aの逆元を求める
  return modpow(a, MOD-2)

MAX = 1000000           #適当な数を入力
fac, finv, inv = [[0]*MAX for i in range(3)]
def combinit():     #MAXまでの下準備
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

def modcomb(n, k):      #mod(nCk)を計算、ただしn<MAX
  if (n < k):
    return 0
  if (n < 0 or k < 0):
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
combinit()          #下準備の実行 O(MAX)

import sys
x, y = map(int, input().split())

if (x+y) % 3 != 0:
  print(0)
  sys.exit()
  
if x < y:
  x, y = y, x
  
k = (2*y - x)//3
print(modcomb(y-k, k))

Measured memory_bytes: 62192
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            int c = (int)Math.Log10(b)+1;
            double d = Math.Pow(10, c)*a+b;
            int e = (int)(Sqrt(d));
            if (e * e == d)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int A, B, C;

int main () {
  cin >> A >> B >> C;
  cout << ((A+B >= C) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#! python3


n,a,b = input().split(' ')
s = input()

n = int(n)
a = int(a)
b = int(b)

rF = 0
ok = 0

for i in range(0, n):
	if s[i] == 'a':
		if ok < a+b:
			print('Yes')
			ok += 1
		else:
			print('No')
	elif s[i] == 'b':
		if ok < a+b and rF < b:
			rF += 1
			print('Yes')
			ok += 1
		else:
			print('No')
	else:
		print('No')

Measured memory_bytes: 4244
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
//const int INF = 1 << 30;
const ll INF = 1LL << 40;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

ll n, m, R;
vector<ll> r;

ll d[210][210];
ll V;

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

ll res;

ll dfs(int s, int i) {
	if (i == R - 1) return res;
	if (d[r[i]][r[i + 1]] == INF) return INF;

	res += d[r[i]][r[i + 1]]; 

	dfs(r[i + 1], i + 1);
}

int main(void){
	cin>>n>>m>>R; V = n;
	r.resize(R);
	for (int i = 0; i < R; i++) {
		cin>>r[i]; r[i]--;
	}

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			(i == j ? d[i][j] = 0 : d[i][j] = INF);
		}
	}

	for (int i = 0; i < m; i++) {
		ll a, b, c; cin>>a>>b>>c;
		a--; b--;
		d[a][b] = d[b][a] = c;
	}

	warshall_floyd();

	sort(r.begin(), r.end());
	ll ans = INF;
	do {
		res = 0;
		ans = min(ans, dfs(r[0], 0));
	} while (next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 640
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)

N = int(input())
T = [defaultdict(int) for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    T[u-1][v-1] = w
    T[v-1][u-1] = w
visited = [0]*N
ans = [0]*N
def dfs(now,col):
    visited[now] = 1
    for i in T[now].keys():
        if visited[i] == 1:
            continue
        if T[now][i]%2==1:
            ans[i] = col^1
            next = col^1
        else:
            ans[i] = col
            next = col
        dfs(i,next)
dfs(0,0)
for i in range(N):
    print(ans[i])



Measured memory_bytes: 88180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF=1 << 30;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vit;
typedef map<string,int> mstit;
typedef priority_queue<int> pqit;
 
 
 
 
 
int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  int a[105];
  double ave=0;
  cin >>n;
  FOR(i,n){
    cin >>a[i];
    ave+=a[i];
  }
  ave/=(double)n;
  int num;
  double ner=INF;
  FOR(i,n){
    if(ner>abs((double)a[i]-ave)){
      num=i;
      ner=abs((double)a[i]-ave);
    }
  }
  cout <<num fin;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,max,min,s,a,j;
  while(scanf("%d",&n),n){
    for(max=min=0;n--;){
      for(j=s=0;j<5;j++){
	scanf("%d",&a);
	s+=a;
      }
      if(max<s)max=s;
      if(min>s||min==0)min=s;
    }
    printf("%d %d\n",max,min);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

static const int N = 100100;

using namespace std;

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

    int n, k;
    string s;

    cin >> n >>s>> k;

    char ss = s[k - 1];

    for (int i = 0; i < n; i++)
    {
        if(s[i]!=ss)
            s[i] = '*';
    }


    cout << s <<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	/*public static Boolean primenumber(int n) {
		Boolean result = true;
		int mid = (int)(n^(1/2));
		if (n > 2) {
			for (int i = 2; i < mid; i++) {
				if (n%i == 0) {
					result = false;
					break;
				}
			}
		}
		return result;
	}*/
	
	public static Boolean primenumber(int n) {
		if (n <= 3) {
			return n > 1;
		}
		else if (n%2 == 0 || n%3 == 0) {
			return false;
		}
		int i = 5;
		while (i*i <= n) {
			if (n%i == 0 || n%(i + 2) == 0) {
				return false;
			}
			i = i + 6;
		}
		return true;
	}
	
	public static int numberprimes(int[] P) {
		int counter = 0;
		for (int p : P) {
			if (primenumber(p)) {
				counter++;
			}
		}
		return counter;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int numintegers = in.nextInt();
		int[] P = new int[numintegers];
		int index = 0;
		while (index < numintegers) {
			int num = in.nextInt();
			P[index] = num;
			index++;
		}
		in.close();
		int result = numberprimes(P);
		System.out.println(result);
	}
}



Measured memory_bytes: 43256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max() / 100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
vector<LL>rest;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000], sub[210000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0)
			sum++;
		ma[a[i]]++;
	}
	if (sum == n) {
		cout << "Yes" << endl;
		return 0;
	}
	if (n % 3 == 0) {
		for (auto it = ma.begin(); it != ma.end(); it++) {
			while (it->second) {
				if (it->second % (n / 3) != 0) {
					cout << "No" << endl;
					return 0;
				}
				it->second -= (n / 3);
				b[cnt] = it->first;
				cnt++;
			}
		}
		if ((b[0] ^ b[1]) == b[2]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 7168
n = int(input())
s = input()

total = 0
for j in range(1, n-1):
    left_d = {"R": set(), "G": set(), "B": set()}
    for k in range(j+1, n):
        left_d[s[k]].add(k-j)
    for i in range(j):
        if s[j] == s[i]:
            continue
        if s[i] == "R" and s[j] == "G" or s[i] == "G" and s[j] == "R":
            target = "B"
        if s[i] == "R" and s[j] == "B" or s[i] == "B" and s[j] == "R":
            target = "G"
        if s[i] == "B" and s[j] == "G" or s[i] == "G" and s[j] == "B":
            target = "R"
        total += len(left_d[target])
        if j-i in left_d[target]:
            total -= 1
        # print(i, j, total, left_d)

print(total)


Measured memory_bytes: 83028
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int dp[2][55][3005];
int n,m,s;
int main(void){
    while(1){
    cin>>n>>m>>s;
    if(!n&&!m&&!s)break;
    n*=n;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=s;j++){
            dp[0][i][j]=0;
            dp[1][i][j]=0;
        }
    }
    dp[0][0][0]=1;
    for(int i=1;i<=m;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=s;k++){
                dp[i%2][j][k]=dp[(i+1)%2][j][k];
                if(k-i>=0&&j>0)dp[i%2][j][k]=(dp[(i+1)%2][j-1][k-i]+dp[i%2][j][k])%100000;
                
            }
        }
    }
    cout<<dp[m%2][n][s]<<endl;
    }
}

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

int main() {
    int n;
    long long ans=0;
    cin >>n;
    long long a[n],num[n]={0};
    rep(i,n) {
        cin >>a[i];
        num[a[i]-1]++;
    }
    rep(i,n) {
        ans+=num[i]*(num[i]-1)/2;
    }
    rep(i,n)cout << ans-num[a[i]-1]+1 <<endl;
    return 0;
}

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

int N, M;
int MOD = 1000000007;
std::vector<int> counts;
std::vector<int> as;

int count(int idx) {
    if (idx == N) {
        return 1;
    }
    if (counts[idx] != -1) {
        return counts[idx];
    }
    int cnt = 0;
    if (as[idx + 1] == 0) {
        cnt += count(idx + 1);
    }
    if (idx + 2 <= N && as[idx + 2] == 0) {
        cnt += count(idx + 2);
    }
    counts[idx] = cnt % MOD;
    return counts[idx];
}


int main() {
    std::cin >> N >> M;

    as = std::vector<int>(N + 1, 0);
    for (int i = 0; i < M; i++) {
        int idx;
        std::cin >> idx;
        as[idx] = 1;
    }

    counts = std::vector<int>(N, -1);

    int sum = count(0);
    std::cout << sum << std::endl;
}


Measured memory_bytes: 8724