akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls rt<<1
#define rs rt<<1|1
const int maxn=1e3+10;
const int N=2e5+10;
using namespace std;
int id(int l,int r){return l+r|l!=r;}
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,ret=1e9,dis[][2]={0,1,1,0,0,-1,-1,0},vis[maxn][maxn];
char a[maxn][maxn];
bool ok(int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
void bfs(int sx,int sy)
{
    queue<pii>pq;
    pq.push(mp(sx,sy));
    vis[sx][sy]=1;
    while(!pq.empty())
    {
        pii x=pq.front();
        pq.pop();
        if(vis[x.fi][x.se]==k+1)return;
        for(int i=0;i<4;i++)
        {
            int tx=x.fi+dis[i][0],ty=x.se+dis[i][1];
            if(ok(tx,ty)&&!vis[tx][ty]&&a[tx][ty]!='#')
            {
                pq.push(mp(tx,ty));
                vis[tx][ty]=vis[x.fi][x.se]+1;
            }
        }
    }
}
int main()
{
    int i,j;
    scanf("%d%d%d",&n,&m,&k);
    rep(i,0,n-1)scanf("%s",a[i]);
    rep(i,0,n-1)rep(j,0,m-1)if(a[i][j]=='S')bfs(i,j);
    rep(i,0,n-1)rep(j,0,m-1)
    {
        if(vis[i][j])
        {
            ret=min(ret,(i+k-1)/k+1);
            ret=min(ret,(j+k-1)/k+1);
            ret=min(ret,(n-i-1+k-1)/k+1);
            ret=min(ret,(m-j-1+k-1)/k+1);
        }
    }
    printf("%d\n",ret);
    return 0;
}


Measured memory_bytes: 4224
using System;

namespace ITP1_9
{
    class Program
    {
        static void Main()
        {
            var w = Console.ReadLine();
            var c = 0;
            for(;;)
            {
                var t = Console.ReadLine();
                if (t == "END_OF_TEXT") break;
                foreach(var u in t.ToLower().Split())
                    if (w == u) c++;
            }
            Console.Write("{0}\n", c);
        }
    }
}

Measured memory_bytes: 9244
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
static const int INF = 1e9;
static const int SIZE = 101;
typedef pair<int, int> P;

int d[SIZE];
vector<int> G[SIZE];

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			G[u].push_back(v);
		}
	}
	for (int i = 0; i < SIZE; ++i)
	{
		d[i] = INF;
	}
	d[1] = 0;
	queue<P> que;
	que.push(P(0, 1));
	while (!que.empty())
	{
		P p = que.front();
		que.pop();
		int v = p.second;
		for (int i = 0; i < G[v].size(); ++i)
		{
			int to = G[v][i];
			if (d[to] > p.first + 1)
			{
				d[to] = p.first + 1;
				que.push(P(d[to], to));
			}
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		if (d[i] == INF)
		{
			cout << i << " " << -1 << endl;
		}
		else
		{
			cout << i << " " << d[i] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  int n;
  string s,sa,sb;
  cin >> n >> s;
  sa = s.substr(n/2);
  if(sa+sa == s)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;
	cin>>n;
	int ans=0;
	FOR(a,1,1e6)FOR(b,1,1e6){
		int c=n-a*b;
		if(c<=0)break;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
int f(int a, int b, char op) {
    if (op == '+') return a + b;
    else return a - b;
}
void solve(){
    string s;
    cin >> s;
    for (char o1 : {'+', '-'}) {
        for (char o2 : {'+', '-'}) {
            for (char o3 : {'+', '-'}) {
                int sum = s[0] - '0';
                sum = f(sum, s[1] - '0', o1);
                sum = f(sum, s[2] - '0', o2);
                sum = f(sum, s[3] - '0', o3);
                if (sum == 7) {
                    cout << s[0] << o1 << s[1] << o2 << s[2] << o3 << s[3] << "=7";
                    return;
                }
            }
        }
    }
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;

int main(){
    iosetup;
    int H, N; cin >> H >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];

    ll sum = accumulate(ALL(A), 0LL);
    if(sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int number = input.nextInt();
        StringBuilder result = new StringBuilder();
        result.insert(0, String.valueOf(input.nextInt()));
        for(int i = 1; i < number; i++){
            int temp = input.nextInt();
            result.insert(0, String.valueOf(temp) + " ");
        }
        System.out.println(result);
    }
}



Measured memory_bytes: 26388
#include <bits/stdc++.h>
using namespace  std;
const int MAXn = 2e5 + 10;

int cnt[MAXn], ar[2 * MAXn + 10], ar2[MAXn], n, m, x;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> ar2[i+1];
		ar[ar2[i+1]-cnt[ar2[i+1]]+ MAXn]++;
		cnt[ar2[i+1]]++;
	}
	for (int i = MAXn + 1; i <= MAXn + n; i++) {
		if (ar[i] == 0)
			x++;
	}
	
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		cnt[ar2[a]]--;
		ar[ar2[a]-(cnt[ar2[a]])+ MAXn]--;
		if (ar[ar2[a]-(cnt[ar2[a]])+ MAXn] == 0 && ar2[a]-(cnt[ar2[a]])+ MAXn > MAXn)
			x++;
		ar2[a] = b;
		ar[ar2[a]-cnt[ar2[a]]+ MAXn]++;
		if (ar[ar2[a]-(cnt[ar2[a]])+ MAXn] == 1 && ar2[a]-(cnt[ar2[a]])+ MAXn > MAXn)
			x--;
		cnt[ar2[a]]++;
		cout << x << '\n';
	}
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a <= 5) {
			b = 0;
		} else if(a <= 12) {
			b /= 2;
		}
		
		System.out.println(b);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>

using namespace std;

int X, K;
int r[100005];
int Q;

int lb[100005], ub[100005];
int sum[100005], Max[100005], Min[100005];

int main(void)
{
	cin >> X >> K;
	for(int i = 1; i <= K; i++) cin >> r[i];
	
	for(int i = 1; i <= K; i++){
		if(i % 2) sum[i] = sum[i-1] - (r[i] - r[i-1]);
		else sum[i] = sum[i-1] + (r[i] - r[i-1]);
	}
	
	Max[0] = X, ub[0] = X;
	for(int i = 1; i <= K; i++){
		ub[i] = ub[i-1];
		if(i % 2){
			Max[i] = Max[i-1] - (r[i] - r[i-1]);
			if(Max[i] < 0) Max[i] = 0;
		}
		else{
			Max[i] = Max[i-1] + (r[i] - r[i-1]);
			if(Max[i] > X){
				ub[i] -= Max[i] - X;
				Max[i] = X;
			}
		}
	}
	Min[0] = 0, lb[0] = 0;
	for(int i = 1; i <= K; i++){
		lb[i] = lb[i-1];
		if(i % 2){
			Min[i] = Min[i-1] - (r[i] - r[i-1]);
			if(Min[i] < 0){
				lb[i] += -Min[i];
				Min[i] = 0;
			}
		}
		else{
			Min[i] = Min[i-1] + (r[i] - r[i-1]);
			if(Min[i] > X) Min[i] = X;
		}
	}
	
	cin >> Q;
	int t, a, pos, val;
	for(int q = 0; q < Q; q++){
		cin >> t >> a;
		pos = upper_bound(r, r+K+1, t) - r-1;
		if(a <= lb[pos]) val = Min[pos];
		else if(a >= ub[pos]) val = Max[pos];
		else val = a + sum[pos];
		if(pos % 2){
			val += t - r[pos];
			val = min(val, X);
		}
		else{
			val -= t - r[pos];
			val = max(val, 0);
		}
		cout << val << endl;
	}
	
	return 0;
}

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

using namespace std;

void Main() {
    int N, H;
    cin >> N >> H;
    priority_queue<pair<int, int> > katanas;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        katanas.push(make_pair(b, 1)); // throw;
        katanas.push(make_pair(a, 0)); // hit
    }

    int ans = 0;
    while (H > 0) {
        auto e = katanas.top();
        katanas.pop();
        if (e.second == 1) { // throw
            H -= e.first;
            ++ans;
        }
        else { // hit
            ans += H / e.first;
            if (H % e.first != 0) {
                ++ans;
            }
            break;
        }
    }

    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int a[100005];
	for(int i=0;i<N;i++){
		int b;
		cin >> b;
		b--;
		a[b] = i+1;
	}
	for(int i=0;i<N;i++)cout << a[i] <<" ";
}

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


int main() {
  string s;
  cin >> s;
  if(s[0] == '9') cout << "Yes" << endl;
  else if (s[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int K,A,B;
    cin >> K >> A >>B;
    for(int i = A;i<=B;i++){
        if(i%K==0){
            cout << "OK";
            return 0;
            }
    }
    cout << "NG";
    return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=998244353;
ll gyaku(ll n){
  ll u=mod-2;
  ll ret=1;
  ll now=n;
  while(u>0){
    if(u%2==1){
      ret*=now;
      ret%=mod;
    }
    now*=now;
    now%=mod;
    u/=2;
  }
  return ret;
}
ll nck(ll n,ll k){
  if(n<k)swap(n,k);
  if(2*k>n)k=n-k;
  ll ret=1;
  for(ll i=1;i<=k;i++){
    ret*=gyaku(i);
    ret%=mod;
  }
  for(ll i=0;i<k;i++){
    ret*=(n-i);
    ret%=mod;
  }
  return ret;
}
int main(){
  ll n,a,b,k;cin>>n>>a>>b>>k;
  ll ans=0;
  ll cc[n+1];
  cc[0]=1;
  for(ll i=1;i<=n;i++){
    cc[i]=cc[i-1]*gyaku(i);
    cc[i]%=mod;
    cc[i]*=(n-i+1);
    cc[i]%=mod;
  }
  
  for(ll i=0;i<=n;i++){
    ll u=k-i*a;
    if(u<0)break;
    if(u%b==0&&u/b<=n){
      ll sum=cc[i]*cc[u/b];
      sum%=mod;
      ans+=sum;
    }
  }
  cout<<ans%mod<<endl;
}
     

Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
    
    unsigned long int N,A,B;
    unsigned long int ans;

    scanf("%lu %lu %lu",&N,&A,&B);

    if((B-A)%2 == 0){
        ans = (B-A)/2;
    }else{
        ans = (((A-1) < (N-B)) ? (A-1):(N-B)) +1 +((B-A)/2);
    }

    printf("%lu",ans);

    return 0;
}

Measured memory_bytes: 128
# Here your code !esa=



n=gets.to_i
array=[]

n.times{
    ss=gets.to_i
    
    array<<ss}
array=array.sort

answer=0
i=0
n.times{
   answer+=array[i] 
    i=i+1
    
}
k=0
kk=-1

loop{
   if array[k]%10!=0
      kk=k
     break
    else k=k+1
    
end

if   k==n

break

end

    
    
    
    
}


if  answer%10==0 &&  kk==-1
  puts  0
 elsif answer%10==0
  puts answer-array[k]

else
  puts answer
end











Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 1000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main() {
    ll n,x=1;
    int mod=1e9+7;
    cin>>n;
    for(int i=1;i<=n;i++){
        x=x*i;
        x%=mod;
    }
    cout<<x<<endl;
    return 0;
}












Measured memory_bytes: 256
N,M = map(int, input().split())

m = [0]*M
ans = 0

for n in range(N):
    a = [int(i) for i in input().split()] 
    for i in a[1:]:
        #print('i',i)
        m[i-1] += 1
        if m[i-1] == N:
            ans +=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
		using namespace std;
		#define int long long int
		#define loop(i,a,b) for(int i=a;i<b;i++)
		#define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
		#define vi vector<int>
		#define si set<int>
		#define pii pair <int, int>
		#define sii set<pii>
		#define vii vector<pii>
		#define mii map <int, int>
		#define pb push_back
		#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
		//Constants
		const int MOD = 1000000007; /* 1e9 + 7*/
		const int MAXN = 1000005; /*1e6 +5 */
		 
		int spf[1000009]; // stores the smallest prime factor of a number
		 
		void sieve()
		{
		spf[1] = 1;
			for (int i=2; i<MAXN; i++)
				spf[i] = i;
			for (int i=4; i<MAXN; i+=2)
				spf[i] = 2;
		 
			for (int i=3; i*i<MAXN; i++)
				if (spf[i] == i)
				{
					for (int j=i*i; j<MAXN; j+=i)
						if (spf[j]==j)
							spf[j] = i;
				}
			}
		
		 
		/* Iterative Function to calculate (x^y)%p in O(log y) */
		int power(int x,  int y, int p)
		{
			int res = 1;     // Initialize result
			x = x % p; // Update x if it is more than or
						// equal to p 
			if (x == 0) return 0; // In case x is divisible by p;     
			while (y > 0)
			{
				// If y is odd, multiply x with result
				if (y & 1)
					res = (res*x) % p;     
				// y must be even now
				y = y>>1; // y = y/2
				x = (x*x) % p;
			}
			return res;
		}
		
		 
		void solve()
		{
			int n,x,t;
			cin>>n>>x>>t;
			int one=n/x;
			if(n%x!=0)
			one++;
			one=one*t;
			cout<<one<<endl;
		}

		 
		int32_t main()
		{
			faster;
			/*sieve();*/
		   // compute();
		  // int t;cin>>t;
		 int t=1;
		while(t--)
			solve();
		 
		 
			return 0;
		}


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

int main(){
  int a, b; cin >> a >> b;
  if(a == 1 && b == 2)
    cout << 3 << endl;
  if(a == 1 && b == 3)
    cout << 2 << endl;
  if(a == 2 && b == 1)
    cout << 3 << endl;
  if(a == 2 && b == 3)
    cout << 1 << endl;
  if(a == 3 && b == 1)
    cout << 2 << endl;
  if(a == 3 && b == 2)
    cout << 1 << endl;
  return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int S=0;
    vector<int> A(N), B(N), C(N-1);
    vector<int> vec;
    for(int n=0; n<N; n++) {
        cin >> A[n];
        if(n>0) {
            if(A[n-1]==A[n]-1) {
                vec.push_back(A[n-1]-1);
            }
        }
    }
    for(int n=0; n<N; n++) {
        cin >> B[n];
        S+=B[n];
    }
    // cout << S << endl;
    for(int n=0; n<N-1; n++) {
        cin >> C[n];
    }
    
    for(int i=0; i<vec.size(); i++) {
        S+=C[vec[i]];
    }
    cout << S << endl;



    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
#define MAXN 100005
typedef long long int64;
using namespace std;
template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}

int N;
int64 p[MAXN][2],sum,ans,t3;
int L[MAXN],R[MAXN],tot,ty[MAXN],cnt[10];
pii pos[MAXN * 2];
multiset<int64> S;
bool cmp(pii a,pii b) {
	return p[a.fi][a.se] < p[b.fi][b.se];
}
void Solve() {
    read(N);
	for(int i = 1 ; i <= N ; ++i) {
		read(p[i][1]);read(p[i][0]);
		ans += p[i][1] + p[i][0];
		pos[++tot] = mp(i,0);
		pos[++tot] = mp(i,1);
	}
	sort(pos + 1,pos + tot + 1,cmp);
	for(int i = 1 ; i <= tot / 2 ; ++i) {
		sum += p[pos[i].fi][pos[i].se];
		if(!pos[i].se) L[pos[i].fi] = 1;
		else R[pos[i].fi] = 1;
		S.insert(p[pos[i].fi][pos[i].se]);
	}
	for(int i = 1 ; i <= N ; ++i) {
		if(L[i] && !R[i]) {ty[i] = 1;cnt[1]++;}
		if(!L[i] && R[i]) {ty[i] = 2;cnt[2]++;}
		if(!L[i] && !R[i]) {ty[i] = 3;cnt[3]++;}
		if(L[i] && R[i]) {ty[i] = 4;cnt[4]++;}
	}
	if(!cnt[1] || !cnt[2] || cnt[3]) {out(sum);enter;return;}
	for(int i = tot / 2 + 1 ; i <= tot ; ++i) {
		int u = pos[i].fi;
		if(cnt[ty[u]] != 1) {
			S.erase(S.find(p[u][pos[i].se ^ 1]));
			ans = min(ans,sum + p[pos[i].fi][pos[i].se] - *(--S.end()));
			S.insert(p[u][pos[i].se ^ 1]);
		}
		else ans = min(ans,sum + p[pos[i].fi][pos[i].se] - *(--S.end()));
	}
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
	return 0;
}


Measured memory_bytes: 9216
#include<iostream>
using namespace std;
int main()
{
	int n, a[100], tmp, j;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
	{
		tmp = a[i];
		for (j = i - 1; j >= 0 && tmp < a[j]; j--)
			a[j + 1] = a[j];
		a[j + 1] = tmp;
		for (int j = 0; j < n; j++) {
			if (j)
				cout << " ";
			cout << a[j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int mx=a*4;
  int mn=a*2;
  if(b%2==0)
  {
  if(mx>=b && mn<=b)
    cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  else
    cout<<"No"<<endl;
}


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

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

int a[300], n;

int main() {
    a[0] = 1;
    for (int i = 0; i <= 32; ++i) {
        if (i == 0) a[i] = 1;
        else if (i == 1) a[i] = a[i-1];
        else if (i == 2) a[i] = a[i-1]+a[i-2];
        else  a[i] = a[i-1]+a[i-2]+a[i-3];
    }

    while (cin >> n, n) {
        if (a[n]%3650 == 0) cout << a[n]/3650 << endl;
        else cout << a[n]/3650+1 << endl;
    }
}

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

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



int main(){
  long int n,k;
  cin >> n >> k;

  long int sum=0;
  for (long int i=n+1; i>=k;i--){
    if(i==n+1){
      sum += 1;
      continue;
    }

    long int B=0, A=0;
    B=0;
    A=0;
    B = n*i - i*(i-1);
    //cout << i << " " << B << " " <<  A << endl;
    sum = sum + (B+1)% (1'000'000'000+7);
      sum %= (1'000'000'000+7);
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int x,y;
	int i, j;
	int n;
	int size;
	int god[10][10];
	int space;
	int mn;
	
	for (i = 0; i < 10; i++){
		for (j = 0; j < 10; j++){
			god[i][j] = 0;
		}
	}
	
	while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
		if (size == 1){
			n = 1;
			god[x][y]++;
			for (i = 0; i < 2; i++){
				if (x + n >= 0 && x + n < 10){
					god[x + n][y]++;
				}
				if (y + n >= 0 && y + n < 10){
					god[x][y + n]++;
				}
				n = -1;
			}
		}
		if (size == 2){
			n = 1;
			god[x][y]++;
			for (i = 0; i < 2; i++){
				if (x + n >= 0 && x + n < 10){
					god[x + n][y]++;
				}
				if (y + n >= 0 && y + n < 10){
					god[x][y + n]++;
				}
				if (x + n >= 0 && x + n < 10 && y + n >= 0 && y + n < 10){
					god[x + n][y + n]++;
				}
				if (x + n >= 0 && x + n < 10 && y - n >= 0 && y - n < 10){
					god[x + n][y - n]++;
				}
				n = -1;
			}
		}
		if (size == 3){
			n = 1;
			god[x][y]++;
			for (i = 0; i < 2; i++){
				if (x + n >= 0 && x + n < 10){
					god[x + n][y]++;
				}
				if (y + n >= 0 && y + n < 10){
					god[x][y + n]++;
				}
				if (x + n >= 0 && x + n < 10 && y + n >= 0 && y + n < 10){
					god[x + n][y + n]++;
				}
				if (x + n >= 0 && x + n < 10 && y - n >= 0 && y - n < 10){
					god[x + n][y - n]++;
				}
				
				if (x + n * 2 >= 0 && x + n * 2 < 10){
					god[x + n * 2][y]++;
				}
				if (y + n * 2 >= 0 && y + n * 2 < 10){
					god[x][y + n * 2]++;
				}
				n = -1;
			}
		}
	}
	space = 0;
	mn = 0;
	for (i = 0; i < 10; i++){
		for (j = 0; j < 10; j++){
			if (god[i][j] == 0){
				space++;
			}
			if (mn < god[i][j]){
				mn = god[i][j];
			}
		}
	}
	
	printf("%d\n%d\n", space, mn);
	
	return (0);
}

Measured memory_bytes: 1028
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int y = scanner.nextInt();
    int s = 10 * n - y / 1000;
    if (s >= 0) {
      for (int i = 0; i <= s / 9; i++) {
        if ((s - 9 * i) % 5 == 0) {
          int a = i;
          int b = (s - 9 * i) / 5;
          int c = n - a - b;
          if (c >= 0) {
            System.out.printf("%d %d %d\n", c, b, a);
            return;
          }
        }
      }
    }
    System.out.println("-1 -1 -1");
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  string S;
  cin >> S;
  REP(i, S.size()) {
    if (S[i] == S[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

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

typedef unsigned long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
ll N,K;
int A[maxn];
int vis[maxn];

int32_t main(){
	fast;
	
	cin>>N>>K;
	
	FOR(i,1,N){
		cin>>A[i];
	}
	
	int x = 1;
	
	while (!vis[x]){
		vis[x] = 1;
		x = A[x];
	}
	
	int num = 0;
	int start = x;
	do{
		num++;
		x = A[x];
	}while (x != start);
	
	
	x = 1;
	
	while (K > 0 && x != start){
		x = A[x];
		K--;
	}
	
	K %= num;
	
	FOR(i,1,K) x = A[x];
	cout<<x;
		
}



Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long 
#define N 200005
int n,m,fa[N],sz[N];
inline int ancestor(int x){return fa[x]==x?x:fa[x]=ancestor(fa[x]);}
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
	std::cin>>n>>m;
	rep(i,1,n) fa[i]=i,sz[i]=1;
	rep(i,1,m){
		int x,y; std::cin>>x>>y;
		x=ancestor(x),y=ancestor(y);
		if(x!=y){
			fa[y]=x;
			sz[x]+=sz[y];
		}
	}
	int ret=0;
	rep(i,1,n) ret=std::max(ret,sz[ancestor(i)]);
	std::cout<<ret<<'\n';
	return 0;
}

Measured memory_bytes: 5428
N, K = map(int, input().split())

P = list(map(int, input().split()))

per = [ (n + 1) / 2 for  n in P]

m = [0] * N
m[0] = sum(per[ : K])
for x in range(1, N - K + 1):
    m[x] = m[x - 1] - per[x - 1] + per[x + K - 1]


print(max(m))




Measured memory_bytes: 78984
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n) {
  int ret = 1;
  for (int i = 1; i < n + 1; ++i) {
    ret = ret * i;
  }
  return ret;
}

/* 最大公約数 */
template <typename T>
T gcd(T x, T y) { return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>
T lcm_n(vector<T> &numbers) {
  T l;
  l = numbers[0];
  for (int i = 1; i < numbers.size(); ++i) {
    l = lcm(l, numbers[i]);
  }
  return l;
}

/*
 * DP向け
 */
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;
}

/*
 * グラフ
 */
class Graph {
 public:
  vector<vector<int>> G;
  vector<int> Trans;
  vector<int> inDeg;
  int numV;

  Graph(int numV) {
    this->numV = numV;
    inDeg.assign(numV, 0);
    Trans.assign(numV, 0);
    G.assign(numV, vector<int>());
  }

  int topologicalSort(int v, vector<int> &dp) {
    if (dp[v] != -1) {
      return dp[v];
    }

    int res = 0;

    for (auto to : G[v]) {
      chmax(res, topologicalSort(to, dp) + 1);
    }

    return dp[v] = res;
  }
};

/**
 * @param N 素因数分解する整数
 * @param result N = 2^3 * 3^2の場合、{{2, 3}, {3, 2}}のような形式のvectorが生成される
 * @brief 2, 3,..., √Nまでの整数をNで割っていき、割り切れる数と割った回数を保存することで、素因数分解を行う。
 *        O(√N)
*/
void prime_factorize(ll N, vector<pair<ll, ll>> &result) {
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll ex = 0;  // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    result.emplace_back(pair<ll, ll>{a, ex});
  }

  // 最後に残った数
  if (N != 1) result.emplace_back(pair<ll, ll>{N, 1});
}

ll type_num(ll v) {
  ll i = 0;
  while (1) {
    if (i * (i + 1) <= 2 * v && 2 * v < (i + 1) * (i + 2)) break;
    ++i;
  }
  return i;
}

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> result;

  prime_factorize(N, result);
  ll ans = 0;

  for (auto v : result) {
    ans += type_num(v.second);
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	int N;
	int *inputs;
	int cnt = 0;

	scanf("%d", &N);

	inputs = (int*)malloc(sizeof(int) * N);
	if(inputs == NULL){
		printf("Memory Error\n");
		exit(1);
	}

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

	int temp;
	for(int i = N - 1; 0 < i; i--){
		for(int j = 0; j < i; j++){
			if(inputs[j + 1] < inputs[j]){
				temp = inputs[j + 1];
				inputs[j + 1] = inputs[j];
				inputs[j] = temp;
				cnt++;
			}
		}
	}

	for(int i = 0;i < N - 1;i++){
		printf("%d ", inputs[i]);
	}
	printf("%d", inputs[N - 1]);
	printf("\n%d\n", cnt);

}


Measured memory_bytes: 1992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;

int main() {
    ll A,B,K;cin>>A>>B>>K;
    cout<<max((ll)0,A-K)<<" "<<max((ll)0,B-max(K-A,(ll)0))<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;

int main() {
  int n, q; cin >> n >> q;
  string s; cin >> s;
  vector<int> c(n+1, 0);
  for(int i=1; i<n; i++) {
    c[i] += c[i-1];
    if(s[i-1] == 'A' && s[i] == 'C') c[i]++;
  }

  int l, r;
  for(int i=0; i<q; i++) {
    cin >> l >> r;
    cout << c[r-1] - c[l-1] << endl;
  }

  return 0;
}



//EOF


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int k =scan.nextInt();
		int x[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
			if(x[i] < k-x[i])sum+=x[i]*2;
			else sum+=(k-x[i])*2;
		}
		scan.close();
		System.out.println(sum);
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    final long X = (long) Math.pow(10, 18);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        if (k%2 == 0) {
            System.out.println(a-b);
        }
        else {
            System.out.println(b-a);
        }
        sc.close();
    }
}

Measured memory_bytes: 35604
while true do
  line = gets
  break if line == nil
  nums = line.split.map {|x| x.to_i}
  nums.sort!
  lcm = 0
  gcd = 0

  i = 1
  while true do
    if ( nums[1] * i ) % nums[0] == 0 then
      lcm = nums[1] * i 
      break
    end
    i += 1
  end

  i = 1
  while true do
    if ( nums[0] % i == 0 && nums[1] % ( nums[0] / i ) == 0 ) then
      gcd = nums[0] / i
      break
    end
    i += 1
  end

  puts "#{gcd} #{lcm}"

end

Measured memory_bytes: 6108
#include <stdio.h>

int main(){
  int i,j,n,count=0;
  scanf("%d",&n);
  int a[n];

  for(i=0; i<n; i++)
    scanf("%d",&a[i]);
  
  for(i=0; i<n; i++)
    for(j=n-1; j>=i; j--)
      if(a[j] < a[j-1]){
	int tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	count++;
      }
  
  for(i=0; i<n-1; i++)
    printf("%d ",a[i]);
  
  printf("%d\n%d\n",a[n-1],count);
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#define N 100
#define S 0
#define G 1
#define K 2

int kazu,Max[N][N];

int d[N],f[N];
int temp;

int data[N];

void visit(int x){
  int i;
  data[x]=G;
  d[x]=++temp;
  for(i=0;i <kazu; i++){
    if(Max[x][i]==0){
      continue;}
    
    if(data[i]==S){
      visit(i);
    }
  }
  data[x]=K;
  f[x]=++temp;
}
void cal(){
  int x;
  for(x=0;x<kazu;x++){data[x]=S;
  }
  temp=0;
  for(x=0; x<kazu;x++){
    if(data[x]==S)visit(x);
  }
  
  for(x=0; x<kazu;x++){
    printf("%d %d %d\n", x+1,d[x], f[x]);

  }
}


int main()
{
  int x,v,k,i,j;
  
  scanf("%d",&kazu);

  for(i=0;i<kazu;i++){
    for( j=0; j<kazu; j++ ) {
      Max[i][j]=0;
    }
    
  }
  
  for(i=0;i <kazu;i++){

    scanf("%d %d",&x,&k);
    
    x--;
    for(j=0;j<k;j++){
      
      scanf("%d",&v);
      v--;
      
      Max[x][v]=1;
    }
  }
  cal();
  return 0;
}



Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------　
signed main() {
	int n, k;
	string s;
	cin >> n >> s >> k;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[k - 1]) {
			s[i] = '*';
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

def solve():
    input = sys.stdin.readline
    N = int(input())
    ht = defaultdict(int)

    for i in range(1, N + 1):
        k = i
        head = k % 10
        while k >= 10:
            k //= 10
        tail = k
        if head > 0: ht[(head, tail)] += 1
    ans = 0
    for i in range(1, N + 1):
        k = i
        tail = k % 10
        while k >= 10:
            k //= 10
        head = k
        if tail > 0: ans += ht[(head, tail)]
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$next = 'a';
$last = '';
$endflg = false;
$cntA = 0;
$cntB = 0;
$cntC = 0;
while(!$endflg){
    switch ($next) {
        case 'a':
            if($cntA===strlen($a)){
                $last = "A";
                $endflg = true;
                break;
            }
            $next = $a{$cntA};
            $cntA++;
            break;
        case 'b':
            if($cntB===strlen($b)){
                $last = "B";
                $endflg = true;
                break;
            }
            $next = $b{$cntB};
            $cntB++;
            break;
        case 'c':
            if($cntC===strlen($c)){
                $last = "C";
                $endflg = true;
                break;
            }
            $next = $c{$cntC};
            $cntC++;
            break;
    }
}
echo $last;
?>

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

#define int long long

int bitcnt[62];
int cache[60][2];
int n,k;


int dp(int in, int less)
{
	if(in<0)
		return 0;
	int &ans=cache[in][less];
	if(ans!=-1)
		return ans;
	ans=0;
	int set=bitcnt[in];
	int unset=n-set;
	if(less)
	{
		if((1ll<<in)&k)
		{
			ans=max((1ll<<in)*unset + dp(in-1,less),(1ll<<in)*set + dp(in-1,less^1));
		}
		else
			ans=(1ll<<in)*set + dp(in-1,less);
	}
	else
		ans=max((1ll<<in)*unset + dp(in-1,less),(1ll<<in)*set + dp(in-1,less));
	return ans;
}



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    
    cin>>n>>k;
    memset(cache,-1,sizeof(cache));
    int a[n]={};
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	for(int j=42;j>=0;j--)
    	{
    		if(a[i]&(1LL<<j))
    			bitcnt[j]++;
    	}
    }
    cout<<dp(42,1);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define ll long long
//#define INF LONG_MAX
//#define int long long
using namespace std;
const int limit = 50;
int n, m;
bool a[limit][limit];
bool visited[limit];

void init() {
  for (int i = 0; i < n; i++) {
    visited[i] = false;
  }
}

void dfs(int x) {
  if (visited[x]) return;
  visited[x] = true;
  for (int i = 0; i < n; i++) {
    if(a[x][i]) dfs(i);
  }  
}

int check() {
  for (int i = 0; i < n; i++) {
    if (!visited[i]) return 1;
  }
  return 0;
}


int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a[i][j] = false;
    }
  }

  int num1, num2; // input
  for (int i = 0; i < m; i++) {
    cin >> num1 >> num2;
    a[num1-1][num2-1] = true;
    a[num2-1][num1-1] = true;
  }

  int ans = 0;
  for (int i = 0; i < n; i++ ) {
    for (int j = i+1; j < n; j++) {
      if (a[i][j] == false) continue;
      init();
      a[i][j] = a[j][i] = false;
      dfs(0);
      ans += check();
      a[i][j] = a[j][i] = true;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int n;
  cin >> n;
  int sen = 0;
  while(sen < n) {
    sen += 1000;
  }
  cout << sen - n << endl;
  return 0;
}

Measured memory_bytes: 3652
//PDF解説に倣ってDP
#include<bits/stdc++.h>
using namespace std;

int main(){
  int M=1e9+7,n,m;
  cin>> n >> m;
  vector<int> s(n),t(m);
  for (int i=0; i<n; i++) cin>> s[i];
  for (int i=0; i<m; i++) cin>> t[i];
  
  vector<vector<int>> dp(n,vector<int>(m));
  if (s[0]==t[0]) dp[0][0]=1;
  for (int i=1; i<n; i++){
    dp[i][0]=dp[i-1][0];
    if (s[i]==t[0]) dp[i][0]++;
  }
  for (int i=1; i<m; i++){
    dp[0][i]=dp[0][i-1];
    if (s[0]==t[i]) dp[0][i]++;
  }
  for (int i=1; i<n; i++){
    for (int j=1; j<m; j++){
      dp[i][j]=dp[i-1][j]+dp[i][j-1];
      if (s[i]==t[j]) dp[i][j]+=1;
      else dp[i][j]-=dp[i-1][j-1];
      dp[i][j]%=M;
      if (dp[i][j]<0) dp[i][j]+=M; //ひょっとして負になってる？
    }
  }
  cout<< (dp[n-1][m-1]+1)%M <<endl;
}

Measured memory_bytes: 16000
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x[50],i;
	double y=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	sort(x,x+n);
	y=x[0];
	for(i=1;i<=n-1;i++){
		y=(y+x[i])/2;
	}
	printf("%lf\n",y);
	return 0;
}


Measured memory_bytes: 1748
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

/*
B__A
B__A
 __A

*/

int ans;
int A, B, AB;  

int main(void) {
    int n;
    cin >> n;
    rep(i, 0, n) {
        string s;
        cin >> s;
        for(int i=0; i<(int)s.size()-1; i++) {
            if (s[i]=='A' && s[i+1]=='B') ans++;
        }
        if (s[0]=='B') B++;
        if (s[(int)s.size()-1]=='A') A++;
        if (s[0]=='B' && s[(int)s.size()-1]=='A') AB++;
    }
    
    if (AB > 0 && AB == A && AB == B) ans += AB - 1; 
    else ans += min(A, B);

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

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

int main()
{
  int a, b, c;

  scanf("%d%d%d", &a, &b, &c);
  printf("%d\n", b + min(c, a+b+1));

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int res = -1;
        for(int i = 1; i <= 1000; i++) {
            int a = (int)Math.floor(i*0.08);
            int b = (int)Math.floor(i*0.1);
            if(a==A && b==B) {
                res = i;
                break;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int main() {
#ifdef LOCAL
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, m;
    cin >> n >> m;
    char mat[n + 2][m + 2];
    memset(mat, '.', sizeof mat);
    forn(i, n) {
        string s;
        cin >> s;
        forn(j, m) {
            mat[i][j] = s[j];
        }
    }
    forn(i, m + 2) {
        cout << '#';
    }
    cout << endl;
    forn(i, n) {
        cout << '#';
        forn(j, m) {
            cout << mat[i][j];
        }
        cout << '#';
        cout << endl;
    }
    forn(i, m + 2) {
        cout << '#';
    }
    cout << endl;
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),K=in();
	auto A=vecin(N);

	ll S=0;
	if(A[0]>K){
		S += A[0]-K;
		A[0]=K;
	}
	REP(i,N-1){
		if(A[i+1]+A[i]>K){
			int D= A[i+1]+A[i]-K;
			S += D;
			A[i+1]-=D;
		}
	}
	
	out(S);
	return 0;
}


Measured memory_bytes: 640
N = int(input())
*A, = map(int, input().split())

list.sort(A, reverse=True)
mx = 10 ** 18
mul = 1

if 0 in A:
    print(0)
    exit(0)
    
for a in A:
    mul *= a
    if mul > mx:
        mul = -1
        break

print(mul)

Measured memory_bytes: 21784
N,M = map(int,input().split())
a = [input() for _ in range(N)]
b = [input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        result = True
        for k in range(M):
            for l in range(M):
                if b[k][l] != a[i+k][j+l]:
                    result = False
        if result:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 9144