akhauriyash/Code-Regression huggingface dataset:
import collections 
import sys
sys.setrecursionlimit(1000000)

n = int(input())
ab = [tuple(map(int,input().split())) for _ in range(n-1)]
tree = [[] for _ in range(n)]
for i in range(n-1):
  tree[ab[i][0]-1].append(ab[i][1]-1)
  tree[ab[i][1]-1].append(ab[i][0]-1)

ans = 0
ab_dic = collections.OrderedDict()
for i in ab:
  ab_dic[i] = 0

def dfs(i,before = -1,color = -1):
  k = 0
  for j in tree[i]:
    if j == before:
      continue
    if k == color:
      k += 1
    dfs(j,i,k)
    ab_dic[(i+1,j+1)] = k
    global ans
    ans = max(ans,k)
    k += 1

dfs(0)
print(ans+1)
for i in ab_dic:
  print(ab_dic[i]+1)

Measured memory_bytes: 99480
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
//#include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using G = greater<T>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, G<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I "; else cout << A[i] << " ";}}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[0], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  LL ans = 0;
  cin >> n;
  REP2(LL, i, 1, n+1)
  {
    if (i % 15 == 0) continue;
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    else ans += i;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);

  ll d_max = 0;
  ll dan = 0;
  ll dif = 0;

  REP(i, N) {
    cin >> A[i];

    ll dif = d_max - A[i];

    if (dif > 0) {
      dan += dif;
    } else {
      d_max = max(d_max, A[i]);
    }
  }
  cout << dan << endl;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vecb a(n, false);
	rep(i, m)
	{
		int t;
		cin >> t;
		a[t] = true;
	}
	int left_sum = accumulate(a.begin(), a.begin() + x, 0);
	int right_sum = accumulate(a.begin() + x + 1, a.end(), 0);
	cout << min(left_sum, right_sum) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int D, G;
    cin >> D >> G;
    int p[100], c[100];
    for (int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int mincount = 99999;
    for (int bit = 0; bit < (1 << D); bit++){
        int total = 0;
        int count = 0;
        for (int i = 0; i < D; i++){
            if (bit & (1 << i)){
                total += 100 * (i + 1) * p[i] + c[i];
                count += p[i];
            }
        }
        if (total < G){
            for (int i = D - 1; i >= 0; i--){
                if (!(bit & (1 << i))){
                    int addcount = (G - total + 100 * (i + 1) - 1)/(100 * (i + 1));
                    if (addcount < p[i]) {
                        count += addcount;
                        total += 100 * addcount * p[i];
                    }
                    break;
                }
            }
        }
        if (total >= G){
            if (count < mincount) mincount = count;
            //cout << "count " << count << " "<< "total " << total << endl;
        }
        //cout << "count " << count << " "<< "total " << total << endl;
    }
    cout << mincount << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mx = 1000010;
long long a[mx], cost[mx], h[mx], f = 1e18+10; 

main()
{
	int n, k;
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	
	cost[1] = 0;
	
	for(int i = 2;  i <= n; i++){	
		cost[i] = f;
		for(int j = k; j >= 1; j--){
			if(i - j > 0){
				
				cost[i] = min(cost[i], abs(h[i]-h[i-j])+cost[i-j]);
			}
		}
	}
	
	cout << cost[n] ;


return 0;
}


Measured memory_bytes: 5120
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;

template <typename T>void read(T &t)
{
	t=0;int f=0;char c=getchar();
	while(!isdigit(c)){f|=c=='-';c=getchar();}
	while(isdigit(c)){t=t*10+c-'0';c=getchar();}
	if(f)t=-t;
}

int a,b,c; 

int main()
{
	read(a),read(b),read(c);
	printf("%d",min(c,b/a));
	return 0;
}


Measured memory_bytes: 256
def main():
  l, r = map(int, input().split())
  LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]
  ans = 2018
  m = 2019
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, LUT[i % m][j % m])
      if ans == 0:
        return 0
  return ans

print(main())


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

struct ModInt {
  static void setMod(int m) {
    mod = m;
  }

  ModInt(int val = 0) : val(val%mod) {}

  inline const ModInt operator + (const ModInt& rhs) const {
    return ModInt((this->val + rhs.val) % mod);
  }

  inline const ModInt operator - (const ModInt& rhs) const {
    return ModInt((this->val + mod - rhs.val) % mod);
  }

  inline const ModInt operator * (const ModInt& rhs) const {
    return ModInt((this->val * rhs.val) % mod);
  }

  inline ModInt& operator += (const ModInt& rhs) {
    this->val = (this->val + rhs.val) % mod;
    return *this;
  }

  inline ModInt& operator -= (const ModInt& rhs) {
    this->val = (this->val + mod - rhs.val) % mod;
    return *this;
  }

  inline ModInt& operator *= (const ModInt& rhs) {
    this->val = (this->val * rhs.val) % mod;
    return *this;
  }

  int val;
  static int mod;
};
int ModInt::mod = MOD9;

const int MAX_N = 3005;
const int MAX_S = 3005;
int N, S;
int A[MAX_N];

ModInt dp[MAX_N][MAX_S][3];

signed main()
{
  cin >> N >> S;
  REP(n,N) {
    cin >> A[n];
  }

  dp[0][0][0] = 1;
  REP(n,N) {
    REP(s,S+1) {
      dp[n+1][s][0] += dp[n][s][0];
      dp[n+1][s][1] += dp[n][s][0] + dp[n][s][1];
      dp[n+1][s][2] += dp[n][s][0] + dp[n][s][1] + dp[n][s][2];
      if (s + A[n] <= S) {
        dp[n+1][s+A[n]][1] += dp[n][s][0] + dp[n][s][1];
        dp[n+1][s+A[n]][2] += dp[n][s][0] + dp[n][s][1];
      }
    }
  }

  cout << dp[N][S][2].val << endl;

  return 0;
}



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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int l = a+b;
  int r = c+d;
  if (l > r) {
    cout << "Left" << endl;
  }else if(r > l){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
}
}

Measured memory_bytes: 256
n = list(input())

co = 0
su = 0

for i in range(len(n)):
    if n[i] == "A" or n[i] == "T" or n[i] == "C" or n[i] == "G":
        co += 1
    else:
        su = max(su,co)
        co = 0
su = max(su,co)
print(su)

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

int main() {
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n);
    vector<int> y(m);
    rep(i,n) cin >> x[i];
    rep(i,m) cin >> y[i];
    for (int z = (X+1); z <= Y; z++) {
        bool ok = true;
        rep(i,n) if (x[i] >= z) ok = false;
        if (ok) {
            rep(i,m) if (y[i] < z) ok = false;
        }
        if (ok) {cout << "No War" << endl; return 0;}
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int r = 0;
  int b = 0;
  for(int i = 0;i<S.size();i++){
    if(S.at(i) == 'R'){
      r++;
    }
  else{
    b++;
    }
  }
  if(r>b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] array = str.split(" ");

		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		if(a < b) System.out.println("a < b");
		else if(a > b) System.out.println("a > b");
		else if(a == b) System.out.println("a == b");

	}
}

Measured memory_bytes: 24160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int k;
		string s;
		cin>>k>>s;
		if(s.size()<=k){
			cout<<s;
		}
		else{
			s = s.substr(0,k);
			s+="...";
			cout<<s;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int n,k;
int a[2*maxn];
int maxi;
bool check(int mid){
	int c = 0;
	for(int i = 1; i <= n; i++){
		
		c += (a[i] + mid - 1) / (mid) - 1 ;
	}
	//cout << c << "\n";
	return c > k;
}

int32_t main(){
	fastio();
	
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		
	}
	
	int low = 1, high = mod;
	int ans = 0;
	
	while(low <= high){
		int mid = (low + high) / 2;
		if(check(mid)){
			low = mid + 1;
		}else{
			ans = mid;
			high = mid - 1;
		}
	}
	
	
	cout << ans;
}


Measured memory_bytes: 5148
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    string s;
    cin >> s;
    size_t n = s.length();
    int ans = 101;
    rep(i, 26){
        int tmp = 0, ma= 0;
        rep(j, n){
            if(s.at(j) - 'a' == i) tmp = 0;
            else tmp++;
            ma = max(ma, tmp);
        }
        ans = min(ans, ma);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

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

    vector<long long> x2(N);
    long long tmp = 0;
    for(int i=0; i<N; i++){
        if(i%2 == 0) tmp += A[i];
        else tmp -= A[i];
    }
    x2[0] = tmp;
    for(int i=1; i<N; i++){
        x2[i] = 2*A[i-1] - x2[i-1];
    }
    for(int i=0; i<N; i++)
        cout << x2[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
N, Y = map(int, input().split())
for a in range(N+1):
	for b in range(N - a + 1):
		if(Y == ((10000 * a) + (5000 * b) + (1000 * (N - a - b)))):
			print(a, b, N - a - b)
			exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	char c;
	cin >> c;
	if (c >= 'a'&&c <= 'z')cout << "a";
	else cout << "A";
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C;
	cin>>A>>B;
	
	C=A+B;
	
	if(C%2!=0)
	cout<<"IMPOSSIBLE"<<endl;
	else 
	cout<<C/2<<endl;
	return 0;
} 

Measured memory_bytes: 256
int n=1<<18;
long dat[1<<19],lazy[1<<19];
eval(i,l,r)
{
	if(lazy[i])
	{
		dat[i]+=lazy[i];
		if(r-l>1)
		{
			lazy[2*i+1]+=lazy[i];
			lazy[2*i+2]+=lazy[i];
		}
		lazy[i]=0;
	}
}
update(a,b,x,k,l,r)long x;
{
	eval(k,l,r);
	if(b<=l||r<=a)return 0;
	else if(a<=l&&r<=b)
	{
		lazy[k]+=x;
		eval(k,l,r);
	}
	else
	{
		update(a,b,x,2*k+1,l,(l+r)/2);
		update(a,b,x,2*k+2,(l+r)/2,r);
		dat[k]=fmax(dat[2*k+1],dat[2*k+2]);
	}
}
long query(a,b,k,l,r)
{
	eval(k,l,r);
	if(b<=l||r<=a)return 0;
	else if(a<=l&&r<=b)return dat[k];
	else return fmax(
		query(a,b,2*k+1,l,(l+r)/2),
		query(a,b,2*k+2,(l+r)/2,r)
	);
}
int N,m;
L[1<<18],R[1<<18],A[1<<18];
first[1<<18],next[1<<18];
main()
{
	scanf("%d%d",&N,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",L+i,R+i,A+i);
	}
	for(int i=1;i<=m;i++)
	{
		next[i]=first[R[i]];
		first[R[i]]=i;
	}
	for(int i=1;i<=N;i++)
	{
		update(i,i+1,query(0,i,0,0,n),0,0,n);
		int p=first[i];
		for(;p!=0;)
		{
			update(L[p],i+1,1L*A[p],0,0,n);
			p=next[p];
		}
	}
	printf("%ld",query(0,N+1,0,0,n));
}

Measured memory_bytes: 12800
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n; scanf(" %d", &n), n;) {
		vector<int> cake(n*(n-1)/2);
		rep(i,n*(n-1)/2) cin >> cake[i];
		cout << accumulate(cake.begin(), cake.end(), 0) / (n-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string S;
  cin >> S;
  for (ll i = 0; i < S.size() / 2; ++i) {
    string f = S.substr(0, (S.size() - i * 2) / 2);
    string s = S.substr((S.size() - i * 2) / 2, (S.size() - i * 2) / 2);
    if (i == 0) {
      continue;
    }
    if (f == s) {
      cout << f.size() * 2 << "\n";
      return 0;
    }
  }
}


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

template<typename T> bool is_prime(T n) {
    if (n < 2 || n % 2 == 0) return(n == 2);
    for (long long i = 3; i*i <= n; i += 2) {
        if (n % i == 0) { return false; }
    }
    return true;
}

int main() {
    int n, a;
    cin >> n;
    int ans = 0;
    while (n--) {
        cin >> a;
        if (is_prime(a)) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3112
#https://atcoder.jp/contests/dp/tasks/dp_a
#2019-01-13
N = int(input())
h = list(map(int, input().split()))

DP = [0, abs(h[0]-h[1])]
for i in range(N-2):
    DP += [min(DP[-2] + abs(h[i]-h[i+2]), DP[-1] + abs(h[i+1]-h[i+2]))]

print(DP[-1])

Measured memory_bytes: 13980
# Here your code !
w=gets.chomp
w=w.split(" ")
a=w[0].to_i
b=w[1].to_i
c=w[2].to_i
if a%2 ==0 || b%2 ==0 || c%2 ==0
    puts "0"
else
   x=[a*b,b*c,c*a]
   x=x.min
   puts x
end

Measured memory_bytes: 1788
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
typedef vector<ii> vii;
typedef vector<lii> lvii;

#define min_prq(t) priority_queue<t,vector<t>,greater<t>>
#define max_prq(t) priority_queue<t>
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
#define mod 1000000007
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_product() { return 1LL; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------


signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,D;
	cin>>n>>D;
	lvi d(n+1),b(n+1);
	for (int i = 0; i < n; ++i)
	{
		cin>>d[i+1];
	}
	b[n]=1;
	for(int i=n-1;i>=0;i--)
	{
		if((d[i+1]>=2*b[i+1])) b[i]=b[i+1];
		else b[i]=b[i+1]+d[i+1];
	}
	lvi a(n+1);
	a[0]=D;
	for(int i=1;i<=n;i++)
	{
		a[i]=min(a[i-1],abs(a[i-1]-d[i]));
	}
	tc(T)
	{
		ll i;
		cin>>i;
		if(b[i]<=a[i-1]) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 15052
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007

int main()
{
    int n;

    scanf("%d", &n);
    long long s = 1;
    for (int i = 1; i <= n; i++) {
        s = s * i % mod;
    }
    printf("%lld\n", s);
}


Measured memory_bytes: 256
/*??£?¨?*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int main()
{
	int max = 0, n, a[5001] = {0},max_=0;
	while (cin >> n, n != 0)
	{
		max_ = 0;
		max = -1000000000;
		rep(i, n)
			cin >> a[i];
		rep(i, n)
		{
			for (int j = i; j < n; j++)
			{
				max_ += a[j];
				if (max < max_)
					max = max_;
			}
			max_ = 0;
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <iostream> 

using namespace std;

int main()
{
    int A,B,C,K;
    cin>>A>>B>>C;
    cin>>K;

    while(1)
    {
        if(K==0 or B>A) break;
        
        K--;
        B *= 2;
    }
    
  if(K>0)
  {
    while(1)
    {
        if(K==0 or C>B) break;
        K--;
        C *=2;
    }
  }
    if(C>B and B>A) cout <<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;

   if(a==b){
    cout << c << endl;
    }else if(b==c){
        cout << a << endl;
    }else{
        cout << b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int health = sc.nextInt();
    int power = sc.nextInt();

    int noOfAttack = health / power;
    if (health % power > 0)
      noOfAttack++;

    System.out.println(noOfAttack);
  }
}

Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int num;
    cin >> num;
    
    vector<string> str(num);
    cin >> str.at(0);
    
    int i=1;
    string tmp;

    while(cin >> tmp){
        for(auto s: str){
            if(s==tmp){
                cout << "No" << endl;
                return 0;
            }
        }
        str.at(i)=tmp;
        if(str[i-1].back() != str[i].front()){
            cout << "No"  << endl;
            return 0;
        }
        i++;
    }
        
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String[] s = new String[n];
        for(int i = 0; i < n; i++)
            s[i] = sc.next();
        sc.close();
        int[] ans = new int[26];
        Arrays.fill(ans, 50);
        for(int i = 0; i < n; i++){
            int[] c = new int[26];
            for(int j = 0; j < s[i].length(); j++){
                c[s[i].charAt(j)-'a']++;
            }
            for(int k = 0; k < 26; k++){
                ans[k] = Math.min(ans[k], c[k]);
            }
        }
        
        for(int i = 0; i < 26; i++){
            for(int j = 0; j < ans[i]; j++){
                System.out.print((char)('a'+i));
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 21460
import sys
input = sys.stdin.readline

n = int(input())
C = [list(map(int,input().split())) for i in range(n-1)]
mod = 10**9 + 7

for i in range(n-1):
    for j in range(2):
        C[i][j] -= 1

ans = 0
M = [[] for i in range(n)]
for i in range(n-1):
    M[C[i][0]].append(C[i][1])
    M[C[i][1]].append(C[i][0])

D = [[1,1] for i in range(n)]
MN = [len(M[i]) for i in range(n)]
# print("MN", MN)

V = [0] * n
Q = []
for i in range(1, n):
    if MN[i] == 1:
        Q.append(i)
        V[i] = 1

# print(Q)

s = 0
while s < len(Q):
    x = Q[s]
    for y in M[x]:
        if V[y] == 0:
            # print("y",y)
            D[y][0] = (D[y][0] * sum(D[x])) % mod
            D[y][1] = (D[y][1] * D[x][0]) % mod
            MN[y] -= 1
            if (y != 0 and MN[y] == 1) or (y == 0 and MN[y] == 0):
                V[y] = 1
                Q.append(y)
    s += 1

print(sum(D[0]) % mod)


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";

#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS
ll n,i,j,k=0,l,r,d;
cin>>l>>r>>d;

for(i=l;i<=r;i++)
{
	if(i%d==0)
{k++;}
}
cout<<k;}







Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define VI vector<int>

int main() {
    //ifstream cin("testE.in");
    int n; cin >> n;

    vector<int> x(n, 0), y(n, 0), a(n, 0);
    for(int i = 0; i < n; ++i)
        cin >> x[i] >> y[i] >> a[i];
    
    vector<vector<double>> d(n, vector<double>(n, 0));

    auto getDist = [&] (int i, int j) -> double {
        double ans = sqrt(0.0 + 1LL * (x[i] - x[j]) * (x[i] - x[j]) + 1LL * (y[i] - y[j]) * (y[i] - y[j]));
        return ans;
    };
    
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            d[i][j] = getDist(i, j);

    auto mst = [&] (vector<int> v) {
        int m = v.size();
        vector<double> dist(m, 2e10);
        vector<int> in(m, 0);
        for(int i = 0; i < m; ++i) {
            dist[i] = d[v[i]][v[0]];
        }

        in[0] = 1;
        double ans = 0.0;

        for(int it = 0; it < m - 1; ++it) {
            double minn = 2e10;
            int who = -1;
            for(int i = 0; i < m; ++i)
                if(not in[i] and dist[i] < minn) {
                    minn = dist[i];
                    who = i;
                }
            
            ans += minn;
            in[who] = 1;
            for(int i = 0; i < m; ++i)
                if(not in[i])
                    dist[i] = min(dist[i], d[v[who]][v[i]]);
        }
        
        return ans;
    };
    
    vector<double> costComp((1 << n), 0);

    for(int mask = 1; mask < (1 << n); ++mask) {
        double cost = 0;
        vector<int> sub;
        for(int i = 0; i < n; ++i) {
            if((1 << i) & mask) {
                cost += a[i];
                sub.push_back(i);
            }
        }
        costComp[mask] = (cost - mst(sub)) / (sub.size() + 0.0);
    }
    
    vector<double> dp((1 << n), 0);
    dp[0] = 1e10;

    for(int mask = 0; mask < (1 << n); ++mask) {
        for(int sub = mask; sub > 0; sub = ((sub - 1) & mask)) {
            dp[mask] = max(dp[mask], min(dp[mask - sub], costComp[sub]));
        }
    }

    cout.precision(15);
    cout << dp[(1 << n) - 1] << "\n";
}

Measured memory_bytes: 896
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    cout << accumulate(a.begin(), a.end(), (ll)0) - N << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define lll unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction

#define linf 3000000000000000000ll
#define inf 999999999
#define MX 1000000
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int ele1,ele2,ele3;
    data() {}
    data(int a,int b,int c)
    {
        ele1=a,ele2=b,ele3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.ele1> b.ele1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;



int main()
{
    int t,tc=1;
    sfl2(N,M);
    sfl1(K);
    
    ll sum1=M+K+(N-2)*M;
    ll sum2=M+K+(N-2)*K;
    ll ans=(sum2-sum1)+1;
    if(ans<=0) ans=0;
    pfl(ans);
    
    
    
    
	return 0;
}

/*



*/


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k = I()
a,b = LI()
for i in range(a,b+1):
    if i % k == 0:
        print('OK')
        quit()
print('NG')

Measured memory_bytes: 65340
#include <iostream>
using namespace std;
 
long long nod(long long a, long long b)
{
  while (a != b && a * b)
  {
    if (a > b)
      a = a % b;
    else
      b = b % a;
    if (a * b == 0)
      a += b;
  }
    return a;
}
 
int main()
{
  int n;
  long long a, b;
  cin >> n;
  cin >> a;
  for (int i = 1; i < n; i++)
  {
    cin >> b;
    a = a / nod(a, b) * b;
  }
  cout << a;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<array>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::array;
using std::queue;
using std::deque;
using std::priority_queue;
using std::multimap;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;
using std::cos;
using std::log;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;
#define PI 3.141592653589793;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N , K;

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

	cin >> N >> K;
	if(K == 1) cout << 0;
	else cout << N-K;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        
        List<String> alphabetList = new ArrayList<>();
        for (int i = 97; i < 123; i++) {
            alphabetList.add(String.valueOf((char)i));
        }
        for (int j = 97; j < 123; j++) {
            char containsAlphabet = (char)j;
            if (word.contains(String.valueOf(containsAlphabet))) {
                alphabetList.remove(String.valueOf(containsAlphabet));
            }
        }
        if (alphabetList.isEmpty()) {
           System.out.println("None"); 
        } else {
            System.out.println(alphabetList.get(0));
        }
    }
}

Measured memory_bytes: 24548
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 c = a*b;
		if(c % 2 == 0 ) {
			System.out.println("Even");
		} else if (c%2 == 1) {
			System.out.println("Odd");
		}
	}
}


Measured memory_bytes: 21844
n = int(input())
N = list(str(n))
ans = str()
res = N[0]
mn = True
bl = True
for x in N:
    if int(res) < int(x):
        mn = False
    if x != res:
        bl = False
if bl:
    print(n)
else:
    if not mn:
        for i in range(len(N)):
            ans += str(int(res) + 1)
        print(ans)
    else:
        for i in range(len(N)):
            ans += str(res)
        print(ans)



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


string inputa,inputb;


void search(int x, int y, int cnt){
  // cout << x << " " << y << " " << cnt << endl;
  if(cnt == 18) return;
  int md = (x+y)/2;

  cout << md << endl << flush;
  string inputx;
  cin >> inputx;
  if(inputx[0] == 'V') return;

  if((md%2 == 0 && inputx==inputa)or(md%2 == 1 && inputx!=inputa)){
    // inputb = inputx;
    search(md+1,y,cnt+1);
  }
  else{
    // inputa = inputx;
    search(x,md-1,cnt+1);
  }
}


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

  cout << 0 << endl << flush;
  cin >> inputa;
  // cout << input << endl;
  // cout << input[0] << endl;
  if(inputa == "Vacant") {
    exit(0);
    return 0;
  }

  cout << n-1 << endl << flush;
  cin >> inputb;
  // cout << input[0] << endl;
  if(inputb == "Vacant") {
    exit(0);
    return 0;
  }

  search(0,n-1,1);

  return 0;



}



Measured memory_bytes: 852
#include <stdio.h>

long int mkgcd(long int x, long int y) {
  if (x % y == 0)
    return y;
  else
    return mkgcd(y, x % y);
}

int main(void) {
  long int a, b, t, gcd, lcm;

  while (scanf("%ld %ld", &a, &b) != EOF) {
    if (a < b) {
      t = a;
      a = b;
      b = t;
    }

    gcd = mkgcd(a, b);
    lcm = a * b / gcd;

    printf("%ld %ld\n", gcd, lcm);
  }

  return 0;
}

Measured memory_bytes: 596
#include <iostream>


using namespace std;
int main()
{

    int r,b,z;
    cin>>r>>b;
if(r>=0 &&  r<=4500  && b>=0 &&  b<=4500){

 z=b-r;
 cout<<z+b<<endl;
}
else cout<<"WRONG";
    return 0;
}


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

int main(){
  int n,k;
  cin >>n >>k;
  int num[n]={0};
  rep(i,k){
    int d;
    cin >>d;
    vector<int> a(d);
    rep(j,d) {
      cin>>a[j];
      a[j]--;
      num[a[j]]++;
    }
  }
  int cnt = 0;
  rep(i,n){
    if(num[i]==0) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  string s;
  cin >> a >> b >> s;
  s[b - 1] += 'a' - 'A';
  cout << s << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,X,T;
    scanf("%d %d %d",&N,&X,&T);
    if(N%X==0)
    {
        printf("%d",N*T/X);
    }
    else
    {
        printf("%d",(N-N%X)*T/X+T);
    }
    return 0;
}

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

ll p5(ll a){
	return a*a*a*a*a;
}

int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0), cout.tie(0);

 ll x;
 cin >> x;
 for(int i=0; 1<=1000; i++){
 	for(int j=i-1; j>=-1000; j--){
 		if(p5(i)-p5(j) == x){
 			cout << i << " " << j << "\n";
 			return 0;
 		}
 	}
 }	

}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	int n,k;cin>>n>>k;
	vector<int> v;
	REP(i,n)
	{
		int tmp;cin >> tmp;
		v.PB(tmp);
	}
	
	sort(ALL(v),greater<int>());
	
	int ans = 0;
	REP(i,k)
	{
		ans += v[i];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n;
    int n1 = 0, n2 = 0, n4 = 0;
    for(int i=0;i<n;i++){
    	cin >> a;
    	int num = 0;
    	while(a % 2 == 0){
    		a /= 2;
    		num++;
    	}
    	if(num == 0) n1++;
        else if(num == 1) n2++;
        else n4++;
    } 
    if(n&1){
    	if(n4 == 0){
    		if(n2 == n){
    			yes();
    		}else{
    			no();
    		}
    	}else{
    		if(n == n4 * 2 + 1)yes();
    		else{
    			n -= n4 * 2;
    			if(n <= n2) yes();
    			else no();
    		}
    	}
    }else{
    	if(n4 == 0){
    		if(n2 == n){
    			yes();
    		}else{
    			no();
    		}
    	}else{
    		n -= n4 * 2;
    		if(n <= n2) yes();
    		else no();
    	}
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



from queue import deque
n,x = map(int, input().split())
a = list(map(int, input().split()))

def sub(p):
    k = p
    res = []
    q = deque([])
    # q: i0<i1<,..., a_i0>a_i1>,...であるようなi0, i1,... のキュー
    for i,num in enumerate(a):
        while q and a[q[-1]]>num:
            q.pop()
        q.append(i)
        if q[0]<=i-k:
            q.popleft()
        if i>=k-1:
            m = a[q[0]] # i-k+1,...iの中の最小値
            res.append(m)
    for j,num in enumerate(a):
        if len(res)>=n:
            break
        while q and a[q[-1] if q[-1]<n else q[-1]-n]>num:
            q.pop()
        q.append(j+n)
        if q[0]<=j+n-k:
            q.popleft()
        m = a[q[0] if q[0]<n else q[0]-n] # i-k+1,...iの中の最小値
        res.append(m)
    return sum(res)


ans = 10**15
for p in range(n):
    ans = min(ans, sub(p+1) + x*p)
print(ans)

Measured memory_bytes: 57048
#include <cstdio>

int main() {
	int A, B, C, Ans = 0;
	scanf("%d%d%d", &A, &B, &C);
	while (Ans < 99) {
		if (A & 1 || B & 1 || C & 1) break;
		int D = B + C, E = A + C, F = A + B;
		A = D / 2, B = E / 2, C = F / 2;
		++Ans;
	}
	printf("%d\n", Ans < 99 ? Ans : -1);
	return 0;
}

Measured memory_bytes: 1728
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

 main()

{
    fast
    int n;
    cin>>n;
    int a[n+5];
    multiset<int>s;
    f(i,1,n)
    {
        cin>>a[i];
        if(s.empty())s.insert(a[i]);
        else
        {
            multiset<int>::iterator it;
            it=s.lower_bound(a[i]);
            if(it==s.begin())
            {
                s.insert(a[i]);
            }
            else
            {
                it--;
                s.erase(it);
                s.insert(a[i]);
            }
        }

    }
    cout<<s.size()<<endl;
    return 0;

}





































Measured memory_bytes: 5760
function main()
  
  N = parse(Int,readline())
  p = map(x -> parse(Int,x), split(readline()))
  p_0 = p
  count = 0
  
  p = sort(p)

  for i in 1:N
    if p_0[i] != p[i]
      count += 1
    end
  end
  
  if count <= 2
    println("YES")
  else
    println("NO")
  end
  
end

main()

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

int main() {
    int n;
    cin >> n;
    pair<int, int> w[n + 1];
    long long result[n + 1] = {};
    for (int i = 1; cin >> w[i].first; i++) {
    	w[i].second = i;
    }
    sort(w + 1, w + n + 1);
    for (int i = n, j = n; i >= 1; i--) {
        j = min(j, w[i].second);
        result[j] += 1ll * (w[i].first - w[i - 1].first) * (n - i + 1);
    }
    for (int i = 1; i <= n; i++) {
    	cout << result[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int H, W; 
cin >> H >> W; 
int A[512][512] = {0}; 
int X[250000][5] = {0}; 
int count = 0; 
for(int i = 1; i <= H; i++){
  for(int j = 1; j <= W; j++){
cin >> A[i][j];
  }
}
for(int i = 1; i <= H; i++){
  for(int j = 1; j < W; j++){
if(A[i][j] % 2 == 1){
  A[i][j] --; 
  A[i][j+1] ++;
  X[count][0] = i, X[count][1] = j, X[count][2] = i, X[count][3] = j+1;   
  count ++; 
}
}
}
for(int i = 1; i < H; i++){
if(A[i][W] % 2 == 1){
  A[i][W] --; 
  A[i+1][W] ++;
  X[count][0] = i, X[count][1] = W, X[count][2] = i+1, X[count][3] = W;   
  count ++; 
}
}
cout << count << endl; 
for(int i = 0; i < count; i++){
cout << X[i][0] << " " << X[i][1] << " " << X[i][2] << " " << X[i][3] << endl; 
}
}

Measured memory_bytes: 8064