akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
#define taskname "A"
#define pb  push_back
#define mp  make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 5e5 + 5;
int n , D;
int d[maxn];
int a[maxn] , b[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP", "r",stdin);
        freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> a[0];
    for(int i = 1 ; i <= n ; ++i){
        cin >> d[i];
        a[i] = min(a[i - 1] , abs(a[i - 1] - d[i]));
//        cout << a[i] << endl;
    }
    b[n] = 1;
    for(int i = n - 1 ; i >= 1 ; --i){
        if(d[i + 1] >= b[i + 1] * 2)b[i] = b[i + 1];
        else b[i] = b[i + 1] + d[i + 1];
//        cout << b[i + 1] << " " << d[i] << endl;
    }
    int q;cin >> q;
    while(q--){
        int x;cin >> x;
        puts((a[x - 1] >= b[x] ? "YES" : "NO"));
    }
}


Measured memory_bytes: 7808
n = int(input())
li = []#[都市名,点数,番号]
for i in range(n):
  li_1 = input().split()
  li_1[1] = int(li_1[1])
  li_1.append(i+1)
  li.append(li_1)
li = sorted(li, key=lambda x: x[0])
new_li = []
new_li_2 = []
a = li[0][0]
for i in range(n):
  if a == li[i][0]:
    new_li_2.append(li[i])
    if i == n-1:
      new_li.append(new_li_2)
  else:
    new_li.append(new_li_2)
    new_li_2 = []
    a = li[i][0]
    new_li_2.append(li[i])
    if i == n-1:
      new_li.append(new_li_2)
#print(new_li)
for i in range(len(new_li)):
  new_li[i] = sorted(new_li[i], key=lambda x: x[1])
  new_li[i].reverse()
ans_li =[]
for i in range(len(new_li)):
  for j in range(len(new_li[i])):
    ans_li += [new_li[i][j]]
for i in range(n):
  print(ans_li[i][2])

Measured memory_bytes: 3064
package main

import "fmt"


func main() {
  var n int
  fmt.Scan(&n)
  
  h := make([]int64,n)
  for i:=0; i < n; i++ {
    fmt.Scan(&h[i])
  }
  
  ans := 0
  count := 0
  for i:= 0; i< n-1; i++ {
    if h[i] >= h[i+1] {
      count++
    }else{
      ans = max(ans,count)
      count = 0
    }
  }
  fmt.Println(max(ans,count))
}


func max(x,y int) int {
  if x < y {
    return y
  }
  return x
}


Measured memory_bytes: 5504
#include<stdio.h>

#define N 2000000000

int n;
long long count=0;
int A[500000];

long long merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1];
    int R[n2];
    for(int i=0; i<n1; i++){
        L[i] = A[left+i];
    }
    for(int i=0; i<n2; i++){
        R[i] = A[mid+i];
    }
    L[n1]=N;
    R[n2]=N;
    int i=0;
    int j=0;

    for(int k=left; k<right; k++){
        
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else{
            A[k] = R[j];
            j++;
            count += n1-i;
        }
    }

    return count;
}

long long mergeaSort(int A[], int left, int right){
    int mid;
    long long n1, n2, n3;
    if(left+1 < right){
        mid = (left+right)/2;
        n1=mergeaSort(A, left, mid);
        n2=mergeaSort(A, mid, right);
        n3=merge(A, left, mid, right);

        return n1+n2+n3;
    }
    else{
        return 0;
    }
}

int main(void){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    mergeaSort(A, 0, n);

    
    printf("%lld\n", count);

    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<P> X;

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        int x; scanf("%d", &x);
        X.push_back(make_pair(x, i));
    }
    sort(X.begin(), X.end());
    
    vector<int> v(N);
    for(int i = 0; i < N; ++i){
        int idx = X[i].second;
        int num = (int)X.size() / 2 - 1;
        num += (i <= num) ? 1 : 0; 
        v[idx] = X[num].first;
    }
    
    for(int i = 0; i < N; ++i) printf("%d\n", v[i]);
    
    return 0;
}

Measured memory_bytes: 4592
#include<stdio.h>
#include<algorithm>
char prime[10000001];
int main(){
	
	for(int i=2;i*i<=10000000;i++){
		if(prime[i]==0){
			prime[i]=1;
			for(int j=i*2;j<=10000000;j+=i)prime[j]=-1;
		}
	}
	for(int i=3162;i<=10000000;i++)if(prime[i]==0)prime[i]=1;
	int a;
	while(scanf("%d",&a),a){
		do{
			if(a>7&&prime[a]==1&&prime[a-2]==1&&prime[a-6]==1&&prime[a-8]==1){
				printf("%d\n",a);
				break;
			}
		}while(a--);
		if(a==0)printf("0\n");
	}
}

Measured memory_bytes: 10000
#include <cstdio>
#include <algorithm>
using namespace std;

int array[100];

void search(int n, int l, int j)
{
	for (int i = min(n, l); i > 0; i--){
		array[j] = i;
		if (i == n){
			for (int k = 0; k <= j; k++){
				if (k != 0){
					printf(" ");
				}
				printf("%d", array[k]);
			}
			puts("");
		}
		else {
			search(n - i, i, j + 1);
		}
	}
}

int main()
{
	int n;
	while (scanf("%d", &n), n){
		search(n, n, 0);
	}
	
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;
vector<vector<int>>G(N);

vector<pair<int,int>>vp;
rep(i,N-1){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a,b);
}
int K=0;

map<pair<int,int>,int>I;

vector<int>cs(N,0);//前の頂点からの色

vector<bool>used(N,0);//探索済みかメモ

queue<int>q;
//cs[0]=0;
used[0]=true;
q.push(0);
while(!q.empty()){
    int v=q.front();q.pop();
    int cur=1;
    if(K<G[v].size())K=G[v].size();

    for(auto u:G[v]){
        if(used[u])continue;
        if(cur==cs[v])cur++;
        cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur++;
        used[u]=1;
        q.push(u);
    }
}


cout<<K<<endl;
for(auto v:vp){
    cout<<I[v]<<endl;
}
 return 0;
}
/*
3
1 2
2 3

2
1
2

8
1 2
2 3
2 4
2 5
4 7
5 6
6 8

4
1
2
3
4
1
1
2

6
1 2
1 3
1 4
1 5
1 6

5
1
2
3
4
5
*/

Measured memory_bytes: 19700
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if ((x - r) < 0 || W < (x + r)) {
		printf("No\n");
	}
	else if ((y - r) < 0 || H < (y + r)) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
aa = [int(x) for x in input().split()]

m = aa[0]
for a in aa[1:]:
  m = lcm(m, a)
  
m = m - 1
ans = 0
for a in aa:
  ans += m % a
  
print(ans)

Measured memory_bytes: 5688
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define nmax_def 110000
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	int n, p[nmax_def];
	int ans = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for (i = 1; i < n - 1; i++)
	{
		bool anstmp = false;
		if ((p[i] > p[i - 1]) && (p[i] < p[i + 1]))
			anstmp = 1;
		else if ((p[i] < p[i - 1]) && (p[i] > p[i + 1]))
			anstmp = 1;
		if (anstmp)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
open System
 
let modConst = 1e9+7. |> int64
 
let N = stdin.ReadLine() |> int64
 
let modpow x y =
    let rec submodpow accum index =
        match index with
        | _ when index = y -> accum
        | _ -> submodpow (accum * x % modConst) (index + 1L)
 
    submodpow 1L 0L
 
let solveF x = modpow x N
 
printfn "%d" ((((solveF 10L) - (solveF 9L) - (solveF 9L) + (solveF 8L)) + 2L * modConst ) % modConst)

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

using namespace std;

void solve(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	int x, y;
	long long product;
	product = max(a*c,b*d);
	product = max(product,a*d);
	product = max(product,b*c);
	cout << product << endl;
}

int main(){

/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//int t;cin >> t;while(t--){solve();}
	solve();
	return 0;
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
def main():
    x, y = map(int, input().split())
    ans = abs(abs(x) - abs(y))
    if x * y < 0:
        ans += 1
    elif x > y and x * y == 0:
        ans += 1
    elif x > y:
        ans += 2
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
          long H = getLong();
          long W = getLong();
          long output = 0;
          if((H == 1 && W > 2) || (W == 1 && H > 2)){
            myout(1);
            return;
          }
          if(H % 2 == 0 && W % 2 == 0){
            output = H * W  / 2;
          }else if(H % 2 != 0 && W % 2 == 0){
            H--;
            output = H * W  / 2;
            output += (W / 2);
          }else if(H % 2 == 0 && W % 2 != 0){
            W--;
            output = H * W  / 2;
            output += (H / 2);
          }else{
            H--;
            W--;
            output = H * W  / 2;
            output += (W / 2) + (H / 2) + 1;
          }
          myout(output);
        }
        //Method addition frame start

        //Method addition frame end
}


Measured memory_bytes: 22996
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int  num = sc.nextInt();
	int  yen = sc.nextInt();
	int x =0;
	int y = 0;
	int z = 0;
	boolean flg = false;
    
	wada: for(int i = 0; i <= num; i++){
		for(int j = 0; j <= num-i; j++){
			x = i;
			y = j;
			z = num -(x+y);
			if(x+y+z == num && yen ==x*10000 + y*5000 + z*1000){
				System.out.println(x +" "+ y + " " + z);
				flg = true;
              	break wada;
			}
		}
	}
	if(!flg){
		System.out.println("-1 -1 -1");
	}
  }
}


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

const int MAX_N = 400;
const Long INF = LLONG_MAX;
Long a[MAX_N + 1], acc[MAX_N + 1];
Long dp[MAX_N][MAX_N];

Long DP(int l, int r) {
	if (l == r) return 0LL;
	if (l + 1 == r) return a[l] + a[r];
	if (dp[l][r] != 0LL) return dp[l][r];
	dp[l][r] = INF;
	for (int i = l; i < r; i++) {
		dp[l][r] = min(dp[l][r], DP(l, i) + DP(i + 1, r) + acc[r] - acc[l - 1]);
	}
	return dp[l][r]; 
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) acc[i] = acc[i - 1] + a[i];
	Long answer = DP(1, n);
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
int main(){
    int N,K;

    scanf("%d%d",&N,&K);
    char S[N];
    scanf("%s",S);

   if(S[K-1]>=65){
        if(S[K-1]<=90){
         S[K-1]=S[K-1]+32;
         }
   }
    printf("%s",S);


return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int dp[3001][3001][4];
Int t[3001][3001];

int main() {
    Int R, C, K;
    cin >> R >> C >> K;
    vector<Int> r(K), c(K), v(K);
    for (Int i = 0; i < K; i++) {
        cin >> r[i] >> c[i] >> v[i];
        r[i]--, c[i]--;
        t[r[i]][c[i]] = v[i];
    }
    for (Int i = 0; i < R; i++) {
       for (Int j = 0; j < C; j++) {
           for (Int k = 0; k < 4; k++) {
               dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
               if (k + 1 < 4) {
                   dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + t[i][j]);
                   dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + t[i][j]);
               }
               dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
           }
       }
    }
    // for (Int k = 0; k < 3; k++) {
    //     for (Int i = 0; i <= R; i++) {
    //         for (Int j = 0; j <= C; j++) {
    //             cout << dp[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    //     cout << endl;
    // }
    Int res = 0;
    for (Int i = 0; i <= C; i++) {
        res = max(res, dp[R][i][0]);
    }
    print(res);
    return 0;
}


Measured memory_bytes: 359596
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> x;
  x.push_back(X);
  rep(i, N) {
    int xn;
    cin >> xn;
    x.push_back(xn);
  }
  sort(x.begin(), x.end());

  vector<int> d;
  rep(i, N) {
    int now = x[i + 1] - x[i];
    if(now == 0) continue;
    d.push_back(now);
  }

  int ans = d[0];
  rep(i, d.size()) {
    ans = gcd(ans, d[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
num = 0
for i in range(N):
  num += min(A[i], B[i])
  if A[i] < B[i]:
    num += min(A[i+1], B[i]-A[i])
    A[i+1] = max(0, A[i+1]-(B[i]-A[i]))
print(num)

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

using namespace std;

int n,i;

int main(){
	scanf("%d", &n);
	int odd = 0;
	int even = 0;
	
	for(i = 0; i < n; i++){
		int x;
		scanf("%d", &x);
		
		if(x % 2 == 0)
		even++;
		else
		odd++;
	}
	
	if(odd % 2 == 1)
	printf("NO\n");
	else
	printf("YES\n");
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
#define N 2050
int n,m,id,i;
int u[N*3],v[N*3],a[N*3],faa[N],dep[N],fa[N*3],in[N],up[N];
bool vis[N*3],viss[N];
vector<int> g[N],son[N*3],S[N];
queue<int> q;
void dfs(int now)
{
	if (vis[now]) return;vis[now]=true;a[now]^=a[fa[now]];
	for (int ii=0;ii<son[now].size();ii++) dfs(son[now][ii]);
}
void gtdp(int now,int lst)
{
	faa[now]=lst;dep[now]=dep[lst]+1;
	for (int ii=0;ii<g[now].size();ii++) if (g[now][ii]!=lst) gtdp(g[now][ii],now);
}
int main()
{
	scanf("%d%d",&n,&m);id=m;
	for (i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		g[x].push_back(y);g[y].push_back(x);in[x]++;in[y]++;
	}for (i=1;i<=n;i++) if (in[i]==1) q.push(i);gtdp(1,0);
	for (i=1;i<=m;i++){
		scanf("%d%d",&u[i],&v[i]);S[u[i]].push_back(i);S[v[i]].push_back(i);
		int x=u[i],y=v[i];
		while (x!=y){
			if (dep[x]<dep[y]) swap(x,y);
			up[x]++;x=faa[x];
		}
	}int ans=0;
	for (i=1;i<=n;i++) ans+=min(up[i],2);printf("%d\n",ans);
	while (!q.empty()){
		int psz=q.front();q.pop();int tot=0;
		for (i=0;i<S[psz].size();i++) if (u[S[psz][i]]==psz&&v[S[psz][i]]==psz) dfs(S[psz][i]);
		else if (!fa[S[psz][i]]) tot++;
		while (tot>=2){
			for (i=0;i<S[psz].size();i++) if (!(u[S[psz][i]]==psz&&v[S[psz][i]]==psz)&&!fa[S[psz][i]]) break;
			int ii=i;for (i++;i<S[psz].size();i++) if (!(u[S[psz][i]]==psz&&v[S[psz][i]]==psz)&&!fa[S[psz][i]]) break;
			int uu,vv;
			if (u[S[psz][i]]==psz) a[S[psz][i]]^=1,uu=v[S[psz][i]];else uu=u[S[psz][i]];
			if (u[S[psz][ii]]==psz) vv=v[S[psz][ii]];else a[S[psz][ii]]^=1,vv=u[S[psz][ii]];
			id++;u[id]=uu;v[id]=vv;S[uu].push_back(id);S[vv].push_back(id);fa[S[psz][i]]=id;fa[S[psz][ii]]=id;son[id].push_back(S[psz][i]);son[id].push_back(S[psz][ii]);
			tot-=2;
		}if (tot){
			for (i=0;i<S[psz].size();i++) if (!(u[S[psz][i]]==psz&&v[S[psz][i]]==psz)&&!fa[S[psz][i]]) break;
			int fdc;
			for (int ii=0;ii<g[psz].size();ii++) if (!viss[g[psz][ii]]) fdc=g[psz][ii];
			id++;fa[S[psz][i]]=id;son[id].push_back(S[psz][i]);
			if (u[S[psz][i]]==psz) u[id]=fdc,v[id]=v[S[psz][i]];else u[id]=u[S[psz][i]],v[id]=fdc;
			S[u[id]].push_back(id);S[v[id]].push_back(id);
		}for (int ii=0;ii<g[psz].size();ii++) if (!viss[g[psz][ii]]){
			if (--in[g[psz][ii]]==1) q.push(g[psz][ii]);
		}viss[psz]=true;
	}
	for (i=1;i<=m;i++) if (a[i]) printf("%d %d\n",u[i],v[i]);else printf("%d %d\n",v[i],u[i]);
	return 0;
}

Measured memory_bytes: 896
n, x = map(int, input().split())
al = [int(i) for i in input().split()]
bi = [i for i in al]
ans = sum(al)
for k in range(1, n):
    bi = [min(bi[i-1], al[i]) for i in range(n)]
    ans = min(ans, k * x + sum(bi))
print(ans)


Measured memory_bytes: 48092
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}
	
	public void run() throws Exception
	{
		BufferedReader file = new BufferedReader(new InputStreamReader(System.in));
		char[] s = file.readLine().toCharArray();
		char[] t = file.readLine().toCharArray();
		TreeSet<Integer>[] sets = new TreeSet[26];
		for(int i =0 ;i<26;i++)
			sets[i] = new TreeSet<Integer>();
		for(int i = 0;i<s.length;i++)
		{
			sets[s[i]-'a'].add(i);
		}
		int current = -1;
		long sum = 0;
		for(int i = 0;i<t.length;i++)
		{
			int ch = t[i]-'a';
			if(sets[ch].isEmpty())
			{
				System.out.println(-1);
				return;
			}
			if(sets[ch].higher(current)!=null)
			{
				current = sets[ch].higher(current);
			}else {
				sum += s.length;
				current = sets[ch].first();
			}
		}
		System.out.println(sum+current+1);
	}
}


Measured memory_bytes: 34984
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	double a[2],b[2],c[2],d[2];
	double atob[2],btoc[2],ctod[2],dtoa[2];
	double edge_ab,edge_bc,edge_cd,edge_da;
	double angle_a,angle_b,angle_c,angle_d;
	for(;;){
		if(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&a[0],&a[1],&b[0],&b[1],&c[0],&c[1],&d[0],&d[1]) == EOF){break;}
		atob[0] = b[0]-a[0];
		atob[1] = b[1]-a[1];
		btoc[0] = c[0]-b[0];
		btoc[1] = c[1]-b[1];
		ctod[0] = d[0]-c[0];
		ctod[1] = d[1]-c[1];
		dtoa[0] = a[0]-d[0];
		dtoa[1] = a[1]-d[1];
		edge_ab = sqrt(atob[0]*atob[0]+atob[1]*atob[1]);
		edge_bc = sqrt(btoc[0]*btoc[0]+btoc[1]*btoc[1]);
		edge_cd = sqrt(ctod[0]*ctod[0]+ctod[1]*ctod[1]);
		edge_da = sqrt(dtoa[0]*dtoa[0]+dtoa[1]*dtoa[1]);
		angle_a = acos(-(atob[0]*dtoa[0]+atob[1]*dtoa[1])/(edge_ab*edge_da));
		angle_b = acos(-(btoc[0]*atob[0]+btoc[1]*atob[1])/(edge_bc*edge_ab));
		angle_c = acos(-(ctod[0]*btoc[0]+ctod[1]*btoc[1])/(edge_cd*edge_bc));
		angle_d = acos(-(dtoa[0]*ctod[0]+dtoa[1]*ctod[1])/(edge_da*edge_cd));
		if(angle_a+angle_b+angle_c+angle_d >6.28318 && angle_a+angle_b+angle_c+angle_d <6.28319){cout <<"YES"<<endl;}
		else{cout<<"NO"<<endl;}
	}
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = n * n * n;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long l = 0;
    long r = 0;
    for(long i=1;i<=Math.sqrt(n);i++){
      if(n%i==0){
        l=i;
        r=n/i;
      }
    }
    System.out.println(l+r-2);
  }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		Integer N = sc.nextInt();
		int ans = 0;
		for (Integer i = 1; i <= N; i++) {
			if (i.toString().length() % 2 != 0)
				ans++;
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 29012
def run():
    input()
    a = list(map(int, input().split()))

    for i in a:
        if i % 2 == 0:
            if i % 3 == 0 or i % 5 == 0:
                continue
            else:
                print("DENIED")
                return
    
    print("APPROVED")
    

if __name__ == "__main__":
    run()

Measured memory_bytes: 2940
N, K = STDIN.gets.chomp.split(' ').map(&:to_i)
s = STDIN.gets.chomp

s.each_char.with_index{ |c, i|
  if i+1 == K then
    if c == 'A' then
      print 'a'
    elsif c == 'B'
      print 'b'
    else
      print 'c'
    end
  else
    print c
  end
}

puts


Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
int main(){
    char s[300000], t[300000];
    scanf("%s%s",s,t);
    int ans = 0;
    for(int i = 0; i < strlen(s); i++)
        if(s[i] != t[i])
            ans ++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2136
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AAtCoderBeginnerContest999 {
public:
	void solve(istream& in, ostream& out) {
        string n; in >> n;
        rep(i,3){
            if(n[i] == '1') out << 9;
            else out << 1;
        }
	}
};

int main() {
	AAtCoderBeginnerContest999 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  char name[10];
  int time;
} CUSTOMER;

int main(){
  CUSTOMER queue[200000];
  int i, n, m, q, t = 0;

  scanf("%d%d",&n, &q);

  for(i = 0; i < n; i++) scanf("%s%d",queue[i].name, &queue[i].time);

  i = 0;

  while(1){
    m = n;

    if(queue[i].time > q){
      t += q;
      queue[i].time -= q;
    }

    else{
      t += queue[i].time;
      printf("%s %d\n",queue[i].name, t);
      n--;
    }

    if(n == 0) break;

    if(n == m) queue[i + n] = queue[i];
    else queue[i + m] = queue[i];

    i++;
  }

  return 0;
}

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

using namespace std;

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

    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-2; i++) {
        int a = l[i];
        for (int j = i+1; j < n-1; j++) {
            int b = l[j];
            int two = a+b;
            auto iter = lower_bound(l.begin()+j+1, l.end(), two);
            int dist = distance(l.begin(), iter);
            sum+= dist-j-1;
        }
    }
    cout << sum << endl;
}

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

int main() {
 int N;
 cin >> N;
  vector<int> a(N);
  
  for(int i = 0;i<N;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  
  int c1 = 0;
  int c2 = 0;
  int c3 = 0;
  int c4 = 0;
  int c5 = 0;
  int c6 = 0;
  int c7 = 0;
  int c8 = 0;
  int c9 = 0;
  
  for(int i = 0;i<N;i++){
   if(a[i]<=399){
     c1++;
   }
    else if(a[i]>=400 && a[i]<=799){
      c2++;
    }
    else if(a[i]>=800 && a[i]<=1199){
      c3++;
    }
    else if(a[i]>=1200 && a[i]<=1599){
      c4++;
    }
    else if(a[i]>=1600 && a[i]<=1999){
      c5++;
    }
    else if(a[i]>=2000 && a[i]<=2399){
      c6++;
    }
    else if(a[i]>=2400 && a[i]<=2799){
      c7++;
    }
    else if(a[i]>=2800 && a[i]<=3199){
      c8++;
    }
    else if(a[i]>=3200){
      c9++;
    }
  }
 vector<int> c = {c1,c2,c3,c4,c5,c6,c7,c8,c9};
 vector<pair<int,int>> p(9);
  
  for(int i = 1;i<=9;i++){
    p[i-1].first = i;
    p[i-1].second = c[i-1];
  }

  if(c[8] < N){
  int sum = 0;
  for(int i = 0;i<8;i++){
   if(c[i]>0){  
    sum++;
    }
   }
  cout << sum << " "<< sum+c[8] << endl;
  }
  else{
    cout << 1 << " "<<c[8] << endl;
  }
}

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

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

    string str1 = "";
    for (int i = 0; i < b; i++) str1 += ('0' + a);
    string str2 = "";
    for (int i = 0; i < a; i++) str2 += ('0' + b);

    if (str1 <= str2) cout << str1 << endl;
    else cout << str2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;cin>>n>>a>>b;
    ll ans=n/(a+b);
    ans*=a;
    ans+=min(a,n%(a+b));
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod2;
        }
        now*=now;
        now%=mod2;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    int a[n];
    int cnt[31];
    fill(cnt,cnt+31,0);
    bool ok[31];
    fill(ok,ok+31,false);
    rep(i,0,n){
        cin>>a[i];
        int u=a[i];
        int num=-1;
        rep(j,0,31){
            int r=u&1;
            if(r==1){
                if(num==-1)num=j;
                cnt[j]++;
            }
            u/=2;
        }
        if(num>=0)ok[num]=true;
    }
    int ans=0;
    int cnt2[31];
    rep(i,0,31)cnt2[i]=cnt[i]%2;
    rrep(i,30,0){
        if(cnt2[i]==0)continue;
        if(ok[i]==false){
            cout<<-1<<endl;
            return 0;
        }
        ans++;
        rep(j,0,i)cnt2[j]^=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
int a,b,c;
  cin>>a>>b>>c;
  cout<<((a+b)*c)/2<<endl;

  return 0;
}







Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N,K;
    cin >> N >> K;
    ll a[N];
    ll b[N];
    ll ans=0;
    ll sum=0;
    FOR(i,0,N-1){
      cin>>a[i]>>b[i];
    }
    std::map<ll, ll> p;

    FOR(i,0,N-1){
    auto itr = p.find(a[i]);        // "xyz" が設定されているか？
    if( itr != p.end() ) {

      ll tmp = b[i]+ itr->second; 
      p.erase(itr);
      p.insert(make_pair(a[i], tmp));

    } else {
            p.insert(make_pair(a[i],b[i]));
    }
    }

    for(auto itr = p.begin(); itr != p.end(); ++itr) {
        K = K -itr->second;
        if(K<=0){
    cout<<itr->first<<endl;

  return 0;
        } 
    }


    cout<<ans<<endl;

  return 0;
}





Measured memory_bytes: 5760
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 3064
/*
  A - Tak and Hotels (ABC Edit)
  Contest 044
  Rakesh Kumar --> 02/08/2020
 */

#include <bits/stdc++.h>

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

    std::vector<int> v(26, 0);
    std::string s;
    std::getline(std::cin, s);
    for (char c : s)
        ++v[c - 'a'];

    std::string res = "Yes";
    for (int c : v) {
        if ((c & 1) == 1) {
            res = "No";
            break;
        }
    }
    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;
long long n,i,v[100001],mmax,pas;
int main()
{
    cin>>n;
    for(i=1; i<=n; ++i)
        cin>>v[i];
    for(i=n; i>1; i--)
        if(v[i]<=v[i-1])
            pas++;
        else
        {
            mmax=max(mmax,pas);
            pas=0;
        }
    mmax=max(mmax,pas);
    cout<<mmax;
    return 0;
}

Measured memory_bytes: 1024
def main():
    a, b, c = map(int, input().split())
    if c - a - b < 0:
        print('No')
        exit()
    if 4 * a * b < (c - a - b) ** 2:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,k;
    cin >> a >>b >> k;
    for(int i = 0; i < k ; i++)
    {
        if(a % 2)
        {
            a--;

        }
        b = b+a/2;
        a/=2;
        swap(a,b);
    }
    if(k%2)cout << b << " " << a <<endl;
    else cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)
INF = sys.maxsize


# input = sys.stdin.readline

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(sys.stdin.readline())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = sys.stdin.readline().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

INF = 10 ** 20

v_num, e_num, r = map(int, input().split())
edges_lst = [[] for _ in range(v_num)]
dist_lst = [INF for _ in range(v_num)]

for _ in range(e_num):
  s, t, dist = map(int, input().split())
  edges_lst[s].append((t, dist))

queue = []
heapq.heappush(queue, (0,r))
dist_lst[r] = 0

while queue:
    dist, node = heapq.heappop(queue)
    for t, cost in edges_lst[node]:
        if dist_lst[t] > dist+cost:
            dist_lst[t] = dist+cost
            heapq.heappush(queue, (dist_lst[t], t))

for dist in dist_lst:
    if dist == INF:
        print("INF")
    else:
        print(dist)





Measured memory_bytes: 90528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vi ans(N);
  rep(i,0,N){
    if(A[i]>i+1){
      cout<<-1<<endl;
      return 0;
    }
  }
  vi B(N);
  rep(i,0,N){
    B[i]=A[i]-1;
    rep(j,0,i){
      if(B[j]>=B[i]) B[j]++;
    }
  }
  vi C(N);
  rep(i,0,N) C[B[i]]=A[i];
  rep(i,0,N) cout<<C[i]<<endl;
  }



Measured memory_bytes: 256
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}


$sc = new Scanner();

$a = $sc->next();
$b = $sc->next();
$result = $a * $b;

if($result % 2 == 0){
    echo 'Even';}
else{
    echo "Odd";}


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

int main(){
    int N;
    char S[110000];
    int ans[110000];
    int sumR=0, sumL=0, ave;

    scanf("%s", &S);
    N = strlen(S);
    S[N]='R';
    for(int i=0; i<=N; i++){
        ans[i]=0;
        if(S[i]=='L'){
            sumL++;
        }else if(S[i]=='R'){
            if(sumL==0){
                sumR++;
            }else{
                ave = (sumR+sumL)/2;
                if((sumR+sumL)%2==0){
                    ans[i-sumL]=ave;
                    ans[i-sumL-1]=ave;
                }else{
                    if(sumR%2==1){
                        ans[i-sumL]=ave;
                        ans[i-sumL-1]=ave+1;
                    }else{
                        ans[i-sumL]=ave+1;
                        ans[i-sumL-1]=ave;
                    }
                }
                sumR=1;
                sumL=0;
            }
        }
    }
    for(int i=0; i<N; i++){
        printf("%d ",ans[i]);
    }

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    int tot = 0;
    rep(i, s.size()) {
        if(s[i] == 'o') tot++;
    }
    if(15 - s.size() >= 8 - tot) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

 using namespace std;

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

   string ans = "No";

   for (int i = 1; i <= 9; i++) {
     for (int j = 1; j <= 9; j++) {
       if (i * j == N) {
         ans = "Yes";
         break;
       }
     }
     if (ans == "Yes") break;
   }
   cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    int diff = 'a' - 'A';
    REP(i, N) {
        if(i == K - 1) {
            S[i] += diff;
            break;
        }
    }
    printf("%s\n", S.c_str());
    return 0;
}


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

using namespace std;

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

    vector<int> primes;
    for(int i=2;i<=300000;i++){
        if(i%7!=1 && i%7!=6) continue;
        bool flag=true;
        for(int j=0;j<(int)primes.size();j++){
            if(i%primes[j]==0){
                flag=false;
                break;
            }
        }
        if(flag)primes.push_back(i);
    }
    int x;
    while(cin>>x){
        if(x==1) return 0;
        cout<<x<<":";
        for(int i=0;i<(int)primes.size();i++){
            if(x%primes[i]==0) cout<<" "<<primes[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3340
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

        int N = scanner.nextInt();
        int[] A = new int[N];
        Set<Integer> ok = new HashSet<>();
        Set<Integer> ng = new HashSet<>();


        for (int i = 0 ; i < N ; i++) {
            A[i] = scanner.nextInt();
        }

        Arrays.sort(A);
        int max = A[A.length - 1];

        for (int i = 0 ; i < N ; i++) {
            int a = A[i];
            if (ng.contains(a)) {
                if (ok.contains(a)) {
                    ok.remove(a);
                }
                continue;
            }

            ok.add(a);
            
            int b = a;
            while (b <= max) {
                ng.add(b);
                b += a;
            }
        }

        System.out.println(ok.size());

//        boolean[] flag = new boolean[N];
//
//
//        for (int i = 0 ; i < N ; i++) {
//            A[i] = scanner.nextInt();
//            flag[i] = true;
//        }
//
//        Arrays.sort(A);
//
//        for (int i = 0 ; i < N - 1 ; i++) {
//            for (int j = i + 1 ; j < N ; j++) {
//                if (A[i] == A[j]) {
//                    flag[i] = false;
//                }
//
//                if (A[j] % A[i] == 0) {
//                    flag[j] = false;
//                }
//            }
//        }
//
//        int count = 0;
//        for (int i = 0 ; i < N ; i++) {
//            if (flag[i]) count++;
//        }
//
//        System.out.println(count);
    }
}


Measured memory_bytes: 124196
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    num = a[i] - 1
    ans += b[num]

    if i == 0:
        continue
    elif a[i - 1] + 1 == a[i]:
        ans += c[num - 1]

print(ans)


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

//GCD and LCM
llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code
map<int, int> mp;
int main()
{
  int n;
  cin>>n;
  rep(i, 0, n)
  {
    int a;
    cin>>a;
    mp[a]++;
  }
  int ans = 0;
  for(auto x : mp)
  {
    if(x.s%2 != 0 ) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 18688
#include<iostream>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
    if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
  else if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
  else{
    if(y==2){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
}

Measured memory_bytes: 3528
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();

            AtCoderMain at = new AtCoderMain();
            Console.WriteLine(at.ABC085CRun(s1));
            Console.ReadKey();

        }
    }

    public partial class AtCoderMain
    {
        /// <summary>
        /// ABC085C - Otoshidama
        /// https://atcoder.jp/contests/abs/tasks/abc085_c
        /// </summary>
        /// <param name="p1"></param>
        /// <returns></returns>
        public string ABC085CRun(string p1)
        {
            string[] tmp = p1.Split(' ');
            int cnt = int.Parse(tmp[0]);
            int total = int.Parse(tmp[1]);

            for (int a = 0; a <= cnt; a++)
            {
                for (int b = 0; a + b <= cnt; b++)
                {
                    int c = cnt - (a + b);
                    if (a * 1000 + b * 5000 + c * 10000 == total)
                    {
                        return string.Format("{0} {1} {2}", c, b, a);
                    }
                }
            }

            return "-1 -1 -1";
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std ;
int main()
{
    int a[7],k;
    for(int i = 1 ; i <= 5 ; i++)
        cin >> a[i];
    cin >> k;
    for(int i = 1 ; i<= 5 ; i++)
        for(int j = i+1 ; j<=5 ; j++)
        {
            if(a[j]-a[i]>k)
            {
                cout << ":(";
                return 0;
            }
        }
    cout << "Yay!";

    return  0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int b1,b2,b3;
	scanf("%d %d %d",&b1,&b2,&b3);
	if(b1==1 && b2==0 && b3==0){
		printf("Close\n");
	}
	else if(b1==0 && b2==1 && b3==0){
		printf("Close\n");
	}
	else if(b1==1 && b2==1 && b3==0){
		printf("Open\n");
	}
	else if(b1==0 && b2==0 && b3==1){
		printf("Open\n");
	}
	else if(b1==0 && b1==0 && b3==0){
		printf("Close\n");
	}
	else{
		printf("Close\n");
	}
	return 0;
}

Measured memory_bytes: 1012