akhauriyash/Code-Regression huggingface dataset:
import math
N, M, X, Y = [int(i) for i in input().split()]
x_ls = [int(i) for i in input().split()]
y_ls = [int(i) for i in input().split()]
max_x = max(x_ls)
min_y = min(y_ls)
flg = 0
for z in range(int(math.ceil(X + 0.00001)), int(Y)):
    if max_x < z <= min_y:
        flg = 1
if flg > 0:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, L;
    cin >> N >> L;

    vector<string> S(N);
    FOR(i, 0, N){
        cin >> S.at(i);
    }

    sort(ALL(S));

    for(string s : S){
        cout << s;
    }
    cout << endl;
    
    return 0;
}

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

int main()
{
  ll n,s=0;
  cin>>n;
  ll m = n;
  while(n)
  {
    s += n%10;
    n/=10;
  }
  if(m%s)
  {
    cout<<"No\n";
  }
  else
  {
    cout<<"Yes\n";
  }
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, a: usize, b: usize,
    }
    if a + b - 1 > n || n > a * b {
        puts!("-1\n");
        return;
    }
    let mut distr = vec![1; a];
    let mut rem = n - a;
    for i in 0..a {
        let r = min(b - 1, rem);
        distr[i] += r;
        rem -= r;
    }
    let mut ans = vec![0; n];
    let mut pos = 1;
    for i in 0..a {
        for j in 0..distr[i] {
            ans[pos - 1 + j] = pos + distr[i] - j - 1;
        }
        pos += distr[i];
    }
    for i in 0..n {
        puts!("{} ", ans[i]);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

int n;
int dp[11][10];

int solve(int num_len, int first_digit){
  int &ans = dp[num_len][first_digit];
  if(ans == -1){
    if(num_len == 1) ans = 1;
    else {
      ans = 0;
      if (first_digit > 0) {
        ans += solve(num_len-1, first_digit-1);
      }
      ans += solve(num_len-1, first_digit);
      if (first_digit < 9) {
        ans += solve(num_len-1, first_digit+1);
      }
    }
  }
  return ans;
}

int main(){
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  int len = -1, fd=0;
  bool done = false;
  for(int i=1;i<=10;++i){
    for(int j=1;j<10;++j){
      if(solve(i, j) >= n) {
	//if(solve(i, j) == n) n-= solve(i, j);
        len = i;
        fd = j;
        done = true;
        break;
      }
      else {
        n -= solve(i, j);
      }
    }
    if(done) break;
  }
  printf("%d", fd);
  int lastd = fd;
  for(int i=len-1;i>0;--i){
    for(int j=max(lastd-1, 0);j<min(lastd+2, 10);++j){
      //printf("n=%d / solve(%d, %d)=%d\n", n, i, j, solve(i, j));
      if(solve(i, j) >= n) {
	//if(solve(i, j) == n) n-= solve(i, j);
        printf("%d", j);
	lastd = j;
        break;
      }
      else n -= solve(i, j);
    }
  }
  puts("");
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = solve <$> B.getLine >>= mapM_ putStrLn

solve :: ByteString -> [String]
solve = g . B.foldl' f (0, [], [])
  where f :: (Int, [Int], [(Int, Int)]) -> Char -> (Int, [Int], [(Int, Int)])
        f (i, st1, st2) x | x == '\\' = (i+1, i:st1, st2)
                          | x == '/' = case st1 of
                                        (j:st1') -> let s = i - j
                                                        (st2', st2'') = span ((j<) . fst) st2
                                                    in (i+1, st1', (j, (s + (sum . map snd) st2')):st2'')
                                        [] -> (i+1, st1, st2)
                          | otherwise = (i+1, st1, st2)
        g (_, _, xs) = let ys = map snd xs
                       in [(show . sum) ys, (unwords . map show . ((length ys):) . reverse) ys]



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

#define Kmax 100005
#define ll long long

using namespace std;

int K;
int A[Kmax];
ll le, ri, mid;
ll ansmin = -1, ansmax = -1;

ll remain(ll X)
{
    for(int i = 1; i <= K; i++)
        X = X - X % A[i];
    return X;
}

int main()
{
    cin >> K;
    for(int i = 1; i <= K; i++)
        cin >> A[i];
    le = 1, ri = LLONG_MAX;
    while(le <= ri)
    {
        mid = le + (ri - le) / 2;
        if(remain(mid) >= 2)
        {
            ri = mid - 1;
            ansmin = mid;
        }
        else
            le = mid + 1;
    }
    le = 1, ri = LLONG_MAX;
    while(le <= ri)
    {
        mid = le + (ri - le) / 2;
        if(remain(mid) <= 2)
        {
            le = mid + 1;
            ansmax = mid;
        }
        else
            ri = mid - 1;
    }
    if(ansmax != -1 && ansmin <= ansmax)
        cout << ansmin << " " << ansmax << "\n";
    else
        cout << "-1\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

int main() {
    cin >> K;
    N = 50;
    vector<ll> a(N, 49);

    for (int i = 0; i < K % N; i++) {
        a[i] += 1;
    }
    for (int i = K % N; i < N; i++) {
        a[i] -= K % N;
    }

    for (int i = 0; i < N; i++) {
        a[i] += ((K - (K % N)) / N);
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> l(n);
	for(int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int sum = 0;
	for (int i = 0; i < n-1; i++) {
		sum += l[i];
	}
	if (sum > l[n-1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
    
	ll h1, s1, h2, s2;
	cin >> h1 >> s1 >> h2 >> s2;
	
	bool flag = true;
	
	while (1) {
		
		if (flag) {
			
			h2 -= s1;
			if (h2 <= 0) {
				cout << "Yes\n";
				break;
			}
		}
		else {
			h1 -= s2;
			if (h1 <= 0) {
				cout << "No\n";
				break;
			}
		}
		flag = !flag;
	}
	//code
	return 0;
}


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

int main(){
    char s;
    cin >> s;
    int ord = s - 'A';
    if(0 <= ord && ord <= 25 ) cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
g = [[[]for i in range(2)] for j in range(N)]

for i in range(N-1):
    u,v,d = map(int,input().split())
    if d%2 == 0:
        g[u-1][0].append(v-1)
        g[v-1][0].append(u-1)
    else:
        g[u-1][1].append(v-1)
        g[v-1][1].append(u-1)

ans = [-1]*N
ans[0] = 0

stack = [0]
not_visit = [True for i in range(N)]
not_visit[0] = False

while stack:
    now = stack.pop()
    for h in range(2):
        if h == 0: #距離が偶数ならば
            for i in range(len(g[now][h])):
                if not_visit[g[now][h][i]]:
                    not_visit[g[now][h][i]] = False
                    ans[g[now][h][i]] = ans[now]
                    stack.append(g[now][h][i])
        if h == 1: #距離が奇数ならば
            for i in range(len(g[now][h])):
                if not_visit[g[now][h][i]]:
                    not_visit[g[now][h][i]] = False
                    ans[g[now][h][i]] = (ans[now] + 1)%2
                    stack.append(g[now][h][i])

for i in range(N):
    print(ans[i])

Measured memory_bytes: 90076
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[0*M]]*N
ans = 0
for i in range(N):
    x = 0
    A[i] = list(map(int, input().split()))
    for j in range(M):
        x += A[i][j] * B[j]

    x += C

    if x > 0:
        ans += 1


print(ans)


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main() {
	ll N, M;
	cin >> N >> M;//N > M
	if (N < M)swap(N, M);
	ll ans = 1;
	if (N - M >= 2)cout << "0" << endl;
	else if (N - M == 1) {
		for (int i = 1; i <= N; i++) {
			ans = ans % mod * i;
		}
		for (int i = 1; i <= M; i++) ans = ans % mod * i;
		cout << ans % mod << endl;
	}
	else {
		for (int i = 1; i <= N; i++) {
			ans = ans % mod * i;
		}
		for (int i = 1; i <= M; i++) ans = ans % mod * i;
		cout << ans * 2 % mod << endl;
	}
}

Measured memory_bytes: 256
using System;
using static System.Console;

namespace abc174
{
    class Program
    {
        static int[] ReadNumList()
        {
            var line = ReadLine().Split(' ');
            if (line.Length == 1 && string.IsNullOrEmpty(line[0]))
            {
                return new int[0];
            }
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static void Main()
        {
            var nk = ReadLine().Split(' ');
            var n = int.Parse(nk[0]);
            var k = int.Parse(nk[1]);
            var aList = ReadNumList();

            var startLen = 0;
            var startCut = 0L;
            var endLen = 1;
            var endCut = 0L;
            foreach (var a in aList)
            {
                startLen = Math.Max(startLen, a);
                endCut += a - 1;
            }
            WriteLine(DivSearch(k, startLen, startCut, endLen, endCut, aList));
        }
        static long CalcCutCount(int length, int[] aList)
        {
            var total = 0L;
            foreach (var a in aList)
            {
                total += (long)Math.Ceiling((double)a / length) - 1;
            }
            return total;
        }
        static long DivSearch(int targetCut, int startLen, long startCut, int endLen, long endCut, int[] aList)
        {
            if (startLen - endLen <= 1)
            {
                if (targetCut >= endCut)
                {
                    return endLen;
                }
                else
                {
                    return startLen;
                }
            }
            var centerLen = (startLen + endLen) / 2;
            var centerCut = CalcCutCount(centerLen, aList);
            if (centerCut <= targetCut)
            {
                return DivSearch(targetCut, centerLen, centerCut, endLen, endCut, aList);
            }
            else
            {
                return DivSearch(targetCut, startLen, startCut, centerLen, centerCut, aList);
            }
        }
    }
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int dp[50000];
int main(){
	int h,n;cin>>h>>n;
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	rep(i,n){
		int a,b;scanf("%d%d",&a,&b);
		rep(j,h+1){
			dp[j+a]=min(dp[j+a],dp[j]+b);
		}
	}
	int Min=INF;
	for(int i=h;i<50000;i++)Min=min(Min,dp[i]);
	cout<<Min<<endl;
}

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

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;


int n;
std::vector<int> g[1005];
int curr[1005];
bool played[1005];
int main()
{
   	
 

    	scanf("%d",&n);

    	for(int i=1;i<=n;i++){
    		for(int j=1,x;j<n;j++){
    			scanf("%d",&x);
    			g[i].pb(x);
    		}
    	}


    	for(int i=1;i<=50000;i++){
    		memset(played,0,sizeof(played));
    		bool ok = false;
    		for(int j=1;j<=n;j++){
    			if(played[j] || curr[j]==n-1)continue;
    			int op = g[j][curr[j]];
    			if(played[op])continue;
    			if(g[op][curr[op]]==j){
    				ok = true;
    				curr[op]++;
    				curr[j]++;
    				played[op]=played[j]=true;
    			}
    		}

    		if(!ok)return !printf("-1\n");
    		int cnt = 0;
    		for(int j=1;j<=n;j++)cnt+=(curr[j]==(n-1));

    		if(cnt==n)return !printf("%d\n",i );

    	}

    	printf("%d",n*(n-1)/2);
}	


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

int main()
{
    string s;
    cin >> s;
    string t = s.substr(0, (s.size() - 1) / 2);
    string u = s.substr((s.size() + 3) / 2 - 1);
    
    string sr = s;
    reverse(sr.begin(), sr.end());
    if (s != sr) {
        cout << "No" << endl;
        return 0;
    }

    string tr = t;
    reverse(tr.begin(), tr.end());
    if (t != tr) {
        cout << "No" << endl;
        return 0;
    }

    string ur = u;
    reverse(ur.begin(), ur.end());
    if (u != ur) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------------//

// a と b の最大公約数を求める
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// a と b の最小公倍数を求める
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int N;
ll t[100];

int main() {
	cin >> N;
	REP(i, N) scanf("%lld", t + i);
	
	ll ans = 1;
	REP(i, N) ans = lcm(ans, t[i]);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
const int MOD = 1000000007;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n - 1)&n) + 1 : 0; }

const int N = 300001;
int i, j, k, m, n, l;

void upd(int& x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
}
bool ok(char c, int x) {
	return c == '?' || c == x + '0';
}
string s;
int dp[N][2][2];
int o0[2][2][2][2], o1[2][2][2][2];
int q[N], p[N];
int ans;

int main() {
	//freopen("x.in", "r", stdin);

	vector<string> pre = { "00", "01", "00", "01", "00", "01", "01", "11", "10", "01", "10", "11", "10", "11", "11", "11" };
	int k = 0;
	F0(i0, 2) F0(i1, 2) F0(j0, 2) F0(j1, 2) {
		o0[i0][i1][j0][j1] = pre[k][0] - '0';
		o1[i0][i1][j0][j1] = pre[k][1] - '0';
		k++;
	}

	p[0] = 1;
	F1(i, N - 1) p[i] = (p[i - 1] * 2) % MOD;
	while (cin >> s) {
		n = SZ(s);
		memset(dp, 0, sizeof(dp));
		memset(q, 0, sizeof(q));

		F1(i, n) q[i] = q[i - 1] + (s[i - 1] == '?');

		if (n == 1) {
			ans = s[0] != '0';
		}
		else {
			ans = 0;
			F0(j0, 2) F0(j1, 2) if (ok(s[n - 2], j0) && ok(s[n - 1], j1)) upd(dp[n - 2][j0][j1], 1);
			for (int i = n - 2; i >= 1; i -= 2) F0(j0, 2) F0(j1, 2) if (dp[i][j0][j1]) {
				int v = dp[i][j0][j1];
				if (i == 1) continue;
				if (j0 && j1) {
					upd(ans, 1LL * p[q[i]] * v % MOD);
					continue;
				}
				F0(i0, 2) F0(i1, 2) if (ok(s[i - 2], i0) && ok(s[i - 1], i1)) {
					upd(dp[i - 2][o0[i0][i1][j0][j1]][o1[i0][i1][j0][j1]], v);
				}
			}
			F0(i, 2) if (ok(s[0], i)) F0(i0, 2) F0(i1, 2) if (i + i0 + i1 >= 2) upd(ans, dp[1][i0][i1]);
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 7680
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

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

	try {
	    StringTokenizer st = new StringTokenizer(br.readLine());
	    int a[] = new int[5];
	    for (int i=0;i<5;i++) {
		a[i] = Integer.parseInt(st.nextToken());
	    }
	    Arrays.sort(a);
	    System.out.println(a[4]+" "+a[3]+" "+a[2]+" "+a[1]+" "+a[0]);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}

Measured memory_bytes: 16868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

vector<ll> divisor(ll n) {
    vector<ll> res;
    ll pre = n+1;
    for (ll i = 1; i * i <= n; i++) {
        if (n / i < pre) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

ll n, k, m;
vector<vector<ll> > dp;

int main() {
    cin >> n >> k;
    vector<ll> d = divisor(n), w;
    m = d.size();
    SORT(d);
    w.resize(m);
    dp.resize(k+1);
    REP(i,k+1) dp[i].resize(m+1, 0);
    w[0] = 1;
    for(int i=1;i<m;i++){
        w[i] = d[i]-d[i-1];
    }

    dp[0][0] = 1;
    for(int i=0;i<k;i++){
        for(int j=0;j<m;j++){
            dp[i+1][m-j-1] += dp[i][j];
        }
        for(int j=m-1;j>0;j--){
            dp[i+1][j-1] += dp[i+1][j];
            dp[i+1][j-1] %= MOD;
        }
        for(int j=0;j<m;j++){
            dp[i+1][j] *= w[j];
            dp[i+1][j-1] %= MOD;
        }
    }
    ll ans = 0;
    for(int i=0;i<m;i++){
        ans += dp[k][i];
        ans %= MOD;
    }
    /* 
    REP(i,k+1){
        REP(j,m+1){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 51448
fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(' ').map { it.toInt() }

    var ans = 0
    for (i in 1..n) {
        val (x, y) = readLine()!!.split(' ').map { it.toDouble() }
        val sqrt = Math.sqrt(x * x + y * y)
        if (d >= sqrt) {
            ans++
        }
    }

    println(ans.toString())
}


Measured memory_bytes: 63528
import math
from functools import reduce
k=int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
s=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            s+=gcd(i,j,l)
print(s)

Measured memory_bytes: 69744
N = int(input())
H = list(map(int,input().split()))

s = 0
i = 0
while 0 <= i < N - 1:
    num = i
    t = 0
    while num < N - 1 and H[num] >= H[num + 1]:
        t += 1
        num += 1
    if s <= t:
        s = t
    i = num + 1
        
print(s)

Measured memory_bytes: 63856
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 str[] = br.readLine().split(" ");

		long a = Long.parseLong(str[0]);
		long b = Long.parseLong(str[1]);
		long x = Long.parseLong(str[2]);

		long bb = b / x;
		long aa = (a - 1) / x;

		if (a == 0) {
			aa = -1;
		}

		System.out.println(bb - aa);
	}
}

Measured memory_bytes: 32436
n,m=map(int,input().split())
from collections import  Counter
from itertools import accumulate
a=list(map(int,input().split()))
b=list(accumulate(a))
b=[0]+b
b=list(map(lambda x:x%m ,b))
e=Counter(b)
ans=0
for i in e.values():
    ans+=i*(i-1)//2

print(ans)

Measured memory_bytes: 64664
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int K = 1e5;
const LL MOD = 1e9+7;
LL memo[K+1];
LL mod_pow(LL base, LL exp)
{
    if(exp==0) return 1;
    if(exp&1) return (base*mod_pow(base,exp-1))%MOD;
    else return mod_pow((base*base)%MOD, exp>>1);
}
int n;
LL dp(int k)
{
    if(k <= 0) return 0;
    if(k == 1) return 1;
    if(k == 2) return mod_pow(k,n)-1;
    if(memo[k]!=-1) return memo[k];

    int lim = floor(sqrt(k))+1;
    LL ans = mod_pow(k,n);
    for(int d = 2; d <= lim-1; d++)
        ans = (ans-dp(k/d))%MOD;
    for(int val = 1; val <= lim; val++)
    {
        LL ub = k/val;
        LL lb = max(lim-1,k/(val+1));
        if(lb < ub)
            ans = (ans-dp(val)*(ub-lb))%MOD;
    }

    return memo[k] = ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int k; cin >> n >> k;
    memset(memo,-1,sizeof memo);
    
    LL sum = 0;
    for(LL d = 1; d <= k; d++)
        sum = (sum+d*dp(k/d))%MOD;
    
    cout<<(sum+MOD)%MOD<<endl;

    cout<<flush;
    return 0;
}

Measured memory_bytes: 4372
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;

using namespace std;
vector<int> a;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	int se = (n + 3) / 2;
	se -= 1;
	string flag = "Yes";
	for (int i = 0; i < (n - 1) / 2; i += 1)
	{
		if (s[i] != s[n - i-1])
		{
			flag = "No";
		}
	}
	string str1 = s.substr(0, (n - 1) / 2);
	string str2 = s.substr(se, (n - 1) / 2);
	for (int i = 0; i < str1.length(); i += 1)
	{
		if (str1[i] != str1[str1.length() - i-1])
		{
			flag = "No";
		}
	}
	for (int i = 0; i < str2.length(); i += 1)
	{
		if (str2[i] != str2[str2.length() - i-1])
		{
			flag = "No";
		}
	}
	cout << flag;
	return 0;
}

Measured memory_bytes: 256
import math

n, d = list(map(int, input().split()))
ls1 = []
for i in range(n):
    ls1.append(list(map(int, input().split())))
#print(ls1)

flag = 0
for i in range(n):
  for j in range(i+1, n):
    total = 0
    for k in range(d):
      total = total + (ls1[i][k]-ls1[j][k])**2
    total_root = math.sqrt(total)
    #print(total_root)
    if total_root.is_integer():
      flag += 1
print(flag)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,0,n) cin >> v[i];
  vector<P> p1(100001),p2(100001);
  rep(i,0,n) {
    if (i % 2 == 0) {
      p1[v[i]].fi++; p1[v[i]].se = v[i];
    } else {
      p2[v[i]].fi++; p2[v[i]].se = v[i];
    }
  }
  sort(rall(p1)); sort(rall(p2));
  int ans;
  if (p1[0].se != p2[0].se) {
    ans = n - p1[0].fi - p2[0].fi;
  } else {
    int k = max(p1[0].fi + p2[1].fi, p1[1].fi + p2[0].fi);
    ans = n-k;
  }
  cout << ans << endl;
  return 0;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> sum(N + 1);
    rep(i, N) sum[i + 1] = sum[i] + A[i];

    vector<ll> B;
    rep(i, N + 1) {
        rep(j, i) B.push_back(sum[i] - sum[j]);
    }

    ll ans = 0;
    int M = B.size();
    vector<bool> available(M, true);
    for (int i = 60; i >= 0; --i) {
        int cnt = 0;
        rep(j, M) if (available[j] && B[j] >> i & 1) cnt++;
        if (K <= cnt) {
            ans += 1L << i;
            rep(j, M) {
                if (!(B[j] >> i & 1)) available[j] = false;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6388
n = int(input())
v = list()
time = 0
for i in range(n):
    a, b = map(int, input().split())
    v.append([a, b])
v = sorted(v, key=lambda x: x[1])
for i in v:
    time += i[0]
    if time > i[1]:
        print('No')
        exit()
print('Yes')

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

int main() {
  string S;
  cin >> S;
  int c=0;
  int m=10000000;
  for (int i=0; i<(int)S.size()-2; i++) {
    c=0;
    for (int j=0; j<3; j++) {
      c+=(S[i+j]-'0')*pow(10, 2-j);
    }
    m=min(m, abs(753-c));
  }
  cout << m << endl;
}



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

int n;
string s;

int main()
{
    cin >> n;
    cin >> s;
    if (n % 2) { printf("No\n"); return 0; }
    n /= 2;
    for (int i = 0; i < n; i++)
        if (s[i] != s[n + i]) { printf("No\n"); return 0; }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9) cout<<"hon"<<endl;
	if(n==0||n==1||n==6||n==8) cout<<"pon"<<endl;
	if(n==3) cout<<"bon"<<endl;
	return 0;
}


Measured memory_bytes: 3652
def main():
    _ = int(input())
    s = input()
    ans = 0
    for i in range(10):
        a = s.find(str(i))
        if a == -1:
            continue
        for j in range(10):
            b = s.find(str(j), a+1)
            if b == -1:
                continue
            for k in range(10):
                if s.find(str(k), b+1) != -1:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

const int maxn = 1e5 + 5;

vector<int> G[maxn];

int h[maxn];
int n, m;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        cin >> h[i];
    } 
    for(int i = 1;i <= m;i++){
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        bool flag = true;
        for(auto v : G[i]){
            if(h[v] >= h[i])
                flag = false;
        }
        if(flag){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

K = []
A = []
for i in range(N):
    k, *a = map(int, input().split())
    K += [k]
    A += a

counter = 0
for j in range(1,M+1):
    if A.count(j) == N:
        counter += 1

print(counter)

Measured memory_bytes: 3064
//om namah shivaaay//
#include <bits/stdc++.h>
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
 #define ll long long
 using namespace std;
 int main()
 {
    Om_namah_Shivaay;
  ll n,m,a;
   ll sum=0;
   cin>>n>>m;
   while(m --)
   {
	   cin>>a;
	   sum+=a;
	   }
	   if(n<sum) cout<<"-1";
	  else cout<<n-sum; 
	
}


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

int main() {
	int n,m,k; cin >> n >> m >> k;
	
	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j){
			if(i*(m-j)+j*(n-i) == k){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

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

int main(){
    int a[5];
    int k;
    bool check = true;
    for(int i = 0;i < 5;i++)
    {
        cin >> a[i];
    }
    cin >> k;
    for(int i = 0;i < 5;i++)
    {
        for(int j = i + 1;j < 5;j++)
        {
            if(a[j] - a[i] > k){
                check = false;
            }
        }
    }
    if(check){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

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

using namespace std;

int main(void)
{
  string s;
  int count=0;
  
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if(s[i] == 'o')
    {
      count++;
    }
  }
  cout<<700+100*count<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

div = ['dream', 'dreamer', 'erase', 'eraser']
end = 0
ans = "YES"

while end < len(S):
    
    isExist = False
    
    for d in div:
        if d == S[len(S) - len(d) - end: len(S) - end]:
            end += len(d)
            isExist = True

    if isExist != True:
        ans = "NO"
        break

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
int main()
{
    optimize();
    vector<pair<int,int>>v;
    pair<int,int>p;
    int n,cnt=0,i;
    cin>>n;
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        p=make_pair(x,y);
        v.push_back(p);

    }
    for(i=0;i<v.size()-2;i++)
    {
        if(v[i].first==v[i].second)
        {
            if(v[i+1].first==v[i+1].second)
            {
                if(v[i+2].first==v[i+2].second)
                {
                    cnt++;
                }
            }
        }
    }
    if(cnt==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, r;
  cin >> n >> r;
  if (n >= 10) cout << r;
  else cout << r + 100*(10-n);

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, LL, RR, v;
long long ans;
vector<int> vec;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	vec.pb(0);
	cin >> n;
	int len = 0, nn = n;
	RR = n % 10;
	while (nn) {
		len++;
		if (nn < 10) LL = nn;
		nn = nn / 10;
	}
	for (int i = 1; i <= n; i++) {
		int tmp = i;
		int L, R;
		R = tmp % 10;
		while (tmp) {
			if (tmp < 10) L = tmp;
			tmp = tmp / 10;
		}
		swap(L, R);
		if (L == 0) {
			vec.pb(0);
			continue;
		}
		if (L == R) ans++;
		int k = 1;
		for (int j = 2; j <= len; j++) {
			if (j > 2) {
				k = k * 10;
			}
			if (j < len)
				ans += k;
			else {
				//if (L * 10 + R <= n)
					//ans++;
				if (L < LL) {
					ans += k;
				}
				else if (L == LL) {
					if (R <= RR) ans++;
					nn = n;
					nn /= 10;
					nn -= k * LL;
					//if (R > RR) nn--;
					if (nn > 0)
						ans += nn;
				}
			}
		}
		//vec.pb(ans);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

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

int main()
{
    int N,K,L[51];
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    sort(L,L+N,greater<int>());
    int sum = 0;
    for(int i=0; i<K; i++){
        sum += L[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

Si, Sj = (0, 0)
for i, a in enumerate(A):
    if "S" in a:
        Si, Sj = (i, a.index("S"))
        A[Si][Sj] = "#"
        break

dist = float("inf")

Q = deque([(0, Si, Sj)])
while Q:
    cnt, i, j = Q.popleft()

    dist = min(dist, i, j, H - i - 1, W - j - 1)
    if dist == 0:
        break

    if cnt >= K:
        continue

    for ni, nj in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)):
        if 0 <= ni < H and 0 <= nj < W and A[ni][nj] == ".":
            A[ni][nj] = "#"
            Q.append((cnt + 1, ni, nj))

print(-(-dist // K) + 1)

Measured memory_bytes: 9196
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    edges <- VU.replicateM (n-1) $ do
        [a,b,c] <- getIntList
        return (a-1,b-1,c)
    let tree :: V.Vector [(Int,Int)]
        tree = V.create $ do
            t <- VM.replicate n []
            VU.forM_ edges $ \(a,b,c) -> do
                VM.modify t ((b,c) :) a
                VM.modify t ((a,c) :) b
            return t
    [q,k] <- getIntList
    query <- VU.replicateM q $ do
        [x,y] <- getIntList
        return (x-1,y-1)
    let costs :: VU.Vector Int
        costs = VU.create $ do
            vec <- VUM.replicate n 0
            let dfs pv pc this = do
                    forM_ (filter ((/= pv) . fst) (tree V.! this)) $ \(child,c) -> do
                        VUM.write vec child (pc+c)
                        dfs this (pc+c) child
            dfs (k - 1) 0 (k - 1)
            return vec
    VU.forM_ query $ \(x,y) -> do
        print $ costs VU.! x + costs VU.! y

Measured memory_bytes: 34808
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
template <class T>
vector<ll> countVector(vector<T>v,T guard=0){
    ll size=v.size();
    v.push_back(guard);
    vector<ll>ret;
    ll count=1;
    for(int i=0;i<size;i++){
        if(v[i]==v[i+1]){
            count++;
        }else{
            ret.push_back(count);
            count=1;
        }
    }
    return ret;
}
ll gcd(ll a,ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
	init();
	ll L,K;cin>>L>>K;
	string s;cin>>s;
	s[K-1]+=32;
	cout<<s<<endl;
}


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

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))

using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  int n,d; cin>>n>>d;
  vvi x(n, vi(d));
  int c = 0;
  upto(i,0,n,1){
    upto(j,0,d,1) cin>>x[i][j];
    vi &a = x[i];
    upto(j,0,i,1){
      vi &b = x[j];
      int t = 0;
      upto(k,0,d,1) t += pow(a[k]-b[k], 2);
      int s = sqrt(t);
      if(s*s==t) c++;
    }
  }
  cout<<c<<endl;
}

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

using namespace std;

const int N = 500;

int n, m, q, c[N+7][N+7], f[N+7][N+7];

void dp() {
	for(int i = n; i >= 1; i--)
		for(int j = 1; j <= n; j++)
			f[i][j] = c[i][j]+f[i][j-1]+f[i+1][j]-f[i+1][j-1];
}

int main() {
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 1, x, y; i <= m; i++) scanf("%d%d", &x, &y), c[x][y]++;
	dp();
	for(int i = 1, l, r; i <= q; i++) {
		scanf("%d%d", &l, &r);
		printf("%d\n", f[l][r]);
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>

using namespace std;
#define ll long long
int main()
{
   ll x,y;
   cin>>x>>y;
   int flag=0;
   for(int i=0;i<=x;i++)
   {
       if((i*2 + (x-i)*4)==y)
       {
           cout<<"Yes"<<endl;
           
           flag=1;
           break;
       }
   }
   if(flag==0)
   cout<<"No"<<endl;
   
   return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root, NIL;


Node treeSearch(Node,int);
void insert(int);
void inorder(Node );
void preorder(Node );
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if (com[0]=='f'){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if (com[0]=='i'){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Node treeSearch(Node x, int k){
  while(x!=NIL&&k!=x->key ){
    if(k<x->key){
      x=x->left;
    }
    else{
      x=x->right;
  }
  }
  return x;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y==NIL){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if (u==NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u==NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}



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

using namespace std;

void abc_150a();

void abc_151a();

void abc_152a();

void abc_154a();

void abc_156a();

int main()
{
  //abc_150a();
  //abc_151a();
  //abc_152a();
  //abc_154a();
  abc_156a();

}

void abc_150a()
{
  int K, X;
  cin >> K >> X;

  if (500 * K >= X) cout << "Yes\n";
  else cout << "No\n";
}

void abc_151a()
{
  char C;
  cin >> C;

  cout << (char)((int)C + 1) << "\n";
}

void abc_152a()
{
  int N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes\n";
  else cout << "No\n";
}

void abc_154a()
{
  string S, T;
  cin >> S >> T;
  int a, b;
  cin >> a >> b;
  string U;
  cin >> U;

  if (S == U) cout << a - 1 << " " << b << "\n";
  else cout << a << " " << b - 1 << "\n";

}


void abc_156a()
{
  int N, R;
  cin >> N >> R;

  if (N >= 10) cout << R << "\n";
  else cout << R + 100 * (10 - N) << "\n";
}

Measured memory_bytes: 3600
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut A: usize = sc.read();
    let mut B: usize = sc.read();
    let C: usize = sc.read();
    if A > B {
        let tmp = A;
        A = B;
        B = tmp;
    }
    if A <= C && C <= B {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}

Measured memory_bytes: 2136