akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int sum = in.nextInt();
		int n = in.nextInt();
		int[] a = new int[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
			max = Math.max(max, a[i]);
		}
		if (max * 2 - 1 <= sum) {
			out.println(0);
		} else {
			out.println(2 * max - 1 - sum);
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 8276
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;


static class P
{
    static void Main()
    {
        var ny = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var y = ny[1];
        for (int i = 0; i <= ny[0]; i++)
        {
            for (int j = 0; j <= ny[0]; j++)
            {
                var remain = y - (i * 10000 + j * 5000);
                if (0 <= remain && remain % 1000 == 0 && remain / 1000 == (ny[0] - i - j))
                {
                    Console.WriteLine($"{i} {j} {remain / 1000}");
                    return;
                }
            }
        }
        Console.WriteLine("-1 -1 -1");
    }
}


Measured memory_bytes: 13396
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
    p_new = [p[i-1], p[i], p[i+1]]
    p_new.sort()
    if p[i] == p_new[1]:
        ans += 1
print(ans)


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

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

    int ans = 0;
    int l1 = S.size();
    for (int i = 0; i < l1; i += 2) {
        bool flag = true;
        S.pop_back();
        S.pop_back();

        int l2 = S.size() / 2;
        for (int j = 0; j < l2; j++) {
            if (S.at(j) != S.at(l2 + j)) {
                flag = false;
            }
        }

        if (flag) {
            ans = S.size();
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;

  cout << c-min(a-b, c) << endl;
}

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

#define ll long long
#define N 100005
#define mod 1000000007

vector<int> adj[2*N];

int main() 
{
    int n,m,i,a,b;
    
    cin>>n>>m;
    
    while(m--)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int flag=0;
    for(i=0;i<adj[1].size();i++)
    {
        int j=adj[1][i];
        
        for(int k=0;k<adj[j].size();k++)
        {
            if(adj[j][k]==n)
            {
                flag=1;break;
            }
        }
        
    }
    
    flag?puts("POSSIBLE"):puts("IMPOSSIBLE");
    
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0,maxii=-mx;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];


	cin>>n>>m>>k;

	vi v;

	f(i,0,n-1){
        cin>>res;
        v.pb(res);
	}
    if(n==1)cout<<abs(v[0]-k)<<endl,exit(0);
    cout<<max(abs(v[n-1]-k),abs(v[n-2]-v[n-1]))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int K = (1e5) + 5;
int memo[K];
int n, k, a[100];

int isW(int k) {
	if (k == 0) return 0;
	int &ret = memo[k];
	if (ret != -1) return ret;
	ret = 0;
	for (int i = 0; i < n; ++i) {
		if (k - a[i] >= 0) {
			if (!isW(k - a[i])) {
				return ret = 1;
			}
		}
	}
	return ret;
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	memset(memo, -1, sizeof memo);
	if (isW(k)) {
		printf("First\n");
	} else {
		printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
bool even(string x) {
	int len = x.length();
	if (len % 2)return false;
	string u = x.substr(0, len / 2);
	string v = x.substr(len / 2, len / 2);
	return u == v;
}
int main(){
	string s; cin >> s;
	s.pop_back();
	while (!even(s))s.pop_back();
	cout << s.length() << endl;
	return 0;
}

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

using namespace std;

int n=0;
int p[100];
int q[100];

int main()
{
	cin >> n;
	for (int i=0; i<n; i++)
		cin >> p[i];
	for (int i=0; i<n; i++)
		cin >> q[i];
	vector<int> v;
	for (int i=0; i<n; i++)
		v.push_back(i+1);	
	int a=0,b=0;
	int cnt=1;
	do
	{
		bool flag = true;
		for (int i=0; i<n; i++)
		{
			if (v[i]!=p[i]){
				flag = false;
				break;
			}
		}
		if (flag)
			a = cnt;

		flag = true;
		for (int i=0; i<n; i++)
		{
			if (v[i]!=q[i]){
				flag = false;
				break;
			}
		}
		if (flag)
			b = cnt;
		
		cnt++;
	}
	while (next_permutation(v.begin(), v.end()));
	cout << abs(a-b);
	return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

lint xor_(lint X) {
    lint ans = 0;
    for (lint d = 0; d < 60; d++) {
        lint T   = (1ll << d) * 2;
        lint cnt = ((X + 1) / T) * T / 2 + max(0ll, ((X + 1) % T) - T / 2);
        cnt %= 2;
        ans += (1ll << d) * cnt;
    }
    return ans;
}

int main() {
    lint A, B;
    cin >> A >> B;
    cout << (xor_(B) ^ xor_(A - 1)) << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1;i<=9;i++){
    int cand = i * 111;
    if(n<=cand) {
      ans = cand;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]
A1 = c[1][0] - c[0][0]
A2 = c[2][0] - c[1][0]
B1 = c[0][1] - c[0][0]
B2 = c[0][2] - c[0][1]
if c[1][1] == A1 + B1 + c[0][0] and c[1][2] == A1 + B1 + B2 + c[0][0] and c[2][1] == A1 + A2 + B1 + c[0][0] and c[2][2] == A1 + A2 + B1 + B2 + c[0][0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9164
/*
54ms	4992KB

*/
#include <cstdio>
#include <algorithm>
typedef long long LL;
const int N=505,M=8100;

int P[1005];
LL A[N][N];

void Init()
{
	static bool notP[M];
	for(int cnt=0,i=2; cnt<1000; ++i)
	{
		if(!notP[i]) P[++cnt]=i;
		for(int j=1,v; j<=cnt&&(v=i*P[j])<M; ++j)
		{
			notP[v]=1;
			if(!(i%P[j])) break;
		}
	}
}
inline LL LCM(LL x,LL y)//longlong
{
	return x/std::__gcd(x,y)*y;
}

int main()
{
	Init();
	int n; scanf("%d",&n);
	if(n==2) return printf("4 7\n23 10\n"),0;
	for(int i=0; i<=n+1; ++i) A[0][i]=1, A[n+1][i]=1, A[i][n+1]=A[i][0]=1;
	for(int i=1; i<=n; ++i)
		for(int j=i&1?1:2; j<=n; j+=2)
			/*if(!(i+j&1))*/ A[i][j]=P[i+j>>1]*P[(i-j+n+1)/2+n];
	for(int i=1; i<=n; ++i)
		for(int j=i&1?2:1; j<=n; j+=2)
			/*if(i+j&1)*/ A[i][j]=LCM(LCM(A[i-1][j],A[i][j-1]),LCM(A[i+1][j],A[i][j+1]))+1;
	for(int i=1; i<=n; ++i,putchar('\n'))
		for(int j=1; j<=n; ++j) printf("%lld ",A[i][j]);

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(void) {
	int a, b, c, cnt = 0, i;
	cin >> a >> b >> c;
	for (i = a; i <= b; i++) {
		if (c % i == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
		return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<math.h>

int main(void){

  int N,i;
  
  
  scanf("%d",&N);
    int array[N];
 

    
  for(i=0;i<N;i++){
    scanf("%d",&array[i]);
  }

  
  printf("%d\n",judge(array,N));
  
  return 0;  
}

int judge(int a[],int N){
  int count=0,count1=0;
  int i,j;




  for(i=0;i<N;i++){
    count=0;

    for(j=2;j<=sqrt(a[i]);j++){
      
      
      if(a[i]%j==0){
	count=count+1;
	break;
    }

   }

    if(count==0){count1++;}
  }

  return count1;  
}



Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	string s;
	cin >> s;
	rep(i,3){
		if((int)s[i]==(int)s[i+1]){
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
}

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

int comp(const void *a,const void *b){
	long long int da = *(long long int*)a;
    long long int db = *(long long int*)b;
    if(da > db)
    	return -1;
    else if(da == db)
    	return 0;
    else return 1;
}

int main()
{
	int a,b,c;
	long long x[1001],y[1001],z[1001];
	long long k1,k,sum = 0;
	long long s[300000];
	memset(x,0,1001);
	memset(y,0,1001);
	memset(z,0,1001);
	
	scanf("%d %d %d %lld",&a,&b,&c,&k);
	for(int i = 0;i < a;i++)
		scanf("%lld",&x[i]);
	for(int i = 0;i < b;i++)
		scanf("%lld",&y[i]);
	for(int i = 0;i < c;i++)
		scanf("%lld",&z[i]);
	
	qsort(x,a,sizeof(x[0]),comp);
	qsort(y,b,sizeof(y[0]),comp);
	qsort(z,c,sizeof(z[0]),comp);
	
	for(int i = 0;i < a;i++){
		for(int j = 0;j < b;j++){
			for(int g = 0;g < c;g++){
				if((i+1)*(j+1)*(g+1) <= k){
					s[sum] = x[i] + y[j] + z[g];
					sum++;
				}
			}
		}
	}
	
	qsort(s,sum,sizeof(s[0]),comp);
	for(int i = 0;i < k;i++)
		printf("%lld\n",s[i]);
	return 0;
}

Measured memory_bytes: 3324
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		String S = sc.next();
		String T = sc.next();

		StringBuilder sb = new StringBuilder();
		char[] q = T.toCharArray();
		for (char c : q) {
			sb.append('[');
			sb.append(c);
			sb.append("\\\\");
			sb.append('?');
			sb.append(']');
		}
		Pattern pattern = Pattern.compile("(?s)(.*)" + sb);
		Matcher matcher = pattern.matcher(S);
		if (matcher.find()) {
			String result = matcher.replaceFirst("$1" + T);
			System.out.println(result.replaceAll("\\?", "a"));
		} else {
			System.out.println("UNRESTORABLE");
		}

	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

int main() {
  std::string str;

  while(std::cin >> str) {
    if(str == "0") break;
    int sum = 0;
    for(int i = 0; str[i] != '\0'; ++i) {
      sum += str[i] - '0';
    }
    std::cout << sum << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)



signed main()
{
	int n;
	int tmp;
	int max = 0;
	int min = 1001;
	cin >> n;

	REP(i, n) {
		cin >> tmp;
		if (max < tmp) max = tmp;
		if (min > tmp) min = tmp;
	}
	cout << max - min << endl;
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int n, k;
		cin >> n >> k;
		vector<int> a(n + 1, 0);
		for (int i = 0; i < n; i++) cin >> a[i];
		while (k--) {
			bool change = true;
			vector<int> b(n + 1, 0);
			for (int i = 0; i < n; i++) {
				b[max(i - a[i], 0)] += 1;

				b[min(i + a[i] + 1, n)] -= 1;
			}
			for (int i = 1; i < n; i++) b[i] += b[i - 1];
			if (a == b) break;
			swap(a, b);
		}
		for (int i = 0; i < n; i++) cout << a[i] << " ";
		cout << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 4952
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<ll> sum(N + 1);
    sum[0] = 0;
    for(int i = 1; i <= N; i++){
        sum[i] = sum[i - 1] + a[i - 1];
    }
    ll ans = INF;
    for(int i = 1; i <= N - 1; i++){
        ll arai = sum[N] - sum[i];
        ans = min(ans, abs(arai - sum[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5584
package main

import (
  "fmt"
)

func reversedString(s string) string {
  r := []rune(s)
  n := len(r)
  for i := 0; i < n / 2; i++ {
    r[i], r[n-1-i] = r[n-i-1], r[i]
  }
  return string(r)
}

func main() {
  var s, t string; fmt.Scan(&s, &t)
  ans := "NO"
  if s == reversedString(t) {ans = "YES"}
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
int main() {
	string s;
	cin >> s;
	char p = s[0];
	for (size_t i = 1; i < s.length(); i++) {
		if (s[i] == p) {
			cout << "Bad";
			return 0;
		}
		p = s[i];
	}
	cout << "Good";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100500;
const int mod = 1e9 + 7;
int a[3];
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 0, u; i < n; ++i) {
		cin >> u;
		if (u % 4 == 0) {
			a[2]++;
		} else {
			a[!(u & 1)]++;
		}
	}
	if (a[0] <= a[2]) {
		if (!a[2] && a[1] == 1) {
			puts("No");
		} else {
			puts("Yes");
		}
	} else {
		if (!a[1] && a[2] + 1 == a[0]) {
			puts("Yes");
		} else {
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    L = []
    for w in line.split():
        if 'apple' in w:
            L.append(w.replace('apple', 'peach'))
        elif 'peach' in w:
            L.append(w.replace('peach', 'apple'))
        else:
            L.append(w)
    print(*L)

Measured memory_bytes: 4252
#include <iostream>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long LL;
LL a[1000];
int opa[2000],opb[2000];

int main()
{
    int n,mx=0,f=1,pos=1,cnt=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        if(abs(a[i])>mx){
            pos=i;
            mx=abs(a[i]);
        }
    }

    for(int i=1;i<=n;i++){
        if(i!=pos&&1LL*a[i]*a[pos]<0){
            a[i]+=a[pos];
            opa[cnt]=pos;
            opb[cnt]=i;
            cnt++;
        }
    }
    if(a[pos]>0){
        for(int i=1;i<n;i++){
            a[i+1]+=a[i];
            opa[cnt]=i;
            opb[cnt]=i+1;
            cnt++;
        }
    }else{
        for(int i=n;i>1;i--){
            a[i-1]+=a[i];
            opa[cnt]=i;
            opb[cnt]=i-1;
            cnt++;
        }
    }

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

    for(int i=0;i<cnt;i++){
        printf("%d %d\n",opa[i],opb[i]);
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>

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

int main() {
	int N;
	char S[123];
	char s[123][123];

	scanf("%d", &N);
	scanf("%s", S);
	rep(i, N) scanf("%s", s[i]);

	int Slen = strlen(S);
	int c = 0;
	rep(i, N) {
		int len = strlen(s[i]);
		bool counted = false;
		rep(space, 60) {
			rep(start, 100) {
				if (len < start + (space + 1) * (Slen - 1) + 1) break;
				bool isright = true;
				rep(it, Slen) {
					if (S[it] != s[i][start + it*(space + 1)]) isright = false;
				}
				if (isright) {
					c++;
					counted = true;
					break;
				}
			}
			if (counted) break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 2716
while True:
    try:
        lst = list(map(int, input().split()))
        a, b = lst[0], lst[1]
        while b != 0:
            a, b = b, a % b
            
        c = lst[0]* lst[1]/ a
        print('{:.0f}'.format(a), end = " ")
        print('{:.0f}'.format(c))

    except:
        break


Measured memory_bytes: 5616
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val p = new Array[Int](n + 1);
        for (i <- (0 until n)) {
            val line = readLine.split(" ").map(_.toInt);
            p(i) = line(0);
            if (i == n - 1) p(n) = line(1);
        }
        println(mcm(p));
    }

    def mcm(p: Array[Int]): Int = {
        val len = p.length;
        val arr = Array.ofDim[Int](len, len).map( e => e.map( f => -1));
        (0 until len).foreach { i => arr(i)(i) = 0}
        def go(first: Int, last: Int): Int = {
            if (arr(first)(last) != -1) {
                return arr(first)(last);
            } else {
                val minimum = (first until last).map { i =>
                    val left = go(first, i);
                    val right = go(i + 1, last);
                    // 左辺の行列の行数(最初の行列の列数) * 左辺の行列の列数 *  右辺の行列の列数
                    val curr = p(first - 1) * p(i) * p(last);
                    left + right + curr;
                }.min
                arr(first)(last) = minimum;
                minimum;
            }
        }
        go(1, len - 1);
    }
}


Measured memory_bytes: 56500
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let mut data:Vec<i64> = read_vec();
    data.sort();
    print!("{}",data.remove(0));
    
    for x in &data {
        print!(" {}",x);
    }
    println!("");
}



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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  multiset<int, greater<int>> s;
  rep(i, n) {
    auto it = s.upper_bound(a[i]);
    if (it != s.end()) {
      s.erase(it);
    }
    s.insert(a[i]);
  }
  out(s.size());
}


Measured memory_bytes: 8200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define all(arr) arr.begin(),arr.end()
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif 
#define unique(a)       sort((a).begin(), a.end()), (a).erase(unique((a).begin(), (a).end()),(a).end())
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);}
const int MOD = 1000000007;
using PII = pair<int, int>;
using LL = long long int;

template <typename T>
void input(vector<T> &arr,LL n) {
	T temp;
	for(LL i=0;i<n;i++) cin>>temp, arr.push_back(temp);
}

template <typename T>
void output(vector<T> arr) {
	T temp;
	for(auto x:arr) cout<<x<<" ";
	cout<<endl;
}


template <typename T>
void input_set(set<T> &arr,LL n) {
	T temp;
	for(LL i=0;i<n;i++) cin>>temp, arr.insert(temp);
}


LL power(LL num,LL base) {
	if(base==0)
		return 1;

	if(base%2)
		return (num%MOD*power(num,base-1)%MOD)%MOD;
	else {
		LL x=power(num,base/2);
		x=(x*x)%MOD;
		return x;
	}
}
int cnt[4];
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	memset(cnt, 0, sizeof cnt);
	int cases;
	cin>>cases;
	while(cases--) {
		string st;
		cin>>st;
		if (st == "AC") {
				cnt[0]++;
		} else if (st == "WA") {
				cnt[1]++;
		} else if (st == "TLE") {
				cnt[2]++;
		} else {
				cnt[3]++;
		}
	}
	cout<<"AC x "<<cnt[0]<<endl;
	cout<<"WA x "<<cnt[1]<<endl;
	cout<<"TLE x "<<cnt[2]<<endl;
	cout<<"RE x "<<cnt[3]<<endl;
}

//things to remember:
//1. int array must be memsetted before use



Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const int INF=1<<30,MOD=1000000007;
const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int c1=0,c2=0,c3=0;
    REP(i,n){
        int p;
        cin>>p;
        if(p>b)c3++;
        else if(p>a)c2++;
        else c1++;
    }
    cout<<min({c1,c2,c3})<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    char c[h+2][w+2];
    rep(i,h){
        rep(j,w){
            cin >> c[i+1][j+1];
        }
    }
    int count = 0;
    rep(i,h){
        rep(j,w){
            if (c[i+1][j+1]=='#' && c[i+1][j]!= '#' && c[i][j+1] != '#'&& c[i+2][j+1] != '#'&& c[i+1][j+2]!= '#') count += 1;
        }
    }
    if (count==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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

int main()
{
	int x;	cin >> x;
	bool prime = false;

	while (true)
	{
		
		int cnt = 0;
		for (int i = 2; i < x; i++) {
			if (x % i == 0) cnt++;
		}

		if (cnt == 0) break;
		x++;
	}
	
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int N,A[60],B[60],C[60],i,sum=0;
    scanf("%d", &N);
    for(i=0;i<N;i++){
        scanf("%d", &A[i]);
    }
    for(i=0;i<N;i++){
        scanf("%d", &B[i]);
    }
    for(i=0;i<N-1;i++){
        scanf("%d", &C[i]);
    }
    for(i=0,sum=0;i<N;i++){
        if((A[i]-A[i-1])==1&&A[i]!=1){
            sum=sum+B[A[i]-1]+C[A[i]-2];
        }
        else{
            sum=sum+B[A[i]-1];
        }
    }
    printf("%d", sum);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod = 1000000007;

int main(){
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int64_t fact=1;
  int64_t ans=0;
  for(int i=0;i<60;i++){
    int64_t cnt0=0,cnt1=0;
    for(int i=0;i<N;i++){
      if(A[i]%2==1){cnt1++;}
      else{cnt0++;}
      A[i]/=2;
    }
    (ans+=cnt0*cnt1%mod*fact%mod)%=mod;
    (fact*=2)%=mod;
  }
  cout<<ans<<endl;
  return 0;                       
}

Measured memory_bytes: 5508
#include<stdio.h>
#define MAX 1001


int max(int a,int b){
if(a>b){return a;}
else{return b;}

}




int func(int V[],int W[],int n,int w){
int dp[n+1][w+1];
int i,j;
int M;

for(i=0;i<n+1;i++){/*初期化*/
 for(j=0;j<w+1;j++){
  dp[i][j]=-1;
 }
}

dp[0][0]=0;

for(i=1;i<=n;i++){

 for(j=0;j<=w;j++){

  if(dp[i-1][j]!=-1){

   if(dp[i-1][j]>dp[i][j])dp[i][j]=dp[i-1][j];/*おろす*/

   if(j+W[i]<=w){
    if(dp[i-1][j]+V[i]>dp[i][j+W[i]]){dp[i][j+W[i]]=dp[i-1][j]+V[i];}
    else{dp[i][j+W[i]]=dp[i-1][j+W[i]];}
   }

  }

 }

}
/*
for(i=0;i<=n;i++){
 for(j=0;j<=w;j++){
  printf("%d ",dp[i][j]);
 }
 printf("\n");
*/




M=-10;
for(i=0;i<=w;i++)M=max(dp[n][i],M);

return M;
}


int main(){
int n,i,x;
int w;
int V[MAX];
int W[MAX];

scanf("%d %d",&n,&w);
for(i=1;i<=n;i++)scanf("%d %d",&V[i],&W[i]);

x=func(V,W,n,w);

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

return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> n;

    int cnt = 0;
    REP2(i, 1, n+1) {
        if (i % 2 == 0) continue;
        int c = 0;
        REP2(j, 1, i+1) {
            if (i % j == 0) c++;
        }
        if (c == 8) cnt++;
    }

    std::cout << cnt << '\n';

    return 0;
}


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

using namespace std;

int a, b, c;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> a >> b >> c;
	if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, i, a, b, c, tmp;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    if(a > c) {
      tmp = a;
      a = c;
      c = tmp;
    }
    if(b > c) {
      tmp = b;
      b = c;
      c = tmp;
    }

    if(a*a + b*b == c*c) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580
using System;

public class Test
{
	public static void Main()
	{
            string[] data = Console.ReadLine().Split();
            int[] num= new int[3]; 
            for(int i=0; i <= 2; i++)
            {
                num[i]=int.Parse(data[i]);
            }
            Array.Sort(num);
            Console.WriteLine("{0} {1} {2}",num[0],num[1],num[2]);
	}
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


// x = |x - K|

int main() {
    i64 N, K; cin >> N >> K;
    if (N % K == 0) {
        cout << 0 << endl;
        return 0;
    }

    i64 div = N / K;
    i64 ans = N;
    chmin(ans, abs(N - div * K));
    chmin(ans, abs(N - (div + 1) * K));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int ary[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

int main() {
	int x, y;
	std::cin >> x >> y;

	if (ary[x - 1] == ary[y - 1]) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string s;
	map<vector<int>, int> anagrams;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		vector<int> occs(26);
		for (int j = 0; j < (int) s.size(); ++j) {
			++occs[s[j] - 'a'];
		}

		++anagrams[occs];
	} 	

	long long pairs = 0;
	for (auto it = anagrams.begin(); it != anagrams.end(); ++it) {
		pairs += (long long) (it->second) * (it->second - 1) / 2;
	}

	cout << pairs << "\n";

	return 0;

}

Measured memory_bytes: 19072
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



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

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        Console.WriteLine(S.Replace("2017", "2018"));
    }
    
}




class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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



Measured memory_bytes: 11092
#include<stdio.h>

int main(){
	int a[4], b[4], hit = 0, blow = 0, i, j;
	while(scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		for(i = 0; i < 4; i++){
			scanf("%d", &b[i]);
		}
		for(i = 0; i < 4; i++){
			for(j = 0; j < 4; j++){
				if(a[i] == b[j]){
					if(i == j){
						hit++;
						continue;
					}
					blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
		hit = 0;
		blow = 0;
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int a, b;
	string s;
	cin >> a >> s >> b;
	string ans = "";
	rep(i, 0, a) {
		if (s[b - 1] == s[i])ans += s[i];
		else ans += "*";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int sum = 0;
    int count = 0;

    int val[4];

    for(int i=0; i<4; i++){
        scanf("%d",&val[i]);
    }

    for(int c_500=0; c_500<=val[0]; c_500++){
        sum = 0;
        for(int c_100=0; c_100<=val[1]; c_100++){

            for(int c_50=0; c_50<=val[2]; c_50++){
                
                if(val[3] == 500*(c_500) + 100*(c_100)+ 50*(c_50) ){
                    count++;
                }

            }

        }

    }

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

    return 0;
}

Measured memory_bytes: 128
N=int(input())
A=[int(a) for a in input().split()]
dp=[-1 for _ in range(N)]
dp[0]=1000
for i in range(1,N):
    tmp=dp[i-1]
    for j in range(i):
        K=dp[j]//A[j]
        res=dp[j]-K*A[j]
        tmp=max(tmp,res+A[i]*K)
    dp[i]=tmp
print(dp[-1])

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

using namespace std;
#define         MAX         2*10000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)
#define         inf         10000000


int main() {

    //input;
    //output;


    int a,b,c,d;
    cin>>a>>b>>c>>d;


    while(1){
        c = c-b;
        if(c<=0){
           cout<<"Yes"<<endl;
           return 0;
        }
        a = a-d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }

    }




    return 0;
}


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

using namespace std;

int N;
vector<int> arr;

int cnt_by_4;
int cnt_by_2;
int cnt_for_other;

int main() {

    cin >> N;

    int num;
    for (int i = 0; i < N; i++) {
        cin >> num;
        if (num % 4 == 0) {
            ++cnt_by_4;
        } else if (num % 2 == 0) {
            ++cnt_by_2;
        } else {
            ++cnt_for_other;
        }
    }

    if (cnt_by_2 > 0) {
        ++cnt_for_other;
    }

    if (cnt_by_4+1 >= cnt_for_other) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        // n円
        int n = Integer.parseInt(sc.next());
        // 1円玉の枚数
        int a = Integer.parseInt(sc.next());
        // n円を500円で割った余りが、1円玉の枚数以下ならyes
        if(n % 500 <= a){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n; cin >> n;
  int a; map<int,int> mp;
  rep(i,n){
    cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto p:mp){
    if(p.first > p.second) ans += p.second;
    else if(p.first < p.second) ans += p.second - p.first;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4736
(declaim (optimize (speed 3) (debug 0) (safety 0)))
(format t "~A~%"
        (let ((a (read))
              (b (read))
              (c (read)))
          (min (* (- (ceiling (/ a 2)) (floor (/ a 2))) b c)
               (* (- (ceiling (/ b 2)) (floor (/ b 2))) c a)
               (* (- (ceiling (/ c 2)) (floor (/ c 2))) a b))))

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

using namespace std;

int main()
{
    double a, b, h, m;
    double PI = acos(-1);
    cin >> a >> b >> h >> m;
    double alpha = (h * 60 + m) / 720 * (PI * 2);
    double beta = m / 60 * (PI * 2);
    double theta = alpha - beta;
    double answer = sqrt(a * a + b * b - 2.0 * a * b * cos(theta));
    cout << fixed << setprecision(15) << answer << endl;
} 

Measured memory_bytes: 4196
#include<cstdio>
using namespace std;
const int M=1e5+5,P=1e9+7;
char s[M];
int cnt[30];
int main(){
	int n;
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++){
		cnt[s[i]-'a']++;
	}
	int ans=1;
	for(int i=0;i<=25;i++)
		ans=1ll*ans*(cnt[i]+1)%P;
	printf("%d\n",((ans-1)%P+P)%P);
	return 0;
}

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

int main() {
	int A,B;
	cin >> A>>B;
	int ans = 0;
	for (int n = 0;n<2; ++n) {
		if (A > B) {
			ans += A;
			--A;
		}
		else {
			ans += B;
			--B;
		}
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>


int main(void) {
    char buf[10];
    int t[1001][2] = {}, month = 0, cid, day, i;

    while (gets(buf) != NULL) {
        if (sscanf(buf, "%d,%d", &cid, &day) != 2) {
            month++;
            continue;
        }
        t[cid][month]++;
    }

    for (i = 0; i < 1001; i++) {
        if (t[i][0] && t[i][1]) {
            printf("%d %d\n", i, t[i][0] + t[i][1]);
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    if(n%10 ==2 ||n%10 ==4 ||n%10 ==5 ||n%10 ==7||n%10 ==9){
        cout << "hon";
    }
    else if(n%10 ==0 ||n%10 ==1 ||n%10 ==6 ||n%10 ==8){
        cout <<"pon";
    }
    else{
        cout << "bon";
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int M;
	cin >> M;

	cout << 24 + (24 - M) << endl;
}

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define piii pair<int,pii>
#define pb push_back
#define mxn 200005

int main(){
sp;
int n,h,w,ans=0,x,y;
cin>>n>>h>>w;
while(n--){
    cin>>x>>y;
    if(x>=h&&y>=w)++ans;
}
cout<<ans;

return 0;}


Measured memory_bytes: 256