akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	final static String EVENT_HIT = "HIT";
	final static String EVENT_HOMERUN = "HOMERUN";
	//final static String EVENT_OUT = "OUT";

	static Main main = new Main();

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String event = "";

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			Inning inning = main.new Inning(0);
			while ((event = br.readLine()) != null) {
				if (event.equals(EVENT_HIT)) {
					inning.singleHit();
				} else if (event.equals(EVENT_HOMERUN)) {
					inning.homeRun();
				} else {
					inning.out();
				}
				if (inning.outs == 3) {
					System.out.println(inning.run);
					break;
				}
			}
		}
	}

	class Inning {

		int diamond;
		int outs;
		int run;

		Inning(int run) {
			diamond = 0;
			outs = 0;
			this.run = run;
		}

		void singleHit() {
			diamond <<= 1;
			diamond |= 1;
			if ((diamond & 8) > 0) {
				run++;
				diamond &= 7;
			}
		}

		void homeRun() {
			for (int i = 0; i < 3; i++) {
				diamond <<= 1;
				if ((diamond & 8) > 0)
					run++;
			}
			run++;
			diamond = 0;
		}

		void out() {
			outs++;
		}
	}
}

Measured memory_bytes: 16880
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if (com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 25172
"""
author : halo2halo
date : 10, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S, T = read().split()
print(len([x for x,y in zip(S,T) if x==y]))


Measured memory_bytes: 3060
n = gets.to_i
x_vec = gets.split.map(&:to_i)
y_vec = gets.split.map(&:to_i)

p_1 = x_vec.zip(y_vec).inject(0) { |sum, (x, y)| sum + (x - y).abs }
p_2 = Math.sqrt(x_vec.zip(y_vec).inject(0) { |sum, (x, y)| sum + ((x - y).abs)**2 })
p_3 = Math.cbrt(x_vec.zip(y_vec).inject(0) { |sum, (x, y)| sum + ((x - y).abs)**3 })
p_inf = x_vec.zip(y_vec).map { |(x, y)| (x - y).abs }.max

printf("%7.6f\n%7.6f\n%7.6f\n%7.6f\n", p_1, p_2, p_3, p_inf)

Measured memory_bytes: 8864
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    String[][] strButton = {
      {".",",","!","?"," "},{"a","b","c"},{"d","e","f"},{"g","h","i"},{"j","k","l"},{"m","n","o"},{"p","q","r","s"},{"t","u","v"},{"w","x","y","z"}
    };

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String str = br.readLine();
    int num = Integer.parseInt(str);

    String[] strArray = new String[num];
    int[][] numArray = new int[num][];

    for (int i = 0; i < num; i++) {
      strArray[i] = br.readLine(); 
      numArray[i] = new int[strArray[i].length()];

      for (int j = 0; j < strArray[i].length(); j++) {
        String str1 = String.valueOf(strArray[i].charAt(j));
        numArray[i][j] = Integer.parseInt(str1);
      }
    }

    String[][] strAnswer = new String[num][76];
    for (int i = 0; i < num; i++) {
      int num1 = 0;

      for (int j = 0; j < numArray[i].length; j++) {
        if (numArray[i][j] != 0) {
          int count = 1;
          int k;
          for (k = 0; numArray[i][j+k+1] != 0; k++) {
            count++;
          }

          int num2 = numArray[i][j] - 1;
          int num3;
          if (count % strButton[num2].length == 0) {
            num3 = strButton[num2].length - 1;
          }
          else {
            num3 = count % strButton[num2].length - 1;
          }

          strAnswer[i][num1] = strButton[num2][num3];

          num1++;
          j += k + 1;
        }
      }
    }

    for (int i = 0; i < num; i++) {
      for (int j = 0; strAnswer[i][j] != null; j++) {
        System.out.print(strAnswer[i][j]);
      }
      System.out.print("\n");
    }
  }
}

Measured memory_bytes: 29808
package main

import "fmt"

func main() {
	var n int
	var v, c []int

	fmt.Scan(&n)
	v = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	c = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}

	var res int
	for i, v := range v {
		if v > c[i] {
			res += v - c[i]
		}
	}
	fmt.Println(res)
}


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

int main() {
  int K;
  cin >> K;
  vector<long> ans;
  auto dfs = [&](auto &&dfs, long n) -> void {
    if (n > 3234566667) return;
    ans.push_back(n);
    for (int next = max(0L, n % 10 - 1); next <= min(9L, n % 10 + 1); next++) {
      dfs(dfs, n * 10 + next);
    }
  };
  for (int i = 1; i <= 9; i++) dfs(dfs, i);
  sort(ans.begin(), ans.end());
  cout << ans.at(K - 1) << "\n";
}

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

int main() {
    ll n;
    cin >> n;
    ll m = 0;
    ll a = 0;
    ll r = 0;
    ll c = 0;
    ll h = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s[0] == 'M') m++;
        else if (s[0] == 'A') a++;
        else if (s[0] == 'R') r++;
        else if (s[0] == 'C') c++;
        else if (s[0] == 'H') h++;
    }
    ll ans = 0;
    ans += m * a * r;
    ans += m * a * c;
    ans += m * a * h;
    ans += m * r * c;
    ans += m * r * h;
    ans += m * c * h;
    ans += a * r * c;
    ans += a * r * h;
    ans += a * c * h;
    ans += r * c * h;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}





int main(){
 
    int d,t,s;
    cin >> d >> t >> s;
    if(s * t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3164
N,M = map(int,input().split())
MOD = 10**9+7
dp = [0]*(N+1)
dp[0]=1
A = [int(input()) for i in range(M)]
ban = [1]*(N+1)
for a in A:
    ban[a]=0
for i in range(N):
    if i-1>=0:
        dp[i+1]=dp[i]*ban[i]+dp[i-1]*ban[i-1]
    else:
        dp[i+1]=dp[i]*ban[i]
    dp[i+1] %= MOD 
print(dp[N])

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sc = new Scanner();
            int[] a = new int[5];
            for (int i = 0; i < a.Length; i++) a[i] = sc.NextInt();
            int k = sc.NextInt();

            for (int i = 0; i < a.Length; i++)
                for (int j = i + 1; j < a.Length; j++)
                {
                    if (a[j] - a[i] > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }

            Console.WriteLine("Yay!");
        }
    }

    class Scanner
    {
        int index = -1;
        string[] buf;

        public Scanner()
        {
        }

        public int NextInt()
        {
            CheckNext();
            return int.Parse(buf[index++]);
        }

        public string NextString()
        {
            CheckNext();
            return buf[index++];
        }

        private void CheckNext()
        {
            if (index >= 0 && index < buf.Length) return;

            buf = Console.ReadLine().Split(' ');
            index = 0;
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define F first 
#define S second 

const int INF=10000000;

struct edge{
  int t,c;
  edge(){}
  edge(int t,int c):t(t),c(c){}
};

typedef pair<int, pair<int,int> > P;


int n,m;
int d[3][111];
vector<edge> g[111];

int main(void){
  while(1){
    cin >> n >> m;
    if(!n && !m)break;

    for(int i=0;i<111;i++){g[i].clear();}

    for(int i=0;i<m;i++){
      int aa,bb,cc;
      cin >> aa >> bb >> cc;
      g[aa].push_back(edge(bb,cc));
      g[bb].push_back(edge(aa,cc));
    }

    /*
    for(int i=1;i<=n;i++){
      for(int j=0;j<g[i].size();j++){
	cout <<"g:" << i << "." <<g[i][j].t << endl; 
      }
    }*/

    priority_queue<P,vector<P>,greater<P> > que;
    for(int i=0;i<3;i++){
      for(int j=0;j<111;j++){
	d[i][j] = INF;
      }
    }
    d[0][1] = d[1][1] = 0;
    que.push(make_pair(0,make_pair(1,1)));

    while(!que.empty()){
      P p = que.top(); que.pop();
      int psf = p.S.F;
      int pss = p.S.S;
      if(d[pss][psf] < p.F) continue;
      for(int i=0;i<g[psf].size();i++){
	if(pss){
	  //cout <<"g:" <<g[psf][i].t << endl; 
	  for(int j=0;j<g[g[psf][i].t].size();j++){
	    if(d[pss-1][g[g[psf][i].t][j].t] > p.F){
		d[pss-1][g[g[psf][i].t][j].t] = p.F;
		que.push(make_pair(d[pss-1][g[g[psf][i].t][j].t],make_pair(g[g[psf][i].t][j].t,pss-1)));
	    }
	  }
	}
	if(d[pss][g[psf][i].t] > p.F+g[psf][i].c){
	  d[pss][g[psf][i].t] = p.F+g[psf][i].c;
	  que.push(make_pair(d[pss][g[psf][i].t],make_pair(g[psf][i].t,pss)));
	}
      }
    }
    cout << min(d[0][n],d[1][n]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
// contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#define YES "Yes"
#define NO "No"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef pair < ut, ut > pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
VI edges[SIZE];
////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
//LL L;
LL exist[2][SIZE];
bool reached[SIZE];
string s;
void init() {

}
LL solve2() {
	
	return 0;
}
LL solve() {
	cin >> N >> M;
	cin >> s;
	s = "1" + s;
	int a, b;
	REP(i, M) {
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
		exist[s[a] - 'A'][b]++;
		exist[s[b] - 'A'][a]++;
	}
	queue<int> qu;
	EFOR(i, 1, N) {
		if (!exist[0][i] or !exist[1][i]) {
			qu.push(i);

			reached[i] = true;
		}
	}
	int ans = 0;
	while (!qu.empty()) {
		int now = qu.front();
		qu.pop();
		ans++;
		for (auto next : edges[now]) {
			if (reached[next]) continue;
			exist[s[now] - 'A'][next]--;
			if (exist[s[now] - 'A'][next] == 0) {
				qu.push(next);
				reached[next] = true;
			}
		}
	}
	return ans!=N;
}
signed main() {
	YESNO;
	cin >> N;
	return 0;
}

Measured memory_bytes: 24008
module Main where

toInt :: String -> Int
toInt s = read s :: Int

strToIntList :: String -> [Int]
strToIntList = map toInt . words

getIntList :: IO [Int]
getIntList = getLine >>= return . strToIntList

main :: IO ()
main = do
  ab <- getLine
  print . length $ filter (== '1') ab

Measured memory_bytes: 380
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define min(a,b) a<b?a:b
int b[101][101],n,m,i,j,k,f,t,c,r,d1[101],d2[101];

void dijkstra(int *d,int s)
{
	int i,v,u[101];
	for(i=0;i<n;i++)
		d[i]=1000000,u[i]=0;
	d[s]=0;

	for(;;)
	{
		v=-1;
		for(i=0;i<n;i++)
			if(!u[i]&&(v==-1||d[i]<d[v]))
				v=i;
		if(v==-1)
			break;
		u[v]=1;
		for(i=0;i<n;i++)
			d[i]=min(d[i],d[v]+(b[v][i]>0?b[v][i]:0));
	}
}

int main()
{
	for(;scanf("%d%d",&n,&m),n;)
	{
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				b[i][j]=1000000;
		for(i=0;i<m;i++,b[f-1][t-1]=b[t-1][f-1]=c)
			scanf("%d%d%d",&f,&t,&c);
		dijkstra(d1,0);
		dijkstra(d2,n-1);
		r=d1[n-1];
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				if(i!=j)
				{
					for(k=0;k<n;k++)
						if(i!=k&&j!=k&&b[i][k]!=1000000&&b[k][j]!=1000000)
							break;
					if(k==n)
						continue;
					r=min(d1[i]+d2[j],r);
				}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
using namespace std;

int a,b,c,x,y;

int main(){
//	freopen("inb.txt","r",stdin);
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	int com = min(x,y);//a b棋盘公共的部分 com套a+b 
	int sum = 0; 
	if(a+b>=c*2){//套装更优惠 
		sum += com*c*2; 
		if(x>=y){
			if(a>=c*2){
				sum += (x-y)*2*c;
			}else{
				sum += (x-y)*a;
			}	
		}else{
			if(b>=c*2){
				sum += (y-x)*2*c;
			}else{
				sum += (y-x)*b;
			}
		}
	}else{//单买更优惠 
		sum = x*a + y*b; 
	}
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 128
a,b,c,d = map(int, input().split())
if a==c and b==d:
    print(abs(a-b))
elif a==d or c==b:
    print(0)
elif a==c:
    print(abs(b-a) if b<d else abs(d-c))
elif b==d:
    print(abs(b-a) if a>c else abs(d-c))
elif a>c:
    if a>d:
        print(0)
    elif a<d<b:
        print(abs(a-d))
    else:
        print(abs(a-b))
else:
    if c>b:
        print(0)
    elif c<b<d:
        print(abs(c-b))
    else:
        print(abs(c-d))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n; cin >> n;
  string s; cin >> s;
  for (char c : s) {
    char nc = ((int)c -65+n)%26 + 65;
    cout << nc;
  }
  return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
   uniform_int_distribution<int> uid(l, r);
   return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
   int n, sum = 0; cin >> n;
   map <int, int> fre;
   for(int i = 1; i <= n; i++) {
     int x; cin >> x;
     fre[x]++; sum += x;
   }
   int q; cin >> q;
   while(q--) {
     int b, c; cin >> b >> c;
     sum -= (fre[b] * b); sum -= (fre[c] * c);
     fre[c] += fre[b]; fre[b] = 0;
     sum += (c*fre[c]);
     cout << sum << '\n';
   }
}

signed main() {   
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
      solve();
  }
}    


Measured memory_bytes: 9568
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 20:43:52 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 20:43:41 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Dec 29 18:42:51 2018

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 20:43:41 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Dec 29 18:42:51 2018

@author: Owner
"""

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""

N = int(input())
A, B = map(int, input().split())
P = [0]*N
P[:] = map(int, input().split())

P.sort()

num1 = len([i for i in P if i <= A])
num3 = len([i for i in P if i >= B+1])
num2 = N-num1-num3

num = min(num1, num2, num3)
print(num)

Measured memory_bytes: 24652
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numA = nextInt();
		int numB = nextInt();
		int numC = nextInt();

		if (numA <= numC && numC <= numB) {
			out.println("Yes");
		} else if (numB <= numC && numC <= numA) {
			out.println("Yes");
		} else {
			out.println("No");
		}

		out.println("");
	}

	private void solveB() {
		int numN = nextInt();
		String sS = next();
		int numK = nextInt();

		char tmp = sS.charAt(numK - 1);

		StringBuilder builder = new StringBuilder();

		for (int i = 0; i < sS.length(); i++) {
			if (sS.charAt(i) != tmp) {
				builder.append('*');
			} else {
				builder.append(tmp);
			}
		}

		out.println(builder.toString());
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;

    vector<int> b(n);
    for(int i = 0; i < n - 1; i++) {
        cin >> b[i];
    }

    int ans;

    ans = b[0];

    FOR(i, 1, n - 1){
        ans += min(b[i], b[i - 1]);
    }

    ans += b[n - 2];


    cout << ans << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

const int N=200005;
int f[N][2],g[N][2],fst[N],high[N],low[N],tot=0;
char s[N];

struct Edge{
	int to,nxt;
}e[N*2];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}

void dfs(int x,int father){
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=father){
			dfs(y,x);
			if (f[y][0]>=f[x][0]) f[x][1]=f[x][0],f[x][0]=f[y][0]+1;
				else if (f[y][0]>=f[x][1]) f[x][1]=f[y][0]+1;
		}
	}
}

void dfs2(int x,int father){
	high[x]=std::min(f[x][0]-1,f[x][1]+1);
	if (s[x]=='1') low[x]=0;else low[x]=1000000000;
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=father){
			int z=f[x][0]==f[y][0]+1?f[x][1]+1:f[x][0]+1;
			g[y][0]=f[y][0];g[y][1]=z;
			if (z>f[y][0]) f[y][1]=f[y][0],f[y][0]=z;
				else if (z>f[y][1]) f[y][1]=z;
			dfs2(y,x);
			low[x]=std::min(low[x],std::max(low[y]+1,g[y][1]+1));
			low[x]=std::min(low[x],std::max(low[y]-1,g[y][0]+1));
		}
	}
}

void dfs3(int x,int father){
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=father){
			low[y]=std::min(low[y],std::max(low[x]+1,g[y][0]+2));
			low[y]=std::min(low[y],std::max(low[x]-1,g[y][1]));
			dfs3(y,x);
		}
	}
}
int main(){
	int n;
	scanf("%d\n",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	scanf("%s",s+1);
	dfs(1,0);
	dfs2(1,0);
	dfs3(1,0);
	long long ans=1;
	for (int i=1;i<=n;i++)
		if (low[i]<=high[i]) ans+=high[i]-low[i]+1;
	printf("%lld\n",ans);
}

Measured memory_bytes: 16128
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define PB push_back
#define PPB pop_back
#define MK make_pair
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, pii> pipii;

constexpr int INF = 1LL << 61;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 2005;

int n, a[MAX_N], mem[MAX_N][MAX_N];

int Dfs(int s, int t) {
    if (mem[s][t] != -1) return mem[s][t];
    if (s == t) return 0;

    if (a[s] < a[t]) {
        t++;
        t %= n;
    } else {
        s += n;
        s--;
        s %= n;
    }

    if (mem[s][t] != -1) return mem[s][t];
    if (s == t) return a[s];

    return mem[s][t] = max(a[s] + Dfs((s + n - 1) % n, t), a[t] + Dfs(s, (t + 1) % n));
}

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

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    memset(mem, -1, sizeof(mem));

    int ans = -1;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, a[i] + Dfs((i + n - 1) % n, (i + 1) % n));
    }

    cout << ans << endl;
}

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

int main() {
  int n,k,d,w;
  cin >>n>>k;
  set<int> a;
  rep(i,k){
    cin>>d;
    rep(j,d){
      cin >>w;
      a.insert(w);
    }
  }
  cout<< n-a.size()<<endl;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

bool check(const vector<string>& vs, int d) {
    int n = vs.size();
    rep(y, n) rep(x, n) {
        int x1 = (x + d) % n;
        int x2 = (y + d) % n;
        if (vs[y][x1] != vs[x][x2]) return false;
    }
    return true;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vector<string> vs(n);
    rep(i, n) cin >> vs[i];

    int ans = 0;
    rep(i, n) {
        if (check(vs, i)) ans += n;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    private static int t = 0;
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        final int n = Integer.parseInt(br.readLine());
        final String[] in = br.readLine().split(" ");
        final int[] s = new int[n];
        for(int i = 0; i<n; i++)
            s[i] = Integer.parseInt(in[i]);
        mergeSort(s, 0, n);
        sb.append(s[0]);
        for(int i = 1; i<n; i++)
            sb.append(' ').append(s[i]);
        sb.append('\n').append(t).append('\n');
        System.out.print(sb);
    }
    private static void mergeSort(int[] a, int l, int r){
        if(l+1<r){
            final int m = (l+r)>>>1;
            mergeSort(a, l, m);
            mergeSort(a, m, r);
            merge(a, l, m, r);
        }
    }
    private static void merge(int[] a, int l, int m, int r){
        final int n1 = m-l;
        final int n2 = r-m;
        final int[] L = new int[n1+1];
        final int[] R = new int[n2+1];
        System.arraycopy(a, l, L, 0, n1);
        System.arraycopy(a, m, R, 0, n2);
        L[n1] = R[n2] = Integer.MAX_VALUE;
        int i = 0, j = 0;
        for(int k = l; k<r; k++){
            if(L[i]<=R[j]) a[k] = L[i++];
            else a[k] = R[j++];
            t++;
        }
    }
}

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

int main()
{
	int x, y;
	int temp;

	while (1) {
		cin >> x >> y;

		if (x == 0 && y == 0) {
			break;
		}

		if (x > y) {
			temp = x;
			x = y;
			y = temp;
		}

		cout << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 3072
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    T = list(input())

    ans = []
    for t in T:
        if t == '?':
            ans.append('D')
        else:
            ans.append(t)
    printlist(ans, '')



if __name__ == '__main__':
    solve()


Measured memory_bytes: 14028
fn getline() -> String{
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let buf = getline();
    let n: usize = buf.trim().parse().unwrap();
    let buf = getline();
    let s = buf.trim();
    let mut cnt = 0;
    // let mut ans: String = "".to_string();
    let mut mi: i32 = 0;
    for c in s.chars() {
        if c == '(' {
            cnt += 1;
            // ans = [ans,"(".to_string()].connect("");
        }else{
            cnt -= 1;
            // let s;
            // if cnt < 0 {
            //     s = "()";
            //     cnt += 1;
            // }else{
            //     s = ")"
            // }
            // ans = [ans,s.to_string()].connect("");
        }
        mi = std::cmp::max(mi,-cnt);
    }
    cnt += mi;
    let mut ans = std::string::String::new();
    for _ in 0..mi {
        ans.push('(');
    }
    ans += s;
    for _ in 0..cnt {
        ans.push(')');
    }
    println!("{}",ans);
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N, P;
string S;
int m[200200];
int A[100100];

signed main() {
    cin >> N >> P;
    cin >> S;
    if (P == 2) {
        int ans = 0;
        rep(i, N) {
            if ((S[i] - '0') % 2 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    } else if (P == 5) {
        int ans = 0;
        rep(i, N) {
            if ((S[i] - '0') % 5 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    int k = 1;
    for (int i = N - 1; i >= 0; --i) {
        m[i] = m[i + 1] + k * (S[i] - '0');
        m[i] %= P;
        k *= 10;
        k %= P;
    }
    rep(i, N + 1) {
        A[m[i]]++;
    }
    int ans = 0;
    rep(i, P + 10) {
        ans += A[i] * (A[i] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli ave = 0, sum = 0;
    int n;
    cin >> n;
    vi x(n, 0);
    rep(i, n){
        cin >> x[i];
        ave += x[i];
    }
    ave /= n;
    lli ans = inf;
    rep(j, 3){
        rep(i, n) sum += (x[i]-(ave+j)) * (x[i]-(ave+j));
        ans = min(ans, sum);
        sum = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next(), b = in.next();
        int c = Integer.valueOf(a+b);
        if(Math.pow((int)Math.sqrt(c), 2) == c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 23636
n, d = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
count = 0
import math
for i in range(n):
    for j in range(i + 1, n):
        sum  = 0
        if i != j:
            for k in range(d):
                sum += (l[i][k] -l[j][k]) ** 2
            dis = math.sqrt(sum)
            if dis % 1 == 0:
                count += 1
print(count)


Measured memory_bytes: 9256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception
    {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String str[] = S.split("");
        int sum = 0;
        for(int i=0;i<str.length;i++)
        {
            if(str[i].equals("+"))
            {
                sum++;
            }
            else if(str[i].equals("-"))
            {
                sum--;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

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

//10^9 + 7
const ll MOD = 1000000007;

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

	string ans = "";
	N = N.back();
	if (N == "2" || N == "4" || N == "5" || N == "7" || N == "9") {
		ans = "hon";
	}
	else if (N == "0" || N == "1" || N == "6" || N == "8"){
		ans = "pon";
	}
	else if(N == "3"){
		ans = "bon";
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
N=int(input())
st= [list(map(str, input().split())) for _ in range(N)]
X=input()
ans=0
check=0
for i in range(N):
    if check==1:
        ans+=int(st[i][1])
    if st[i][0]==X:
        check=1
    
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int X = scan.nextInt();

		int count = 0;
		for(int a = 0; a<= A; a++){
			for(int b = 0; b<=B; b++){
				for(int c = 0; c<=C; c++){
					if(500*a+100*b+50*c==X){
						count++;
					}
				}
			}

		}
		int 	answer = count;
		System.out.println(answer);

	}

}


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

int main(){
  string T;
  cin>>T;
  for(int i=0;i<T.length();i++){
    if(T.at(i)=='?'){
      cout<<'D';
    }
    else cout<<T.at(i);
  }
  cout<<endl;
  return 0;
  /*
  T=T+'K';
  int ans=0;
  for(int i=0;i<T.length()-1;i++){
    if(T.at(i)=='D'||T.at(i)=='?'||(T.at(i)=='P'&&T.at(i+1)=='D')||(T.at(i)=='?'&&T.at(i+1)=='D')||(T.at(i)=='P'&&T.at(i+1)=='?')){
      ans++;
    }
  }
  cout<<ans<<endl;
  */
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define vll vector <ll>
using namespace std;
ll dp[105][100005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    	ll n, w;
    	cin >> n >> w;
    	ll wt[n], val[n];
	vector <vll> dp(n, vll (w+1));
    	for(int i = 0; i < n; i++) {
		cin >> wt[i] >> val[i];
	}
	for(int i = wt[0]; i <= w; i++) dp[0][i] = val[0];
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= w; j++){
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
			if(j - wt[i] >= 0){
				dp[i][j] = max(dp[i][j], val[i] + dp[i-1][j-wt[i]]);
			}
		}
	}
	cout << dp[n-1][w] << "\n";
	return 0;
}


Measured memory_bytes: 79488
#include<stdio.h>

void araisanSort(int a[], int len) {

	int min=0 , temp;
	int i, j, cou = 0;
	for (i = 0; i < len; i++)
	{
		min = i;
		for (j = i + 1;j < len;j++) {
			if (a[j] < a[min])
			{
				min = j;
			}
		}
		if (min != i) {
			temp = a[min];
			a[min] = a[i];
			a[i] = temp;
			cou++;
		}
		
	}
	for (i = 0;i < len - 1;i++)
	{
		printf("%d ", a[i]);
	}
	printf("%d\n%d\n", a[i], cou);
}
int main() {
		int n;
		int i;
		int ar[100];
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d", &ar[i]);
		}
		araisanSort(ar, n);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
#define MAX (50)
int main(void){
    unsigned long A[MAX];
    int n;
    cin>>n;
    A[0]=1;
    A[1]=1;
    for(int i=2;i<=MAX;i++)A[i]=A[i-1]+A[i-2];
    
    cout<<A[n]<<endl;
    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string n;
        cin >> n;
            if(n.at(0) == '1'){
                n.at(0) = '9';
            }else{
                n.at(0) = '1';
            }
            if(n.at(1) == '1'){
                n.at(1) = '9';
            }else{
                n.at(1) = '1';
            }
            if(n.at(2) == '1'){
                n.at(2) = '9';
            }else{
                n.at(2) = '1';
            }
                cout << n << endl;

    return 0;}

Measured memory_bytes: 256
const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question('', (N) => {
  rl.question('', (nums) => {
    const arr = nums.split(' ');
    const divNums = arr.map((num) => 1/parseInt(num));
    const sum = divNums.reduce((accum, curVal) => accum + curVal);
    console.log(1/sum);
  });
});

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

const int MAXN = 1e5 + 10;
int N;
int A[MAXN];

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
	// freopen("./input.txt", "r", stdin);
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int ans = gcd(A[0], A[1]);
    for (int i = 2; i < N; ++i) {
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
    
 	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vp a;

int main(){
	cin>>m>>n;
	a=vp(n);
	for(int i=0;i<n;i++){
		int A,B;
		cin>>A>>B;
		a[i]={B,A};
	}
	sort(a.begin(),a.end());
	int res=0,I=0;
	for(int i=0;i<n;i++) if(I<=a[i].second){
		I=a[i].first;
		res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

func ZArray(s string) []int {
	n := len(s)
	z := make([]int, n)
	var l, r, k int
	for i := 0; i < len(s); i++ {
		if i > r {
			l = i
			r = i
			for r < n && s[r-l] == s[r] {
				r++
			}
			z[i] = r - l
			r--
		} else {
			k = i - l
			if z[k] < r-i+1 {
				z[i] = z[k]
			} else {
				l = i
				for r < n && s[r-l] == s[r] {
					r++
				}
				z[i] = r - l
				r--
			}
		}
	}
	return z
}

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	var ans int
	for i := 0; i < n; i++ {
		z := ZArray(s[i:n])
		for j := 0; j < n-i; j++ {
			if z[j] > j {
				z[j] = j
			}
			if ans < z[j] {
				ans = z[j]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7764
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: usize = read();
    let b: usize = read();
    let M: usize = 10_usize.pow(9) + 7;
    let max = pow(2, n, M);
    let mut ans =
        (max as i32 - 1 - combination(n, a, M) as i32 - combination(n, b, M) as i32) % M as i32;
    if ans < 0 {
        ans += M as i32;
    }
    println!("{}", ans);
}

#[test]
fn combi_works1() {
    assert_eq!(combination(6, 2, 17), 15);
}
#[test]
fn combi_works2() {
    assert_eq!(combination(6, 2, 13), 2);
}
#[test]
fn combi_works3() {
    assert_eq!(combination(6, 2, 11), 4);
}
fn combination(n: usize, k: usize, m: usize) -> usize {
    if n == 0 && k == 0 {
        return 1;
    }
    if n < k {
        return 0;
    }
    let k_fact = factorial(k, m);
    let mut ans = 1;
    for i in n - k + 1..n + 1 {
        ans *= i;
        ans %= m;
    }
    (ans * pow(k_fact, m - 2, m)) % m
}

#[test]
fn pow_works1() {
    assert_eq!(pow(5, 2, 100), 25);
}
#[test]
fn pow_works2() {
    assert_eq!(pow(5, 2, 20), 5);
}
fn pow(a: usize, b: usize, m: usize) -> usize {
    let mut ans = 1;
    let mut b = b;
    let mut a = a;
    while b != 0 {
        if b % 2 == 1 {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        b /= 2;
    }
    ans
}

#[test]
fn factorial_works1() {
    assert_eq!(factorial(4, 100), 24);
}
#[test]
fn factorial_works2() {
    assert_eq!(factorial(4, 10), 4);
}
fn factorial(a: usize, m: usize) -> usize {
    let mut ans = 1;
    for i in 1..a + 1 {
        ans *= i;
        ans %= m;
    }
    ans
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define TR(it,c) for( typeof(c.begin()) it = c.begin(); it != c.end(); ++it )
#define TRR(it,c) for( typeof(c.rbegin()) it = c.rbegin(); it != c.rend(); ++it
#define REP(i,a) for (int i = 0; i < (a); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)

#define DRI(a) int a; scanf("%d", &a);
#define DRII(a, b) int a, b; scanf("%d %d", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c);
#define RI(a) scanf("%d", &a);
#define RII(a, b) scanf("%d %d", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define MM(arr, num) memset((arr), (num), sizeof((arr)))
#define DEB(x) cerr << ">>> " << (#x) << " -> " << (x) << endl;
#define DEBA(x,n) cerr << (#x) << " "; deba((x),(n));
void deba(int * a, int n){ cerr << "| "; REP(i,n) cerr << a[i] << " "; cerr << "|" << endl;}


inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<30;
typedef long long ll;
typedef unsigned long long ull;
/*******************************************************/
ii a[123456];

int main() {

  DRI(n);
  REP(i,n){
    DRI(x);
    a[i] = MP(x,i%2);
  }
  sort(a,a+n);
  int b =0;
  REP(i,n){
    if(i%2 != a[i].ss)b++;
  }

  cout << b/2 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

using int64 = long long;

int main()
{
  int64 A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  double ret = 0;
  int64 aa = 100 * A, bb = 0;
  for(int64 a = 0; a <= 30; a += A) {
    for(int64 b = 0; b <= 30; b += B) {
      int64 water = 100 * a + 100 * b;
      for(int64 c = 0; c <= 3000; c += C) {
        for(int64 d = 0; d <= 3000; d += D) {
          int64 solid = c + d;
          if(water + solid > F) continue;
          if((a + b) * E < solid) continue;
          if(100 * solid > ret * (water + solid)) {
            ret = (100.0 * solid) / (water + solid);
            aa = water + solid;
            bb = solid;
          }
        }
      }
    }
  }

  cout << aa << " " << bb << endl;
}

Measured memory_bytes: 888
n=int(input())
a=list(map(int,input().split()))
minf=-10000000000000
x=[[0,0,0] for i in range(n)]
x[0]=[0,0,a[0]]
for i in range(n-1):
    if i%2==0:
        x[i+1]=[max(x[i][0],x[i][1]),x[i][2],x[i][0]+a[i+1]]
    else:
        x[i+1]=[max(x[i][1],x[i][2]),x[i][0]+a[i+1],x[i][1]+a[i+1]]
print(max(x[-1][1],x[-1][2]) if n%2==0 else max(x[-1][0],x[-1][1]))


Measured memory_bytes: 51856
import java.util.Scanner;
//import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        int N = sc.nextInt();
        int counter = 0;
        int [] in = new int [N];
        for (int i = 0; i < N; i++){
            in[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++){
            if(in[i] == i+1){
                counter++;
                if (i != N-1) {
                    int temp = in[i];
                    in[i] = in[i + 1];
                    in[i + 1] = temp;
                }
                else{
                    int temp = in[i];
                    in[i] = in[i-1];
                    in[i-1] = temp;
                }
            }
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 59068