akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  int ans = 0, h;
  REP(i, N){
    cin >> h;
    if(K <= h) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, ii, iii, n, f = 0,tmp, tmp2, m, ans = 0;
    long long int k, A[200000], B[200000], a[200000], b[200000];
    scanf("%d%d%lld", &n, &m, &k);
    for (i = 0; i < n; i++)
        scanf("%lld", A + i);
    for (i = 0; i < m; i++)
        scanf("%lld", B + i);
    a[0] = A[0];
    b[0] = B[0];
    for (i = 1; i < n; i++)
        a[i] = a[i - 1] + A[i];
    for (i = 1; i < m; i++)
        b[i] = b[i - 1] + B[i];
        
    tmp = m - 1;
    for (i = 0; b[i] <= k && i < m; i++)
        ;
    ans = i - 2;
    for (i = 0; i < n; i++)
    {
        if (a[i] > k)
            break;
        for (ii = tmp; a[i] + b[ii] > k; ii--)
        {
            if (ii == 0)
            {
                f = 1;
                break;
            }
        }
        if (f)
        {
            ii = -1;
            if (ans < i + ii)
                ans = i + ii;
            tmp = 0;
        }
        else
        {                   
            tmp = ii;
            if (ans < i + ii)
                ans = i + ii;
                    
            
            if (tmp < 0)
                break;
        }
    }
    printf("%d", ans + 2);
}


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

class dice
{
public:
    int F[6];
    int q1, q2;
    dice();
    void input();
    void roll_a();
    void roll_b();
    bool check(const dice& d);
    bool equal(const dice& d);
};

dice::dice(){}

void dice::input()
{
    int i;
    for(i = 0; i < 6; i++) scanf("%d", &F[i]);
    q1 = F[0] + F[1] + F[2] + F[3] + F[4] + F[5];
    q2 = F[0] * F[5] + F[1] * F[4] + F[2] * F[3];
}

void dice::roll_a()
{
    int i;
    i = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = i;
    i = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = i;
}

void dice::roll_b()
{
    int i;
    i = F[0]; F[0] = F[5]; F[5] = i;
    i = F[1]; F[1] = F[3]; F[3] = i;
    i = F[2]; F[2] = F[4]; F[4] = i;
}
 
bool dice::check(const dice& d)
{
    int l, m;
    if((d.F[0] != F[0]) || (d.F[5] != F[5])) return false;

    for(l = 1; l <= 4; l++){
        for(m = 1; m <= 4; m++){
            if(d.F[m] != F[(l * m) % 5]) break;
        }
        if(m == 5) return true;
    }
    return false;
}

bool dice::equal(const dice& d)
{
    bool eq;
    if((q1 != d.q1) || (q2 != d.q2)) return false;
    for(int i = 0; i < 2; i++){
        eq = check(d);
        if(!eq){ roll_a(); eq = check(d); }
        if(!eq){ roll_a(); eq = check(d); }
        if(eq || i == 1) break;
        roll_b();
    }
    return eq;
}

int main()
{
    dice d[100];
    int n, i, j;

    scanf("%d", &n);
    for(i = 0; i < n; i++){ d[i].input(); }

    for(i = 0; i < n; i++){
        for(j = i + 1; j < n; j++){
            if(d[i].equal(d[j])) break;
        }
        if(j < n) break;
    }
    if(i + j == 2 * n){ printf("Yes"); }else{ printf("No"); }
    printf("\n");

    return 0;
}

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

using namespace std;


int main() {
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];
    sort(T.begin(), T.end());


    int last = -1;
    int ans = 0;
    int counter = 0;
    for (int i = 0; i < N; i++) {
        if (last == -1) {
            counter++;
            ans++;
            last = T[i];
            continue;
        }

        if (T[i] <= last + K && counter < C) {
            counter++;
        } else {
            ans++;
            counter = 1;
            last = T[i];
        }
    }
    cout << ans << endl;
}


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

int main()
{
	long long n; cin >> n;
	long long nx, ny, ans = 9223372036854775807;

	for (long long i = 1; i * i <= n; i++) {		
		if (n % i == 0) {
			long long tmpNx = i;
			long long tmpNy = n / i;
			ans = min(ans, abs(tmpNx - 1) + abs(tmpNy - 1));
		}		
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	char s[4];
	cin >> s;
	int n = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+')
			n++;
		else
			n--;
	}
	cout << n << endl;
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 2007 , __ = _*_ , mo = 1000000007;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint jc[__],rjc[__];

inline void fuck(int n=__-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,m;
lint f[_][_]={0};

int main()
{//
	n=ty(),m=ty();
	if(m<=1){puts("1");return 0;}

	fuck();
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>0)f[i][j]=(f[i][j]+f[i][j-1]*(n-j+1)%mo*C(n*m-i-(j-1)*(m-1)-1,m-2)%mo)%mo;
		}
	}
	printf("%lld\n",f[n][n]);

	return 0;
}


Measured memory_bytes: 93184
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()
############# CODE STARTS HERE #############
n=ii()
x, y, z=mi()
for _ in range(n-1):
    a, b, c=mi()
    a+=max(y, z)
    b+=max(x, z)
    c+=max(y, x)
    x, y, z=a, b, c
print(max(x, y, z))

Measured memory_bytes: 43372
#include <iostream>
using namespace std;
int n, a;
int main(void){
    // Your code here!
    cin >> n;
    int max = 1, min = 1000;
    for (int i = 0; i < n; i++) {
        cin >> a;
        max  = (max > a ? max : a);
        min = (min < a ? min : a);
    }
    cout << max - min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

const int N=100005;
int vis[N],ds[N],even[N];
vector<int> G[N];
bool cmp(int x,int y){
    if (!vis[x]&&!vis[y]) return ds[x]<ds[y];
    return !vis[x];
}

void work(int x,int y){
    printf("%d %d\n",x,y);
}
int main(){
   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int n,m;cin>>n>>m;
    if (m%2) {puts("-1");return 0;}
    for (int i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        G[x].pb(y);G[y].pb(x);
        ds[x]++,ds[y]++;
    }
    int he,ta;
    static int q[N];q[he=ta=1]=1;vis[1]=1;
    for (int i=1;i<=n;i++){
        int x=q[i];
        for (int y:G[x]) if (!vis[y]) {q[++ta]=y;vis[y]=1;}
    }
    memset(vis,0,sizeof(vis));
    for (int i=n;i>=1;i--){
        int x=q[i];vis[x]=1;
        sort(G[x].begin(),G[x].end(),cmp);
        while (!G[x].empty()&&vis[G[x].back()]) G[x].pop_back();
        if ((ds[x]&1)^even[x]){
            work(G[x].back(),x);ds[G[x].back()]--;
            even[G[x].back()]^=1;G[x].pop_back();
        }
        for (int y:G[x]){
            work(x,y);ds[y]--;
        }
    }

    return 0;
}


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

int main() {
    int n, m;
    cin >> n;
    vector<string> vec_n(n);
    rep(i, n) cin >> vec_n[i];
    cin >> m;
    vector<string> vec_m(100);
    rep(i, m) cin >> vec_m[i];
    
    int max = -100;
    rep(i, n){
        int cnt = 0;
        rep(j, n){
            if(vec_n[i] == vec_n[j]) cnt++;
        }
        rep(j, m){
            if(vec_n[i] == vec_m[j]) cnt--;
        }
        
        if(cnt > max) max = cnt;
    }
    
    
    if(max < 0){
        cout << 0 << endl;
    }else cout << max << endl;
}

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

using namespace std;

int main(){

  int n, k, x;
  int d = 0;
  cin >> n >> k;

  for ( int i = 0; i < n; i++ ){
    cin >> x;

    int a = x;
    int b = abs( x - k );
    
    if ( a < b ){
      d += 2 * a;
    }else {
      d += 2 * b;
    }
  }
  cout << d << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

int main(){
	int N;
	int grid[2][110];
	int dp[2][110];
	
	cin >> N;
	for(int i = 0 ; i < 2 ; i++){
		for(int j = 0 ; j < N ; j++){
			cin >> grid[i][j];
			dp[i][j] = 0;
		}
	}
	
	dp[0][0] = grid[0][0];
	dp[1][0] = grid[1][0];
	
	for(int j = 1 ; j < N ; j++){
		dp[0][j] = dp[0][j-1] + grid[0][j];
		dp[1][j] = dp[1][j-1] + grid[1][j];
	}
	
	int ans = grid[0][0] + grid[1][0];
	
	for(int j = 0 ; j < N ; j++){
		ans = max(ans, dp[0][j] + (dp[1][N-1] - dp[1][j-1]));
	}
	
	cout << ans << endl;
	
	return 0;
}


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

const int MN = 300010;

int N;
int A[MN], inva[MN];

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        A[i]--;
    }
    for(int i = 0; i < N; i++) inva[A[i]] = i;

    int st = 0;
    while(st < N) {
        int ed = N - 1;
        for(int i = st; i < N; i += 2) {
            if(A[i] == i) {
                ed = i - 2;
                break;
            }
        }

        if(st > ed) {
            st++;
            continue;
        }

        for(int i = st + 1; i <= ed; i += 2) {
            if(A[i] != i) {
                printf("No");
                return 0;
            }
        }
        for(int i = st; i <= ed; i++) {
            if(A[i] < st || ed < A[i]) {
                printf("No");
                return 0;
            }
        }

        int mx1 = -1;
        int mx2 = -1;
        for(int i = st; i <= ed; i += 2) {
            if(inva[i] < i) {
                if(mx1 >= inva[i]) {
                    printf("No");
                    return 0;
                }
                mx1 = inva[i];
            }
            else {
                if(mx2 >= inva[i]) {
                    printf("No");
                    return 0;
                }
                mx2 = inva[i];
            }
        }

        st = ed + 1;
    }
    printf("Yes");
}


Measured memory_bytes: 2688
/*
ACplease
　　 ●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#include <cassert>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------------------------------------
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    srand((unsigned)time(NULL));
    
    int n,m; cin >> n >> m;
    int ans = 0;
	if(n > 1) ans += n*(n-1)/2;
    if(m > 1) ans += m*(m-1)/2;
    ANS;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ {
	class Program {
		static void Main(string[] args) {
			new Calc().Solve();

		}

		public class Calc {
			public void Solve() {
				int N = Utils.GetInt();
				var S = Console.ReadLine().Split().Select(int.Parse).ToList();
				if (N != S.Count) return;
				int cnt = 0;
				int M = Utils.GetInt();
				var list= Console.ReadLine().Split().Select(int.Parse).ToList();
				if (M != list.Count) return;
				foreach (var item in list) {
					if (S.BinarySearch(item) >= 0) cnt++;
				}
				Console.WriteLine(cnt);
				return;
			}
		}
	}

	public static class Utils {
		public static int GetInt() {
			return int.Parse(Console.ReadLine());
		}
		public static void WL(this object obj) { Console.WriteLine(obj); }
		public static void WL<T>(this IEnumerable<T> ie) {
			foreach (var item in ie) {
				item.WL();
			}
		}
	}
}

Measured memory_bytes: 22512
A=int(input())
B=int(input())
C=int(input())
D=int(input())
if A<=B and C<=D:
 print(A+C)
elif A<=B and C>D:
 print(A+D)
elif A>B and C<=D:
 print(B+C)
elif A>B and C>D:
 print(B+D)

Measured memory_bytes: 3064
import java.io.*;

public class Main {
    public static void main(String[] args) {
        int S;
        int W;

        try (InputScanner is = new InputScanner(System.in)) {
            S = is.ni();
            W = is.ni();
        }

        if (W >= S) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

    }

    //-------------------------------------------------------------------
    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }

        //next int
        public int ni() {
            return Integer.parseInt(this.nextElement());
        }

        //next long
        public long li() {
            return Long.parseLong(this.nextElement());
        }

        //next int array
        public int[] nia(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if (!hasElement()) {
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null) {
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
//-------------------------------------------------------------------
}


Measured memory_bytes: 34048
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    S=list(input())
    N=len(S)
    ans=0
    for i in range(N//2):
        ans+=1 if S[i]!=S[N-1-i] else 0
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;
    string out;
    for(char ch:S){
        if(ch + N > 'Z')
            out += ch + N - 'Z' + 'A' - 1;
        else
            out += ch + N;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

const int MAX_N=1e5+10,MAX_M=2e5+10;

int N,M,Min,w,num;
vector<int> D(MAX_N),color(MAX_N,-1),ans(MAX_M,INF);
vector<vector<pair<int,int>>> G(MAX_N);
vector<vector<int>> nG(MAX_N);

void dfs(int v,int p){
    for (int u:nG[v]){
        if (u==p) continue;
        color[u]=color[v]^1;
        dfs(u,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for (int i=0;i<N;++i) cin >> D[i];
    for (int i=0;i<M;++i){
        int u,v; cin >> u >> v; --u,--v;
        G[u].emplace_back(v,i);
        G[v].emplace_back(u,i);
    }
    for (int v=0;v<N;++v){
        Min=INF+1;
        for (auto p:G[v]) if (D[p.first]<Min){
            Min=D[p.first]; w=p.first; num=p.second;
        }
        if (D[v]<Min){cout << -1 << '\n'; return 0;}
        ans[num]=D[v];
        nG[v].emplace_back(w);
        nG[w].emplace_back(v);
    }
    for (int v=0;v<N;++v){
        if (color[v]!=-1) continue;
        color[v]=0;
        dfs(v,-1);
    }
    for (int i=0;i<N;++i) cout << (color[i]?'B':'W');
    cout << '\n';
    for (int i=0;i<M;++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 17536
#include<bits/stdc++.h>
#define pb push_back
#define fori(j,n) for(int i=j ; i<n ; i++)
#define forj(i,n) for(int j=i ; j<n ; j++)
#define fork(i,n) for(int k=i ; k<n ; k++)
#define ppb pop_back()
#define umap unordered_map
#define uset unordered_set
#define lli long long int
#define mod 1000000007

using namespace std;

int minimumChar(string S1, string S2) 
{ 
    int n = S1.size(), m = S2.size(); 
    int ans = INT_MAX; 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
        ans = min(minRemovedChar, ans); 
    } 
    return ans; 
} 

void solve()
{
	string s,t;cin>>s>>t;
	cout<< minimumChar(t,s);
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	// int t;cin>>t;
	// while(t--)
	// {
		solve();
		// cout<<endl;
	// }

	return 0;

}


Measured memory_bytes: 3652
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47464
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
using namespace std;
int main(){
int y,m,d;
while(cin>>y>>m>>d){
if(y>1989||(y==1989&&m>1)||(y==1989&&m==1&&d>=8))
cout<<"heisei "<<y-1988<<" "<<m<<" "<<d<<endl;
else if(y>1926||(y==1926&&m>12)||(y==1926&&m==12&&d>=25))
cout<<"showa "<<y-1925<<" "<<m<<" "<<d<<endl;
else if(y>1912||(y==1912&&m>7)||(y==1912&&m==7&&d>=30))
cout<<"taisho "<<y-1911<<" "<<m<<" "<<d<<endl;
else if(y>1868||(y==1868&&m>9)||(y==1868&&m==9&&d>=8))
cout<<"meiji "<<y-1867<<" "<<m<<" "<<d<<endl;
else
cout<<"pre-meiji"<<endl;

}

}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  string S;
  cin >> S;
  int cnta=0, cntb=0;
  rep(i, S.size()){
    if(S[i]=='0') cnta++;
    else cntb++;
  }
  int tmp=min(cnta, cntb);
  cout << tmp*2 << endl;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n;

int main()
{
    cin >> n;
    vi a;
    REP(i, 4)
    {
        a.push_back(n % 10);
        n /= 10;
    }
    bool f = false;
    REP(i, 2)
    {
        f = true;
        int k = a[i];
        REP(j, 3)
        {
            f &= k == a[i + j];
        }
        if (f)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
from fractions import gcd

A, B, C, D = map(int, input().split())

BperC = B // C
AperC = (A - 1) // C
BperD = B // D
AperD = (A - 1) // D
BperCD = B // (C * D // gcd(C, D))
AperCD = (A - 1) // (C * D // gcd(C, D))

AB = B - (A - 1)
ABperC = BperC - AperC
ABperD = BperD - AperD
ABperCD = BperCD - AperCD

out = AB - ((ABperC + ABperD) - ABperCD)
print(out)



Measured memory_bytes: 5364
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t,x;
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return ans*ans;
    return x*ans*ans;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
  //  cin>>t;
    // int tmp=t;
    while(t--)
    {
        cin>>x;
        cout<<360/gcd(360, x)<<endl;
    }
    
}


Measured memory_bytes: 3576
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define i128 __int128
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

ll p, ans = 0;
struct mat {
  ll v[3][3];
  mat(int type = 0) {
    memset(v, 0, sizeof(v));
    if (type) {
      for (int i = 0; i < 3; i++) {
        v[i][i] = 1;
      }
    }
  }
  mat operator * (const mat &rhs) const {
    mat ret;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          ret.v[i][j] = (ret.v[i][j] + v[i][k] * rhs.v[k][j]) % p;
        }
      }
    }
    return ret;
  }
};
i128 n, a, b;
template <class T> void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
mat pwm(mat a, i128 b) {
  mat ret(1);
  while (b) {
    if (b & 1)
      ret = ret * a;
    a = a * a, b >>= 1;
  }
  return ret;
}
int main() {
  read(n), read(a), read(b), cin >> p;
  i128 pw = 1;
  for (int i = 0; i <= 36; i++, pw *= 10) {
    i128 l = pw <= a ? 0 : (pw - a - 1) / b + 1, r = min((pw * 10 - 1 - a) / b, n - 1);
    if (pw > a + (n - 1) * b)
      break;
    if (l > r)
      continue;
    if (pw * 10 <= a)
      continue;
    i128 fst = (a % p + l % p * b) % p;
    mat base;
    base.v[0][1] = base.v[1][1] = base.v[1][2] = base.v[2][2] = 1;
    base.v[0][0] = pw * 10 % p;
    mat res = pwm(base, r - l + 1);
    ans = (ans * res.v[0][0] + fst * res.v[0][1] + b % p * res.v[0][2]) % p;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    double n2 = log10(n);
    int digitNum = 1 + (int)n2;
    int ret = 0;

    switch (digitNum)
    {
    case 6:
        n = 99999;
    case 5:
        ret += n - 9999;
        n = 999;
        goto three;
    case 4:
        n = 999;
    three:
    case 3:
        ret += n - 99;
        n = 9;
    case 2:
        n = 9;
    case 1:
        ret += n;
        break;

    default:
        return 0;
    }

    cout << ret << endl;

    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int c[26]={};
	bool ans=false;
	int a,b;
	for(int i=0;i<s.length()-1;i++){
		if(s[i]==s[i+1]){
			ans=true;
			a=i+1;
			b=i+2;
			break;
		}else if(i!=s.length()-2 && s[i]==s[i+2]){
			ans=true;
			a=i+1;
			b=i+3;
			break;
		}
	}
	if(ans) cout << a << ' ' << b << endl;
	else cout << -1 << ' ' << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
    char num[1001];
    int sum;
    
    while(1) {
        sum=0;
        scanf("%s", num);
        
        if (num[0]=='0') {
            break;
        }
        
        for(int i=0; num[i]!='\0'; i++) {
            sum+=num[i]-'0';
        }
        printf("%d\n", sum);
    }
    
    return 0;
}



Measured memory_bytes: 2044
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    int n = 0;
    rep(i, a.size()){
        n *= 10;
        n += (a[i] - '0');
    }
    rep(i, b.size()){
        n *= 10;
        n += (b[i] - '0');
    }
    bool flag = false;
    for(int i = 1 ; i * i <= n ; i++){
        if(i * i == n){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

s = input()
t = input()

tl = len(t) ; sl = len(s)

if tl > sl :
  print('UNRESTORABLE')
  sys.exit()

for i in range(sl,tl-1,-1) :
  st = s[i-tl:i]
  c = 0
  for j in range(tl) :
    if st[j] == '?' :
      continue
    elif st[j] != '?' and st[j] == t[j] :
      continue
    c = 1
    break
  if c == 0 :
    s = s[:i-tl] + t + s[i:]
    break

if c == 1 :
  print('UNRESTORABLE')
else : 
  print(s.replace('?', 'a'))

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

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> a(N);
    vector<int> b(N);
    for (int i : irange(0, N)) {
        cin >> a[i] >> b[i];
    }

    constexpr int INF = 1 << 30;
    vector<int> dp(H + 1, INF);
    dp[0] = 0;
    for (int i : irange(0, N)) {
        for (int h : irange(0, H + 1)) {
            dp[h] = min(dp[h], dp[max(0, h - a[i])] + b[i]);
        }
    }
    cout << dp[H] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N=100005;
int n;
long long a[N];
vector<pair<long long,long long> >res;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	int j=n;
	for(int i=1;i<=n-1;i++)
		if(a[i]>0)
		{
			j=i;
			break;
		}
	if(j==1)
	{
		for(int i=2;i<=n-1;i++)
			res.push_back(make_pair(a[1],a[i])),a[1]-=a[i];
		res.push_back(make_pair(a[n],a[1])),a[n]-=a[1];
		printf("%lld\n",a[n]);
		for(auto [x,y]:res)
			printf("%lld %lld\n",x,y);
		return 0;
	}
	for(int i=j;i<=n-1;i++)
		res.push_back(make_pair(a[1],a[i])),a[1]-=a[i];
	for(int i=1;i<=j-1;i++)
		res.push_back(make_pair(a[n],a[i])),a[n]-=a[i];
	printf("%lld\n",a[n]);
	for(auto [x,y]:res)
		printf("%lld %lld\n",x,y);
	return 0;
}

Measured memory_bytes: 6064
a,b,c = map(int, input().split())
tot = a*b*c
axis_a = abs(tot - 2*((a//2)*b*c))
axis_b = abs(tot - 2*((b//2)*a*c))
axis_c = abs(tot - 2*((c//2)*b*a))

print(min(axis_a,axis_b,axis_c))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > 8 || b > 8) System.out.println(":(");
        else System.out.println("Yay!");
    }
}


Measured memory_bytes: 35616
N,X = map(int,input().split())
ans = N
a,b = X,N-X
if a>b: a,b = b,a
while a:
    d,m = divmod(b,a)
    ans += d*a*2
    a,b = m,a
    if a>b: a,b = b,a
ans -= b
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
const int MOD=1e9+7;
 
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

const int N=1e5+5;

int n,k;
int v[N][4];
int dp[N][4];
int go(int pos,int last)
{
    if(pos==n+1)
        return 0;
    int &ans=dp[pos][last];
    if(ans!=-1)
        return ans;
    ans=0;
    if(pos==1)
    {
        ans=max(ans,v[pos][1]+go(pos+1,1));
        ans=max(ans,v[pos][2]+go(pos+1,2));
        ans=max(ans,v[pos][3]+go(pos+1,3));
    }
    else
    {
        if(last==1)
        {
            ans=max(ans,v[pos][2]+go(pos+1,2));
            ans=max(ans,v[pos][3]+go(pos+1,3));
        }
        else if(last==2)
        {
            ans=max(ans,v[pos][1]+go(pos+1,1));
            ans=max(ans,v[pos][3]+go(pos+1,3));
        }
        else if(last==3)
        {
            ans=max(ans,v[pos][1]+go(pos+1,1));
            ans=max(ans,v[pos][2]+go(pos+1,2));
        }
    }
    return ans;
}
int32_t main()
{
    IOS;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=3;j++)
        {
            cin>>v[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<go(1,0)<<endl;


}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#define llint long long

using namespace std;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string S;
	cin >> S;
	if(S == "SUN") cout << 7 << endl;
	if(S == "MON") cout << 6 << endl;
	if(S == "TUE") cout <<  5 << endl;
	if(S == "WED") cout <<  4 << endl;
	if(S == "THU") cout <<  3 << endl;
	if(S == "FRI") cout <<  2 << endl;
	if(S == "SAT") cout <<  1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int n, x[100], y[100];
	double p1 = 0, p2 = 0, p3 = 0, punl = 0, max = 0, abs;
	(void)scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		(void)scanf("%d", &x[i]);
	}
	for (int i = 0; i < n; i++) {
		(void)scanf("%d", &y[i]);
		abs = fabs(x[i] - y[i]);
		p1 += abs;
		p2 += pow(abs, 2.0);
		p3 += pow(abs, 3.0);
		if (abs >= max) max = abs;
	}
	p2 = sqrt(p2);
	p3 = cbrt(p3);
	punl = max;
	printf("%lf\n%lf\n%lf\n%lf\n", p1, p2, p3, punl);
}



Measured memory_bytes: 3000
#include <iostream>

using namespace std;

int main()
{
    int N, n;
    cin >> N;
    n = N % 10;
    if(n == 3){
        cout << "bon";
    }
    else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon";
    }
    else{
        cout << "hon";
    }
}

Measured memory_bytes: 3640
n = gets.to_i
m = gets.to_i
target = gets.chomp.split.map(&:to_i)
score = Array.new(n, 0)
m.times{|game|
    vote = gets.chomp.split.map(&:to_i)
    vote.each_with_index{|v, i| score[i] +=1 if v == target[game]}
    score[target[game] - 1] += n - vote.count(target[game])
}
puts score


Measured memory_bytes: 6980
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a;
	cout << "ABC" << a << "\n";
	
	std::cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  if (s == "Cloudy") cout << "Rainy" << endl;
  if (s == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    string S;
    cin >> N >> S;
    
    if (N % 2 == 0) {
        if (S.substr(0, N/2) == S.substr(N/2, N/2))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  cin >> n;
  for(int i=1;i<=9;i++)
  {
  	if(n%i == 0 && n/i <= 9)
    {
    	cout << "Yes";
      return 0;
    }
  }
  cout << "No"
;}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  double a,b,n;
  cin >> a >> b >> n;
  
  double m;
   if(n>=b-1) {
     m=floor(a*(b-1)/b)-a*floor((b-1)/b);
     cout << m << endl;
     exit(0);
   }
   m=floor(a*n/b)-a*floor(n/b);
   cout << m << endl;
}

Measured memory_bytes: 3900
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
d = [0]*m
for i in range(1,m):
    d[i] = x[i]-x[i-1]
d.sort()
if n < m:
    d = d[1:m-n+1]
else:
    d = [0]
ans = 0
for i in range(len(d)):
    ans += d[i]
print(ans)

Measured memory_bytes: 13960
n,m,r_=map(int,input().split())
r=list(map(int,input().split()))
g=[[]for _ in range(n)]
for _ in range(m):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  g[a].append([b,c])
  g[b].append([a,c])
from heapq import heapify,heappush,heappop
def dks(t0,t1):
  kyori=[-1]*n
  todo=[[0,t0]]
  heapify(todo)
  while todo:
    d,t=heappop(todo)
    kyori[t]=d
    if t==t1:break
    l=g[t]
    for li,c in l:
      if kyori[li]==-1:
        heappush(todo,[c+d,li])
  return kyori[t1]
ans=pow(10,9)
allr=[]
import sys
sys.setrecursionlimit(10**7)
def dfs(s,k): #s:list, k:set
  if len(k)==1:
    s.append(k.pop())
    return [s]
  ret=[]
  for ki in k:
    ret.extend(dfs(s+[ki],k-{ki}))
  return ret
allr=dfs([],set(r))
d={}
for i in range(r_-1):
  for j in range(i+1,r_):
    k=dks(r[i]-1,r[j]-1)
    d[r[i]-1,r[j]-1]=k
    d[r[j]-1,r[i]-1]=k

for j in range(len(allr)):
  r1=allr[j]
  ansi=0
  for i in range(r_-1):
    ansi+=d[(r1[i]-1,r1[i+1]-1)]
  ans=min(ans,ansi)
print(ans)


Measured memory_bytes: 20168
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L
const int mxN = 2e2;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    map<int, int> mp;
    for (auto x : a) {
        if (x % 2 == 0) {
            mp[2]++;
            while (x % 2 == 0) {
                x /= 2;
            }
        }
        for (int i = 3; i <= sqrt(x); i++) {
            if (x % i == 0) {
                mp[i]++;
                while (x % i == 0) {
                    x /= i;
                }
            }
        }
        if (x > 2) {
            mp[x]++;
        }
    }
    int mx = 0;
    for (auto it : mp) {
        mx = max(mx, it.second);
    }
    if (mx <= 1) {
        cout << "pairwise coprime" << endl;
    }
    else if (mx == n) {
        cout << "not coprime" << endl;
    }
    else {
        cout << "setwise coprime" << endl;
    }
    return 0;
}

Measured memory_bytes: 10700
# -*- coding: utf-8 -*-

import sys
import numpy as np

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# dp[この子までの範囲で][飴を配る総数] = 場合の数
dp = np.zeros((N+1, K+1), dtype=np.int64)
# 0番目まで(誰もいない)の範囲で0個配る場合の数は1通り
dp[0,0] = 1

for i, a in enumerate(A):
    # 今回のiを次の遷移させる区間の始点としてまとめて追加
    dp[i+1] = dp[i]
    # 今回のiをa+1個ずらして、遷移させる区間の終点としてまとめて追加
    dp[i+1,a+1:] -= dp[i,:-(a+1)]
    # 累積和すれば、元の状態からそれぞれa個先まで遷移させた状態になる
    # (区間の始点・終点の記録→累積和の流れはいもす的な感じ)
    dp[i+1] = dp[i+1].cumsum()
    dp[i+1] %= MOD

print(dp[N][K])


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

using pii = pair<int, int>;

int main() {
    int N; cin >> N;
    vector<pii> score(N);
    for(int i = 0; i < N; ++i) {
        score[i].first = 0, score[i].second = i;
    }
    for(int i = 0; i < N * (N - 1) / 2; ++i) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        if(c > d) {
            score[a - 1].first += 3;
        } else if(c == d) {
            score[a - 1].first++;
            score[b - 1].first++;
        } else {
            score[b - 1].first += 3;
        }
    }
    sort(rbegin(score), rend(score));
    
    vector<int> ans(N);
    for(int i = 0; i < N; ++i) {
        if(i != 0 && score[i].first == score[i - 1].first) {
            ans[score[i].second] = ans[score[i - 1].second];
        } else {
            ans[score[i].second] = i + 1;
        }
    }

    for(auto x : ans) {
        cout << x << endl;
    }
}



Measured memory_bytes: 3060
change_K = int(input().split(" ")[-1])
word_S = list(input())
S = list(word_S)
word1 = ""
for i in range(change_K - 1):
    word1 = word1 + S[i]
word2 = S[change_K - 1]
word3 = ""
count = 0
while True:
    try:
        word3 = word3 + S[change_K + count]
        count += 1
    except IndexError:
        break
word2 = word2.swapcase()
print(word1 + word2 + word3)


Measured memory_bytes: 9156
from decimal import Decimal 
n, k = map(int, input().split())
count = 0
p = 0

if n >= k:
    a = n
    p += Decimal((a - k + 1) / a)
    n = k
    for i in range(k, 1, -1):
        n = n / i * (i - 1)
        while n < k:
            n *= 2
            count += 1
        p += Decimal(1 / a * (1 / 2) ** count)
    print(p)
else:
    a = n

    while n < k:
        n *= 2
        count += 1
    p += Decimal(1 / a * (1/2) ** count)

    for i in range(a, 1, -1):
        n = n / i * (i - 1)
        while n < k:
            n *= 2
            count += 1
        p += Decimal(1 / a * (1 / 2) ** count)
    print(p)

Measured memory_bytes: 10056
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long ans = 0;
        if (N%2==0) {
            N/=2;
            long tmp =1;
            for (int i=0;i<27;i++) {
                tmp*=5;
                ans += N/tmp;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int len = s.size();
	//cout << s << "￥" << s.size() << endl;
	for (int i = 0; i < len - 1; i++)
	{
		//cout << s[i] << "@" << endl;
		if (s[i] == 'S' && s[i + 1] == 'T')
		{
			//cout << i << "%" << i + 1 << endl;
			s.erase(i, 2);
			len -= 2;
			i -= 2;
		}
	}
	cout << len<< endl;

	return 0;
}

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

int compare = 0;

void merge(vector<int>& nums, int l, int m, int r)
{
    vector<int> left(m - l + 1); // + 1 for infinity
    vector<int> right(r - m + 1); // + 1 for infinity
    for (int i = 0; i < left.size() - 1; i++) {
        left[i] = nums[l + i];
    }
    left.back() = numeric_limits<int>::max();
    for (int i = 0; i < right.size() - 1; i++) {
        right[i] = nums[m + i];
    }
    right.back() = numeric_limits<int>::max();
    int i = 0;
    int j = 0;
    for (int k = l; k < r; k++) {
        if (left[i] <= right[j]) {
            nums[k] = left[i++];
        } else {
            nums[k] = right[j++];
        }
        compare++;
    }
}

void mergeSort(vector<int>& nums, int l, int r)
{
    if (r - l <= 1) return;
    int m = l + (r - l) / 2;
    mergeSort(nums, l, m);
    mergeSort(nums, m, r);
    merge(nums, l, m, r);
}

int main()
{
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    mergeSort(nums, 0, nums.size());
    for (int i = 0; i < nums.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << nums[i];
    }
    cout << endl;
    cout << compare << endl;
}


Measured memory_bytes: 6824
#include<iostream>
using namespace std;
int main() {
	long long int N, x = 1;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		x *= i;
		if (x >= 1000000007) {
			x -= 1000000007*(x / 1000000007);
		}
	}
	cout << x << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, A = MAP()

if X < A:
	print(0)
else:
	print(10)

Measured memory_bytes: 6100
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

vector<int> splitChar(const std::string &s,char c)
{
    std::vector<int> v;
    std::istringstream iss(s);
    std::string next;
    while (std::getline(iss, next, c))
        v.push_back(stoi(next));
    return v;
}

int main(void){
string s;
	vector<vector<int>>w;
	vector<vector<int>>sumw;
	int st=0;int prev=0;
	while(getline(cin,s)){
		vector<int> v=splitChar(s,',');
		w.push_back(v);
		vector<int>v1;
		int tmp;
		if(st==0){v1.push_back(v[0]);sumw.push_back(v1);}
		
		if(st>0 && v.size()>prev){
			for(int j=0;j<v.size();j++){
				if(j==0){v1.push_back((sumw[st-1])[0]+(w[st])[0]);}
				if(j==v.size()-1){v1.push_back((sumw[st-1])[st-1]+(w[st])[st]);}
				if(j>0 && j<v.size()-1){v1.push_back(max(  (sumw[st-1])[j-1]+(w[st])[j],(sumw[st-1])[j]+(w[st])[j] ));}
			}
			sumw.push_back(v1);
		}
			
		if(st>0 && v.size()<prev){
			for(int j=0;j<v.size();j++){
				v1.push_back(max(  (sumw[st-1])[j]+(w[st])[j],(sumw[st-1])[j+1]+(w[st])[j] ));
			}
			sumw.push_back(v1);
		}
		prev=v.size();
		if(st>0 && prev==1)break;
		st++;
	}

	cout<<(sumw[sumw.size()-1])[0]<<endl;
	
return 0;
}




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

vector<string> subs;
int K;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;
    cin >> s;
    cin >> K;
    for(int i=1; i<=min((int)s.size(), K); i++){
        for(int j=0; j<=(int)s.size()-i; j++){
            subs.push_back(s.substr(j, i));
            // cout << s.substr(j, i) << endl; 
        }
    }
    sort(subs.begin(), subs.end());
    subs.erase(unique(subs.begin(), subs.end()), subs.end());
    // for(auto it = subs.begin(); it != subs.end(); it++){
    //     cout << *it << endl;
    // }
    cout << subs[K-1] << endl;
}


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

int maxProfit(vector<int>& array);

int main()
{
    int size;
    vector<int> array;
    cin >> size;
    for (int i = 0; i < size; i++) {
        int tmp;
        cin >> tmp;
        array.push_back(tmp);
    }
    cout << maxProfit(array) << endl;
    return 0;
}

int maxProfit(vector<int>& array)
{
    int min = array[1] > array[0] ? array[0] : array[1];
    int max_val = array[1] - array[0];
    for (int i = 2; i < array.size(); i++) {
        int profit = array[i] - min;
        if (profit > max_val) {
            max_val = profit;
        }
        if (min > array[i]) {
            min = array[i];
        }
    }
    return max_val;
}

Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll a,b,c;cin>>a>>b>>c;
  if(a+b>=c){
    cout << b+c << endl;
  } else {
    cout << min(a+2*b+1, b+c) << endl;
  }
  return 0;
}

Measured memory_bytes: 256