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

const int M=3010;
int n;
vd dp(M);

int main(){
	cin>>n;
	dp[0]=1;
	for(int i=0;i<n;i++){
		double p;
		cin>>p;
		vd DP(M);
		for(int j=0;j<M-5;j++){
			DP[j]+=dp[j]*(1-p);
			DP[j+1]+=dp[j]*p;
		}
		dp=DP;
	}
	double res=0;
	for(int i=(n+1)/2;i<M;i++) res+=dp[i];
	cout<<syosu(11)<<res<<endl;
}

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

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

NK_min = min(N, K)

Max = 0
for r in range(NK_min + 1):
    for l in range(NK_min - r + 1):
        rev = K - r - l
        having = None
        if r == 0:
            having = V_lst[:l]
        else:
            having = V_lst[:l] + V_lst[-r:]
        having.sort()
        for _ in range(rev):
            if len(having) == 0:
                break
            if having[0] < 0:
                having.pop(0)
            else:
                break

        if Max < sum(having):
            Max = sum(having)
#        print(r,l,rev,Max)

print(Max)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int A, B, C;
	cin >> A>> B;
	int ans = (int)A/B;
	if (A%B != 0)
		ans ++;
	cout << ans << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
import scala.io.Source

object Main extends App {
  val inputStrings = Source.stdin.getLines().toList
  val List(s, t) = inputStrings.take(2)
  val result = if (s == t.take(s.length) && t.length == s.length + 1)
    "Yes"
  else
	"No"
  println(result)
}


Measured memory_bytes: 54936
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int cnt=0;
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    if(s[1]>='A'&&s[1]<='Z'){
        cout<<"WA"<<endl;
        return 0;
    }
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C')cnt++;
        else if(s[i]>='A'&&s[i]<='Z'){
            cout<<"WA"<<endl;
            return 0;
        }
    }
    if(s[s.size()-1]>='A'&&s[s.size()-1]<='Z'){
        cout<<"WA"<<endl;
        return 0;
    }
    if(cnt==1)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
    return 0;
}

Measured memory_bytes: 256
N,*A=*$<;p A.count{|x|c=*0..N.to_i;r=->a{a!=c[a]?r[c[a]]:a};(A-[x]).map{|s|eval"c[r[%d]]=r[%d]"%s.split};(c.map(&r)|[])[2]}

Measured memory_bytes: 2044
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        val = (4*n*h - N*n - N*h)
        if val > 0:
            if (N*n*h) % val == 0:
                print(h,n,(N*n*h)//val)
                exit()
            


Measured memory_bytes: 40428
#include <bits/stdc++.h>
#define ll long long int
#define NMAX 100
using namespace std;
char s[NMAX];
char a;
bool unu, doi;
int main()
{while(cin>>a)
    {
     if(a=='C')
         unu=1;
     if(a=='F' && unu)
         doi=1;
    }
 if(unu && doi)
        cout<<"Yes";
      else
        cout<<"No";
    return 0;
}


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

using namespace std;

set <int> s;
int n,k,t;
int cnt[200001];

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

	cin >> n >> k;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		s.insert(t);
		cnt[t]++;
	}

	vector <int> v;
	for(auto it : s)
	{
		v.push_back(cnt[it]);
	}
	sort(v.begin(),v.end());

	int res = 0;
	int m = s.size();
	for(int i=0;i<m-k;i++)
	{
		//cout << v[i] << '\n';
		res += v[i];
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 11512
Scanf.scanf "%d %d" (fun n m ->
    let lim = 1 lsl n in
    let sentinel = max_int / 2 in
    let dp = Array.make lim sentinel in
    dp.(0) <- 0;
    for i = 1 to m do
        Scanf.scanf " %d %d" (fun x y ->
            let rec loop i acc =
                if i = y then acc else
                    let c = Scanf.scanf " %d" (fun c -> c) in
                    loop (i + 1) (acc lor (1 lsl (c - 1)))
            in
            let c = loop 0 0 in
            for j = 0 to lim - 1 do
                dp.(j lor c) <- min dp.(j lor c) (dp.(j) + x)
            done
        )
    done;
    Printf.printf "%d\n" @@ if dp.(lim - 1) = sentinel then -1 else dp.(lim - 1)
)

Measured memory_bytes: 5924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b;
  cin>>r>>g>>b;
  int k;
  cin>>k;
    while(g<=r){k--;g=g*2;}
    while(b<=g){k--;b=b*2;}
    if(k>=0)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            string s = ReadLine();
            int ans = 1;
            for (int i = 0; i < n - 1; i++)
            {
                if (s[i] != s[i + 1])
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11232
main(N, s, d, t, i){
    for(scanf("%d",&N);N--;){
        for(t=!scanf("%d%d",&s,&d);s-d;t++){
            for(i=(i=abs(s))?i&-i:1<<30;;i/=2){
                if(s + i <= d){s += i; break;}
            }
        }
        printf("%d\n", t);
    }
}

Measured memory_bytes: 600
from math import atan, degrees
a, b, x = map(int, input().split())
if x<=a*a*b//2:
  tan = (2*x)/(a*b*b)
  print(90-degrees(atan(tan)))
else:
  m = a*b*a-x
  if m==0:
    print(0)
  else:
    tan = a*a*a/(2*m)
    print(90-degrees(atan(tan)))

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

int main(){
    int c1,c2,c3;

    while(cin>>c1){
        cin>>c2>>c3;

        array<bool,10> card;
        int total=0;
        card.fill(true);

        card[c1-1]=card[c2-1]=card[c3-1]=false;

        for(int i=20-c1-c2;i<10;i++){
            card[i]=false;
        }

        for_each(card.begin(),card.end(),[&](bool x){ if(x) total++;});

        cout<< (total>=4?"YES":"NO") <<endl;
    }

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

int main(){
	long long a, b;
	long long ans;
	cin >> a >> b;
	if(a == 1 || b == 1)ans = 1;
	else if(a%2 == 1 && b%2 == 1)ans = (a*b)/2 + 1;
	else ans = a*b/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int n;

void solve() {
	int s = 0;
	bool flag = true;
	
	for_(i,0,n) {
		char p; int x; cin >> p >> x;
		if (p == '(') s += x;
		else s -= x;
		if (s < 0) flag = false;
	}
	
	if (s > 0) flag = false;
	
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main() {
	cin >> n;
	solve();
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int cnt[27];

void fail()
{
	printf("No\n");
	exit(0);
}

int main(void)
{
	int n, m;
	scanf("%d%d", &n, &m);

	string S;
	for(int i = 0;i < n;i++)
	{
		cin >> S;
		for(auto it: S) cnt[int(it-'a')]++;
	}

	int a = 0;
	for(int i = 0;i < 27;i++) a += cnt[i]%2;
	if(a > (n%2 && m%2)) fail();	
	
	a = 0;
	int b = 0;
	if(n%2) b += m/2;
	if(m%2) b += n/2;
	for(int i = 0;i < 27;i++) a += (cnt[i]%4 == 2);
	if(a > b) fail();
	
	printf("Yes\n");
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n=0;
	scanf("%d", &n);
	int array[10000]={0};
	for(int i=1; i<n+1; i++)
	{
		scanf("%d", &array[i]);
	}
	int sum=0;
	for(int j=1; j<n+1; j++)
	{
		while(array[j]%2==0)
		{
			array[j]=array[j]/2;
			sum++;
		}
	}
	printf("%d", sum);
}

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

int main(){	
	//ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	vector<int> in(m);
	int cost[10]{0,2,5,5,4,5,6,3,7,6};

	for(int i = 0; i < m; ++i)
		cin >> in[i];
	sort(in.begin(), in.end());
	
	vector<pair<int,int>> dp(n+1);
	dp[n].first = 1;
	
	for(int i = n; i >= 0; --i){
		if(dp[i].first){
			for(auto v : in){
				if(i - cost[v] >= 0){
					if(dp[i - cost[v]].second < dp[i].second+1){
						dp[i - cost[v]].second = dp[i].second+1;
						dp[i-cost[v]].first = v;					
					}else if(dp[i - cost[v]].second == dp[i].second+1){
						if(dp[i-cost[v]].first < v)
							dp[i-cost[v]].first = v;
					}
				}
			}
		}
	}
	
	int i = 0;
	vector<int> resp;
	while(i != n){
		resp.push_back(dp[i].first);
		i += cost[dp[i].first];
	}
	
	//reverse(resp.begin(), resp.end());
	for(auto c : resp)
		cout << c;
	
    return 0;  
}








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

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    vector<int> b(N + 2);
    vector<int> next(N + 2);

    next[0] = 1;
    for (int i = 1; i <= N; i++) {
        cin >> b[i];
        next[i] = i + 1;
    }

    vector<int> ans(N, -1);

    for (int i = N - 1; i >= 0; i--) {
        int last = -1;
        int index = 1;
        int lastIndex = -1;
        for (int j = 0; j < N; j++) {
            if (next[j] > N || next[j] <= 0) continue;
            if (b[next[j]] == index) {
                last = next[j];
                lastIndex = index;
                // cout << i << " " << j << "\n";
            }
            index++;
        }
        if ( last == -1 ) {
            cout << "-1\n";
            return 0;
        } else {
            ans[i] = lastIndex;
            for (int k = 0; k <= N; k++) {
                if ( next[k] == last ) {
                    next[k] = next[last];
                    break;
                }
            }
            next[last] = -1;
        }
        // SHOW(next);
    }
    // SHOW(ans);

    for (int i = 0; i < N; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int mod;
const int nax = 2005;
int dp[3*nax][nax];

void add_self(int& a, int b) {
	a += b;
	if(a >= mod) {
		a -= mod;
	}
}

int mul(int a, int b) {
	return (long long) a * b % mod;
}

int main() {
	int n;
	scanf("%d%d", &n, &mod);
	dp[3*n][0] = 1;
	for(int rem = 3*n; rem >= 1; --rem) {
		for(int pt = 0; pt <= n; ++pt) {
			int me = dp[rem][pt];
			if(me == 0) {
				continue;
			}
			debug() << imie(rem) imie(pt) imie(me);
			add_self(dp[rem-1][pt], me);
			if(rem >= 2) {
				add_self(dp[rem-2][pt+1], mul(me, rem - 1));
			}
			if(rem >= 3) {
				add_self(dp[rem-3][pt+1], mul(me, mul(rem - 1, rem - 2)));
			}
		}
	}
	int answer = 0;
	for(int pt = 0; pt <= n; ++pt) {
		add_self(answer, dp[0][pt]);
	}
	printf("%d\n", answer);
}


/*

_ _ _ _ 5 3 _ _ _ _
        ===
        
     8 6 5 3 - impossible

_ _ _ _ 3 5 _ _ _ _ _


_ _ 6 1 2 _ _ _ _
    =====
    
_ _ _ _ _ _ 7 9 _  -> I'm using a pair
  ... 33333 1 222

#(pairs+triples) <= N       10 x 3         6 x 3,  5 x 2   ? x 1

333
...
22.
.22
333
.22
22.




dp[triples][pairs][singles]
dp[N][0][0]
dp[N-1][0][1]
    
    
1 2 _ _ _ _ _ _ _
maybe
different triples

618
x2?

?61

241536798

2??
5??
4??

x6?
5??
4??

x6?
5??
x1?

x67
xx9
xx8

*/


Measured memory_bytes: 47360
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(12)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    string s;
    cin>>s;
    ll n=s.length();
    ll a=15-n;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='o')
            a++;
    }
    if(a>=8)
        cout<<"YES";
    else
        cout<<"NO";
} 

Measured memory_bytes: 256
#標準入力
a,b = map(int,input().split())

#ドレスの数とパーティーの数が同じであればbをaで割った商を出力する
if b % a == 0:print(b // a)

#でなければbをaで割った商に1を足した値を出力する
else:print(b // a + 1)


Measured memory_bytes: 5588
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

struct edge{ll to, cost;};

int n, d[100010];
vector<edge> g[100010];

void dijkstra(int s) {
  priority_queue<PII, vector<PII>, greater<PII>> que;
  fill(d, d+n, INF);
  d[s] = 0;
  que.push(PII{0, s});

  while(que.size()) {
    PII p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(edge e: g[v]) {
      if(d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(PII{d[e.to], e.to});
      }
    }
  }
}

int a[200010], b[200010], cost[200010];
map<ll, ll> mp;
signed main(void)
{
  int m, c;
  cin >> n >> m >> c;
  ll sum = 0;
  REP(i, m) {
    cin >> a[i] >> b[i] >> cost[i];
    a[i]--, b[i]--;
    g[a[i]].PB({b[i], cost[i]});
    g[b[i]].PB({a[i], cost[i]});
    sum += cost[i];
  }
  dijkstra(0);
  VL v;
  REP(i, n) v.PB(d[i]);
  sort(ALL(v));
  v.erase(unique(ALL(v)), v.end());
  //???????????????????????????
  REP(i, m) {
    ll tmp = max(d[a[i]], d[b[i]]);
    // cout << tmp << " " << cost[i] << endl;
    if(mp.find(tmp) == mp.end()) mp[tmp] = cost[i];
    else mp[tmp] += cost[i];
  }

  // cout << "sum:" << sum << endl;
  ll ret = LLINF;
  for(int i: v) {
    // cout << "i:" << i << " " << mp[i] << endl;
    chmin(ret, c*i+(sum-mp[i]));
    sum -= mp[i];
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 26004
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
const int maxn=100010;
int a[maxn];
int main(){
	int i,j,k,n,m;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int flag=0,ans=1;
	for(i=2;i<=n;i++){
		if(flag==1 && a[i]>=a[i-1])continue;
		if(flag==-1 && a[i]<=a[i-1])continue;
		if(flag==0){
			if(a[i]>a[i-1])flag=1;
			else if(a[i]<a[i-1])flag=-1;
			else flag=0;
		}
		else{
			ans++;flag=0;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    k--;
    s[k] -= 'A';
    s[k] += 'a';
    cout << s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}
*/


//3111111111111111111111111111111


	void solve(){

		ini(n);
		ini(n1);
		vector<pair<pair<int,int>,pair<int,int>>> morty1;
		int morty[n][n1];
		int rick = 0;
		FOR(i,0,n)FOR(i1,0,n1)in(morty[i][i1]);
		FOR(i,0,n)FOR(i1,0,n1-1){
			if(morty[i][i1]%2 == 1){
				rick++;
				morty[i][i1+1]++;
				morty1.push_back(make_pair(make_pair(i+1,i1+1),make_pair(i+1,i1+2)));
			}
		}
		FOR(i,0,n-1){
			if(morty[i][n1-1]%2){
				rick++;
				morty[i+1][n1-1]++;
				morty1.push_back(make_pair(make_pair(i+1,n1),make_pair(i+2,n1)));
			}
		}
		out(rick);
		FOR(i,0,rick){
			out(morty1[i].first.first,morty1[i].first.second,morty1[i].second.first,morty1[i].second.second);
		}













	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 8176
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
	|| (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
	|| (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import numpy as np
n=int(input())
a=list(map(int,input().split()))

#連続する重複を除外
arr=np.array(a)
diff=np.diff(np.hstack((0,arr)))
aa=arr[np.nonzero(diff)]

aaa=aa.tolist()
point=[]
cnt=1
if len(aaa)<=2:
    print(1)
else:
    for i in range(len(aaa)-2):
        if (aaa[i+1]-aaa[i])*(aaa[i+2]-aaa[i+1])<0:
            cnt+=1
            point.append(i)
    
    if len(point)>1:
        for i in range(1,len(point)):
            if point[i]-1==point[i-1]:
                point[i]-=1
                cnt-=1
    print(cnt)

Measured memory_bytes: 25008
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
const ll INF=4e9+5;
ll n,cnt;
set<ll>s;
void turn(ll step,ll last,ll num){
//	cout<<step<<' '<<last<<' '<<num<<'\n';
//	cnt++;
//	if(cnt>1e7)exit(0);
	if(last==-1||num>INF){
		if(num<INF*10)s.insert(num);
		return;
	}
	if(step>10)return;
	if(step==0)for(int i=1;i<10;i++)turn(step+1,i,i);
	else{
		for(int i=last-1;i<last+2;i++)if(i>=0&&i<10)turn(step+1,i,num*10+i);
		turn(step+1,-1,num);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	turn(0,0,0);
	cin>>n;
	set<ll>::iterator it=s.begin();
	for(int i=0;i<n-1;i++,it++);
	cout<<*it;
	return 0;
}


Measured memory_bytes: 15616
open System
open System.Collections
open System.Collections.Generic
open System.IO
open System.Linq
open System.Net
open System.Security.Cryptography.X509Certificates

[<EntryPoint>]
let main _ = 
    let x = Console.ReadLine() |> int64
    let ans = 
        let a = (x / 11L) * 2L
        let b = 
            let t = x % 11L
            if   t =  0L then 0L
            elif t <= 6L then 1L
            else              2L
        a + b
    printfn "%i" ans
     
    0
    



Measured memory_bytes: 13916
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long

using namespace std;

int N;

int yuclid(int a,int b){
    while(a!=0&&b!=0){
        if(a>b){
            a=a%b;
        }
        else{
            b=b%a;
        }
    }
    if(a!=0){
        return a;
    }
    else{
        return b;
    }
}

int main(){
    cin >> N;
    vector<int> A(N,0);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    vector<int> gcd1(N-1,0);
    vector<int> gcd2(N-1,0);
    gcd1[0]=A[N-1];
    gcd2[0]=A[0];
    for(int i=0;i<N-1;i++){
        gcd1[i+1]=yuclid(A[N-2-i],gcd1[i]);
        gcd2[i+1]=yuclid(A[i+1],gcd2[i]);
    }
    vector<int> ans;
    ans.push_back(gcd1[N-2]);
    for(int i=0;i<N-2;i++){
        ans.push_back(yuclid(gcd1[N-3-i],gcd2[i]));
    }
    ans.push_back(gcd2[N-2]);
    sort(ans.begin(),ans.end());
    cout << ans[ans.size()-1] << endl;
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>

int main(int argc, char const* argv[])
{
	int input_array[100];
	int len;

	std::cin >> len;
	for (size_t i = 0; i < len; i++)
		std::cin >> input_array[i];

	for (size_t i = 0; i < len; i++)
	{
		std::cout << input_array[len - 1 - i];
		if( i != len - 1)
			std::cout << " ";
	}
    std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=10;j<=m;j++)
		if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int a, b; cin >> a >> b;
    cout << (b-1+a-2)/(a-1) << endl;
    return 0;
}

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

int N , A ,B,C ;

int main(){
  cin >> N;
    for(int i = 0;i <= N/4 ; i++){
       A = 4*i ;
      for(int j = 0; j <= N/7;j++){
        B = 7*j ;
        C = A + B ;
        if(C >= N){
           break;
          }
       }
         if(C == N){
        cout << "Yes" << endl;
        break;
         }
      }
        if(C != N){
          cout << "No" << endl;
    }
}
 



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe\n";
	else cout << "safe\n";

	return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = 10000000000000;
    for (size_t i = 1; i < 10000000; i++)
    {
        if (i == n)
        {
            break;
        }
        if (n % i == 0)
        {
            ll a = i + n / i - 2;
            if (a < ans)
            {
                ans = a;
            }
        }

        /* code */
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int a,b,k;
	cin >> a >> b >> k;
	for(int i=min(a,b);i>=1;i--){
		if(a%i==0&&b%i==0) k--;
		if(k==0){
			cout << i << endl;
			break;
		}
	}
	
/////////////////////////////////////////////
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	a,b,x=MI()
	ans=(b-a)//x

	c=a+x*ans

	if b//x*x==-(-c//x)*x:
		ans+=1

	print(ans)






if __name__ == "__main__":
	main()


Measured memory_bytes: 9080
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int h, w;
	cin >> h >> w;
	int ch = h + 1;
	int cw = w + 1;
	vector<pair<int, int>> e;
	for (int i = 0; i < h + w; i++) {
		int x;
		cin >> x;
		e.push_back({x, i < h});
	}
	int ans = 0;
	sort(e.begin(), e.end());
	for (int i = 0; i < h + w; i++) {
		if (e[i].second == 0) {
			ans += e[i].first * ch;
			cw--;
		} else {
			ans += e[i].first * cw;
			ch--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6996
/*
1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 1 から N-1 まで
3     v = A[i]
4     j = i - 1
5     while j >= 0 かつ A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
 */

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn print_vec(v: &Vec<i32>){
    for i in 0..v.len() {
        print!("{}", v[(i as usize)]);
        if i != v.len() - 1 {
            print!(" ");
        }
    }
    println!("");
}

fn main(){
    let n:usize = read();
    let mut a:Vec<i32> = read_vec();
    print_vec(&a);
    for i in 1..n {
        let mut j:usize = i - 1;
        while 0 <= (j as i32) && a[j] > a[j+1] {
            let tmp:i32 = a[j+1];
            a[j+1] = a[j];
            a[j] = tmp;

            if j == 0 { break; }
            j -= 1;
        }
        // println!("{:?}", a);
        print_vec(&a);
    }
    
}


Measured memory_bytes: 5036
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const double pi = acos(-1);
const double eps = 1e-10;


template<class T>
bool equals(T a,T b){ return fabs((a)-(b)) < eps; }

struct Point{
    double x, y;
    Point(){}
    Point(double x, double y) : x(x), y(y){}
    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x-p.x, y-p.y); }
    Point operator * (double a) { return Point(x*a, y*a); }
    Point operator / (double a) { return Point(x/a, y/a); }
    double norm() {return x*x+y*y;}
    double abs() {return sqrt(norm());}

    bool operator < (const Point &p) const {
        return x!=p.x ? x<p.x : y<p.y;
    }
    bool operator == (const Point &p) const {
        return fabs(x-p.x) < eps && fabs(y-p.y) < eps;
    }
};

bool sort_x(Point a, Point b){ return !equals(a.x,b.x)?a.x<b.x:a.y<b.y; }
bool sort_y(Point a, Point b){ return !equals(a.y,b.y)?a.y<b.y:a.x<b.x; }

typedef Point Vector;
typedef vector<Point> Polygon;
double norm(Vector a) { return a.x*a.x+a.y*a.y; }
double abs(Vector a) { return sqrt(norm(a)); }
double dot(Vector a, Vector b) { return a.x*b.x+a.y*b.y; }
double cross(Vector a, Vector b) { return a.x*b.y-a.y*b.x; }

struct Segment {
    Point p1, p2;
    Segment(){}
    Segment(Point p1, Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c, double r) : c(c),r(r) {}
};

bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a,b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
    return isOrthogonal(a1-a2, b1-b2);
}
bool isOrthogonal(Segment s1, Segment s2){
    return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a, Vector b){
    return equals(cross(a,b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2){
    return isParallel(a1-a2, b1-b2);
}
bool isParallel(Segment s1, Segment s2){
    return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1),0.0);
}

Point project(Segment s, Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}
Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    Segment s(Point(x1,y1),Point(x2,y2));
    ll q;cin>>q;
    rep(Q,q){
        double x0,y0;
        cin>>x0>>y0;
        Point x=reflect(s,Point(x0,y0));
        cout<<x.x<<" "<<x.y<<endl;
    }
    return 0;
}



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

using namespace std;
using ll=long long;

int main()
{
    int n,k;cin >>n >>k;
    vector<int>dp(n,-1);
    int h[n];
    for(int i=0;i<n;i++){
        cin >>h[i];
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i-j>=0){
                if(dp[i]<0)dp[i]=dp[i-j]+abs(h[i]-h[i-j]);
                else dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout << dp[n-1]<< endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<60;
int main(){
    unsigned long long C[55][55];
    for(int i=0;i<51;i++){
        for(int j=0;j<=i;++j){
            if(j == i or j==0) C[i][j] = 1ull;
            else C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
    int n,a,b;
    cin>>n>>a>>b;
    vector<ll> v(n);
    for(auto &a : v) cin>>a;
    sort(v.rbegin(),v.rend());
    double ret = 0.0;
    for(int i=0;i<a;++i){
        ret += v[i];
    }
    ret /= a;
    int all,count;
    all = count =0;
    for(int i=0;i<n;++i){
        if(v[i] == v[a-1]){
            all++;
            if(i < a)count++;
        }
    }
    unsigned long long retc = 0ull;
    if(count == a) {
        for(int i=a;i<=b;++i){
            retc += C[all][i];
        }
    }else retc += C[all][count];
    cout<< fixed << setprecision(20) <<  ret << endl;
    cout << retc << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

struct Weighted_Graph {
  struct edge { ll node, cost; };
  vector<vector<edge>> e;

  void set(ll x) {
	e.resize(x + 1);
  }

  void add_edge(ll a, ll b, ll c) { e[a].pb(edge{ b,c }); }

  vll dijkstra(ll start) {
	priority_queue<pll, vector<pll>, greater<pll>> pq;
	ll u;
	pll p;
	vll dist(e.size(), inf);
	dist[start] = 0;
	pq.push(pll(0, start));

	while (!pq.empty()) {
	  p = pq.top(); pq.pop();
	  u = p.second;
	  if (dist[u] < p.first) continue;
	  for (edge e1 : e[u]) {
		if (dist[e1.node] > dist[u] + e1.cost) {
		  dist[e1.node] = dist[u] + e1.cost;
		  pq.push(pll(dist[e1.node], e1.node));
		}
	  }
	}
	return dist;
  }

};


int main(void) {
  cin >> n;
  Weighted_Graph wg;
  vll d;
  ll a, b, c, q, k;
  wg.set(n);
  rep(i, n - 1) {
	scan(a); scan(b); scan(c);
	wg.add_edge(a, b, c);
	wg.add_edge(b, a, c);
  }
  cin >> q >> k;
  d = wg.dijkstra(k);

  rep(i, q) {
	scan(a); scan(b);
	printf("%lld\n", d[a] + d[b]);
  }

  return 0;
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int N; cin>>N;
    vector<pair<int,int>> Edge;
    vector<vector<int>> G(N);
    rep(i,0,N-1){
        int a,b; cin>>a>>b;
        Edge.emplace_back(a-1,b-1);
        G.at(a-1).push_back(b-1);
        G.at(b-1).push_back(a-1);
    }

    map<pair<int,int>,int> Mp;
    vector<int> Used(N,0),cParent(N,0);
    int K=0;

    queue<int> q;
    q.push(0);

    while(!q.empty()){
        int n=q.front(); q.pop();

        Used.at(n)=1;
        K=max(K,(int)G.at(n).size());

        int c=1;
        for(auto g:G.at(n)){
            if(Used.at(g)) continue;

            if(c==cParent.at(n)) c++;
            cParent.at(g)=Mp[make_pair(n,g)]=Mp[make_pair(g,n)]=c++;
            
            q.push(g);
        }
    }

    cout<<K<<endl;
    for(auto e:Edge) cout<<Mp[e]<<endl;
}

Measured memory_bytes: 20084
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    ll n,k,q;
    cin >> n >> k >> q;
    map<ll,ll> m;
    // rep(i,n) m[i+1] = k;
    rep(i,q){
        int a; cin >> a;
        m[a]++;
    }
    rep(i,n){ 
        if(m[i+1] > q-k)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 8448
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

LL weight[101], value[101], dp[100001];
const LL INF = 1e18l + 10;

int main()
{
    fast();


    LL t,n,i,j,k,x,y,c, W;
    cin >> n >> W;
    LL sum = 0;
    REP(i, n){
        cin >> weight[i] >> value[i];
        sum += value[i];
    }

    LL V = sum;

    REP(i, V + 1){
        
        dp[i] = INF;
        
    }

    dp[0] = 0;

    REP(i, n){
        for(LL val = sum - value[i]; val >= 0; --val){
            dp[val + value[i]] = min(dp[val + value[i]], dp[val] + weight[i]);
        }
    }
    LL ans = MIN;
    REP(i, sum + 1){
        if(dp[i] <= W){
            ans = max(ans, i);
        }
    }
    cout << ans;
}

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

vector<int> prime_factors(int n){
    vector<int> ans;
    for (int i=2; i*i<=n; i++){
        if (n%i==0){
            ans.push_back(i);
            while(n%i==0) {
                n /= i;
            }
        }
    }
    if (n!=1) ans.push_back(n);
    return ans;
}

int cnt[1000010];

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

    int n;
    cin>>n;
    int a[n], b[n];
    for (int i=0; i<n; i++) cin>>a[i];

    int pairwise = 1;

    for (int i=0; i<n; i++){
        vector<int> v = prime_factors(a[i]);
        for (auto e:v){
            cnt[e]++;
        }
    }

    for (auto e:cnt){
        pairwise &= (e<=1);
    }

    if (pairwise) {
        cout<<"pairwise coprime"<<endl;
    }
    else {
        int g = a[0];
        for (int i=1; i<n; i++){
            g = __gcd(g, a[i]);
        }
        if (g==1){
            cout<<"setwise coprime"<<endl;
        }
        else{
            cout<<"not coprime"<<endl;
        }
    }

    return 0;
}


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


int comp(const void *a, const void *b)
{
    return (*(int *)a - *(int *)b);
}


int main(void)
{
    int n, m;
    int t[20001];
    int i, j;
    int max;
    
    while (1){
        scanf("%d%d", &n, &m);
        if (n == 0 && m == 0){
            break;
        }
        t[0] = 0;
        for (i = 1; i <= n + m; i++){
            scanf("%d", &t[i]);
        }
        qsort(t, n + m + 1, sizeof(int), comp);
        
        max = 0;
        for (i = 0; i < n + m; i++){
            if (max < t[i + 1] - t[i]){
                max = t[i + 1] - t[i];
            }
        }
        printf("%d\n", max);
    }
    return (0);
}



Measured memory_bytes: 2080
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
signed main(){
	int n,lian=1,ans=0;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
		sort(s[i].begin(),s[i].end());
	sort(s,s+n);
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			ans+=lian;
			lian++;
		}
		else
			lian=1;
	}
	cout<<ans;
	return 0;
}

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


void solve(long long A, long long B){
    cout << A * B << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
signed main(){
    int Ans=0;
    int lg[100000][2]={};
    int lg2[100000]={};
    int lg3[100000]={};
    int H,W,D,Q;
    int A[302][302];
    int x,y;
    int L[114514],R[114514];
    
    
	cin >> H >> W >> D;
	REP(i,H){
	    REP(j,W){
	        cin >> A[i][j];
	    }
	}
	
	cin >> Q;
	
	REP(i,Q){
	    cin >> L[i] >> R[i];
	}
	
	REP(i,H){
	    REP(j,W){
	        lg[A[i][j]][0]=i;
	        lg[A[i][j]][1]=j;
	    }
	}
	for(int i=1;i<=H*W;i++){
	    if(i<=D)continue;
	    lg2[i]=abs(lg[i][0]-lg[i-D][0])+abs(lg[i][1]-lg[i-D][1]);
	}
	
	for(int i=1;i<=H*W;i++){
	    if(i<=D){
	        lg3[i]=lg2[i];
	    }else{
	        lg3[i]=lg2[i]+lg3[i-D];
	    }
	}
	
	//cout << Q << endl;
	for(int i=0;i<Q;i++){
	    Ans=0;
	    x=L[i];
	    y=R[i];
	    Ans+=lg3[y]-lg3[x];
	    cout << Ans << endl;
	}
	return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,A,B,C;
  cin >> N;
  B=C=0;
  for (int i=0;i<N;i++) {
    cin >> A;
    if (A==B+1) {B++;} else {C++;}
  }
  if (B==0) {cout << -1 << endl;} else {cout << C << endl;}
}


Measured memory_bytes: 384
/******************************************

******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define vll vector<ll>
#define fo(i, n) for(int i=0;i<n;i++)
#define MOD 1000000007

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	ll n=0, m=0;
	cin >> n>> m;
	ll sum=0;
	fo(i, m){
		ll x=0;
		cin >> x;
		sum+=x;
	}
	if(n>=sum){
		cout << n-sum;
	}
	else{
		cout << -1;
	}
	
	return 0;
}

Measured memory_bytes: 3656
n=int(input())
a=[]
b=[]
import math
for i in range(1,math.ceil(math.sqrt(n)+1)):
    if n%i==0:
        a.append(i)
        b.append(n//i)
c=[]
for i in range(len(a)):
    c.append(max(a[i],b[i]))
d=str(min(c))
print(len(d))

Measured memory_bytes: 3064
n,m=map(int,input().split())
MOD = 1000000007 
D=[0] * (n + 1)
for _ in range(m):
    D[int(input())] = -1
for i in range(n+1):
    if D[i] == -1:
        continue
    if i in (0, 1):
        D[i] = 1
        continue
    if D[i-1] != -1:
        D[i] += D[i-1]
    if D[i-2] != -1:
        D[i] += D[i-2]
    D[i]%=MOD
print(D[i] % MOD)

Measured memory_bytes: 6876