akhauriyash/Code-Regression huggingface dataset:
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>


class BigInt
{
	public:
	int c;
	int a[100];
	BigInt()
	{
		c=1;
		memset(a,0,sizeof(a));
	}
	BigInt(int x)
	{
		if(!x)
		{
			c=1;
			memset(a,0,sizeof(a));
			return;
		}
		c=0;
		memset(a,0,sizeof(a));
		while(x!=0)
		{
			a[c++]=x%10000;
			x/=10000;
		}
	}
	BigInt operator+(const BigInt &b)const
	{
		BigInt result;
		result.c=max(c,b.c);
		for(int i=0;i<result.c;i++)
		{
			result.a[i]+=a[i]+b.a[i];
			result.a[i+1]=result.a[i]/10000;
			result.a[i]%=10000;
		}
		if(result.a[result.c]>0)
		{
			result.c++;
		}
		return result;
	}
	BigInt operator*(const BigInt &b)const
	{
		BigInt result;
		result.c=c+b.c;
		for(int i=0;i<c;i++)
		for(int j=0;j<b.c;j++)
		{
			result.a[i+j]+=a[i]*b.a[j];
		}
		int d=0;
		for(int i=0;i<result.c;i++)
		{
			result.a[i]+=d;
			d=result.a[i]/10000;
			result.a[i]%=10000;
		}
		if(d)result.a[result.c++]=d;
		while(result.a[result.c-1]==0)result.c--;
		return result;
	}
	BigInt operator-(const BigInt &b)const
	{
		BigInt result;
		result.c=max(c,b.c);
		for(int i=0;i<result.c;i++)
		{
			result.a[i]+=a[i]-b.a[i];
			if(result.a[i]<0)result.a[i+1]--,result.a[i]+=10000;
		}
		while(result.a[result.c-1]==0)result.c--;
		return result;
	}
	void print()const
	{
		printf("%d",a[c-1]);
		for(int i=c-2;i>=0;i--)
		{
			printf("%04d",a[i]);
		}
	}
};

const int maxn=105;
int n,sum;
int a[maxn];
bool f;

int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		if(a[i]%10!=0)f=true;
		sum+=a[i];
	}
	if(!f){
		cout<<0;
		return 0;
	}
	sort(a,a+n);
	if(sum%10!=0){
		cout<<sum<<endl;
		return 0;
	}
	rep(i,n){
		if((sum-a[i])%10!=0){
			cout<<sum-a[i]<<endl;
			return 0;
		}
	}
} 


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int N, M, Q; cin >> N >> M >> Q;
		if (N == 0) break;
		vector< vector<bool> > a(M, vector<bool>(N, true));
		string b(M, '0');
		while (Q--) {
			string S, B; cin >> S >> B;
			for (int j = 0; j < M; j++)
				for (int i = 0; i < N; i++)
					if ((B[j] == b[j] && S[i] == '1') || (B[j] != b[j] && S[i] == '0'))
						a[j][i] = false;
			b = B;
		}
		for (int j = 0; j < M; j++) {
			int cnt = 0;
			for (int i = 0; i < N; i++)
				cnt += a[j][i];
			if (cnt > 1) {
				cout << '?';
				continue;
			}
			for (int i = 0; i < N; i++)
				if (a[j][i])
					cout << (i < 10 ? (char)('0' + i) : (char)('A' + i - 10));
		}
		cout << endl;
	}
}

Measured memory_bytes: 1288
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int a;
long long int hasil; 

int main()
{
	
	hasil=1; 
	scanf("%lld",&a);
	for(int loop=a;loop>=1;loop--)
	{
		hasil=hasil*loop;
	}
	printf("%lld\n",hasil);
	return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  int r;
  cin >> r;
  cout << pow(r,2) << endl;  
}


Measured memory_bytes: 256
#include <iostream>

int main ()
{
  int k, n;
  std::cin >> k >> n;
  
  int m = 0;
  int a0;
  std::cin >> a0;
  int ab = a0;
  
  int a;
  for (int i = 1; i < n; i++)
  {
    std::cin >> a;
    int d = a - ab;
    ab = a;
	if (d > m)
    {
      m = d;
    }
  }
  int d = a0 + k - a;
  
  if (d > m)
  {
    m = d;
  }
  
  std::cout << k - m << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
from collections import deque
k = int(input())

q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for _ in range(k):
    ans = x = q.popleft()
    x0 = x % 10
    if x0 >= 1:
        q.append(x * 10 + x0 - 1)
    q.append(x * 10 + x0)
    if x0 <= 8:
        q.append(x * 10 + x0 + 1)

print(ans)


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

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

    string much_ptrn[4] = {"dream", "dreamer", "erase", "eraser"};

    reverse(S.begin(), S.end());
    for (int i=0; i<4; i++) {
        reverse(much_ptrn[i].begin(), much_ptrn[i].end());
    }

    bool can_solve = true;
    for (int i=0; i<S.size();) {
        bool is_much = false;
        for (int j=0; j<4; j++) {
            string pattern = much_ptrn[j];
            if (S.substr(i, pattern.size()) == pattern) {
                is_much = true;
                i += pattern.size();
            }
        }
        if (!is_much) {
            can_solve = false;
            break;
        }
    }
    if (can_solve) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    if(65 <= n && n <= 90){
        cout << 1 << endl;
    }else if(97 <= n && n <= 122){
        cout << 2 << endl;
    }else{
        cout << 0 << endl;
    }
}



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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int maxv  = (n-1)*(n-2)/2;
  if(maxv < k){
    cout << -1 << endl;
    return 0;
  }
  vector<p> res;
  for (int i = 1; i <= n-1; i++) {
    res.push_back({i, n});
  }

  int add = maxv - k;
  for (int i = 2; i <= n-1 ; i++) {
    for (int j = 1; j < i; j++) {
      if(add == 0) break;
      res.push_back({i, j});
      add--;
    }
  }

  cout << res.size() << endl;
  for(auto a : res){
    cout << a.first << ' ' << a.second << endl;
  }


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}
int main() {
    string s;
    cin >> s;
    int n = s.length();
    if (isPalindrome(s) && isPalindrome(s.substr(0, (n-1)/2)) && isPalindrome(s.substr((n+1)/2)))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

const int N=2000;
bool ab[100000], ac[100000], bc[100000];

bool match(char c1, char c2) {
    return ( c1=='?' || c2=='?' || c1==c2 );
}

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    int A=a.length();
    int B=b.length();
    int C=c.length();

    REP(i,A) REP(j,B) if(!match(a[i], b[j])) ab[i-j+50000]=true;
    REP(i,A) REP(j,C) if(!match(a[i], c[j])) ac[i-j+50000]=true;
    REP(i,B) REP(j,C) if(!match(b[i], c[j])) bc[i-j+50000]=true;

    int ans=3*N;
    for(int i=-2*N; i<=2*N; i++) {
        for(int j=-2*N; j<=2*N; j++) {
            if( !ab[i+50000] && !ac[j+50000] && !bc[j-i+50000]) {
                int l=min({0, i, j});
                int r=max({A, B+i, C+j});
                ans=min(ans, r-l);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n, p[45], t[45];

pii solve(){
    int dp[n][4];
    rep(i, n)rep(j, 4) dp[i][j] = mod;
    dp[0][0] = 0;
    rep(i, n-1){
        bool flag = false;
        rep(j, 4)if(dp[i][j] < mod){
            flag = true;
            if(j < 3 && t[i] + (j+1) * abs(p[i+1] - p[i]) <= t[i+1]){
                chmin(dp[i+1][j+1], dp[i][j] + abs(p[i+1] - p[i]));
            }
            if(t[i] + (j+1) * p[i] + p[i+1] <= t[i+1]){
                chmin(dp[i+1][1], dp[i][j] + p[i] + p[i+1]);
            }
        }
        if(!flag) return {0, i};
    }
    int ret = mod;
    rep(j, 4) chmin(ret, dp[n-1][j]);
    return {1, ret};
}

int main(){
    while(scanf("%d", &n) && n){
        p[0] = 0, t[0] = 0;
        For(i, 1, n+1) scanf("%d%d", &p[i], &t[i]);
        n += 2;
        p[n-1] = 0, t[n-1] = mod;
        auto ans = solve();
        printf("%s %d\n", (ans.fi ? "OK" : "NG"), ans.se);
    }
}


Measured memory_bytes: 3112
N = (input())
if int(N[-1]) == 2 or int(N[-1]) == 4 or int(N[-1]) == 5 or int(N[-1]) == 7 or int(N[-1]) == 9:
  print('hon')
elif int(N[-1]) == 0 or int(N[-1]) == 1 or int(N[-1]) == 6 or int(N[-1]) == 8:
    print('pon')
elif int(N[-1]) == 3:
    print('bon')

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
char  a[1001][1001];
int main()
{ ios_base::sync_with_stdio(0);
cin.tie(0);
    int n;
    cin>>n;
    if(n==1)
    {
        cout<<"Hello World";
    }
    else 
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b;
    }

}


Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0 + a[-1]
    for i in range(n-2):
        k = a[-((i+4)//2)]
        ans += k
    print(ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 32560
<?php
    fscanf(STDIN,'%d',$x);
    $b = 0;
    while(true){
        if(preg_match('/^[0-9]+$/', $a = pow($x + pow($b, 5), 1 / 5))){
            echo $a.' '.$b.PHP_EOL;
            break;
        }
        if (preg_match('/^[0-9]+$/', $a = pow($x - pow($b, 5), 1 / 5))) {
            echo $a . ' -' . $b . PHP_EOL;
            break;
        }
        ++$b;
    }
?>

Measured memory_bytes: 16908
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1

for i in range(1, N):
    if H[i-1] == H[i]:
        pass
    elif H[i-1] < H[i]:
        H[i] -= 1
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 14252
#include <stdio.h>
#define maxn 105
int a[5][5],b[maxn],vis[5][5];
int main(){
	int i,j,n,k,flag=0;
	for(i=1;i<=3;i++)
		for(j=1;j<=3;j++)
			scanf("%d",&a[i][j]);
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&b[i]);
	for(i=1;i<=n;i++)
		for(j=1;j<=3;j++)
			for(k=1;k<=3;k++)
				if(b[i]==a[j][k])vis[j][k]=1;
	for(i=1;i<=3;i++)
		if(vis[i][1]==1&&vis[i][2]==1&&vis[i][3]==1)flag=1;
	for(j=1;j<=3;j++)
		if(vis[1][j]==1&&vis[2][j]==1&&vis[3][j]==1)flag=1;
	if(vis[1][1]==1&&vis[2][2]==1&&vis[3][3]==1)flag=1;
	if(vis[1][3]==1&&vis[2][2]==1&&vis[3][1]==1)flag=1;
	if(flag)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    }
}

Measured memory_bytes: 62504
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n=N()
l=L()
sx=0
for i in l[2:]:
    sx^=i
if sx>l[0]+l[1]:
    print(-1)
    quit()
if (l[0]+l[1]-sx)%2==1:
    print(-1)
    quit()
if sx^l[0]^l[1]==0:
    print(0)
    quit()
x=(l[0]+l[1]-sx)//2
y=x
if x&sx>0:
    print(-1)
    quit()
if x>l[0]:
    print(-1)
    quit()
for i in range(45,-1,-1):
    if sx>>i&1:
        if l[0]>=(x+(1<<i)):
            x+=(1<<i)
if x==0:
    print(-1)
    quit()
print(l[0]-x)

Measured memory_bytes: 62192
import math
a, b, C = map(int, input().split())
sinC = math.sin(math.radians(C))
cosC = math.cos(math.radians(C))
S = 0.5 * a * b * sinC
L = a + b + math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * cosC))
h = b * sinC
print(S, L, h, sep='\r\n')


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    int N;
    cin>>N;
    vector<string>S(N);
    map<string,int>ma;
    int max=0;
    rep(i,N){
        cin>>S.at(i);
    }
    for(auto x:S){
        ma[x]++;
        if(ma.at(x)>max){
            max=ma.at(x);
        }
    }
    for(auto x:ma){
        if(max==x.second){
            cout<<x.first<<endl;
        }
    }

    return 0;
}

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

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long , long> pll;
typedef vector< pll > vll;
typedef set<ll> sl;
typedef map<string, int> msi;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define inf 0x3f3f3f3f
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))

const ll md = 1000000007;
//void mod(ll &x){if (x >= md) x -= md; if (x < 0) x += md;}

vector<ll> g[100000+1];
ll dp[100000+1];
bool vis[100000+1];

ll dfs(ll x){
	if(dp[x]!=-1)
		return dp[x];
		
	if(g[x].size()==0)
		return 0;
		
	for(auto i:g[x]){
		dp[x] = max(dp[x],1+dfs(i));
	}
	return dp[x];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m,x,y,ans=-1,i;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(i=0;i<m;i++){
		cin>>x>>y;
		g[x].pb(y);
	}
	for(i=1;i<=n;i++){
		ans = max(ans,dfs(i));
	}
//	for(i=0;i<=4;i++){
//		cout<<dp[i]<<" ";
//	}
//	cout<<"\n";
	cout<<ans;
    return 0;
}




Measured memory_bytes: 7936
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<int> a(N);
	REP(i, N) cin >> a[i];
	FOR(i, 0, N) {
		int j = i;
		while (j > 0 && a[j - 1] > a[j]) {
			int tmp = a[j];
			a[j] = a[j - 1];
			a[j - 1] = tmp;
			j--;
		}
		REP(k, N) {
			if (k < N - 1) cout << a[k] << " ";
			else cout << a[k] << "\n";
		}
	}


	return 0;
}


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

int dp[5005][5005];
int main(){
    int N;string S;cin>>N>>S;
    for(int i=N-1;i>=0;i--){
        for(int j=N-1;j>=0;j--)if(S.at(i)==S.at(j))dp[i][j]=dp[i+1][j+1]+1;    
    }
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i>=j)continue;
            int now=min(dp[i][j],j-i);
            ans=max(ans,now);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 98048
//树状数组，区间修改，单点查询 
#include<bits/stdc++.h>
using namespace std;

int n,m;
int a[100005],c[100005]; //对应原数组和树状数组

int lowbit(int x){
    return x&(-x);
}

void updata(int i,int k){    //在i位置加上k
    while(i <= n){
        c[i] += k;
        i += lowbit(i);
    }
}

int getsum(int i){        //求D[1 - i]的和，即A[i]值
    int res = 0;
    while(i > 0){
        res += c[i];
        i -= lowbit(i);
    }
    return res;
}

int main(){
	int cnt=0;
    cin>>n>>m;
    int x,y;
    for(int i=0;i<m;i++){
    	cin>>x>>y;
    	//[x,y]区间内加上k
	    updata(x,1);    //A[x] - A[x-1]增加k
	    updata(y+1,-1);        //A[y+1] - A[y]减少k
	}
	//查询i位置的值
	for(int i=1;i<=n;i++){
		if(getsum(i)==m)cnt++;
	}
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int CH = sc.nextInt()-1;
        int CW = sc.nextInt()-1;
        int DH = sc.nextInt()-1;
        int DW = sc.nextInt()-1;
        char[][] map = new char[H][W];
        for (int i = 0; i < H; i++) {
            String line = sc.next();
            for (int j = 0; j < W; j++) {
                map[i][j] = line.charAt(j);
            }
        }
        boolean[][] alr = new boolean[H][W];
        Deque<int[]> deq = new ArrayDeque<>();
        int[] walkH = {0,1,0,-1};
        int[] walkW = {1,0,-1,0};
        int[] warpH = {1,1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1};
        int[] warpW = {1,-1,1,-1,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,0,1,2,2};
        int[] point = {CH, CW, 0};
        deq.addFirst(point);
        while (!deq.isEmpty()) {
            int[] now = deq.pollFirst();
            if (now[0] == DH && now[1] == DW) {
                System.out.println(now[2]);
                return;
            }
            if (alr[now[0]][now[1]]) {
                continue;
            }
            alr[now[0]][now[1]] = true;
            for (int i = 0; i < walkH.length; i++) {
                int goH = now[0] + walkH[i];
                int goW = now[1] + walkW[i];
                if (-1 < goH && goH < H && -1 < goW && goW < W && map[goH][goW] != '#') {
                    int[] goWalk = {goH, goW, now[2]};
                    deq.addFirst(goWalk);
                }
            }
            for (int i = 0; i < warpH.length; i++) {
                int goH = now[0] + warpH[i];
                int goW = now[1] + warpW[i];
                if (-1 < goH && goH < H && -1 < goW && goW < W && map[goH][goW] != '#') {
                    int[] goWarp = {goH, goW, now[2]+1};
                    deq.addLast(goWarp);
                }
            }
        }
        System.out.println(-1);
    }
}


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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for(int h = 0; h < H; ++h) {
    for(int w = 0; w < W; ++w) {
      if(w < A) {
        if(h < B) {
          cout << 0;
        } else {
          cout << 1;
        }

      } else {
        if(h < B) {
          cout << 1;
        } else {
          cout << 0;
        }
      }
    }
    cout << endl;
  }

  return 0;
}

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

int const M = 1e9 + 7;
vector<int64_t> dp(5500000, -1);
string K; int D;

int add_mod(int x, int y, int M) {
	if ((x += y) >= M) x -= M;
	return x;
}

int count(size_t i, int total, bool upto) {
	if (i == K.size()) return total == 0;

	// 14 bits for index, 7 bits for total, 1 bit for upto
	int64_t key = (i << 9) + (total << 1) + upto;
	if (dp[key] >= 0) return dp[key];

	int sum = 0, leading = K[i] - '0';
	for (int digit = 0; digit <= (upto ? leading : 9); ++digit) {
		if (digit == leading)
			sum += count(i+1, (total+digit) % D, upto);
		else
			sum += count(i+1, (total+digit) % D, false);
		sum %= M;
	}

	return dp[key] = sum;
}

int main() {
	ios_base::sync_with_stdio(false);

	getline(cin, K);
	cin >> D;

	int answer = count(0, 0, true) - 1;
	if (answer < 0) answer += M;
	cout << answer << endl;
}


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

#define MAXN 300010
#define ll long long
#define mod 1000000007

using namespace std;

int n, maxk;
ll ans;
ll a[MAXN];
ll s[MAXN][70];

bool cmp(ll x, ll y) {
	return x < y;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	
	sort(a + 1, a + n + 1);
	
	for (int i = 1; i <= n; i++) {
		ll cc = a[i];
		int k = 0;
		while (cc) {
			s[i][k] += cc & 1;
			cc >>= 1;
			++k;
		}
		maxk = k - 1;
	}
	
	for (int i = 0; i <= 60; i++) {
		for (int j = 1; j <= n; j++) {
			s[j][i] += s[j - 1][i];
		}
	}
	
//	for (int j = maxk; j >= 0; j--) {
//		for (int i = 1; i <= n; i++) {
//			cout << s[i][j] << " ";
//		}
//		cout << endl;
//	}
	
//	cout << (1 << 0) << endl;
	for (int i = 1; i <= n; i++) {
//		cout << "turn: " << i << endl;
		ll cc = a[i];
		int k = 0;
		while (cc) {
			ll t = 1ll << k;
			t %= mod;
			if (cc & 1) {
				ans += 1ll * t * (n - i - s[n][k] + s[i][k]);
				ans %= mod;
			}
			else {
				ans += 1ll * t * (s[n][k] - s[i][k]);
				ans %= mod;
			}
			cc >>= 1;
			++k;
//			cout << ans << endl;
		}
		while (k <= maxk) {
			ll t = 1ll << k;
			t %= mod;
			ans += 1ll * t * (s[n][k] - s[i][k]);
			ans %= mod;
			k++;
		}
//		cout << ans << endl;
	}
	cout << ans % mod << endl;
	return 0;
}


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

int n, m, x, c[12], a[12][12], u[12], ans = 1e9;
bool b = 0;

int main() {
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}
	for (int idx = 0; idx < 1 << n; idx++) {
		int cost = 0;

		fill(u, u + m, 0);
		for (int i = 0, bit = idx; bit; i++, bit >>= 1) {
			if (bit & 1) {
				cost += c[i];
				for (int j = 0; j < m; j++)
					u[j] += a[i][j];
			}
		}
		bool flag = 1;
		for (int j = 0; j < m; j++)
			if (u[j] < x)
				flag = 0;
		if (flag) {
			b = 1;
			ans = min(ans, cost);
		}

	}
	cout << (b ? ans : -1) << endl;

}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var tmp = 25 - NextInt();
            Console.WriteLine("Christmas" + string.Join("", Enumerable.Repeat(" Eve", tmp)));
        }
    }

    class MyMath {
        public static long mod = 1000000007;

        public static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static List<long> Factor(long n) {
            var list = new List<long>();
            n = DivideToLimit(n, 2, list);
            n = DivideToLimit(n, 3, list);
            long sqrt = Sqrt(n);
            for (int i = 5; i <= n && i <= sqrt; i += 4) {
                n = DivideToLimit(n, i, list);
                i += 2;
                n = DivideToLimit(n, i, list);
            }
            if (n > 1) list.Add(n);
            return list;
        }

        public static long Sqrt(long n) {
            if (n < 0) return 0;
            long a = 0, tmp = 0, b = 0;
            for (int i = 62; i >= 0; i -= 2) {
                tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
                a = a << 1 | tmp;
                n -= (((b << 1) + 1) * tmp) << i;
                b = (b << 1) + tmp + tmp;
            }
            return a;
        }

        static long DivideToLimit(long divisor, long dividend, List<long> list) {
            while (divisor % dividend == 0) {
                list.Add(dividend);
                divisor /= dividend;
            }
            return divisor;
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
[m,d] = [int(i) for i in input().split()]
ans = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        da = str(j)
        if j < 10:
            d10 = 0
            d1 = da
        else:
            d10 = da[0]
            d1 = da[1]
        if int(d10) >= 2 and int(d1) >= 2 and int(d10) * int(d1) == i:
            ans += 1
print(ans)


Measured memory_bytes: 72848
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    d = collections.Counter(list(map(int, input().rstrip('\n').split())))
    m = int(input().rstrip('\n'))
    t = collections.Counter(list(map(int, input().rstrip('\n').split())))
    for k, v in t.items():
        if v > d[k]:
            print("NO")
            exit()
    print("YES")


if __name__ == '__main__':
    solve()


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    for(int i = 0; ;i++){
        c -= b;
        if(c < 1){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a < 1){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////

void Main() {
  ll A, B, C; cin >> A >> B >> C;
  if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
    cout << 0 << endl;
    return;
  }
  ll res;
  ll ma = max({A, B, C});
  if(A == ma) res = B * C;
  else if(B == ma) res = A * C;
  else res = A * B;
  cout << res << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 256
/*
 * Author       : YangDavid
 * Created Time : 2019年07月12日 星期五 11时55分29秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 111111;
int n, m, a[maxn], odd;
vector<int> b;

void output() {
    rep(i, m) printf("%d%c", a[i], " \n"[i == m]);
    int sz = b.size();
    printf("%d\n", sz);
    for(int i = 0; i < sz; ++i)
        printf("%d%c", b[i], " \n"[i == sz - 1]);
    exit(0);
}
void ins(int x) { if(x > 0) b.push_back(x); }

int main() {
    scanf("%d%d", &n, &m);
    rep(i, m) scanf("%d", &a[i]), odd += (a[i] & 1);
    if(odd > 2) { puts("Impossible"); return 0; }
    sort(a + 1, a + m + 1, [](int x, int y) { return (x&1)>(y&1); });

    if(m == 1) { ins(n - 1), ins(1); output(); }
    else if(m == 2) { ins(a[1] - 1), ins(a[2] + 1), output(); }

    if(a[2] & 1) swap(a[2], a[m]);
    for(int i = 1; i <= m; ++i) {
        if(i == 1) ins(a[i] - 1);
        else if(i == m) ins(a[i] + 1);
        else ins(a[i]);
    }
    output();

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


vector<vector<int>> field(15, vector<int>(1005));
vector<vector<int>> cumfield(15, vector<int>(1005));

int main(void) {
    int H, W, K; cin >> H >> W >> K;
    for (int h = 1; h <= H; h++) {
        string s; cin >> s;
        for (int w = 1; w <= W; w++) {
            field[h][w] = s[w-1] - '0';
        }
    }

    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            cumfield[h][w] = field[h][w] + cumfield[h][w-1];
        }
    }
    for (int w = 1; w <= W; w++) {
        for (int h = 1; h <= H; h++) {
            cumfield[h][w] = cumfield[h][w] + cumfield[h-1][w];
        }
    }

    // for (int h = 1; h <= H; h++) {
    //     for (int w = 1; w <= W; w++) {
    //         cout << cumfield[h][w] << " ";
    //     }
    //     cout << endl;
    // }

    int ans = 1000000;
    for (int i = 0; i < (1 << (H-1)); i++) {
        int cnt_cut = 0;
        vector<int> cut;
        cut.push_back(0);
        for (int j = 0; j < H-1; j++) {
            if (i & (1 << j)) {
                cnt_cut++;
                cut.push_back(j+1);
            }
        }
        cut.push_back(H);

        int pre_w = 0; 
        for (int w = 1; w <= W; w++) {
            int flag = 1;

            for (int j = 1; j < cut.size(); j++) {
                int white_sum = cumfield[cut[j]][w] - cumfield[cut[j-1]][w] - cumfield[cut[j]][pre_w] + cumfield[cut[j-1]][pre_w];
                if (white_sum > K) {
                    flag = 0;
                }
            }

            if (flag == 0) {
                if (w-1 == pre_w) {
                    continue;
                } else {
                    pre_w = w-1;
                    cnt_cut++;
                    w--;
                    flag = 1;
                }
            }
            if (w == W) {
                ans = min(ans, cnt_cut);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
def factorize(n):
    tmp = n

    for i in range(2, int(n**0.5)+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in fact:
                fact[i] = max(fact[i],cnt)
            else:
                fact[i] = cnt
         
    if tmp != 1:
        if tmp in fact:
            fact[tmp] = max(fact[tmp],1)
        else:
            fact[tmp] = 1
    
    if len(fact) == 0:
        if N in fact:
            fact[N] = max(fact[N],1)
        else:
            fact[N] = 1

def inv(n, p):
    return pow(n, p-2, p)
    
N = int(input())
A = list(map(int, input().split()))
p = 10**9+7

fact = {}

for i in range(N):
    if A[i] != 1:
        factorize(A[i])

lcm = 1

for key, val in fact.items():
    lcm *= pow(key, val, p)
    lcm %= p

inv_sum = 0

for i in range(N):
    inv_sum += inv(A[i], p)
    inv_sum %= p

print(lcm * inv_sum % p)

Measured memory_bytes: 79816
# import bisect
from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    h, w, n = map(int, open(0).read().split())

    print(math.ceil(n/max(h, w)))

if __name__ == '__main__':
    main()

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

int main(){
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define lli long long int
#define timesave ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const lli M = 1e6 + 5;
const lli MOD = 998244353;
lli cnt[M], A[M];

lli Big_Mod(lli base, lli power)
{
    if(power == 0) return 1;
    if(power == 1) return base;

    lli val = Big_Mod(base, power/2) % MOD;

    val = (val * val) % MOD;

    if(power%2) val = (val * base) % MOD;

    return val;
}

void solve(int t_case)
{
    lli n;
    cin >> n;

    lli arr[n+5];
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        cnt[arr[i]]++;
    }

    lli d = Big_Mod(2, MOD-2) % MOD;
 
    for(lli i = 1; i <= 1000000; i++){
        lli pref_sum = 0;

        for(lli j = i; j <= 1000000; j += i){
            A[i] += (pref_sum * ((cnt[j] * j)%MOD))%MOD;
            A[i] %= MOD;
            A[i] += (((((cnt[j] * (cnt[j]-1))%MOD) * ((j * j)%MOD))%MOD) * d);
            A[i] %= MOD;
            pref_sum += (cnt[j] * j)%MOD;
            pref_sum %= MOD;
        }
    }

    lli sum = 0;

    for(lli i = 1000000; i >= 1; i--){
        for(lli j = i+i; j <= 1000000; j += i){
            A[i] -= A[j];
            if(A[i] < 0) A[i] = (A[i]+MOD) % MOD;
        }
       
        sum += (A[i] * Big_Mod(i, MOD-2)) % MOD;
        sum %= MOD;
    }

    cout << sum << "\n";
}
 
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    timesave;

    int tc = 1, t_case = 1;
    //cin >> tc;
    while(tc--) solve(t_case++);
 
    return 0;
}


Measured memory_bytes: 20800
n,y=map(int,input().split())
for i in range(2*(10**3)+1):
  for j in range(4*(10**3)+1):
    res=y-i*10000-j*5000
    if res>=0 and res%1000==0 and res//1000+i+j==n :
      print(i,j,res//1000)
      exit()
print(-1,-1,-1)


Measured memory_bytes: 40684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mod=1000000007;
int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int gcd(int a, int b){return min(a,b)==0?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return min(a,b)==0 ?llmax(a,b):llgcd(llmin(a,b),llmax(a,b)%llmin(a,b));}

int main(void){
    long long n,m,ans;
    scanf("%lld%lld",&n,&m);
    ans=n*m/llgcd(n,m);
    char s[n+3],t[m+3];
    scanf("%s%s",s,t);
    for (long long i=0; i<llgcd(n,m); i++){
                                            //printf("%c %c\n",s[i*ans/m],t[i*ans/n]);
        if (s[i*ans/m]!=t[i*ans/n]){
            ans=-1;
            break;
        }
    }
    printf("%lld\n",ans);
	return 0 ;
}


Measured memory_bytes: 384
my_M = 0
kingaku = 0
A = []
B = []
x = 0
y = 0

N,M = map(int,input().split())
for i in range(N):
    x,y = map(int,input().split())
    A.append(x)
    B.append(y)
C = zip(A,B)
CC = sorted(C)

for j in range(N):
    my_M = my_M + CC[j][1]
    if my_M < M:
        kingaku = kingaku + CC[j][0]*CC[j][1]
    elif my_M == M:
        kingaku = kingaku +CC[j][0]*CC[j][1]
        break
    elif my_M > M:
        kingaku = kingaku +CC[j][0]*(M-(my_M-CC[j][1]))
        break

print(kingaku)
    


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

bool solve(string s, int n1, int n2) {
  bool check = true;
  n1--;
  n2--;
  for (int i = n1; i <= n2; i++) {
    if (s.at(i) != s.at(n2 - i)) {
      check = false;
      break;
    }
  }
  return check;
}

int main() {
  string s;
  cin >> s;
  int N = s.size();
  if (solve(s, 1, (N - 1) / 2) && solve(s, (N + 3) / 2, N))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        int h;
        cin >> h;
        if (h >= K)
        {
            count++;
        }
    }
    cout << count << endl;
}


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

int main(){
    string S;
    int N;
    int K;
    cin >> N >> S >> K;
    char remain = S.at(K - 1);
    for(int i=0; i < N; i++){
        if(S.at(i) != remain){
            S.at(i) = '*';
        }
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;while(t--)
ll zero=0;
ll one=1;
ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime(ll n){ll i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b)
{   if(a.second == b.second)
    return a.first < b.first;
    return (a.second < b.second);}

//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[]={0,1,1,1,0,-1,-1,-1,};
ll cc[]={1,1,0,-1,-1,-1,0,1};

signed main()
{
    bolt;
    string s,t;cin>>s>>t;
    ll dp[s.length()+5][t.length()+5];ms(dp,0);
    ll n=s.length(),m=t.length();
    forci(1,s.length()+1)
    {
        forcj(1,t.length()+1)
        {
            if(s[i-1]==t[j-1])  //matches
                dp[i][j]=dp[i-1][j-1]+1;
            else        //doesnt matches
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll val=dp[n][m];
    string ans;
    ll i=n,j=m;
    while(i&&j)
    {
        if(dp[i][j]!=max(dp[i-1][j],dp[i][j-1]))
        {
            ans.pb(s[i-1]);i--;j--;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
                i--;
            else
                j--;
        }
    }
    reverse(all(ans));
    cout<<ans;
}


Measured memory_bytes: 70784
#include <stdio.h>

int main(){

    int H,W;

    scanf("%d %d",&H,&W);

    while(!(H==0&&W==0)){
        for(int i=0;i<H;i++){
            for(int f=0;f<W;f++){
                if((i%2==0&&f%2==0)||(i%2==1&&f%2==1))
                    printf("#");
                else
                    printf(".");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d",&H,&W);
    }
}


Measured memory_bytes: 2036
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    vector<int> cnt(10000);
    string S;
    cin >> S;
    rep(i, S.size()) { cnt[S[i]]++; }
    int cnt2 = 0;
    rep(i, cnt.size()) {
        if (cnt[i] == 2) {
            cnt2++;
        } else if (cnt[i] != 0) {
            cout << "No";
            return 0;
        }
    }
    if (cnt2 == 2) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String n = sc.next();
		long ans = 0;
		
		if(n.length() != 1){
			boolean isAll9 = true;
			for(int i = 1; i < n.length() && isAll9; i++){
				if(n.charAt(i) != '9') isAll9 = false;
			}
			if(isAll9){
				ans = (n.charAt(0) - '0') + 9 * (n.length() - 1);
				System.out.println(ans);
				return;
			}
		}
		
		if(n.charAt(0) == '1'){
			ans = Math.max(9 * (n.length()-1), 1);
		}else{
			ans = Math.max((n.charAt(0) - '0') - 1 + 9 * (n.length()-1), (n.charAt(0) - '0'));
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    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;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    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();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23124