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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

void solve(long long N, long long K, long long C, std::string S) {
    vi L(K), R(K);
    size_t k = 0;
    for (ll i = 0; i < N; i++) {
        if (S[i] == 'o') {
            L[k] = i + 1;
            k++;
            i += C;
        }
        if (k == K) {
            break;
        }
    }
    k = 0;
    for (ll i = N - 1; i >= 0; i--) {
        if (S[i] == 'o') {
            R[k] = i + 1;
            k++;
            i -= C;
        }
        if (k == K) {
            break;
        }
    }

    /*
    for (auto item : L) {
        cout << item << " ";
    }
    cout << endl;
    for (auto item : R) {
        cout << item << " ";
    }
    cout << endl;
     */

    auto l = L.cbegin();
    auto r = R.crbegin();

    for (auto i = 0; i < K; i++) {
        if (*l == *r) {
            cout << *l << endl;
        }
        l++;
        r++;
    }
}

int main() {
    long long N;
    std::cin >> N;
    long long K;
    std::cin >> K;
    long long C;
    std::cin >> C;
    std::string S;
    std::cin >> S;
    solve(N, K, C, S);
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int n,m;
  cin>>n>>m;
  ll x[n],y[n],z[n];
  for(i=0;i<n;i++)cin>>x[i]>>y[i]>>z[i];
  ll a[8][n];
  ll ex[8]={-1,-1,-1,-1,1,1,1,1};
  ll ey[8]={-1,-1,1,1,-1,-1,1,1};
  ll ez[8]={-1,1,-1,1,-1,1,-1,1};
  for(i=0;i<8;i++){
    for(j=0;j<n;j++){
      a[i][j]=ex[i]*x[j]+ey[i]*y[j]+ez[i]*z[j];
    }
  }
  for(i=0;i<8;i++){
    sort(a[i],a[i]+n,greater<ll>());
  }
  ll ans[8];
  for(i=0;i<8;i++)ans[i]=0;
  for(i=0;i<8;i++){
    for(j=0;j<m;j++)ans[i]+=a[i][j];
  }
  ll ma=0;
  for(i=0;i<8;i++)ma=max(ma,ans[i]);
  cout<<ma<<endl;
}

Measured memory_bytes: 384
def resolve():
	N,M,C=map(int,input().split())
	B=list(map(int,input().split()))
	ans=0
	for i in range(N):
		A=list(map(int,input().split()))
		chk=0
		for j in range(M):
			chk+=A[j]*B[j]
		if chk+C>0:
			ans+=1
	print(ans)
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, x, y);
    if(x % y == 0) Cout(-1);
    else{
        Cout(x*(y-1));
    }
}





Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,count=0;cin>>n;
    bool answer = false;
    while(n--){
        int a1,a2;cin>>a1>>a2;
        if(a1==a2)count++;
        else count=0;
        if(count>=3)answer = true;
    }
    cout<< (answer?"Yes":"No");
}


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {

	N := oneInt()
	var words []string
	for i := 0; i < N; i++ {
		words = append(words, oneStr())
	}
	words = removeDuplicate1(words)
	fmt.Print(len(words))
}

// 重複した要素を削除して返却
func removeDuplicate1(args []string) []string {
	results := make([]string, 0, len(args))
	encountered := map[string]bool{}
	for i := 0; i < len(args); i++ {
		if !encountered[args[i]] {
			encountered[args[i]] = true
			results = append(results, args[i])
		}
	}
	return results
}

func exp(val int) float64 {
	var temp float64
	for index := 1; index <= val; index++ {
		temp += float64(index)
	}
	return temp / float64(val)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 26284
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        printf("a > b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2592
n,m = map(int,input().split())
PS = sorted([input().split() for i in range(m)], key=lambda x:x[0])
PS += [["",""]]
ac = 0
wa = 0

pre = ""
wa_tmp=0
ac_tmp=0

# if PS[0][1] == "WA":
#     wa_tmp += 1

pre = ""
for p,s in PS:
    if pre!=p:
        wa_tmp=0
        ac_tmp=0
    if s == "AC":
        if not ac_tmp:
            ac+=1 
            wa+=wa_tmp
            wa_tmp=0
            ac_tmp+=1
    elif s == "WA":
        wa_tmp+=1
    pre = p

print(ac,wa)

Measured memory_bytes: 34564
#include<stdio.h>
#include <stdlib.h>
int main(void){
	int a,b,c,d,sum=0;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a>b){
	sum+=b;
	}else{
	sum+=a;
	}
	if(c>d){
	sum+=d;
	}else{
	sum+=c;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
a=[0]*M
b=[0]*M
adj = [[0 for _ in range(N)] for _ in range(N)]
flag = [0]*N
bridge = 0

for i in range(M):
    a[i],b[i]=map(int,input().split())
    adj[a[i]-1][b[i]-1] = adj[b[i]-1][a[i]-1] = 1

def dfs(cv):
    flag[cv-1]=1
    for i,x in enumerate(adj[cv-1]):
        if x==1 and flag[i]==0 :
            dfs(i+1)
    return

for i in range(M):
    flag=[0]*N
    adj[a[i]-1][b[i]-1] = adj[b[i]-1][a[i]-1] = 0
    dfs(1)
    if sum(flag)<N:
        bridge+=1
    adj[a[i]-1][b[i]-1] = adj[b[i]-1][a[i]-1] = 1

print(bridge)


Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int x,y;
    cin >> x >> y;
    int ans = x+y+2;
    for(int i = 0;i <= x;i++){
        if((y*i)%x == 0){
            ans--;
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3104
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printc;
using io::prints;

#define Fail prints("No"), exit(0);
const int N = 3e5 + 7;
int n, p[N];

inline bool pd(int l, int r) {
	if (l == r) return 0;
	int L = 0, R = 0;
	for (int i = l; i <= r; i += 2)
		if (p[i] < l || p[i] > r) return 0;
		else if (i < p[i]) {
			if (L && p[i] < L) return 0;
			else L = p[i];
		} else {
			if (R && p[i] < R) return 0;
			else R = p[i];
		}
	return 1;
}

int main() {
	rd(n), rda(p, n);
	for (int l = 1, r = 1; l <= n; l = ++r) {
		if (p[r] == r) continue;
		while (r + 2 <= n && p[r+1] == r + 1 && p[r+2] != r + 2) r += 2;
		if (!pd(l, r)) Fail;
	}
	prints("Yes");
	return 0;
}

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

using namespace std;

int n;
set<string> s;

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

    cin >> n;

    while(n--){
        string k;

        cin >> ws >> k;

        s.insert(k);
    }

    cout << s.size() << "\n";
    
    return 0;
}

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

int main(){
  int N, W;
  cin >> N >> W;
  W++;
  
  vector<int> v(N), w(N);
  vector<vector<long>> dp(N, vector<long>(W, 0));
  
  for(int i=0; i<N; i++){
    cin >> w[i] >> v[i];
  }
  
  
  for(int s=w[0]; s<W; s++){
    dp[0][s] = v[0];
  }
  for(int i=1; i<N; i++){
    for(int s=0; s<w[i]; s++){
      dp[i][s] = dp[i-1][s];
    }
    for(int s=w[i]; s<W; s++){
      dp[i][s] = max(dp[i-1][s], dp[i-1][s-w[i]] + v[i]);
    }
  }
  cout << dp[N-1][W-1] << endl;
  return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve(){
   string str;cin>>str;
   for (int i = 0; i < 3; ++i)
   {
       if(str[i]==str[i+1]){
        cout<<"Bad";
        return 0;
       }
   }
   cout<<"Good";
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

  int a;
  string s;

  cin >> a >> s;
  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,b,r,S=0,sum=0;
  cin>>N>>b>>r;
  S=N/(b+r)*b;
  if(N-(N/(b+r)*(b+r))<b){
    S+=N-(N/(b+r)*(b+r));
  }else{
   S+=b;
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF LONG_LONG_MAX
using namespace std;

signed main(){
    int n,k; cin>>n>>k;
    vector<int> x(n);
    int ksum=0;
    rep(i,n) cin>>x.at(i);
    rep(i,k-1) ksum+=x.at(i+1)-x.at(i);
    vector<int> ksums(n-k+1);
    x.push_back(INF);
    rep(i,n-k+1){
        ksums.at(i)=ksum+min(abs(x.at(i)),abs(x.at(i+k-1)));
        ksum-=x.at(i+1)-x.at(i);
        ksum+=x.at(i+k)-x.at(i+k-1);
    }
    sort(all(ksums));
    cout<<ksums.front()<<endl;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N, A;
long long dp[51][51 * 51];

int main() {
    cin >> N >> A;
    vector<int> nums(N);
    for (int i = 0; i < N; i++)
        cin >> nums[i];

    dp[0][0] = 1;
    for (int k = 1; k <= N; k++) {
        for (int i = k - 1; 0 <= i; i--) {
            for (int j = 0; j <= 50 * i; j++) {
                dp[i + 1][j + nums[k - 1]] += dp[i][j];
            }
        }
    }

    long long res = 0;
    for (int i = 1; i <= N; i++) {
        int val = i * A;
        res += dp[i][val];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X,Y;
  X = 0;
  cin >> N;
  Y = N;
  for (int i = 0; i < 8; i++) {
    X += Y%10;
    Y /=10;
    if(Y == 0){
      break;
    }
  }
  
  if (N%X == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する
ll calc(int n){
    ll ret = 1;
    rep(i,0,n){
        ret = (ret * 2) % (1000000007);
    }
    return ret;
}


int main() {
    int N;
    cin >> N;
    vector<int> inp(N,0);
    rep(i,0,N){
        int tmp;
        cin >> tmp;
        inp[tmp]++;
    }
    if(N % 2 == 1){
        if(inp[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        for(int i = 2; i < N; i+=2){
            if(inp[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
//        ll
        cout << calc(N/2) << endl;
    }else{
        for(int i = 1; i < N; i+=2){
            if(inp[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
        cout << calc(N/2) << endl;
    }

    return 0;
}


Measured memory_bytes: 640
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, M = read_ints()
S, C = read_col(M, 2)

for i in range(1000):
    n = str(i)
    if len(n) != N:
        continue
    is_ok = True
    for s, c in zip(S, C):
        if n[s - 1] == str(c):
            pass
        else:
            is_ok = False
            break
    if not is_ok:
        continue
    print(i)
    exit()
print(-1)


Measured memory_bytes: 3064
import math
N = int(input())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]

P = 0
Q = 0
for i in range(N-1):
    cnt_p = 0
    cnt_q = 0
    for j in range(i+1, N):
        if p[i] > p[j]:
            cnt_p += 1
        if q[i] > q[j]:
            cnt_q += 1
    P += cnt_p*math.factorial(N-1-i)
    Q += cnt_q*math.factorial(N-1-i)
print(abs(P-Q))

Measured memory_bytes: 3064
n=int(input())
lst=[]
for i in range(2,55555):
    for j in range(2,int(i**(1/2))+1):
        if i%j==0:
            break
    else:
        lst.append(i)
li=[]
count=0
for u in lst:
    if u%5==2:
        li.append(u)
        count+=1
        if count==n:
            break
print(*li)

Measured memory_bytes: 3444
a = input().split()
x = []
y = []
z = []
a[0] = int(a[0])
a[1] = int(a[1])
a[2] = int(a[2])
for i in range(a[0]):
    b = input().split()
    x.append(b)
    z.append([])
for i in range(a[1]):
    b  = input().split()
    y.append(b)
for i in range(a[0]):
    for j in range(a[2]):
        z[i].append(0)    
for i in range(a[0]):
    for j in range(a[2]):
        for k in range(a[1]):
            z[i][j] += int(x[i][k])*int(y[k][j])
for i in range(len(z)):
    for j in range(a[2]):
        z[i][j] = str(z[i][j])
for i in z:
    gam = " ".join(i)
    print(gam)


Measured memory_bytes: 7404
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iterator>
using namespace std;

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

struct Graph{
    struct Node{
        vector<int> dests;
        int len = -1;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    int id(Node* n){ return n - &nodes[0]; }
    int id(Node& n){ return &n - &nodes[0]; }
    void print(){ for(auto& node : nodes){ prints(id(node), node.dests); } }
    void addEdge(int from, int dest){
        nodes[from].dests.push_back(dest);
    }
    int dfs(int idx){
        if(nodes[idx].len != -1){
            return nodes[idx].len;
        }
        int ret = 0;
        for(int didx : nodes[idx].dests){
            ret = max(ret, dfs(didx) + 1);
        }
        return nodes[idx].len = ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        g.addEdge(x, y);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans, g.dfs(i));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0;
    rep(i,s.size()){
        if (s[i] == 'a') a++;
        else if (s[i] == 'b') b++;
        else if (s[i] == 'c') c++;
    }
    if (max({a, b, c}) - min({a, b, c}) > 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
using namespace std;
     
int main()
{
  int a, b, c;
 
  cin >>a>>b>>c;
 
  if((a<b)&&(b<c))
  {
    cout <<"Yes\n";
  }
  else
  {
    cout <<"No\n";
  }
 
  return 0;
}

Measured memory_bytes: 1124
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
    int x;
    cin >> x;
    if(x == 1){
        cout << "Hello World" << endl;
    }else{
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

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

using namespace std;
const int MAX = 1000000;
typedef pair<int, int> PII;
typedef long long ll;
bool marked[MAX];
vector<pair<ll, ll>>adj[MAX];

bool sortbysec(const pair<pair<ll,ll>, ll> &a, const pair<pair<ll,ll>, ll> &b)
{
     return (a.first.second < b.first.second);
}

int prim(ll x)
{
    priority_queue<PII, vector<PII>, greater<PII> > Q;
    ll y;
    ll minimumCost = 0;
    PII p;
    Q.push(make_pair(0, x));
    while(!Q.empty())
    {
        // Select the edge with minimum weight
        p = Q.top();
        Q.pop();
        x = p.second;
        // Checking for cycle
        if(marked[x] == true)
            continue;
        minimumCost += p.first;
        marked[x] = true;
        for(ll i = 0;i < (int)adj[x].size();++i)
        {
            y = adj[x][i].second;
            if(marked[y] == false)
                Q.push(adj[x][i]);
        }
    }
    return minimumCost;
}

int main() {
    
    ll n;
    cin>>n;
//    vector<int, int>coordinates;
    vector<pair<pair<ll, ll>, ll>>coordinates;
    for(ll i=0;i<n;i++)
    {
         ll x, y;
         cin>>x>>y;
         coordinates.push_back(make_pair(make_pair(x, y), i));
    }
    
    sort(coordinates.begin(), coordinates.end());
    
     for(ll i=0;i<n-1;i++)
     {
         ll weight = abs(coordinates[i+1].first.first - coordinates[i].first.first); 
         adj[coordinates[i+1].second].push_back(make_pair(weight, coordinates[i].second));
         adj[coordinates[i].second].push_back(make_pair(weight, coordinates[i+1].second));
     }
    
     sort(coordinates.begin(), coordinates.end(), sortbysec);
     
     for(ll i=0;i<n-1;i++)
     {
         ll weight =abs(coordinates[i+1].first.second - coordinates[i].first.second); 
         adj[coordinates[i+1].second].push_back(make_pair(weight, coordinates[i].second));
         adj[coordinates[i].second].push_back(make_pair(weight, coordinates[i+1].second));
     }
     
//     for(int i=1;i<=n;i++)
//     {
//          for(int j=0;j<(int)adj[i].size();j++)
//          {
//               cout<<i<<" "<<adj[i][j].first<<" "<<adj[i][j].second<<"\n";
//          }
//     }
     
//   cout<<adj.size()<<"\n";
     
     ll minimumCost = prim(1);
     cout << minimumCost << endl;
     
     return 0;
}

Measured memory_bytes: 37616
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


h, n = LI()
A = []
B = []
for _ in range(n):
    a, b = LI()
    A += [a]
    B += [b]


dp = [INF] * (h + 1)
dp[0] = 0
for i in range(n):
    for j in range(h):
        dp[min(h, j + A[i])] = min(dp[min(j + A[i], h)], dp[j] + B[i])


print(dp[-1])




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

int main(){
    int d[5];
    for(size_t i = 0; i < 5; i++)
    {
        cin >> d[i];
    }

    int k;
    cin >> k;

    for(size_t i = 0; i < 5; i++)
    { 
        bool bk = false;
        for(size_t j = 0; j < 5; j++)
        {
            if (j > i && d[j] - d[i] > k) 
            {
                bk = true;
                break;
            }
        }

        if (bk) 
        {
            cout << ":(" << endl;
            break;
        }
        else if (i==4) 
        {
            cout << "Yay!" << endl;
        }       
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using ll = long long;

#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void init_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() { init_io();
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i + i + 1 <= n; i++) {
    ans++;
  }
  cout << ans << endl;
}

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

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

    int n, m;
    cin >> n >> m;
    int b1, b2;
    vector<int> sol;
    vector<bool> chk;
    for (int i = 0; i <= n; ++i) {
        sol.push_back(1);
        chk.push_back(false);
    }
    chk[1] = true;
    int result = 1;
    while(m --> 0) {
        cin >> b1 >> b2;
        sol[b1]--;
        sol[b2]++;
        if (!chk[b2] && chk[b1]) {
            result++;
            chk[b2] = true;
        }
        if (sol[b1] == 0 && chk[b1]) {
            result--;
            chk[b1] = false;
        }
    }
    cout << result << "\n";
}


Measured memory_bytes: 892
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string s = buf;

  for (size_t i = 1; i < s.length(); ++i)
    if (s[i-1] == s[i])
      return !printf("%zu %zu\n", i, i+1);

  for (size_t i = 1; i+1 < s.length(); ++i)
    if (s[i-1] == s[i+1])
      return !printf("%zu %zu\n", i, i+2);

  puts("-1 -1");
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9 + 1)

int ABS(int a){
	return a >= 0 ? a : -a;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, K, i, j;
	scanf("%d%d", &N, &K);
	int *h = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &h[i]);
	}
	int *dp = (int *)malloc(sizeof(int) * N);
	dp[0] = 0;
	for(i = 1; i < N; i++){
		dp[i] = inf;
	}
	for(i = 0; i < N; i++){
//		printf("dp[%d] = %d\n", i, dp[i]);
		for(j = 1; j <= K && i + j < N; j++){
			dp[i + j] = min(dp[i + j], dp[i] + ABS(h[i] - h[i + j]));
		}
	}
	printf("%d\n", dp[N - 1]);
	return 0;
}

Measured memory_bytes: 896
import sys
sys.setrecursionlimit(1000000)
N=int(input())
ab=[[] for _ in range(N)]
for _ in range(N-1):
  a,b=map(int,input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)
"""
N=10**5
ab=[[]]*N
ab[0]=[2]
ab[N-1]=[N-1]
for i in range(1,N-1):
  ab[i]=[i,i+2]
"""
par=[0]*N
  
def dfs(pre,p):
  global path
  par[p-1]=pre
  if p==N:
    pass
  else:
    for i in ab[p-1]:
      if i!=pre:
        dfs(p,i)

dfs(-1,1)
path=[N]
p=N
while p!=1:
  p=par[p-1]
  path.append(p)
path.reverse()

spath=set(path)

def dfs2(pre,p):
  a=0
  for i in ab[p-1]:
    if i in spath:
      pass
    elif i==pre:
      pass
    else:
      a+=dfs2(p,i)
  return 1+a

ff=0
sf=0
L=len(path)
for i in range(L):
  if i<=(L-1)//2:
    ff+=dfs2(-1,path[i])
  else:
    sf+=dfs2(-1,path[i])
    
if ff>sf:
  print("Fennec")
else:
  print("Snuke")


Measured memory_bytes: 110260
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int K = Int ();
        int X = Int ();

        var list = L<int> ();
        for (int i = X - K + 1; i <= X + K - 1; i++) {
            if (-1000000 <= i && i <= 1000000) {
                list.Add (i);
            }
        }
        Dbg (list);
    }

    static Scanner cin = new Scanner ();
    const int M = 1000000007;
    static void Dbg (object a) => Console.WriteLine (a);
    static void Dbg (string a) => Console.WriteLine (a);
    static void Dbg<T> (IEnumerable<T> a) => Dbg (string.Join (" ", a));
    static void Dbg<T> (params object[] a) => Dbg (string.Join (" ", a));
    static void Dbgs<T> (IEnumerable<T> a) => Dbg (string.Join ("\n", a));
    static void Dbgs<T> (params object[] a) => Dbg (string.Join ("\n", a));
    static int Int () => cin.nextInt ();
    static long Long () => cin.nextLong ();
    static int[] Ints () => cin.arrayInt ();
    static long[] Longs () => cin.arrayLong ();
    static double Double () => cin.nextDouble ();
    static double[] Doubles () => cin.arrayDouble ();
    static string String () => cin.nextString ();
    static string[] Strings () => cin.arrayString ();
    static T Max<T> (params T[] a) => a.Max ();
    static T Min<T> (params T[] a) => a.Min ();

    static List<T> L<T> () => new List<T> ();
}

class Scanner {
    string[] s;
    int i;
    int max_i;

    public Scanner () {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        } else {
            return s[i++];
        }
    }

    public int nextInt () {
        return int.Parse (nextString ());
    }

    public long nextLong () {
        return long.Parse (nextString ());
    }

    public double nextDouble () {
        return double.Parse (nextString ());
    }

    public string[] arrayString () {
        return Console.ReadLine ().Split (' ');
    }

    public int[] arrayInt () {
        string[] str = Console.ReadLine ().Split (' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = int.Parse (str[i]);
        }
        return array;
    }

    public long[] arrayLong () {
        string[] str = Console.ReadLine ().Split (' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = long.Parse (str[i]);
        }
        return array;
    }

    public double[] arrayDouble () {
        string[] str = Console.ReadLine ().Split (' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = double.Parse (str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007;
#define INF 10*60;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,M;cin>>N>>M;
  if(2*N>=M){
    print(M/2)
  }
  else {
    int ans=N;
    M-=2*N;
    ans+=M/4;
    print(ans)
  }

}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<double> vi(N);
    for (int i=0;i<N;i++) cin >> vi[i];
    sort(vi.begin(),vi.end());
    double sum = vi[0];
    for (int i=1;i<N;i++) {
        sum = (sum + vi[i])/2.0;
    }
    cout << fixed << setprecision(6) << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

set = [a,b,c,d,e]
min_t = min(a,b,c,d,e)

time = (n-1) // min_t + 1

time += 4

print(time)

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


string S,T;
void input() {
  cin >> S >> T;
}

void solve() {
  T.pop_back();
  if(S == T) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<char, int>;
const int INF = 1001001001;

bool dp[2][8005][16010];

int main(void){
  string s;
  int x, y;
  cin >> s >> x >> y;
  int n = s.size();
  vector<P> v;
  for(int i = 0; i < n;){
    int j = i;
    while(j < n && s[i] == s[j]) j++;
    v.emplace_back(P(s[i], j-i));
    i = j;
  }
  dp[0][0][n] = dp[1][0][n] = true;
  int m = v.size();
  int d = 0;
  bool first = true;
  REP(i, m){
    char c = v[i].first;
    int l = v[i].second;
    if(c == 'T'){
      first = false;
      if(l%2) d ^= 1;
      REP(j, 2*n+1){
        dp[0][i+1][j] = dp[0][i][j];
        dp[1][i+1][j] = dp[1][i][j];
      }
    }else{
      REP(j, 2*n+1){
        if(j+l < 2*n+1) dp[d][i+1][j+l] |= dp[d][i][j];
        if(!first && j-l >= 0) dp[d][i+1][j-l] |= dp[d][i][j];
        dp[d^1][i+1][j] = dp[d^1][i][j];
      }
    }
  }
  if(dp[0][m][n+x] && dp[1][m][n+y]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int n, a[1000005];

int main() {
  while(1){
    cin>>n;
    if(n==0) break;
    REP(i,0,n){
      cin>>a[i];
    }
    sort(a,a+n);
    int ans = 1e9;
    REP(i,0,n-1){
      ans = min(ans, abs(a[i]-a[i+1]));
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    cout << n - ( m - 1);
}


Measured memory_bytes: 4352
#coding: utf-8
N = int(input())
w = list(input())
wl = [w]
for i in range(N-1):
    nw = list(input()) 
    if w[-1] == nw[0] and nw not in wl:
        wl.append(nw)
        w = nw[:]
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	st s;
	cin >> s;
	if (s.substr(5, 2) <= "04"&&s.substr(8, 2) <= "30") {
		cout << "Heisei";
	}
	else {
		cout << "TBD";
	}
	return 0; 
}

Measured memory_bytes: 256
def examA():
    N, K = LI()
    St = S()
    ans = St[0:(K-1)] + St[(K-1):K].lower() + St[K:]
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

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


int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P.at(i);
    for (int i = 0; i < N; i++) cin >> Q.at(i);
    
    vector<int> A(N);
    for (int i = 0; i < N; i++) A.at(i) = i+1;
    
    int counter1 = 0;
    int counter2 = 0;

    while (P != A) {
      next_permutation(A.begin(), A.end());
      counter1++;
    }

    vector<int> B(N);
    for (int i = 0; i < N; i++) B.at(i) = i+1;

    while (Q != B) {
      next_permutation(B.begin(), B.end());
      counter2++;
    }

    cout << abs(counter1 - counter2) << endl;
}

Measured memory_bytes: 256