akhauriyash/Code-Regression huggingface dataset:
//██████╗ ██╗   ██╗██╗      ██████╗ ███████╗
//██╔══██╗██║   ██║██║      ██╔══██╗██╔════╝
//██████╔╝██║   ██║██║█████╗██║  ██║█████╗
//██╔══██╗██║   ██║██║╚════╝██║  ██║██╔══╝
//██║  ██║╚██████╔╝██║      ██████╔╝███████╗
//╚═╝  ╚═╝ ╚═════╝ ╚═╝      ╚═════╝ ╚══════╝
#include <bits/stdc++.h>

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
using namespace std;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))

#define ADD_OPERATORS_IN(T, COMP) \
    bool operator < (const T& ot) const { return COMP(ot) == -1; } \
    bool operator > (const T& ot) const { return COMP(ot) == 1; } \
    bool operator == (const T& ot) const { return COMP(ot) == 0; } \
    bool operator != (const T& ot) const { return COMP(ot) != 0; }

#define ADD_OPERATORS_OUT(T, COMP) \
    bool operator < (const T& a, const T& b) const { return COMP(a, b) == -1; } \
    bool operator > (const T& a, const T& b) const { return COMP(a, b) == 1; } \
    bool operator == (const T& a, const T&b) const { return COMP(a, b) == 0; } \
    bool operator != (const T& a, const T&b) const { return COMP(a, b) != 0; }


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;

mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());

template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { return (a < b ? (a = b, true) : false); }
template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { return (b < a ? (a = b, true) : false); }

const int maxn = (int) 1e6+10;
const int maxlog = 21;
const int base = 998'244'353;
const ld eps = (ld) 1e-9;
const ld PI = acos(-1.);
const int pp = 41;
const int INF = (int) 2e9;
const ll llinf = (ll) 1e18;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

//  freopen("input.txt", "r", stdin);
  int n;
  cin >> n;
  map<string, int> m;
  for (int i = 0; i < n; i ++) {
    string s;
    cin >> s;
    sort(all(s));
    m[s] ++;
  }
  ll ans = 0;
  for (auto & it : m) {
    int cnt = it.second;
    ans += 1ll * cnt * (cnt - 1) / 2;
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 11264
//ITP 1_2_C
#include <iostream>
using namespace std;

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

  if(a > b) swap(a, b);
  if(b > c) swap(b, c);
  if(a > b) swap(a, b);
  
  cout << a << " " << b << " " << c << endl;
  return 0;
}



Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        string[] inp = Console.ReadLine().Split();
        int x = int.Parse(inp[0]);
        int a = int.Parse(inp[1]);
        Console.WriteLine(x < a ? 0 : 10);
    }
}

Measured memory_bytes: 13140
import java.math.BigInteger;
import java.util.Scanner;

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

        int N = Integer.parseInt(sc.next());

        BigInteger MAX = new BigInteger("10");
        MAX = MAX.pow(80);

        for (int i = 0; i < N; i++) {
            BigInteger a = new BigInteger(sc.next());
            BigInteger b = new BigInteger(sc.next());

            System.out.println(((a.add(b)).compareTo(MAX) >= 0)? "overflow" : a.add(b));
        }
    }
}

Measured memory_bytes: 26264
import sys


def main():
    n, m = list(map(int, sys.stdin.readline().strip().split()))

    cur = [-1] * n

    # s = [0] * m
    # c = [0] * m

    for i in range(m):
        s, c = list(map(int, sys.stdin.readline().strip().split()))

        s -= 1

        # 0 in the head. e.g.
        # 3 1
        # 1 0
        if c == 0 and s != n - 1:
            return -1

        if cur[s] == -1:
            cur[s] = c
        else:
            if cur[s] == c:
                continue
            else:
                return -1

    if cur[0] == -1:
        if n > 1:
            cur[0] = 1
    for i in range(n):
        if cur[i] == -1:
            cur[i] = 0

    return ''.join([str(num) for num in cur])


result = main()
print(result)


Measured memory_bytes: 38384
//in the name of Allah
//#isart
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define S second
#define F first
#define MP make_pair
const int N = 1e5 + 10;
set<pair<int, int> > s1, s2, s3;
int a[N], b[N], c[N];
pair<int, int> d[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, z;
	cin >> x >> y >> z;
	int n = x + y + z;
	ll sumt = 0;
	for(int i = 0; i < n; i ++){
		cin >> a[i] >> b[i] >> c[i];
		a[i] -= c[i];
		b[i] -= c[i];
		d[i] = MP(a[i] - b[i], i);
		sumt += c[i];
	}
	sort(d, d + n);
	reverse(d, d + n);
	ll sum1 = 0, sum2 = 0;
	for(int i = 0; i < x; i ++){
		s1.insert(MP(a[d[i].S], i));
		sum1 += a[d[i].S];
	}
	for(int i = x; i < n; i ++){
		if(i - x < y){
			s2.insert(MP(b[d[i].S], i));
			sum2 += b[d[i].S];
			continue;
		}
		auto itr = s2.begin();
		int mn = itr -> F;
		if(mn < b[d[i].S]){
			s2.erase(itr);
			s3.insert(MP(itr -> F, itr -> S));
			sum2 -= mn;
			s2.insert(MP(b[d[i].S], i));
			sum2 += b[d[i].S];
		}
		else{
			s3.insert(MP(b[d[i].S], i));
		}
	}
	ll ans = sum1 + sum2;
	for(int i = x; i < n - y; i ++){
		auto itr = s1.begin();
		int mn = itr -> F;
		if(mn < a[d[i].S]){
			s1.erase(itr);
			sum1 -= mn;
			s1.insert(MP(a[d[i].S], i));
			sum1 += a[d[i].S];
		}
		if(s2.find(MP(b[d[i].S], i)) != s2.end()){
			s2.erase(MP(b[d[i].S], i));
			sum2 -= b[d[i].S];
			auto itr2 = s3.end();
			itr2 --;
			s2.insert(MP(itr2 -> F, itr2 -> S));
			sum2 += itr2 -> F;
			s3.erase(itr2);
		}
		else{
			s3.erase(MP(b[d[i].S], i));
		}
		ans = max(ans, sum1 + sum2);
	}
	cout << ans + sumt;
	return 0;
}

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

int main() {
	long long N; cin >> N;
	long long a[5];
	cin >> a[0];
	long long m = a[0];
	int z = 0;
	for (int i = 1; i < 5; i++) {
		cin >> a[i];
		if (m > a[i]) {
			m = a[i];
			z = i;
		}
	}
	long long ti;
	if (N % m == 0)ti = N / m;
	else ti = N / m + 1;
	cout << ti + 4;
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
//constexpr ll MOD = 1e9+7;
constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll n, s;
	cin >> n >> s;
	Vec a(n);
	rep(i, n) cin >> a[i];

	Vec sum(s + 1);

	ll ans = 0;
	rep(i, n){
		repnr(j, s){
			if(j > a[i]) sum[j] += sum[j - a[i]];
			if(j == a[i]) sum[j] += i + 1;
		}
		rep(i, s + 1) sum[i] %= MOD;
		ans += sum[s];
		ans %= MOD;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var t = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            var s = int.Parse(line[2]);
            if (t == -1 && h == -1 && s == -1) break;
            var def = new TimeSpan(2, 0, 0) - new TimeSpan(t, h, s);
            Console.WriteLine("{0:00}:{1:00}:{2:00}", def.Hours, def.Minutes, def.Seconds);
            var t3 = TimeSpan.FromSeconds(def.TotalSeconds * 3);
            Console.WriteLine("{0:00}:{1:00}:{2:00}", t3.Hours, t3.Minutes, t3.Seconds);
        }
    }
}

Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define ITR(x, c) for(__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
    vector<PP> V;
    cin>>n;
    rep(i,n){
        cin>>a>>b;
        V.push_back({a+b,a-b});
    }

    sort(all(V));

    vl BEGIN(n,0),END(n,0),MAX(n,0),dp(n,0);
    rep(i,n){
        BEGIN[i]=V[i].second;
        END[i]=V[i].first;   
    }

    rep(i,n){
        x=upper_bound(all(END),BEGIN[i])-END.begin();
        if(x==0){
            dp[i]=1;
            if(i==0)MAX[i]=1;
            else MAX[i]=max(MAX[i-1],dp[i]);
        }
        else{
            dp[i]=MAX[x-1]+1;
            MAX[i] = max(MAX[i - 1], dp[i]);
        }
    }

    cout<<MAX[n-1]<<endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<double> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    for(int i=0;i<n;i++){
        cout<<vec[n-i-1];
        if(i==n-1){
            printf("\n");
        }
        else{
            printf(" ");
        }
    }
}


Measured memory_bytes: 3264
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
    ll N;
    cin >> N;

    if (N % 2 == 1){
        cout << 0 << endl;
    }
    else{
        ll div = 10;
        ll ans = 0;
        while (N / div > 0){
            ans += (N / div);
            div *= 5;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import scala.annotation.tailrec

object Main extends App {
  @tailrec
  def loop(ints: List[Int], sum: Int, count: Int, l: Int): Int =
    ints match {
      case List() => sum + count / 2
      case r :: remaining =>
        loop(remaining, sum + (if (l == r) 0 else count / 2), if (l == r) count + 1 else 1, r)
    }

  val sc = new java.util.Scanner(System.in)
  val x :: xs = List.fill(sc.nextInt())(sc.nextInt())
  println(loop(xs, 0, 1, x))
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const ll INF = 1e15;
auto minn(auto& a, auto b){a = min(a, b);}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, W;
  cin >> N >> W;

  auto total = 0;
  vi w(N), b(N);
  rep(i, 0, N) {
    cin >> w[i] >> b[i];
    total += b[i];
  }
  auto dp = vector<ll>(total + 1, INF); // dp[i] = min weight needed for i benefit
  dp[0] = 0;
  rep(i, 0, N) {
    for (int benefit = total; benefit >= 0; benefit--) {
      if (benefit >= b[i])
	minn(dp[benefit], dp[benefit - b[i]] + w[i]);
    }
  }
  int best = 0;
  rep(i, 1, total + 1)
    if (dp[i] <= W)
      best = i;
  cout << best << '\n';
  
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	count := 0
	for i := 1; i <= N; i++ {
		N_str := fmt.Sprintf("%d", i)
		if len(N_str) % 2 == 1 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>
#define N 100

int naosi(char []);
void kyosei(int);

int main(void){
	int i,j;
	int n,a,b;
	char str[N];
	scanf("%d",&n);
	while(n--){
		scanf("%s",str);
		a=naosi(str);
		scanf("%s",str);
		b=naosi(str);
		a+=b;
		kyosei(a);
	}
	return 0;
}

int naosi(char str[]){
		int k=0;
		int i,j;
		int kotae=0;
		for(i=0;i<strlen(str);i++){
			if('0'<=str[i] && str[i]<='9'){
				k*=10;
				k+=str[i]-'0';
			}else{
				switch(str[i]){
					case 'm':
					if(k==0) kotae+=1000;
					else kotae+=k*1000;
					k=0;
					break;
					case 'c':
					if(k==0) kotae+=100;
					else kotae+=k*100;
					k=0;
					break;
					case 'x':
					if(k==0) kotae+=10;
					else kotae+=k*10;
					k=0;
					break;
					case 'i':
					if(k==0) kotae+=1;
					else kotae+=k*1;
					k=0;
					break;
				}
			}
		}
		return kotae;
}

void kyosei(int a){
	int i,j;
	if(a/1000!=0){
		if(a/1000==1){
			printf("m");
		}else{
			printf("%dm",a/1000);
		}
	}
	a%=1000;
	
	if(a/100!=0){
		if(a/100==1){
			printf("c");
		}else{
			printf("%dc",a/100);
		}
	}
	a%=100;
	
	if(a/10!=0){
		if(a/10==1){
			printf("x");
		}else{
			printf("%dx",a/10);
		}
	}
	a%=10;
	
	if(a/1!=0){
		if(a/1==1){
			printf("i");
		}else{
			printf("%di",a/1);
		}
	}
	a%=1;
	printf("\n");
}

Measured memory_bytes: 612
def main():
    buf = input()
    n = int(buf)
    buf = input()
    buflist = buf.split()
    b = list(map(int, buflist))

    a = []
    for i in range(n):
        a.append(100001)
    for i in range(n-1):
        a[i] = min(a[i], b[i])
        a[i+1] = min(a[i+1], b[i])

    ans = sum(a)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,A,B; cin>>N;
	ll ret=0;
	vector<ll> X(N);
	for (int i=0; i<N; i++)
		cin>>A>>B, ret-=B, X[i]=A+B;
	sort(X.rbegin(),X.rend());
	for (int i=0; i<N; i+=2)
		ret+=X[i];
	cout<<ret<<"\n";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int H, W; cin >> H >> W;
  int h, w; cin >> h >> w;

  int ans = W * H - h * W - (H - h) * w;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  int m = 1;
  for (int i = 0; i < n; i++)
  {
    if (m * 2 >= m + k)
    {
      m += k;
    }
    else
    {
      m *= 2;
    }
  }
  cout << m << endl;
  return 0;
}

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

int main(){
    long long A, B; cin >> A >> B; A--;
    long long ans = 0;

    for( long long i = (A/4)*4; i <= A; i++ ) ans = ans ^ i;
    for( long long i = (B/4)*4; i <= B; i++ ) ans = ans ^ i;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int A, B, l1, r1, l2, r2, l3, r3;

void solve(){
    l1 = ceil((float)(A) * 100 / 8);
    r1 =ceil(float(A+1) * 100 / 8)-1;
    // cout << l1 << " " << r1 << endl;
    l2 = floor(B * 10);
    r2 = (B+1) * 10 - 1;
    // cout << l2 << " " << r2 << endl;

    l3 = max(l1, l2);
    r3 = min(r1, r2);
    // cout << l3 << " " << r3 << endl;
    if(l3<=r3)
        cout << l3 << endl;
    else
        cout << -1 << endl;
    }

int main(){
    cin >> A >> B;

    solve();
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,i,s,ten=1;
    while(cin >> a >> b ){
        s=a+b;
        for(i=1;i<8;i++){
            ten=ten*10;
            if(s/ten==0){
                cout << i << endl;
                break;
            }
        }
        ten=1;
    }

return 0;
}

Measured memory_bytes: 1160
def unique(S):
    new = []
    for i in S:
        if not i in new:
            new.append(i)
    return new

def solve(S):
    if not len(unique(S)) == len(S):
        return False
    for i in range(len(S)-1):
        if not S[i][-1] == S[i+1][0]:
            return False
    return True

N = int(input())
S = [input() for i in range(N)]
print("Yes" if solve(S) else "No")


Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
const int INF=-333;
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
struct masu{
bool ue,si,mi,hi;
};
int main(){
	int w,h;
	while(true){
	cin>>w>>h;
	if(w==0&&h==0)break;
	masu t[50][50];
	int ans[50][50];
	queue<pair<int,int> >bfs;
	for(int i=0;i<50;i++)for(int j=0;j<50;j++)t[i][j].ue=0,t[i][j].si=0,t[i][j].hi=0,t[i][j].mi=0,ans[i][j]=INF;
	int neko=0;
	for(int i=0;i<h*2-1;i++){
		int tmp;
		if(i%2==0)for(int j=0;j<w-1;j++){
		cin>>tmp;
		if(tmp==1)t[neko][j].mi=1,t[neko][j+1].hi=1;
		}
		else for(int j=0;j<w;j++){
		cin>>tmp;
		if(tmp==1)t[neko][j].ue=1,t[neko-1][j].si=1;
		}
		if(i==0)neko++;
		else if(i%2==0)neko++;
	}
	/*for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	cout<<i<<" "<<j<<"  ";
	if(t[i][j].ue==1)cout<<"ue"<<" ";
	if(t[i][j].si==1)cout<<"sita"<<" ";
	if(t[i][j].mi==1)cout<<"migi"<<" ";
	if(t[i][j].hi==1)cout<<"hidari"<<" ";
	cout<<endl;
	}
	}*/
	ans[0][0]=0;
	pair<int,int> xxx(0,0);
	bfs.push(xxx);
	while(bfs.empty()==false){
	pair<int,int>tmp=bfs.front();
	bfs.pop();
	//cout<<tmp.first<<" "<<tmp.second<<endl; 
	int tf=tmp.first,ts=tmp.second;
	if(tf+1<h&&t[tf][ts].si==0&&ans[tf+1][ts]==INF){//下に行くことができかつ下に壁はない。
	ans[tf+1][ts]=ans[tf][ts]+1;
	bfs.push(make_pair(tf+1,ts));
	}
	if(tf-1>=0&&t[tf][ts].ue==0&&ans[tf-1][ts]==INF){//上に行けて上に壁はない
	ans[tf-1][ts]=ans[tf][ts]+1;
	bfs.push(make_pair(tf-1,ts));
	}
	if(ts+1<w&&t[tf][ts].mi==0&&ans[tf][ts+1]==INF){
	ans[tf][ts+1]=ans[tf][ts]+1;
	bfs.push(make_pair(tf,ts+1));
	}
	if(ts-1>=0&&t[tf][ts].hi==0&&ans[tf][ts-1]==INF){
	ans[tf][ts-1]=ans[tf][ts]+1;
	bfs.push(make_pair(tf,ts-1));
	}
	}
	if(ans[h-1][w-1]==INF)cout<<0<<endl;
	else cout<<ans[h-1][w-1]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
N, M = map(int, input().split())
#A = [0]*M
A_map = map(int, input().split())
A = list(A_map)
sum_homeworkday = 0
for i in range(M):
    sum_homeworkday = A[i] + sum_homeworkday
play_days = N -sum_homeworkday
if play_days >= 0:
    print(play_days)
else:
    print(-1)

Measured memory_bytes: 10192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    string S;
    cin >> N >> S;
    /*vector<vector<ll>> v(26);
    rep(i,N){
        v[S[i]-'a'].push_back(i);
    }*/
    vector<vector<ll>> dp(5005, vector<ll>(5005));
    for(ll i=N-1;i>=0;i--){
        for(ll j=N-1;j>=0;j--){
            if(S[i] == S[j]){
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }
    ll ans = 0;
    rep(i,N){
        rep(j,N){
            if(i >= j) continue;
            cmax(ans, min(dp[i][j], ll(j-i)));
        }
    }    
    cout << ans << endl;
    /*(i,N-1){
        cnt = 0;
        ll st = i+1;
        REP(j,i+1,N){
            if(st <= i){
                cmax(ans,cnt);
                cnt = 0;
                continue;
            }
            if(S[i] == S[j]){
                cnt++;
                i++;
            }else{
                cmax(ans, cnt);
                cnt = 0;
                st = (j+1);
            }
        }
    }
    cmax(ans, cnt);
    cout << ans << endl;*/
}   

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



#define REP(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    VI;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int>> VVI;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

double func(ll a_){
    ll a = a_;
        ll s = 0;
        while(a>0){
            s+=a%10;
            a = a/10;
        }
        return (double)a_/s;
}
int main(){
    long long k;
    
    cin >> k ;
    vector<ll> c;
    vector<double> fs;
    for(int i = 0; i < 9; i++){
        c.push_back(i+1);
        fs.push_back(func(i+1));
    }
    for(int i = 19; i < 100LL; i+=10){
        c.push_back(i);
        fs.push_back(func(i));
    }
    ll a = 1;

    for(ll ke = 3; ke <=15; ke++){
        for(ll i = 101; i <= 1000; i++){
            c.push_back(i*a-1);
            fs.pb(func(i*a-1));
        }
        a*=10;
    }

    ll n = 0;
    for(int i = 0; i < c.size(); i++){
        double f = fs[i];
        bool b = true;
        //cout << c[i] <<" "<< fs[i] << endl;
        for(int j = i+1; j < c.size(); j++){
            if(f > fs[j]){
                //cout << fs[i] << endl;
                b = false;
                break;
            }
        }
        //if(b && n < k)cout << c[i] << " " << fs[i] << "sunuke" <<endl;
        if(b && n < k){cout << c[i] <<endl;
        
        n++;}
        //else cout << c[i] << " " << fs[i] <<endl;
    }

    return 0;
}

Measured memory_bytes: 512
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))

d = {0: 1}

for cur in X:
  for k, v in list(d.items()):
    d[cur + k] = d.get(cur + k, 0) + v
    
print(d[0]-1)

Measured memory_bytes: 3188
s = input()
a = s[0]
b = s[len(s)-1]
n = len(s) % 2
if n == 1 and a == b:
    print('Second')
elif n == 1 and a != b:
    print('First')
elif n == 0 and a == b:
    print('First')
else:
    print('Second')


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define mp(x,y) 	     make_pair(x,y)
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define loop(n,i,a)      for(int i=a;i<n;i++)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        loop(n,i,0){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i;
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define pp               pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
//int m=10000009;
//int arr[100000];
#define M 					1000000007 
int isprime(int n)
{
        if(n<=1) return 0;
        if(n<=3) return 1;
        if(n%2==0 ||n%3==0)
        return 0;
    for(int i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)
        return 0;
    }
    return 1;
}
#define PI 3.1415926535
signed main(){
				fast
				//	freopen("input.txt","r",stdin);
				//	freopen("output.txt","w",stdout);
				int n;
				cin>>n;
				string s;
				cin>>s;
				if(!(n<3200))
				cout<<s;
				else cout<<"red";			}
			
				
		
		 
		 


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main()
{
  int N, mas[100001];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> mas[i];
  const int inf = (1 << 30);
  vector<int> cost(N, inf);
  typedef pair<int, int> P;
  priority_queue<P, vector<P>, greater<P> > que;
  cost[0] = 0;
  que.push(P(0, 0));
  while(!que.empty()){
    P p = que.top(); que.pop();
    if(p.second >= N-1){
      cout << p.first << endl;
      break;
    }
    if(p.first > cost[p.second]) continue;
    if(mas[p.second] == 0){
      for(int i = 1; i <= 6; i++){
	if(p.second + i >= 0 &&
	   p.second + i < N &&
	   p.first + 1 < cost[p.second + i]){
	  cost[p.second + i] = p.first + 1;
	  que.push(P(p.first + 1, p.second + i));
	}
      }
    } else {
      if(p.second + mas[p.second] >= 0 &&
	 p.second + mas[p.second] < N &&
	 p.first < cost[p.second + mas[p.second]]){
	cost[p.second + mas[p.second]] = p.first;
	que.push(P(p.first, p.second + mas[p.second]));
      }
    }
  }
  return 0;
}

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

int main()
{
	int a, b, c, num = 0;
	cin >> a >> b >> c;
	for (int i = 0; b >= a + i; i++) {
		if (c%(i + a) == 0) {
		num= num + 1;
		}
	}
	cout << num << '\n';

	return 0;
}

Measured memory_bytes: 3084
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
cum_a=[0]*(n+2)
for i in range(n+1):
  cum_a[i+1]=cum_a[i]+abs(a[i+1]-a[i])
for i in range(n):
  print(cum_a[n+1]-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]))

Measured memory_bytes: 65644
#include<stdio.h>
#include<string.h>
int main()
{
	int i,j;
	char s[90],t[90];
	for(;gets(s);)
	{
		for(i=0;i<27;i++)
		{
			for(j=0,memcpy(t,s,sizeof(s));s[j];j++)
				if(s[j]>=97&&s[j]<123)
					t[j]=s[j]+i<123?s[j]+i:s[j]+i-26;
			if(strstr(t,"the")||strstr(t,"this")||strstr(t,"that"))
				break;
		}
		puts(t);
	}
	return 0;
}

Measured memory_bytes: 524
# AGC008A - Simple Calculator
from itertools import product


def main():
    x, y = tuple(map(int, input().rstrip().split()))
    ans = float("inf")
    for i, j in product(range(2), repeat=2):
        a, b, cnt = x, y, 0
        # reverse signs
        a *= -1 if i == 1 else 1
        b *= -1 if j == 1 else 1
        cnt += i + j

        if a <= b:
            cnt += abs(b - a)
            ans = min(ans, cnt)
    print(ans)


if __name__ == "__main__":
    main()

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto && (i) : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
// constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n;
  cin >> n;
  cout << (n == 0 ? 1 : 0) << '\n';
  return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;


namespace AtCoderDotNetCore
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			var a = new int[3, 3];
			var dict = new Dictionary<(int, int), bool>();
			for (var j = 0; j < 3; ++j) {
				var array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				for (var k = 0; k < 3; ++k) {
					a[j, k] = array[k];
					dict.Add((j, k), false);
				}
			}

			long n = int.Parse(Console.ReadLine());
			var b = new int[n];
			for (var j = 0; j < n; ++j) {
				b[j] = int.Parse(Console.ReadLine());
			}

			for (var j = 0; j < 3; ++j) {
				for (var k = 0; k < 3; ++k) {
					for (var l = 0; l < n; ++l) {
						if (b[l] == a[j, k]) {
							dict[(j, k)] = true;
						}
					}
				}
			}

			bool bingo = dict[(0, 0)] && dict[(0, 1)] && dict[(0, 2)];
			bingo = bingo || (dict[(1, 0)] && dict[(1, 1)] && dict[(1, 2)]);
			bingo = bingo || (dict[(2, 0)] && dict[(2, 1)] && dict[(2, 2)]);
			bingo = bingo || (dict[(0, 0)] && dict[(1, 0)] && dict[(2, 0)]);
			bingo = bingo || (dict[(0, 1)] && dict[(1, 1)] && dict[(2, 1)]);
			bingo = bingo || (dict[(0, 2)] && dict[(1, 2)] && dict[(2, 2)]);
			bingo = bingo || (dict[(0, 0)] && dict[(1, 1)] && dict[(2, 2)]);
			bingo = bingo || (dict[(0, 2)] && dict[(1, 1)] && dict[(2, 0)]);

			if (bingo) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}
}

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


void solve(long long X){
    long long ans = 0;
    for(long long b = 1; b < 1000; ++b){
        for(long long p = 2; p < 1000; ++p){
            long long num = pow(b, p);
            if(num <= X) ans = max(ans, num);
        }
    }
    cout << ans << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>

using namespace std;


int main() {

    int S, W;
    cin >> S >> W;

    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }


    return 0;

}

Measured memory_bytes: 3584
sx,sy,tx,ty=map(int,input().split())
x,y=tx-sx,ty-sy
Root=''
#Go1
Root+='L'+'U'*(y+1)+'R'*(x+1)+'D'
#Back1
Root+='L'*x+'D'*y
#Go2
Root+='D'+'R'*(x+1)+'U'*(y+1)+'L'
#Back2
Root+='D'*y+'L'*x
print(Root)

Measured memory_bytes: 3060
text={'S':[1,2,3,4,5,6,7,8,9,10,11,12,13],'H':[1,2,3,4,5,6,7,8,9,10,11,12,13],'C':[1,2,3,4,5,6,7,8,9,10,11,12,13],
      'D':[1,2,3,4,5,6,7,8,9,10,11,12,13]}
lim=int(input())
j=1
while(j<=lim):
  p=input().split(" ")  
  i=0
  for key in text:
      
      if key==p[i]:
          for k in range(13):
              if int(p[i+1])==text[key][k]:
                  del text[key][k]
                  break
  j+=1
for e in [k for k,v in text.items() if len(v) == 0]: text.pop(e)
for key in text:
    for t in range(0,len(text[key]),1):
        print(key,text[key][t])


Measured memory_bytes: 5624
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

int main(){
	char str[30];
	int i=0;
	
	cin >> str;
	
	for(i = strlen(str) - 1;i>=0;i--) cout<<str[i];
	
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 1136
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    long[] A=new long[N];

	    long k=0;
	    long g=0;
        for(int i=0; i<N;i++) {
            A[i]=gl();
            if(A[i]%2==0) {
            	g++;
            } else {
            	k++;
            }
	    }
	    
        if(k%2==0) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }

		//System.out.println();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 58256
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100000+1];
int l[100000+1];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d",&a[i]);
    l[0]=a[0];
    int chang=1;
    for (int i=1;i<n;i++)
    {
        if(l[chang-1]<a[i]){
            l[chang++]=a[i];

        }else{
        *lower_bound(l,chang+l,a[i])=a[i];
        }
    }
    printf("%d\n",chang);
    return 0;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	vector<vector<int>> A(3, vector<int>(3));
	for(int i=0; i<3; i++) for(int j=0; j<3; j++){
		cin >> A[i][j];
	}
	int N;
	cin >> N;
	vector<int> B(N);
	for(int i=0; i<N; i++) cin >> B[i];

	bool ok = false;
	vector<vector<bool>> m(3, vector<bool>(3));
	for(int i=0; i<3; i++) for(int j=0; j<3; j++){
		for(int k=0; k<N; k++){
			if(A[i][j]==B[k]) m[i][j]=true;
		}
	}

	if(m[0][0]&&m[0][1]&&m[0][2] ||
			m[1][0]&&m[1][1]&&m[1][2] ||
			m[2][0]&&m[2][1]&&m[2][2] ||
			m[0][0]&&m[1][0]&&m[2][0] ||
			m[0][1]&&m[1][1]&&m[2][1] ||
			m[0][2]&&m[1][2]&&m[2][2] ||
			m[0][0]&&m[1][1]&&m[2][2] ||
			m[2][0]&&m[1][1]&&m[0][2]){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
#n = int(input())
#d, t, s = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))

t = input()
ans = 10000
for i in range(len(s) - len(t) + 1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1

    if cnt < ans:
        ans = cnt

print(ans)






Measured memory_bytes: 27132
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int N; cin >> N;

    int m = N % 100;
    int r = N / 100;

    if (r * 5 >= m)
        cout << 1 << '\n';
    else 
        cout << 0 << '\n';
    
}


Measured memory_bytes: 256
import collections,sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
N = I()
S = S()
ans = 0
for i in range(N):
    set_top = set()
    set_bottom = set()
    for s in collections.Counter(S[:i]):
        set_top.add(s)
    for s in collections.Counter(S[i:]):
        set_bottom.add(s)
    ans = max(ans,len(set_top&set_bottom))
print(ans)


Measured memory_bytes: 3316
#pragma optimize("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
// #include<iomanip>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
    Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
    }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
    Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
    }
};

ll modpower(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
ll power(ll x, ll y)
{
    ll res = 1;     // Initialize result
    x = x ;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}
// int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return modpower(a,p-2,p);}

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

long long safe_sqrt(long long n) {
    long long res = sqrt((long double) n);
    if (res*res == n) return res;
    const long double eps = 1e-8;
    if ((long double)(res+1)*(res+1) < n + eps) return res+1;
    if ((long double)res*res + eps > n) return res-1;
    return res;
}   
// (a+b-1)/b for ceil
void solve(){
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    f(i, 0, n){
        if (i==k-1)
        {
            char c = s[i]+'a'-'A';
            cout<<c;
        }
        else {
            cout<<s[i];
        }
    }
    return ;
}
int main()
{
    IO;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
    int T = 1;
    // cin >> T;
    f(c, 0, T){
        solve();
    }
    return 0;
}//multiset m make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue 
//cout<<setprecision(12); push_back pop_back pop_front push_front  lower_bound upper_bound  reverse

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<climits>
using namespace std;
void File(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define inf INT_MAX
ll a,b,c,k;
int main(){
	//File();
	cin>>a>>b>>c>>k;
	int s=(k%2==0) ? a-b : b-a;
	if(abs(s)>(int)1e18)cout<<"Unfair"<<endl;
	else cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
int dc(int n)
{
    if(n==0) return 1;
    int c = 0;
    while(n>0){
        c++;
        n/=10;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a,c=0;
    cin>>a;
    f1(i,a) c+=dc(i)%2;
    cout << c;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

long long int j,i,min,max,sum;
long long int n[10000];
sum = 0;
scanf("%ld",&j);
for(i = 0; i < j;i++){
scanf("%ld",&n[i]);
}
for(i =0 ; i < j;i++){
sum += n[i];
}
max = n[0];
for(i = 0; i < j; i++)
  if(max < n[i]){
  max = n[i];
}
min = n[0];
for(i = 0; i < j; i++)
  if(min > n[i]){
  min = n[i];
}
printf("%ld %ld %ld\n",min,max,sum);
return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
const int mod=1e9+7,N=100005;
int n,ans;
int a[N],du[N],cir[N],vis[N],footL[N],sum[N],f[N];
int qm(int x) {return x>=mod?x-mod:x;}
void workcir(int x) {
	int now=0,fr=0,ed=0,frL=0;
	while(cir[x]) {
		++now,cir[x]=0;
		if(footL[x]) {
			if(!fr) ed=fr=now,frL=footL[x];
			else {
				int kl=(footL[x]<now-ed)+(footL[x]<=now-ed);
				ans=1LL*ans*kl%mod,ed=now;
			}
		}
		x=a[x];
	}
	if(!fr) ++sum[now];
	else {
		int kl=(frL<now-ed+fr)+(frL<=now-ed+fr);
		ans=1LL*ans*kl%mod;
	}
}
void work() {
	for(RI i=1;i<=n;++i) {
		if(du[i]) continue;
		int x=i,len=0;while(!cir[x]) x=a[x],++len;
		footL[x]=len;
	}
	ans=1;
	for(RI i=1;i<=n;++i) if(cir[i]) workcir(i);
	//cout<<ans<<endl;
	for(RI i=1;i<=n;++i) {
		if(!sum[i]) continue;
		f[0]=1;
		for(RI j=1;j<=sum[i];++j) {
			if(i>1&&(i&1)) f[j]=qm(f[j-1]+f[j-1]);
			else f[j]=f[j-1];
			if(j>1) f[j]=qm(f[j]+1LL*f[j-2]*(j-1)%mod*i%mod);
		}
		ans=1LL*ans*f[sum[i]]%mod;
	}
}
int main()
{
	n=read();
	for(RI i=1;i<=n;++i) a[i]=read(),++du[a[i]];
	for(RI i=1;i<=n;++i) {
		if(vis[i]) continue;
		int x=i;while(!vis[x]) vis[x]=i,x=a[x];
		if(vis[x]!=i) continue;
		while(!cir[x]) cir[x]=1,x=a[x];
	}
	for(RI i=1;i<=n;++i)
		if((cir[i]&&du[i]>2)||(!cir[i]&&du[i]>1)) {puts("0");return 0;}
	work();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2176