akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int a=n,cnt=0;
    while (a!=0){
        a = a/10;
        cnt++;
    }
    int sn=0;a=n;
    for (int j=cnt; j>0; j--){
        sn += a%10;
        a = a/10;
    }
    cout << (n%sn==0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
# Atcoder C - 白昼夢 / Daydream

def main():
    S = input()

    while len(S) >= 5:
        if len(S) >= 7 and S[-7:] == "dreamer":
            S = S[:-7]
            continue

        if len(S) >= 6 and S[-6:] == "eraser":
            S = S[:-6]
            continue

        elif S[-5:] == "dream" or S[-5:] == "erase":
            S = S[:-5]
            continue

        else:
            break

    if len(S) == 0:
        print("YES")
    else:
        print("NO")

main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



Int n,m,_,x,y,q;
string s,sb;
bool ok;

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

  cin>>n; Int a[n]; rep(i,n)cin>>a[i];
  Int ans=0,odd=0;
  rep(i,n){
    if(a[i]<=odd){
      ans+=a[i]; odd=0;
    }else{
      y=a[i]-odd; a[i]=y; ans+=odd; odd=0;
      x=a[i]/2;
      a[i]%=2; if(a[i])odd++;
      ans+=x;
    }
  }
  END
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	s :=readBytes()
	m := make(map[byte]int)
	for _, v:= range s {
		m[v]++
	}
	for _, c:=range m {
		if c%2==1{
			println("No")
			return
		}
	}
	println("Yes")
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll d, n,sa,sum=0;
	cin >> d >> n;
	sa = n - d;
	for (ll i = 1; i <= sa; i++) {
		sum += i;
	}
	cout << sum-n<< endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;

int main() {
	cin >> n;
	if(n <= 999) puts("ABC");
	else puts("ABD");
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	int r=0;
	char S[4],T[4];
	scanf("%s %s",&S,&T);
	if(S[0]==T[0])
	{
		r=r+1;
	}
	if(S[1]==T[1])
	{
		r=r+1;
	}
	if(S[2]==T[2])
	{
		r=r+1;
	}
	printf("%i",r);
	return 0;
}


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

static const int INF = 1000001;

int main() {
	while (true) {
		int e;
		cin >> e;
		if (e == 0) break;
		
		int i;
		for (i = 0; i * i * i <= e; i++)
			;
		int t = i - 1;
		
		int m = INF;
		for (int j = t; j >= 0; j--) {
			int tz = j * j * j;
			for (int k = 0; tz + k * k <= e; k++) {
				int ty = k * k;
				int tx = e - tz - ty;
				if (tx + k + j < m)
					m = tx + k + j;
			}
		}
		
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    X -= Z;
    cout << X /(Y + Z) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  int t=0;
  int num[6]={0};
  char point;

  for(int i=0;i<6;i++){
  cin >>num[i];
  }

  while(cin >>point){
    if(point=='E'){
      swap(num[0],num[3]);
      swap(num[3],num[5]);
      swap(num[5],num[2]);
    }
    if(point=='W'){
      swap(num[0],num[2]);
      swap(num[2],num[5]);
      swap(num[5],num[3]);
}
    if(point=='S'){
      swap(num[0],num[4]);
      swap(num[4],num[5]);
      swap(num[5],num[1]);
    }
    if(point=='N'){
      swap(num[0],num[1]);
      swap(num[1],num[5]);
      swap(num[5],num[4]);
    }
  }

    cout <<num[0] <<endl;

  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int H, W; cin >> H >> W;
    vector<vector<char>>S(H + 2, vector<char>(W + 2, '.'));
    REP(i, H + 1) {
        string s;
        cin >> s;
        REP(j, W + 1)S[i][j] = s.at(j-1);
    }
    REP(i, H + 1) {
        REP(j, W + 1) {
            if (S[i][j] == '#') {
                if (S[i + 1][j] != '#' && S[i - 1][j] != '#' && S[i][j + 1] != '#' && S[i][j - 1] != '#') {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3572
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
vector<ll>fact;
ll ncr(ll n,ll r)
{
    if(r==0)
    {
        return 1ll;
    }
    if(r==1)
    {
        return n%mod;
    }
    if(n==r)
    {
        return 1ll;
    }
    if(n<r)
    {
        return 0ll;
    }
    ll ans=fact[n];
    ll x=(fact[r]*fact[n-r])%mod;
    x=power(x,mod-2);
    ans=(ans*x)%mod;
    return ans;
}
int main()
{
fast;
fact.pb(1);
for(ll i=1;i<=1e5;i++)
{
    fact.pb((i*fact[i-1])%mod);
}
ll n,k;
cin>>n>>k;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
sort(v.begin(),v.end());
ll ans=0;
for(ll i=0;i<n;i++)
{
    ll a=n-(i+1);
    ll b=i;
    ans=(ans+(ncr(b,k-1)*v[i])%mod)%mod;
    ans=(ans-(ncr(a,k-1)*v[i])%mod+mod)%mod;
}
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
vector< vector<int> > graph(100100, vector<int>());
vector<bool> visited(100100, false);

int dfs(int now) {
    int g = 0;
    for(int i = 0; i < graph.at(now).size(); ++i) {
        if(!visited.at(graph.at(now).at(i))) {
            visited.at(graph.at(now).at(i)) = true;
            g ^= dfs(graph.at(now).at(i));
        }
    }
    return g+1;
}

int main() {
    cin >> n;
    for(int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }
    visited.at(0) = true;
    int ans = dfs(0)-1;

    if(ans == 0) cout << "Bob" << endl;
    else cout << "Alice" << endl;
}

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


int main(void) {
    using namespace std;

    long d, g;
    cin >> d >> g;

    vector<long> p(d), c(d);
    for(int i=0; i<d; i++)
        cin >> p[i] >> c[i];

    // dp[縺ｨ縺乗焚][蝠城｡檎分蜿ｷ] = 譛螟ｧpt
    vector<vector<long>> dp(1000+1, vector<long>(11));

    for(int i=1; i<=d; i++) {
        for(int j=1; j<=1000; j++) {
            for(int k=0; k<p[i-1]; k++)
                if(j-k >= 0)
                    dp[j][i] = max(dp[j][i], dp[j-k][i-1] + 100*i*k);
            if(j-p[i-1] >= 0)
                dp[j][i] = max(dp[j][i], dp[j-p[i-1]][i-1] + 100*i*p[i-1] + c[i-1]);
        }
    }

    for(int i=0; i<=1000; i++) {
        if(dp[i][d] >= g) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[200005];
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    if(a[i]%2==0){
        if(a[i]%3!=0&&a[i]%5!=0){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
}
cout<<"APPROVED"<<endl;
}





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

int main() {

    //値の取得
  string T;
  cin >> T;

  for(int i = 0; i < T.size(); i++){
      if(T[i] == '?'){
          T[i] = 'D';
      } 
  }
  cout << T << endl;
}


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

int main() {
    int N, K;
    int disp = 1;
    int add = 1;
    int multi = 1;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        multi *= 2;
        add += K;
        if(multi > add){
            disp = add;
        }else{
            disp = multi;
        }
        multi = disp;
        add = disp;
    }
    cout << disp << endl;
}

Measured memory_bytes: 3628
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local function dbgpr_t(tbl, use_pairs)
    if DBG then
        local enum = ipairs
        if use_pairs then
            enum = pairs
        end
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in enum(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end

----
local N, Kmax = io.read("n", "n")
local V = {}
for i=1,N do
    V[i] = io.read("n")
end

local lim_left = math.min(N, Kmax)
local ans = 0
for a=0, lim_left do
    local got_left = {}
    local lim_right = math.min(N-a, Kmax-a)
    assert(lim_right >= 0)
    for i=1,a do
        got_left[i] = V[i]
    end
    for b=0, lim_right do
        local got = {table.unpack(got_left)}
        for i=1,b do
            got[#got + 1] = V[N+1-i]
        end
        table.sort(got)
        local ndiscard = Kmax - a - b
        local ndiscard_orig = ndiscard
        assert(ndiscard >= 0)
        local value = 0
        for i=1, #got do
            if got[i] < 0 and ndiscard > 0 then
                ndiscard = ndiscard - 1
            else
                value = value + got[i]
            end
        end
        dbgpr(a, b, #got, ndiscard_orig, value)
        ans = math.max(ans, value)
    end
end
print(ans)

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

const int N = 1e5+7, M = 1e9+7;
int ll[N];
long long a[N], dp[N], sum[N];

long long getsum(int l, int r) {
    if (r < l)  return 0;
    if (l == 0) return sum[r];
    return sum[r] - sum[l-1];
}

void zero() {
    cout<<0<<endl;
    exit(0);
}

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

    int n;
    cin>>n;

    long long x, y;
    cin>>x>>y;

    if (x > y)  swap(x, y);

    for (int i=1; i<=n; i++)    cin>>a[i];

    for (int i=1; i<=n; i++) {
        if (i == 1 || a[i-1] > a[i]-x) ll[i] = i;
        else    ll[i] = ll[i-1];
    }

    for (int i=3; i<=n; i++)
        if (a[i] - a[i-2] < x)  zero();

    dp[0] = sum[0] = 1;
    int ptr = 0;
    for (int i=1; i<=n; i++) {
        while (a[ptr+1] <= a[i] - y)   ptr++;

        int en = ptr, st = max(0, ll[i-1]-1);


        dp[i] = getsum(st, en)%M;
        sum[i] = (dp[i] + sum[i-1])%M;
//        cout<<i<<" "<<a[i]<<" --> "<<st<<" "<<en<<" --> "<<dp[i]<<" "<<sum[i]<<endl;

    }

    long long ans = getsum(ll[n]-1, n);
    cout<<(ans%M+M)%M<<endl;
}


Measured memory_bytes: 6392
"use strict";

function main(input) {
  input = input.trim();
  if (input == 0) {
    console.log(1);
  } else {
    console.log(0);
  }
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29592
BIG_NUM = 2000000000

table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

N = int(input())

for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add


x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()


Measured memory_bytes: 5628
//115
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int H, W, h, w, A, B, C;

int main() {
	cin >> A;

	cout << "Christmas";
	for (int i = 24; i >= A; i--)cout << " Eve";
	cout << endl;


	return 0;
}

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

count = [0] * (N-1)


for i in range(1,N):
    path = abs(X-i) +1
    for j in range(i+1,N+1):
        dist = min(j-i, path+abs(Y-j))
        count[dist-1] +=1


print(*count, sep="\n")

Measured memory_bytes: 74428
/*input
3 4 240
60 90 120
80 150 80 150
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll n, m, k;
	cin >> n >> m >> k;
	ll ans = 0, i = n, j = 0;
	vector<ll> a(n + 1), b(m + 1);
	for(ll i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for(ll i = 1; i <= m; i++) {
		cin >> b[i];
		b[i] += b[i - 1];
	}
	while(i >= 0) {
		while(j <= m && a[i] + b[j] <= k) {
			j++;
		}
		if(a[i] <= k)
			ans = max(ans, j - 1 + i);
		i--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
  int n;
  cin >>n;
  if(n%2!=0){
      cout << "No" << endl;
      return 0;
  }
  char s[1000],t[1000];
  for(int i=0; i<n/2;i++){
      cin >> s[i];
  }

   for(int i=0; i<n/2;i++){
      cin >> t[i];
      if(s[i]!=t[i]){
          cout <<"No" <<endl;
          return 0;
      }
  }
  cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#import math
from functools import reduce

def gcd_list(numbers):
    def gcd(a, b):
        if (b == 0):
            return a;
        return gcd(b, a % b)

    return reduce(gcd, numbers)


input_list1 = list(map(int, input().split()))
input_list2 = list(map(int, input().split()))
#input_list1 = [3, 81]
#input_list2 = [33, 105, 57]
N = input_list1[0]
X = input_list1[1]

#print('N:', N)
#print('X:', X)

# 都市のリストにXを追加し、小さい順にソートする
input_list2.append(X)
input_list2.sort()
#print(input_list2)

# それぞれの差を取る
ans_list = []
for i, target in enumerate(input_list2):
    if i == N:
        break
    aa = input_list2[i + 1] - input_list2[i]
    #print(input_list2[i + 1], '-' , input_list2[i])
    ans_list.append(aa)

# 重複排除
ans_list = set(ans_list)

# 最大公約数を求める
if len(ans_list) > 1:
    print(gcd_list(ans_list))
else:
    print(min(ans_list))


Measured memory_bytes: 14596
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# [a, b].min が遅いので
def min(a, b)
  return a < b ? a : b
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
A, B, H, M = gets_i_list

pi = Math::PI

h_pi = 2 * pi * (H.to_f/12 + M.to_f/720)
m_pi = 2 * pi * (M.to_f/60)

dpp [h_pi, m_pi]
dpp [(h_pi - m_pi).abs, 2 * pi - (h_pi - m_pi).abs]

d_pi = min((h_pi - m_pi).abs, 2 * pi - (h_pi - m_pi).abs)

dpp d_pi
dpp d_pi * (180.to_f/pi)
dpp Math.cos(d_pi)

# 浮動小数点数のフォーマット
ans = Math.sqrt(A ** 2 + B ** 2 - 2 * A * B * Math.cos(d_pi))
puts sprintf("%10.9f", ans)

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

int main(void)
{
  int h, w, i, j;
  while(1) {
    cin >> h >> w;
    if(h == 0 && w ==0) break;
    for(i = 0; i < h; i++){
      if (i == 0 || i == h-1){
        for(j = 0; j < w; j++) cout << "#";
      }
      else {
        for(j = 0; j < w; j++){
          if (j == 0 || j == w-1)  cout << "#";
          else cout <<".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	r, c := nextInt(), nextInt()
	table := make([][]int, r+1)
	for i := 0; i < r; i++ {
		table[i] = make([]int, c+1)
		for j := 0; j < c; j++ {
			table[i][j] = nextInt()
		}
	}
	table[r] = make([]int, c+1)

	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			table[i][c] += table[i][j]
			table[r][j] += table[i][j]
		}
	}

	for i := 0; i < c; i++ {
		table[r][c] += table[r][i]
	}

	for i := 0; i <= r; i++ {
		for j := 0; j <= c; j++ {
			fmt.Fprintf(out, "%d", table[i][j])
			if j != c {
				fmt.Fprintf(out, " ")
			}
		}
		fmt.Fprintf(out, "\n")
	}
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1416
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( int i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const int MAX= 3e3 +3;

ll dp[MAX][MAX],mod=1e9+7;
int main(){
	fastio;
	ll n;
	string s;
	cin>>n>>s;
	dp[1][1]=1;
	f(i,2,n+1){
		if(s[i-2]=='<'){
			f(j,2,i+1) 
				dp[j][i]=dp[j-1][i-1]+dp[j-1][i];
			
		}
		else{
			af(j,i-1,1) dp[j][i]=dp[j][i-1]+dp[j+1][i];
		}	
		f(j,1,n+1) dp[j][i]=dp[j][i]%mod;
	}
	ll ans=0;
	f(i,1,n+1) ans+=dp[i][n];
	cout<<ans%mod<<endl;

    return 0;

}

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

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int ans=0;
  rep(i,0,n){
    if(s[i]=='L'){
      if(i-1>=0 && s[i-1]=='L')ans++;
    }else{
      if(i+1<n && s[i+1]=='R')ans++;
    }
  }
  cout<<min(ans+2*k,n-1)<<endl;
  return 0;
}

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

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
 long long n;
 long long m;
 long long ans = 0;
 cin >> n >> m;
 long long small = m*(m-1)/2;
 long long large = (n-m)*m+m*(m+1)/2;
 for(int i = m;i < n+2;++i){
	 ans +=large-small+1;
	 small += i; 
	 large += n-i;
 }
cout<<ans%1000000007;
}   

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define error(x) cerr << #x << " = " << x << endl


int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m,i,j,k,sum=0;
	int a,b;
	cin>>n>>a>>b;
	int temp = n/(a+b);
	int left = n%(a+b);
	int ans = a*temp;
	n = n-temp*a-temp*b;
	if(a>n) ans += n;
	else ans+=a;	
	cout<<ans<<'\n';
	
	
	
	return 0;
}

Measured memory_bytes: 256
import bisect
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
VU = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N)]
for v, u in VU:
    v -= 1
    u -= 1
    graph[v].append(u)
    graph[u].append(v)

dp = [INF] * (N + 10)
ans = [0] * N
root = 0


def dfs(v, p):
    i = bisect.bisect_left(dp, A[v])
    prev = dp[i]
    dp[i] = A[v]
    ans[v] = bisect.bisect_left(dp, INF)
    for u in graph[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = prev


dfs(root, None)
print(*ans, sep='\n')


Measured memory_bytes: 261020
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint l(N);

    int sum=0;
    REP(i,N){
        cin>>l[i];
        sum+=l[i];
    }
    sort(ALL(l));

    cout<<(l.back()<sum-l.back()? "Yes":"No")<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
string ans="";
ans+=str[0];
ans+=str[1];
ans+=str[2];
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
<?php

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d", $H, $W);
if (DEBUG) echo "{$H} {$W}\n";
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
if (DEBUG) var_dump($a);

$m = array(array());

$X = $Y = 0;
$xx = 1;

foreach ($a as $k => $v) {
    for ($i = 0; $i < $v; $i++) {
        if (DEBUG) echo "k:{$k} i:{$i}\n";
        $m[$Y][$X] = $k + 1;
        $X += $xx;
        if ($X >= $W || $X < 0) {
            if ($X < 0) $X = 0;
            if ($X >= $W) $X = $W - 1;
            $Y++;
            $xx = -$xx;
        }
        if (DEBUG) echo "X:{$X} Y:{$Y} k:{$k}\n";
    }
}

for ($i = 0; $i < $H; $i++) {
    ksort($m[$i]);
    echo implode(" ", $m[$i]) . PHP_EOL;
}


Measured memory_bytes: 6776
s = input()
cs = [c in {'A', 'T', 'C', 'G'} for c in s]

q = 0
for i, c in enumerate(cs):
    p = 0
    if c:
        for j in range(i, len(cs)):
            if not cs[j]:
                break
            p += 1
        if q == 0 or q < p:
            q = p

print(q)

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;
                                                                                                     
ll MOD=1000000007;                                                                                     
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,c,k; cin>>a>>b>>c>>k;
    while(a>=b){
        b*=2; k--;
    }
    while(b>=c){
        c*=2; k--;
    }
    if(k>=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, K;

    cin >> N >> K;

    ll mod = N % K;
    mod = min( mod, K-mod);
    cout << mod << endl;
}


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

using namespace std;

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

#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)

#define INF 987654321
#define IINF 2987654321987654321
#define MOD 100000

struct Edge {
	int x, y, val;
};

int main() {
	int l; scanf("%d", &l);
	if(l <= 50) {
		int n = 2, m = l;
		printf("%d %d\n", n, m);
		for(int i = 0; i < l; i++)
			printf("%d %d %d\n", 1, 2, i);
		return 0;
	}

	vector<int> v;
	vector<Edge> E;
	int k = l;
	while(k) v.push_back(k), k /= 2;
	v.pop_back();
	reverse(v.begin(), v.end());
	int cur = 1;
	for(int i = 0; i < (int)v.size(); i++) {
		if(i == 0) {
			for(int t = 0; t < v[0]; t++)
				E.push_back({cur, cur+1, t});
			cur++;
			continue;
		}

		if(v[i] & 1) E.push_back({1, cur+1, v[i]-1});
		E.push_back({cur, cur+1, 0});
		E.push_back({cur, cur+1, v[i]/2});
		cur++;
	}

	printf("%d %d\n", cur, (int)E.size());
	for(auto e : E) printf("%d %d %d\n", e.x, e.y, e.val);
}

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

using namespace std;
#define ll long long int
bool a[100];

int main(){
  int n,l;
  cin >> n >> l;
  vector < string > s(n);
  for ( int i = 0; i < n; ++ i ) cin >> s[i];

  sort ( s.begin(), s.end() );
  for ( int i = 0; i < n; ++i ){
    cout << s[i];  
  }
  cout << endl;
  return 0;
}



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

#include <algorithm>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long X, long long Y, long long A, long long B, long long C,
           std::vector<long long> p, std::vector<long long> q,
           std::vector<long long> r) {
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector<int> d;
    rep(i, X) d.push_back(p[i]);
    rep(i, Y) d.push_back(q[i]);
    rep(i, C) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i, X + Y) { ans += d[i]; }
    cout << ans << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    std::vector<long long> p(A);
    for (int i = 0; i < A; i++) {
        scanf("%lld", &p[i]);
    }
    std::vector<long long> q(B);
    for (int i = 0; i < B; i++) {
        scanf("%lld", &q[i]);
    }
    std::vector<long long> r(C);
    for (int i = 0; i < C; i++) {
        scanf("%lld", &r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
    return 0;
}


Measured memory_bytes: 4724
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N,M = LI()
ab = [[] for i in range(M)]
for i in range(M):
    a,b = LI()
    a -= 1
    b -= 1
    ab[i] = [a,b]


ans = 0
ab = sorted(ab,key = lambda x:x[1])
ans += 1
a,b = ab[0]
cutting = b-1
for i in range(1,M):
    a,b = ab[i]
    if a <= cutting < b:
        pass
    else:
        cutting = b-1
        ans += 1

print(ans)

# print(ab)


Measured memory_bytes: 25036
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
X = int(input())
for A in range(-1000,1001):
    for B in range(-1000,1001):
        if A**5 - B**5 == X:
            print(A,B)
            exit()
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9148
# inputを高速化する。
import sys
input = sys.stdin.readline

a,b,m = map(int, input().split())

As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

ans = min(As) + min(Bs)

for i in range(m):
    x,y,c = map(int, input().split())
    total = As[x-1] + Bs[y-1] - c
    ans = min(ans , total)

print(ans)

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

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

A, P = MAP()
print((3*A+P)//2)


Measured memory_bytes: 5148
#include<cstdio>
#include<cstring>
int main()
{
	int n,i;double s=0,l=0;
	scanf("%d",&n);double a[n];
	for(i=0;i<n;i++)
	{
	 scanf("%lf",&a[i]);
	
		l=l+1.0/a[i];
	}
	s=1/l;
	printf("%f",s);
	
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll A[100000];
ll cnt[100001];
ll cnt_[100001];
ll cumsum[100001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll N, M;
    cin >> N >> M;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        cnt[A[i]]++;
        cnt_[A[i]]++;
    }
    for(ll i = 99999; i >= 0; i--) cnt[i] += cnt[i+1];
    cumsum[100000] = 100000*cnt_[100000];
    for(ll i = 99999; i >= 0; i--) {
        cumsum[i] =cumsum[i+1]+i*cnt_[i];
    }
    ll l = 1;
    ll r = 200001;
    while(r-l > 1){
        ll c = (r+l)/2;
        ll sum = 0;
        for(ll i = 0; i < N; i++){
            if(c-A[i] > 100000) continue;
            if(c-A[i] <= 0) {
                sum += N;
                continue;
            }
            sum += cnt[c-A[i]];
        }
        if(sum >= M) l = c;
        else r = c;
    }
    // cout << l << endl;
    ll sum = 0;
    for(ll i = 0; i < N; i++){
        if(r-A[i] > 100000) continue;
        if(r-A[i] <= 0) {
            sum += N;
            continue;
        }
        sum += cnt[r-A[i]];
    }
    
    ll rem = M-sum;
    ll ans = rem*l;
    ll c = 0;
    // cout << l << ' ' << r << endl;
    // cout << cumsum[0] << endl;
    // cout << ans << endl;
    // cout << sum << ' ' << rem << endl;
    for(ll i = 0; i < N; i++){
        // cout << r-A[i] << endl;
        if(r-A[i] <= 0) {
            ans += ((ll)N*A[i]+cumsum[0]);
            c += N;
            // cout << N*A[i] << ' ' << cumsum[0] << endl; 
            continue;
        }
        if(r-A[i] > 100000) continue;
        if(r-A[i] >= 0) {
            ans += ((ll)(cnt[r-A[i]]*A[i])+cumsum[r-A[i]]);
            c += cnt[r-A[i]];
            // cout << cnt[r-A[i]] << ' ' << A[i] << endl;
            // cout << (cnt[r-A[i]]*A[i])<< ' ' << cumsum[r-A[i]] << endl;
        }
    }
    // cout << c << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
#define int ll
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
const int N=500010,Inf=1e18+10;
int front[N],cnt,dep[N],cur[N],s,t,n,a[N],b[N];queue<int>Q;
struct node{int to,nxt,w;}e[N<<1];
void Add(int u,int v,int w){
    e[cnt]=(node){v,front[u],w};front[u]=cnt++;
    e[cnt]=(node){u,front[v],0};front[v]=cnt++;
}
bool bfs(){
    Q.push(s);memset(dep,0,sizeof(dep));dep[s]=1;
    while(!Q.empty()){
        int u=Q.front();Q.pop();
        for(int i=front[u];~i;i=e[i].nxt){
            int v=e[i].to;
            if(!dep[v] && e[i].w){
                dep[v]=dep[u]+1;Q.push(v);
            }
        }
    }
    return dep[t];
}
int dfs(int u,int flow){
	if(u==t || !flow)return flow;
	for(int &i=cur[u];~i;i=e[i].nxt){
		int v=e[i].to;
		if(dep[v]==dep[u]+1 && e[i].w){
			int di=dfs(v,min(flow,e[i].w));
			if(di){
				e[i].w-=di;e[i^1].w+=di;
				return di;
			}
			else dep[v]=0;
		}
	}
	return 0;
}
int Dinic(){
	int flow=0;
	while(bfs()){
		for(int i=s;i<=t;i++)cur[i]=front[i];
		while(int d=dfs(s,Inf))flow+=d;
	}
	return flow;
}
signed main(){
	n=gi();memset(front,-1,sizeof(front));
	s=0;t=n+n+2;
	for(int i=1;i<=n+1;i++){a[i]=gi();Add(i+n,t,a[i]);}
	for(int i=1;i<=n;i++)b[i]=gi();
	for(int i=1;i<=n;i++){
		Add(s,i,b[i]);Add(i,i+n,Inf);Add(i,i+n+1,Inf);
	}
	printf("%lld\n",Dinic());
	return 0;
}


Measured memory_bytes: 37888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> a(n, 0);
	for(int i=0; i<m; i++){
		int t;
		cin >> t;
		a[t] = 1;
	}
	int ans = inf;
	for(int i=-1; i<=1; i+=2){
		int sub = 0;
		for(int j=x; 0<=j && j<n; j+=i){
			sub += a[j];
		}
		ans = min(ans, sub);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
// reverse algorithm example

#include <iostream>

using namespace std;


int main () {
int a,b;
cin>>a>>b;
if (a >b){
    for(int i=0;i<a;i++)
        cout<<b;
}
if (a<b){
    for (int i=0;i<b;i++)
        cout<<a;
}
if (a==b){
    for (int i=0;i<b;i++)
        cout<<b;

}

return 0;

}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N;
  vector<lpair> xy;
  vector<llong> rx, ry;

  cin >> N;
  xy.resize(N);
  for (auto &in: xy) {
    cin >> in.first >> in.second;
    rx.push_back(in.first + in.second);
    ry.push_back(in.first - in.second);
  }
  sort(ALL(rx));
  sort(ALL(ry));

  cout << max((rx.back() - rx.front()), (ry.back() - ry.front())) << endl;

  return 0;
}

Measured memory_bytes: 9780
from sys import stdin
a = stdin.readline().split(" ")
num=int(a[0])
find=int(a[1])
j=1
w2=[]
while j<=num:
    z = stdin.readline().rstrip('\n')
    w2.append(int(z))
    j+=1
w2.sort()
minnum=w2[find-1]-w2[0]
for i in range(len(w2)-find+1):
    minnum=min(minnum,w2[i+find-1]-w2[i])
print(minnum)

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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
//#define int ll
#define pii pair<int, int>
const int SZ = 3e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

int n;
string s1, s2;

void read() {
    cin >> n >> s1 >> s2;
}

void solve() {
    string s = "";
    for (int i = 0; i < n; ++i) {
        s += s1[i];
        s += s2[i];
    }
    cout << s;
}

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

    read();
    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        String[] ar = new String[n];

        for (int i = 0; i < n; i++) {
            ar[i] = sc.next();
            switch (ar[i]) {
                case "AC":
                    ac++;
                    break;
                case "WA":
                    wa++;
                    break;
                case "TLE":
                    tle++;
                    break;
                case "RE":
                    re++;
                    break;
            }

        }
        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);

    }
}

Measured memory_bytes: 65344
r,c = map(int,input().split())
ans = [[0]*c for j in range(r+1)]
for i in range(r):
	ans[i] = list(map(int, input().split()))

for i in range(c):
    for j in range(r):      
        ans[r][i] += ans[j][i]
        
for j in range(r+1):  
    m = 0
    for i in range(c):
        m += ans[j][i]
        print(ans[j][i], end = " ")
    print(m)


Measured memory_bytes: 6216
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x;
    cin>>x;
    for(long long i=0;i*i*i*i*i<=x/2;i++)
    if(pow((long long)(pow(x-i*i*i*i*i,.2)),5)==x-i*i*i*i*i)
        cout<<(long long)(pow(x-i*i*i*i*i,.2))<<' '<<-i<<endl,exit(0);
    for(long long i=0;i*i*i*i<=x;i++)
        if(pow((long long)(pow(i*i*i*i*i-x,.2)),5)==i*i*i*i*i-x)
            cout<<i<<' '<<(long long)(pow(i*i*i*i*i-x,.2))<<endl,exit(0);
}

Measured memory_bytes: 4096
from scipy.special import comb
# a = comb(n, r)
n,k=map(int,input().split())
p=n//k
q=p+1
ans=0
ans1 = (comb(p, 3, exact=True)+comb(p, 2, exact=True))*6+p
ans2 = (comb(q, 3, exact=True)+comb(q, 2, exact=True))*6+q
ans+=ans1
if k%2==0:
    if k*p+k//2>n:
        ans+=ans1
    else:
        ans+=ans2
# print(p)
# print(q)
print(ans)

Measured memory_bytes: 42056
#include <iostream>
#include <algorithm>
#define ll long long 
using namespace std;

int main()
{
	ll A, B, C; cin >> A >> B >> C;
	if (!(A % 2) || !(B % 2) || !(C % 2))
	{
		cout << 0;
		return 0;
	}
	ll s1 = A * B, s2 = B * C, s3 = A * C;
	ll m = min(s1, s2);
	m = min(m, s3);
	cout << m;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<string> S(n);
    for(int i = 0; i < n; i++) cin >> S[i];
    char c = 'a';
    int Now,Min;
    map<char,int> mp;
    while(c <= 'z'){
        Now = 0;
        Min = 51;
        //ｎ個の文字列調査
        for(int i = 0; i < n; i++){
            Now = 0;
            //文字列数え上げ
            for(int j = 0; j < S[i].size(); j++){
                if(S[i][j] == c) Now++;
            }
            Min = min(Min,Now);
        }
        //mapに入力
        mp[c] = Min;
        c++;
    }
    string X = "a";
    for(char i = 'a'; i <= 'z'; i++){
        for(int j = 0; j < mp[i]; j++) X += i;
    }
    sort(X.begin(),X.end());
    for(int i = 1; i < X.size(); i++) cout << X[i];
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
ll k, num;
int cnt = 1;
int main()
{
	cin >> k;
	num = 7;
	if (k % 2 == 0)
	{
		cout << -1;
		return 0;
	}
  if (k == 7 || k==1)
	{
		cout << 1;
		return 0;
	}
	while (num)
	{
		if (cnt > 1000000)
		{
			cout <<-1;
			return 0;
		}
		num *= 10;
		num += 7;
		if(num>k)num %= k;
		cnt++;
	}
	cout << cnt;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e+9+7;
int main(void){
    
    int n;cin>>n;
    long long s[n];
    
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    
    long long res = 0;
    for(int i=0;i<63;i++){
        long long y=0,z=0;
        long long x=0;
        for(int j=0;j<n;j++){
            if(s[j]%2==0)y++;
            else z++;
            s[j]/=2;
        }
        //cout<<y<<endl;
        x = y*z;
        x%=mod;
        x*= ((long long)1<<i)%mod;
        //cout<<z<<endl;
        x%=mod;
        res+=x;
        res%=mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 2560
def main():
    N, K = [int(i) for i in input().split()]
    R, S, P = [int(i) for i in input().split()]
    T = input()
    hand = {"r":P, "s":R, "p":S}
    res = 0
    for i in range(K):
        # print(K)
        last = ""
        j = i
        while j < N:
            # print(j)
            aite = T[j]
            if aite != last:
                res += hand[aite]
                last = aite
            else:
                last=""
            j += K
    print(res)
main()

Measured memory_bytes: 3316
n = int(input())

pf = {}


for i in range(2,int(n**0.5)+1):
    while n%i == 0:
        pf[i] = pf.get(i,0)+1
        n //= i
if n>1: pf[n] = 1

num_group = [0]*11 #2**50 > 10**12  55=1+2+...+10
for i in range(10):
    num_group[i+1] = num_group[i] + (i+1)
#print(num_group)

ans = 0
for prime in pf.keys():
    for i in range(1,11):
      if pf[prime]<num_group[i]:
          break
    ans += i-1
print(ans)

Measured memory_bytes: 63632
def calc_num_digits(x):
    num_digits = 0
    while True:
        if x // 10 == 0:
            num_digits += 1
            break
        x //= 10
        num_digits += 1
    return num_digits


def main():
    n = int(input())
    ans = 0

    for i in range(1, n + 1):
        num_digits = calc_num_digits(i)
        if num_digits % 2 == 1:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int a[100010];
int main(){
	int n,k,q;
	cin>>n>>k>>q;
	fill(a,a+n,0);
	
	for(int i=0;i<q;i++)
	{
		int x;
		cin>>x;x--;
		a[x]++;
	}
	for(int i=0;i<n;i++)
	{
		if(k+a[i]-q>0)cout<<"Yes"<<"\n";
		else cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1024