akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct packet_t {
  uint32_t t;
  uint32_t s;
  uint32_t d;

  bool operator<(const packet_t &packet) { return t < packet.t; }
};

int32_t main() {
  while (true) {
    uint32_t N, M;
    cin >> N >> M;
    if (N == 0) break;

    vector<packet_t> packets;
    for (uint32_t i = 0; i < M; i++) {
      uint32_t t, s, d;
      cin >> t >> s >> d;
      packet_t p({t, s, d});
      packets.push_back(p);
    }

    sort(packets.begin(), packets.end());
    vector<bool> infected(N + 1);
    infected[1] = true;
    for (uint32_t i = 0; i < packets.size(); i++) {
      if (infected[packets[i].s]) {
        infected[packets[i].d] = true;
      }
    }

    uint32_t count = 0;
    for (uint32_t i = 1; i <= N; i++) {
      if (infected[i]) {
        count++;
      }
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;


int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   int n; cin >> n;
   int ans = 0;
   for(int i = 1; i <= n; i++){
      if(i <= 9) ans++;
      else if(i >= 100 && i <= 999) ans++;
      else if(i >= 10000 && i <= 99999) ans++;
   }  
   cout << ans ;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int s[100005];
int main() {
     int n;
     scanf("%d", &n);
     for (int i = 0; i < n; i++) {
          scanf("%d", &s[i]);
     }
     long long a = 2, b = 2;
     for (int i = n - 1; i >= 0; i--) {
          a = (a + s[i] - 1) / s[i] * s[i];
          b = (b / s[i]) * s[i] + s[i] - 1;
     }
     if (a > b)printf("-1\n");
     else printf("%lld %lld\n", a, b);
     return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef complex<double> Point;
double EPS=1e-10;

int main()
{
	for(int n;cin>>n,n;){
		vector<Point> points;
		vector<int> nums;
		rep(i,n){
			Point p;
			scanf("%lf,%lf",&p.real(),&p.imag());
			
			bool unique=true;
			rep(j,points.size()){
				if(abs(points[j]-p)<EPS){
					nums[j]++;
					unique=false;
					break;
				}
			}
			if(unique){
				points.push_back(p);
				nums.push_back(1);
			}
		}
		
		vector<Point> ip;
		rep(i,points.size()){
			repi(j,i+1,points.size()){
				Point d=points[j]-points[i];
				if(abs(abs(d)-2)<EPS)
					ip.push_back((points[i]+points[j])/2.0);
				else if(abs(d)<2){
					double t=acos(abs(d)/2);
					ip.push_back(points[i]+polar(1.0,arg(d)+t));
					ip.push_back(points[i]+polar(1.0,arg(d)-t));
				}
			}
		}
		
		int res=1;
		rep(i,ip.size()){
			int temp=0;
			rep(j,points.size())
				if(abs(points[j]-ip[i])<1+EPS)
					temp+=nums[j];
			res=max(res,temp);
		}
		
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,m = input().split()

nn = str(n * int(m))
mm = str(m * int(n))

aa = [nn,mm]
aa.sort()
print(aa[0])





Measured memory_bytes: 3316
// PrintTestCases.cc
// オンラインジャッジでは、提出されたプログラムが複数の入力データそれぞれに対して
// 正しい出力を行っているかを判定するために、１つの入力データファイルに
// 複数のデータセットが含まれているものがあります。
// この問題は、そのようなデータセットを処理するための練習問題です。
// 
// １つの整数 x を読み込み、それをそのまま出力するプログラムを作成して下さい。
// ただし、この問題は以下に示すようにいくつかのデータセットが与えられることに注意して下さい。
// 【入力】
// 入力は複数のデータセットから構成されています。
// 各データセットは１つの整数 x を含む１行から構成されています。
// x が 0 のとき入力の終わりを示し、このデータセットに対する出力を行ってはいけません。
// 【出力】
// 各データセットごとに、以下の形式で x を出力して下さい：
// Case i: x
// ここで、i は１から始まるデータセットの番号を示します。
// Caseと番号 iの間に１つの空白を入れて下さい。
// また、:（コロン）と整数 x の間に１つの空白を入れて下さい。
// サンプル入出力を参考にして下さい。
// 【制約】
// ・1 ≤ x ≤ 10,000
// ・データセットの数は 10,000 を超えない。
// 【例】
// 入力：
// 3
// 5
// 11
// 7
// 8
// 19
// 0
// 出力：
// Case 1: 3
// Case 2: 5
// Case 3: 11
// Case 4: 7
// Case 5: 8
// Case 6: 19
#include<iostream>
using namespace std;

int main( void) {
  int i = 1, x;

  while ( true) {
    cin >> x;

    if ( x == 0) break;

    cout << "Case " << i++ << ": " << x << endl;
  }
}



Measured memory_bytes: 2980
import numpy as np
n, m, c = map(int, input().split())
li = list(map(int, input().split()))
s_li = [list(map(int, input().split())) for i in range(n)]
array1 = np.array(li)
array2 = np.array(s_li)
ans = 0
for j in range(n):
    if sum(array1 * array2[j]) + c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 12496
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int>v(n,1<<30);
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    cin >> v[i]; v[i]--;
    cnt += i == v[v[i]];
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3692
# coding:utf-8
import sys
while True:
    array = map(int, raw_input().split())
    if array[0] == 0 and array[1] == 0:
        break
    for i in range(array[0]):
        for j in range(array[1]):
            sys.stdout.write('#')
        else:
            print
    print

Measured memory_bytes: 4640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5 + 10;
typedef long double ldb;

struct Edge{
	int to , nex , val;
}e[N << 2];int head[N] , ecnt;
void adde(int fr,int to,int v){
	e[++ecnt] = (Edge){to , head[fr] , v};
	head[fr] = ecnt;
}
void addedge(int fr,int to,int v){
	adde(fr , to , v);
	adde(to , fr , v);
}
int dep[N];
void dfs(int x,int par){
	for (int j = head[x];j;j = e[j].nex)
	if (e[j].to != par){
		dep[e[j].to] = dep[x] ^ e[j].val;
		dfs(e[j].to , x);
	}
}
int n;
int main(){
	cin >> n;
	for (int i = 1;i < n;i++){
		int u , v , val;scanf("%d%d%d",&u,&v,&val);
		addedge(u , v , val & 1);
	}
	dfs(1 , 0);
	for (int i = 1;i <= n;i++) printf("%d\n",dep[i]);
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<map>
#define ll long long
using namespace std;

const int N=100005;

int n,cnt,t,ans;
ll w,s;
int pri[N],p[N];
ll a[N],b[N];
bool vis[N];
map<ll,int> mp;
map<ll,bool> tag;

void getpri(int n){
	int i,j;
	for (i=2;i<=n;i++){
		if (!vis[i]) pri[++cnt]=i;
		for (j=1;j<=cnt&&pri[j]*i<=n;j++){
			vis[i*pri[j]]=1;
			if (i%pri[j]==0) break;
		}
	}
}

ll read(){
	ll num=0; char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9'){
		num=num*10+c-'0';
		c=getchar();
	}
	return num;
}

int main(){
	int i,j;
	getpri(N-5);
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		a[i]=read(); b[i]=1; s=a[i];
		for (j=1;pri[j]<=2154;j++) if (a[i]%pri[j]==0){
			while (a[i]%(1ll*pri[j]*pri[j]*pri[j])==0){
				a[i]/=1ll*pri[j]*pri[j]*pri[j];
				s/=1ll*pri[j]*pri[j]*pri[j];
			}
			if (a[i]%pri[j]==0){
				w=a[i]; b[i]*=1ll*pri[j]*pri[j]*pri[j];
				while (w%pri[j]==0){
					w/=pri[j],b[i]/=pri[j];
					s/=pri[j];
				}
			}
		}
		if (s>1){
			w=sqrt(s);
			while ((w+1)*(w+1)<=s) w++;
			if (w*w==s) b[i]*=w;
			else b[i]*=s*s;
		}
	}
	for (i=1;i<=n;i++) mp[a[i]]++;
	if (mp[1]) ans++; tag[1]=1;
	for (i=1;i<=n;i++)
		if (!tag[a[i]]){
			ans+=max(mp[a[i]],mp[b[i]]);
			tag[a[i]]=tag[b[i]]=1;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 27008
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	cout << (n / 2) - !(n % 2) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 8;

char m[N + 1][N + 1];

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

void dfs(pii);

int main(void){
    int n, cnt = 0; cin >> n;

    while(n--){
        rep(i, N) cin >> m[i];
        pii p; cin >> p.X >> p.Y;
    
        dfs(mp(p.X - 1, p.Y - 1));

        cout << "Data " << ++cnt << ":" << endl;
        rep(y, N) cout << m[y] << endl;
    }

    return 0;
}

void dfs(pii cur){
    m[cur.Y][cur.X] = '0';   

    rep(i, 4) COUNT(j, 3){
        pii next = mp(cur.X + dx[i] * j, cur.Y + dy[i] * j);
        if(next.X < 0 || N <= next.X ||
           next.Y < 0 || N <= next.Y) continue;

        if(m[next.Y][next.X] == '1'){
            dfs(next);
        }
    }
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4

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

    int n, m;
    cin >> n >> m;
    vector<P> drink(n);
    int a, b;
    rep (i, n) {
        cin >> a >> b;
        drink[i] = {a, b};
    }
    sort(all(drink));

    int money = 0;
    repall (d, drink) {
        if (d.second <= m)
            money += d.first * d.second;
        else
            money += d.first * m;
        m -= d.second;
        if (not(m > 0)) break;
    }
    print(money);

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

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


Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}



def main():
    N, M = map(int, input().split())
    unf = UnionFind(N)
    for i in range(M):
        A, B = map(int, input().split())
        if not unf.same(A-1, B-1):
            unf.union(A-1, B-1)

    print(-min(unf.parents))

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 76888
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int x,y,a,b,c,A[N],B[N],C[N];
bool cmp(int x,int y) {return x>y;}

int main() {
	qr(x); qr(y); qr(a); qr(b); qr(c);
	for(int i=1;i<=a;i++) qr(A[i]);
	for(int i=1;i<=b;i++) qr(B[i]);
	for(int i=1;i<=c;i++) qr(C[i]);
	sort(A+1,A+a+1,cmp);
	sort(B+1,B+b+1,cmp);
	sort(C+1,C+c+1,cmp);
	A[0]=B[0]=1<<30;
	for(int i=1,j=x,k=y;i<=c;i++) {
		int u=C[i]-A[j],v=C[i]-B[k];
		if(u>=v&&u>0&&j) A[j--]=C[i];
		else if(v>=u&&v>0&&k) B[k--]=C[i];
		else break;
	}
	ll ans=0;
	for(int i=1;i<=x;i++) ans+=A[i];
	for(int i=1;i<=y;i++) ans+=B[i];
	pr2(ans);
	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
	fastio
	//t_case
	{
		ll n,m,ans=0,f=1,k=0,x,y,sum=0,h,l  ;cin>>n>>m ;
		fr(i,0,n){
			cin>>x>>y;
			if ((x*x)+(y*y)<=(m*m)) ans++;
		}
		
		cout<<ans;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, a[300], s;
ll DP[90334], res;

int main() {
	cin >> N;
	res = 1;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		s += a[i];
		res *= 3;
		res %= mod998;
	}
	DP[0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = s ; j >= 0; --j) {
			DP[j + a[i]] += DP[j];
			DP[j + a[i]] %= mod998;
			DP[j] *= 2;
			DP[j] %= mod998;
		}
	}
	for (int i = s; i * 2 >= s; --i) {
		res -= DP[i] * 3 % mod998;
		res += mod998;
		res %= mod998;
	}
	if (s % 2 == 0) {
		memset(DP, 0, sizeof DP);
		DP[0] = 1;
		for (int i = 0; i < N; ++i) {
			for (int j = s; j >= 0; --j) {
				DP[j + a[i]] += DP[j];
				DP[j + a[i]] %= mod998;
			}
		}
		res += DP[s / 2] * 3 % mod998;
		res %= mod998;
	}
	cout << res << endl;
}

Measured memory_bytes: 896
// C - Traveling Plan /

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n), e(n + 1, 0), f, g;
  g.pb(0);
  rep(i, 0, n)
  {
    cin >> d[i];
    g.pb(d[i]);
  }
  g.pb(0);
  f.pb(abs(d[0]));
  rep(i, 0, n - 1)
  {
    w = abs(d[i + 1] - d[i]);
    f.pb(w);
  }
  f.pb(abs(0 - d[n - 1]));
  rep(i, 0, n + 1)
  {
    ans += f[i];
  }
  rep(i, 0, n)
  {
    count = ans - f[i] - f[i + 1] + (abs(g[i + 2] - g[i]));
    cout << count << endl;
  }
}

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

const int maxn = 500015;
const int INF = (int) 1e9;
int e_num = 1, S, T;
int hed[maxn], dep[maxn];
struct Edge {
  int from, to, nxt, c;
} edge[maxn * 4];
void addedge(int from, int to, int c) {
  edge[++e_num] = (Edge){from, to, hed[from], c};
  hed[from] = e_num;
}
void adde(int from, int to, int c) {
  addedge(from, to, c);
  addedge(to, from, 0);
}
int que[maxn + 5], head = 0, tail = 0;
bool bfs() {
  head = tail = 0;
  que[tail++] = S;
  for (int i = S; i <= T; i++) dep[i] = 0;
  dep[S] = 1;
  while (head != tail) {
    int cur = que[head++]; head %= maxn;
    for (int i = hed[cur]; i; i = edge[i].nxt) {
      int to = edge[i].to;
      if (!dep[to] && edge[i].c) {
        dep[to] = dep[cur] + 1;
        que[tail++] = to; tail %= maxn;
      }
    }
  }
  return dep[T];
}
int dfs(int x, int flow) {
  if (x == T) return flow;
  int ret = 0;
  for (int i = hed[x]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (dep[to] == dep[x] + 1 && edge[i].c) {
      int tmp = dfs(to, std::min(flow, edge[i].c));
      edge[i].c -= tmp;
      edge[i ^ 1].c += tmp;
      flow -= tmp;
      ret += tmp;
      if (!flow) {
        break;
      }
    }
  }
  if (!ret) dep[x] = 0;
  return ret;
}
int dinic() {
  int ret = 0;
  while (bfs()) {
    ret += dfs(S, INF);
  }
  return ret;
}

const int N = 100233;
int n, visit[N], son[N], fa[N];
vector<int> e[N], g[N];
int main() {
  scanf("%d", &n);
  S = 0, T = n * 2 + 1;
  for (int i = 1, t, x; i < n; i++) {
    adde(S, i, 1);
    scanf("%d", &t);
    while (t--) {
      scanf("%d", &x);
      e[i].push_back(x);
      g[x].push_back(i);
      if (x > 1) adde(i, x + n, 1);
    }
  }
  for (int i = 2; i <= n; i++) {
    adde(i + n, T, 1);
  }
  int p = dinic();
  if (p < n - 1) return puts("-1"), 0;
  for (int i = 1; i < n; i++) {
    for (int e = hed[i]; e; e = edge[e].nxt) {
      if (edge[e].to > n && !edge[e].c) {
        son[i] = edge[e].to - n;
      }
    }
  }
  queue<int> q;
  for (auto x : g[1]) {
    q.push(x);
    visit[x] = 1;
    fa[x] = 1;
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto y : g[son[x]]) {
      if (!visit[y]) {
        q.push(y);
        visit[y] = 1;
        fa[y] = son[x];
      }
    }
  }
  if (accumulate(visit + 1, visit + n, 0) != n - 1) return puts("-1"), 0;
  for (int i = 1; i < n; i++) {
    printf("%d %d\n", fa[i], son[i]);
  }
}


Measured memory_bytes: 32000
N=int(input())
AS = list(map(int,input().split()))
if 0 in AS:
  print(0)
  exit()
s = 0
sum = 1
l=len(AS)
for i in range(l):
  A=AS[i]
  sum = sum * A
  if sum > 10**18:
    s=2
    break
if sum > 10**18:
  print(-1)
else:
  print(sum)

Measured memory_bytes: 21620
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string n;
    cin >> n;
    cout << (n[0] == n[1] || n[1] == n[2] || n[2] == n[3] ? "Bad" : "Good") << endl;
}

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

static const int maxsize = 100;


int main()
{
	int n,a[maxsize];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cout << a[i];
		if (i < n - 1)cout << " ";
	}
	cout << endl;
	for (int i = 1; i < n; i++) {
		int key = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > key) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = key;

		for (int k = 0; k < n; k++) {
			cout << a[k];
			if (k < n - 1)cout << " ";
		}
		cout << endl;
	}

    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

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 T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

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

Measured memory_bytes: 256
def main():
    global result, S
    S = int(input())
    result = 0
    bfs(0, '')
    print(result)


def bfs(i, s):
    global result, S
    if s != '' and int(s) <= S and len(set(s)) == 3:
        result += 1
    if i == len(str(S)):
        return
    i += 1
    bfs(i, s + '3')
    bfs(i, s + '5')
    bfs(i, s + '7')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
 
using namespace std;
 
 
int main() {
    
    
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '9')
        {
            s[i] = '1';
        }
        else
        {
            s[i] = '9';
        }
    }
  
  	cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, ans = 1, ma;
	cin >> n >> ma;

	for(int i=0;i<n-1;i++){
		int h;
		cin >> h;
		if(ma<=h){
			ma = h;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from math import factorial as f
def comb(n, k):
  return f(n)//(f(k) * f(n-k))
n, p = map(int, input().split())
A = list(map(int, input().split()))
o, e = 0, 0
for i in A:
  if i%2:
    o += 1
  else:
    e += 1
t = 0
for i in range(p, o+1, 2):
  t += comb(o, i)
ans = 2**e * t
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma optimize ("O3")
#pragma target ("sse4")
const int MAXN=35;
const int INF=1e9+17;
const int MOD=1000000021;
using namespace std;

char a[60][60];
int h, w;
bool ok(int i, int j) {return i>=0&&j>=0&&i<h&&j<w;}
void mainp()
{
    cin>>h>>w;
    for(int i=0; i<h; i++)
    {
        string s;
        cin>>s;
        for(int j=0; j<w; j++) a[i][j]=s[j];
    }
    
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
        {
            if(a[i][j]=='.') continue;
            int fl=0;
            if(ok(i-1, j)&&a[i-1][j]=='#') fl=1;
            if(ok(i+1, j)&&a[i+1][j]=='#') fl=1;
            if(ok(i, j-1)&&a[i][j-1]=='#') fl=1;
            if(ok(i, j+1)&&a[i][j+1]=='#') fl=1;
            if(fl==0)
            {
                cout<<"No"<<endl;
                return;
            }
        }
        
    cout<<"Yes"<<endl;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mainp();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 2019;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}


signed main()
{
	
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int s,w;
		cin>>s>>w;

		if(w >= s)
		{
			cout<<"unsafe\n";
		}
		else
		{
			cout<<"safe\n";
		}
	}
}

Measured memory_bytes: 3572
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[100000],cnt[100005],ans,x;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    cnt[a[i]]++;
}
x=1;
ans=cnt[1]+cnt[0];
for(ll i=1;i<100000;i++)
{
    if(cnt[i]+cnt[i-1]+cnt[i+1]>ans){
        ans=cnt[i]+cnt[i-1]+cnt[i+1];
        x=i;
    }
}
cout<<ans;
}



Measured memory_bytes: 1792
let (n1, n2, n_limit) = (4, 16, 45)

let area =
  [| [1; 4]; [0; 2; 5]; [1; 3; 6]; [2; 7]
   ; [0; 5; 8]; [1; 4; 6; 9]; [2; 5; 7; 10]; [3; 6; 11]
   ; [4; 9; 12]; [5; 8; 10; 13]; [6; 9; 11; 14]; [7; 10; 15]
   ; [8; 13]; [9; 12; 14]; [10; 13; 15]; [11; 14] |]

let goal = Array.init n2 (fun i -> (i + 1) mod n2)

let md = Array.make_matrix n2 n2 0

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space lower =
  let rec doit i space moved lower =
    if i = limit then begin
      if a = goal then begin
        List.length moved - 1 |> Printf.printf "%d\n";
        exit 0;
      end
    end else
      List.iter (fun j ->
        let x = a.(j) in
        if x = List.hd moved then () else
        let lower = lower - md.(x).(j) + md.(x).(space) in
        if lower + i > limit then ()
        else begin
          a.(j) <- 0;
          a.(space) <- x;
          doit (i + 1) j (x :: moved) lower;
          a.(j) <- x;
          a.(space) <- 0;
        end) area.(space) in
  doit 0 space [-1] lower

let () =
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let rec findi i =
    if i = n2 then assert false
    else if a.(i) = 0 then i
    else findi (i + 1) in
  let space = findi 0 in
  let lower =
    Array.fold_left (fun (i, sum) e -> (i + 1, sum + md.(e).(i))) (0, 0) a |> snd in
  for limit = lower to n_limit do
    idastar a limit space lower
  done

Measured memory_bytes: 4496
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

ll f(ll n, ll mult){
    return n / mult;
}

int main(){
    ll a,b,c,d; scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ll lcm = c * d / __gcd(c,d);
    ll range = b - a + 1;
    ll mult_c = f(b,c) - f(a-1,c);
    ll mult_d = f(b,d) - f(a-1,d);
    ll mult_cd = f(b,lcm) - f(a-1,lcm);
    printf("%lld\n", range - mult_c - mult_d + mult_cd);
    return 0;
}


Measured memory_bytes: 256
import itertools
N,M,Q = map(int, input().split())
L = [list(map(int, input().split())) for i in range(Q)]
ans = 0
for A in itertools.combinations_with_replacement([i for i in range(1,M+1)],N):
    sorted(A)
    pre_ans = 0
    for i in range(Q):
        a,b,c,d = L[i]
        if A[b-1] - A[a-1] == c:
            pre_ans += d
        ans = max(ans,pre_ans)
print(ans)

Measured memory_bytes: 9108
print([2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843][int(input())])

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if !ONLINE_JUDGE
#define debug
#endif

using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;
 
typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

#ifdef debug
#define dbg(...) { cerr<<"[ "; dump(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.ff<<","<<x.ss<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const unordered_map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
} 
 
template <typename Arg1>
void dump(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void dump(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    dump(names.substr(1+(int)name.size()), args...);
}
#else
    #define dbg(args...)
#endif
 
ll powmod(ll x, ll y) 
{ 
    ll res = 1;  
    x = x % MOD;
    while (y > 0) 
    { 
        if (y & 1) 
  	      res = (res*x) % MOD; 
        y = y>>1; // y = y/2 
        x = (x*x) % MOD;   
    } 
    return res; 
} 

int main()
{
	#if !ONLINE_JUDGE
	//freopen("in.txt","r",stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	
 	int n;cin>>n;
 	string s;cin>>s;

 	vector<int>f(26);
 	for(auto e:s)
 		f[e-97]++;

 	ll ans=1;
 	rep(i,26)
 		ans=ans*(f[i]+1)%MOD;

 	cout<<((ans-1)%MOD+MOD)%MOD;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
vector<int> prime(100010),dp(100010);
int isprime(int x){
    if(x==1) return 0;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return 0;
    }
    return 1;
}
void query(){
    int l,r;cin>>l>>r;
    l--;
    cout<<dp[r]-dp[l]<<endl;
}
void Main(){
    ll q;cin>>q;
    For(i,1,100001) prime[i]=isprime(i);
    For(i,1,100001) dp[i]=dp[i-1]+(prime[i]&&prime[(i+1)/2]);
    For(i,0,q) query();
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 1408
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int N, K;
		String S;

		N = scan.nextInt();
		K = scan.nextInt();
		S = scan.next();

		char[] charArray = S.toCharArray();
		String smallChar = String.valueOf(charArray[K - 1]).toLowerCase();

		char[] tmpcharArray = smallChar.toCharArray();
		charArray[K - 1] = tmpcharArray[0];

		System.out.println(new String(charArray));
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
 
int main() {
	int n, count=0;
	std::cin>>n;
	int* ara = new int[n]; 
	int* arb = new int[n];
 
	for(int i=0; i<n; i++){
        std::cin>>ara[i];
        arb[i]=ara[i];
    }
 
	std::sort(ara, ara+n);
 
	for(int i=0; i<n; i++) if(ara[i]!=arb[i]) count++;
 
	if(count==2 || count==0) std::cout<<"YES";
	else std::cout<<"NO";
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
typedef long long ll;


int main()
{
	ll mn=0 ,n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	mn = min({ a,b,c,d,e });
	cout << (n+mn-1) / mn + 4 << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		if(Math.abs(a-c) <= d) System.out.println("Yes");
		else if(Math.abs(a-b) <= d && Math.abs(b-c) <= d) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

const int mod = 2019;

int main(){
  int l, r;
  cin >> l >> r;
  vector<int> a(mod, 0);
  for(int i=l; i<=r; i++){
    int tmp = i%mod;
    if(a[tmp])
      break;
    else
      a[tmp]++;
  }
  int ans = mod;
  for(int i = 0; i<mod-1; i++){
    if(!a[i])
      continue;
    for(int j = i+1; j<mod; j++){
      if(!a[j])
        continue;
      if(i*j%mod < ans)
        ans = i*j%mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+100;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f3f3f3f3f;
ll t,n,k,a[maxn];
int main(){
    //freopen("in.txt","r",stdin);
    string a;
    cin>>a;
    ll res=0;
    for(int i=0;i<a.size();i++){
        res+=a[i]-'0';
    }
    if(res%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            char[] str = line.toCharArray();
            char c;
            for (int i = 0, j = str.length - 1; i < str.length / 2; i++, j--) {
                c = str[i];
                str[i] = str[j];
                str[j] = c;
            }
            System.out.println(str);
        }
    }
}

Measured memory_bytes: 16852
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(1e5)+5
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define max3(x, y, z) max(x, max(y, z))
#define ull long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	ll x, k;
	cin >> x >> k;
	x -= k*(x/k);
	while(abs(x-k) < x)
		x = abs(x-k);
	cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string S[3]; int c[3] = { 0 };
	int at = 0; bool f = false;
	cin >> S[0] >> S[1] >> S[2];

	do {		
		if (c[at] == S[at].length()) {
			if (at == 0) { cout << "A"; }
			else if (at == 1) { cout << "B"; }
			else { cout << "C"; }
			cout << endl; return 0;
		}
		char s = S[at][c[at]];
		if (s == 'a') {
			c[at]++;
			at = 0;
		}
		else if(s == 'b'){
			c[at]++;
			at = 1;
		}
		else if(s == 'c'){
			c[at]++;
			at = 2;
		}
	} while (1);
}

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

typedef struct {
	char team[3];
	int win;
	int lose;
} DATA;

int main(void)
{
	int n;
	int i, j;
	DATA data[11], temp;
	int r;

	while (1){

		scanf("%d", &n);
		if (n == 0) break;

		for (i = 0; i < n; i++){
			data[i].win = data[i].lose = 0;
			scanf("%s", data[i].team);
			for (j = 0; j < n - 1; j++){
				scanf("%d", &r);
				if (r == 0){
					data[i].win++;
				}
				else if (r == 1){
					data[i].lose++;
				}
			}
		}
		for (i = 0; i < n; i++){
			for (j = 0; j < n - 1; j++){
				if (data[j].win < data[j + 1].win){
					temp = data[j];
					data[j] = data[j + 1];
					data[j + 1] = temp;
				}
				else if (data[j].win == data[j + 1].win && data[j].lose > data[j + 1].lose){
					temp = data[j];
					data[j] = data[j + 1];
					data[j + 1] = temp;
				}
			}
		}
		for (i = 0; i < n; i++){
			printf("%s\n", data[i].team);
		}
	}
	return (0);
}





		
			
			
			
			

		

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

int main(){
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    rep(i, S.size()-1){
        if(S[i]==S[i+1]){
            printf("no\n");
            return 0;
        }
    }
    printf("yes\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r = sc.nextInt();
    if(n<=10){
      System.out.println(100*(10-n)+r);
    }else{
      System.out.println(r);
    }
  }
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    
    int sum = 0;
    
    for (int i = 0; i < n; i++) {
        string x;
        cin >> x;
        
        if (x == "Y") {
            sum += 1;
        }
    }
    
    if (sum > 0) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}

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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  rep(i, 10){
    cout << r*x-D << endl;
    x=r*x-D;
  }
}

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

using namespace std;

int main(void)
{
    int n;
    cin >>n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        v.push_back(tmp);
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        int c;
        cin >>c;
        if(v[i] - c > 0){
            sum += v[i] - c;
        }
    }

    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 256