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

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  string s;cin>>s;
  if(s[2] == s[3] && s[4] == s[5]){
    print("Yes");
  }else{
    print("No");
  }
  return 0;
}


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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

int  gcd(int x, int y) {
  while (y != 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main(){
    int k;
    cin >> k;
    int sum=0;

    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c=1; c<=k; c++){
                sum+=gcd(a,gcd(b,c));
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	if (s[a] != '-') {
		cout << "No" << endl;
		return 0;
	}
	bool ok = true;
	rep(i, a + b + 1) {
		if (i != a && s[i] == '-' ) {
			ok = false;
			break;
		}
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int N,i,Number;
  int Digit;
  int Count = 0;
  scanf("%d",&N);
  
  for ( i = 1; i <= N; i++ ){
    Digit = 0;
    Number = i;
    while ( Number > 0 ){
      Number /= 10;
      Digit++;
    }
    if ( Digit % 2 == 1 )
      Count++;
  }

  printf("%d\n",Count);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>

#define gec     getchar
#define FILE(F) freopen(F".in","r",stdin),freopen(F".out","w",stdout)

typedef long long ll;
template<typename T>
inline void read(T &x)
{
	x=0;bool f=0; char c=gec();
	for(;c<'0'||c>'9';c=gec())f=(c=='-');
	for(;c>='0'&&c<='9';c=gec())x=x*10+c-'0';
	x=f?-x:x;
}
namespace IO
{
inline void fpr(char *c){fprintf(stderr,"%s\n",c);}
inline void fpr(int           x,char *c){fprintf(stderr,"[ %s ] : = %d   \n",c,x);}
inline void fpr(ll            x,char *c){fprintf(stderr,"[ %s ] : = %lld \n",c,x);}
inline void fpr(double        x,char *c){fprintf(stderr,"[ %s ] : = %.5lf\n",c,x);}
inline void fpr(long double   x,char *c){fprintf(stderr,"[ %s ] : = %.5Lf\n",c,x);} 
}using namespace IO;

int n;ll A,B,C,D;
int main()
{
	read(n);read(A);read(B);read(C);read(D);
	B-=A;
	for(int i=1;i<n-1;i++)
	{
		ll L1=i*C,R1=i*D;
		ll R2=-(n-2-i+1)*C,L2=-(n-2-i+1)*D;
		if(L1+L2<=B&&B<=R1+R2){puts("YES");return 0;}
	}
	puts("NO");
	return 0;
}	

Measured memory_bytes: 128
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------

K = int(input())						# 5


A=[0,1,2,3,4,5,6,7,8,9]
S=[]
for a in A:
	S.append(str(a))

from collections import deque
Q = deque()


B=list(S)

while True:
	for a in B:
		Q.append(str(a))
	B=[]

	while Q:
		s = Q.popleft()
		
		a = int(s[0])
		
		x = (str(a-1) + s) if a>0 else ""
		y = (str(a) + s)
		z = (str(a+1) + s) if a<9 else ""
		
		if x!="": B.append(x)
		if y!="": B.append(y)
		if z!="": B.append(z)

	B.sort()
	for b in B:
		if b[0]=="0": continue
		A.append(int(b))

	if len(A)>K:
		ans = A[K]
		print(ans)
		#p(A)
		#p(B)
		exit(0)



Measured memory_bytes: 21768
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[100005];

bool ans;

int n;

bool calc(int x) {
	int cnt = 0, left = x;

	for (int i = 1; i <= n; ++i) {
		if (arr[i] == x) {
			++cnt;
		}
		else {
			--left;
		}
	}

	if (left < 0) {
		return 0;
	}

	if (left == 0 && cnt > 0) {
		return 0;
	}

	if (cnt < left * 2) {
		return 0;
	}

	return 1;
	// 2 unique, 3 not - need 4
	// means we need 2 groups
	// each group - minimum 2 persons
	// 3 < 2 * 2 => "NO"               
}

void solve() {                   
	scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);
    }

    int mn = arr[1], mx = arr[1];

    for (int i = 2; i <= n; ++i) {
    	mn = min(mn, arr[i]);
    	mx = max(mx, arr[i]);
    }                      

    if (mx > mn + 1) {
    	printf("No\n");
    	return;
    }            

    if (mx == mn) {
    	ans |= calc(mn);
    }
        
    ans |= calc(mn + 1);
    printf(ans ? "Yes\n" : "No\n");
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
dictionary = {}
N = int(input())
for i in range(N):
    word = input()
    if word not in dictionary:
        dictionary[word] = 1
    else:
        dictionary[word] += 1
M = int(input())
for i in range(M):
    word = input()
    if word not in dictionary:
        dictionary[word] = -1
    else:
        dictionary[word] -= 1

anslist = sorted(dictionary.items(), key = lambda x: -x[1])
ans = anslist[0][1]
if ans < 0: ans = 0
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, m;

char ask(int i) {
    cout << i << endl;
    string s;
    cin >> s;
    return s[0];
}



int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n;
    char c = ask(0);
    if (c == 'V') {
        return 0;
    }
    int l = 0, r = n;
    while(l+1 < r) {
        int mid = (l+r)/2;
        char nc = ask(mid);
        if (nc == 'V') return 0;
        if ((mid % 2 == l % 2) == (c == nc)) {
            l = mid;
            c = nc;
        } else {
            r = mid;
        }
    }
    return 0;
}

Measured memory_bytes: 852
package main

import "fmt"
import "bufio"
import "os"

func main() {
	var H, W int
	fmt.Scanf("%d %d\n", &H, &W)
	grid := make([]bool, (H+2)*(W+2)) // 余白
	sc := bufio.NewScanner(os.Stdin)
	for i := 1; i < H+1; i++ {
		sc.Scan()
		for j, c := range sc.Text() {
			j++
			if c == '#' {
				grid[i*(W+2)+j] = true
			} else {
				grid[i*(W+2)+j] = false
			}
		}
	}

	for i := 1; i < H+1; i++ {
		for j := 1; j < W+1; j++ {
			if !grid[i*(W+2)+j] {
				continue
			}
			if !grid[i*(W+2)+j+1] && !grid[i*(W+2)+j-1] && !grid[i*(W+2)+j+W+2] && !grid[i*(W+2)+j-W-2] {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 640
import java.util.Scanner;

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

        int N = scanner.nextInt();

        int[] A = new int[N + 1];
        int[] B = new int[N + 1];
        int[] C = new int[N + 1];

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

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

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

        int score = 0;

        for (int i = 1 ; i <= N ; i++) {
            score += B[A[i]];
            if (A[i - 1] == A[i] - 1) {
                score += C[A[i - 1]];
            }
        }

        System.out.println(score);
    }
}


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

const int N = 200010;
const int M = 2010;
const int moder = 1e9 + 7;
const int inv2 = 5e8 + 4;

int fac[M << 2], inv[M << 2];
int a[N], b[N];
int dp[M << 1][M << 1];

int powermod(int a, int exp){
	int ret = 1;
	for ( ; exp > 0; exp >>= 1){
		if (exp & 1){
			ret = 1ll * ret * a % moder;
		}
		a = 1ll * a * a % moder;
	}
	return ret;
}

int comb(int n, int m){
	if (n < m || m < 0) return 0;
	return 1ll * fac[n] * inv[m] % moder * inv[n - m] % moder;
}

int main(){
	fac[0] = 1;
	for (int i = 1; i < M << 2; ++ i){
		fac[i] = 1ll * fac[i - 1] * i % moder;
	}
	inv[(M << 2) - 1] = powermod(fac[(M << 2) - 1], moder - 2);
	for (int i = (M << 2) - 1; i; -- i){
		inv[i - 1] = 1ll * inv[i] * i % moder;
	}
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d%d", &a[i], &b[i]);
		++ dp[M - a[i]][M - b[i]];
	}
	for (int i = 1; i < M << 1; ++ i){
		dp[0][i] = (dp[0][i - 1] + dp[0][i]) % moder;
	}
	for (int i = 1; i < M << 1; ++ i){
		dp[i][0] = (dp[i - 1][0] + dp[i][0]) % moder;
		for (int j = 1; j < M << 1; ++ j){
			dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1]) % moder;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++ i){
		ans = (ans + dp[a[i] + M][b[i] + M]) % moder;
		ans = (ans - comb(a[i] + b[i] << 1, a[i] << 1) + moder) % moder;
	}
	ans = 1ll * ans * inv2 % moder;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 65024
#include <bits/stdc++.h>
using namespace std;
int a,b; 


int main()
{
	scanf("%d%d",&a,&b);
	int x,y,z;
	x=a+b;
	y=a-b;
	z=a*b;
	if(x>=y&&x>=z) printf("%d",x);
	else if(y>x&&y>=z) printf("%d",y);
	else if(z>x&&z>y) printf("%d",z);
	
	
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int d, t, s;
  cin >> d >> t >> s;

  if (s * t >= d) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 3688
#coding:utf-8
n = int(input())
s = input()

string = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
letter = []
ans = []

for i in s:
    letter.append(i)

for i in letter:
    for j in range(0, 26):
        if  i == string[j]:
            tmp = j + n
            #print(tmp)
            if tmp > 25:
                tmp = tmp % 26
            ans.append(string[tmp])

#print(ans)
print(''.join(ans))


Measured memory_bytes: 3188
#include<iostream>
#include<math.h>
#include<set>
#include<string.h>
#define ll long long
using namespace std;


int main(){
  ll X;
  cin >> X;

  ll pent[1000]={};
  for(ll i=0; i<1000; i++) pent[i] = i*i*i*i*i;


  ll plus, minus;
  for(int i=0; i<1000; i++)
    for(int j=0; j<1000; j++){
      if(pent[i] == pent[j]+X){
        cout << i << " " << j << endl;
        return 0;
      }
      if(pent[i] == X-pent[j]){
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  //cout << plus <<  " " <<minus << " "<< pent[10]<<  endl;
  return 0;
}

Measured memory_bytes: 3644
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,x=map(int,input().split())
x_lst=list(map(int,input().split()))
x_lst=list(map(lambda a:abs(a-x),x_lst))
print(gcd_list(x_lst))

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

void show_vector(vector<int> &v);

int main(int argc, char *argv[])
{
    int n, tmp;
    vector<int> a;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
    }

    int v, j;
    for (int i = 0; i < n; i++)
    {
        v = a[i];
        j = i - 1;
        while (j > -1 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;

        show_vector(a);
    }

    return 0;
}

void show_vector(vector<int> &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if (i != v.size() - 1)
        {
            cout << " ";
        }
        else
        {
            cout << endl;
        }
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1<<30;
const ll MOD = 1e9 + 7;
const ll MAX_N = 100000;
vector<ll> T[MAX_N];
vector<int> num(MAX_N, 0);
void search(int depth, int cnt)
{
    cnt++;
    num[depth] += cnt;
    for(int u = 0; u < T[depth].size(); u++)
    {
        if(num[T[depth][u]]) continue;
        search(T[depth][u], cnt);
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<pair<ll, ll>> v;
    for(ll i = 0; i < n - 1; i++)
    {
        ll a, b; cin >> a >> b;
        a--, b--;
        v.push_back(make_pair(a, b));
        T[a].push_back(b);
        T[b].push_back(a);
    }
    vector<ll> cost(n);
    for(ll i = 0; i < n; i++) cin >> cost[i];
    sort(cost.begin(), cost.end());
    vector<int> cnt(n);
    for(int i = 0; i < n; i++) if(T[i].size() == 1) search(i, 0);
    vector<P> tmp;
    for(int i = 0; i < n; i++) tmp.push_back(P(num[i], i));
    sort(tmp.begin(), tmp.end(), greater<P>());
    vector<int> ans(n);
    for(int i = 0; i < n; i++)
    {
        ans[tmp[i].second] = cost[i];
    }
    ll res = 0;
    for(ll i = 0; i < v.size(); i++) res += min(ans[v[i].first], ans[v[i].second]);
    cout << res << endl;
    for(ll i = 0; i < n; i++)
    {
        if(i) cout << " ";
        cout << ans[i];
        if(i == n - 1) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n, m; cin >> n >> m;

        vector<int> v;
        int s = 0;
        for (int x = 0; x < n; ++x){
            int q; cin >> q;
            v.push_back(q);
            s += q;
        }

        int cnt = 0;
        for (auto x : v){
            if (x * 4 * m >= s) cnt++;
        }

        if (cnt >= m) cout << "Yes" << endl;
        else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
const long long int inf = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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

int main(){
    ll r;
    cin>>r;
    cout<<2*r*3.141592<<endl;

    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll n=s.size(),i,x,sum=0,count=0,j,k,count1=0,count2=0;
    vector<ll> vi;
    if(n==1){
        cout<<1;
    }
    else{
        for(i=0;i<n;i++){
            if(s[i]=='>'){
                count++;
            }
            else{
                break;
            }
        }   
        //cout<<count<<endl;
        sum+=(count*1ll*(count+1))/2;
        count=0;
        for(j=i;j<n;j++){
            if(s[j]=='<'){
                count1++;
            }
            else{
                for(k=j;k<n;k++,j++){
                    if(s[k]=='>'){
                        count2++;  
                    }
                    else{
                        break;
                    }
                }
                //cout<<count1<<" "<<count2<<endl;
                if(count1<count2){
                    swap(count1,count2);
                }
                sum+=(count1*1ll*(count1+1))/2;
                sum+=(count2*1ll*(count2-1))/2;
                j--;
                count1=0,count2=0;
            }
        }
        sum+=(count1*1ll*(count1+1))/2;
        cout<<sum;
    }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n,k;
    cin >> n >> k;
    queue<int> q;
    string s;
    cin >> s;
    int t=0,p=0,b=0,ans=0,m=0,u=0;
    rep(i,n){
        p++;
        b++;
        if (s.at(i)=='1'){
            if (t==0){
                q.push(p-1);
                p=1;
                t=1;
            } 
        }
        if (s.at(i)=='0'){
            if (t==1) {
                t=0;
                m++;
                ans+=b-1;
                b=1;
                if (m>k){
                    ans-=q.front();
                    q.pop();
                }
                u=max(ans,u);
            }
        }
        //cout << u << endl;
    }
    m++;
        ans+=b;
        if (m>k){
        ans-=q.front();}
        u=max(ans,u);
    cout << u << endl;
}

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

int main(){
	ll A,B,K,x; cin >> A >> B >> K;

	if(K <= A){
		cout << A-K << ' ' << B << endl;
	}else if(K <= A+B){
		x = K-A;
		B = B - x;
		cout << 0 << ' ' << B << endl;
	}else{
		cout << 0 << ' ' << 0 << endl;
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
a, b = map(int,input().split())
P = list(map(int,input().split()))

A = [0,0,0]
for i in range(n):
    if P[i] <= a:
        A[0] += 1
    elif P[i] <= b:
        A[1] += 1
    else:
        A[2] += 1
print(min(A))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define int long long
using namespace std;

struct block {int s, w, v;};
vector<block> blocks;

int cur[30005];
int pre[30005];

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n; cin >> n;
	for(int i = 0;i < n;i++){
		int s, w, v; cin >> w >> s >> v;
		blocks.push_back({s,w,v});
	}
	
	sort(blocks.begin(),blocks.end(), [&](block a, block b){ return a.s + a.w > b.s + b.w; });
	
	for(block B : blocks){
		swap(pre, cur);
		for(int i = 0;i <= 30000;i++) cur[i] = pre[i];
		
		for(int i = B.w;i <= 30000;i++){
			int remS = min(B.s, i - B.w);
			cur[remS] = max(cur[remS], pre[i] + B.v);
		}
		cur[B.s] = max(cur[B.s], B.v);
	}
	
	cout << *max_element(cur,cur+30005);
}


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

int main(){
  int num,ten;
  int tmp;
  int root;
  int cnt = 0;
  
  cin >> num >> ten;
  vector<vector<int>> vec(num,vector<int>(ten));
  for(int i = 0; i < num; i++){
    for(int j = 0; j < ten; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  for(int i = 0; i < num; i++){
    for(int j = i+1; j < num; j++){
      root = 0;
      
      for(int k = 0; k < ten; k++){
        tmp = abs(vec.at(i).at(k) - vec.at(j).at(k));
        root += tmp * tmp; 
      }
      
      for(int k = 1; k <= root; k++){
        if(k * k == root){
          cnt++;
          break;
        }
      }
    }
  }
  
  cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int k, x;
    cin >> k >> x;
    int fir = max(-1000000, x - k + 1);
    int sec = min(1000000, x + k - 1);
    for (int i = fir; i <= sec; i++) {
        cout << i << ' ';
    }







}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m[100];
int main()
{
    int n;
    cin>>n;
    int i;
    int avg=0;
    int avg1;
    for(i=0;i<n;i++)
       {
           cin>>m[i];
           avg+=m[i];
       }
    avg=avg/n;
    avg1=avg+1;
    int x1=0,x2=0;
    for(i=0;i<n;i++)
        {
            x1+=(m[i]-avg)*(m[i]-avg);
            x2+=(m[i]-avg1)*(m[i]-avg1);
        }
    cout<<min(x1,x2);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int n = s.length();
        int count = 0;
//        for (int i=0; i<n-1; i++){
//            i = 0;
//            if ((s.charAt(i)=='0') & (s.charAt(i+1)=='0')){
//                s = s.substring(i+1);
//                s.replaceFirst("0", "1");
//                count++;
//            }
//            else if ((s.charAt(i)=='1') & (s.charAt(i+1)=='1')){
//                s = s.substring(i+1);
//                s.replaceFirst("1", "0");
//                count++;
//            }
//            else if ((s.charAt(i)=='0') & (s.charAt(i+1)=='1')){
//                s = s.substring(i+1);
//            }
//            else if ((s.charAt(i)=='1') & (s.charAt(i+1)=='0')){
//                s = s.substring(i+1);
//            }
//            n -= 1;
//        }
//        System.out.println(count);

        String bw[] = new String[n];
        String wb[] = new String[n];
        int bw_count = 0;
        int wb_count = 0;

        for (int i=0; i*2<n; i++){
            bw[i*2] = "0";
            wb[i*2] = "1";
        }
        for (int i=1; i*2<n+1; i++){
            bw[i*2-1] = "1";
            wb[i*2-1] = "0";
        }

        for (int i=0; i<n; i++){
            if (!String.valueOf(s.charAt(i)).equals(bw[i])){
                bw_count++;
            }
        }
        for (int i=0; i<n; i++){
            if (!String.valueOf(s.charAt(i)).equals((wb[i]))){
                wb_count++;
            }
        }

        if (bw_count<wb_count)  System.out.println(bw_count);
        else System.out.println(wb_count);
    }
}




Measured memory_bytes: 35944
n = int(input())
NIL = -1
MAX = 10000

class Node():
    def __init__(self):
        self.parent = [0] * MAX
        self.left = [0] * MAX
        self.right = [0] * MAX
        self.Pr = []
        self.I = []
        self.Po = []
        
    def preparse(self, u):
        if u == NIL:
            return
        self.Pr.append(u)
        self.preparse(self.left[u])
        self.preparse(self.right[u])
        return self
    
    def inoparse(self, u):
        if u == NIL:
            return
        self.inoparse(self.left[u])
        self.I.append(u)
        self.inoparse(self.right[u])
        return self
    
    def postparse(self, u):
        if u == NIL:
            return
        self.postparse(self.left[u])
        self.postparse(self.right[u])
        self.Po.append(u)
        return self
        
def main():
    T = Node()
    for i in range(n):
        T.parent[i] = NIL
    
    for i in range(n):
        v, l, r = (int(x) for x in input().split())
        T.left[v] = l
        T.right[v] = r
        if l != NIL:
            T.parent[l] = v
        if r != NIL:
            T.parent[r] = v
    
    for i in range(n):
        if T.parent[i] == NIL:
            root = i
    
    T.preparse(root)
    T.inoparse(root)
    T.postparse(root)
    pr = [str(i) for i in T.Pr]
    ino = [str(i) for i in T.I]
    po = [str(i) for i in T.Po]
    
    print('Preorder')
    print(' ' + ' '.join(pr))
    print('Inorder')
    print(' ' + ' '.join(ino))
    print('Postorder')
    print(' ' + ' '.join(po))

main()


Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> dp(n + 1, 0);
    rep(i, m) {
        ll l, r;
        cin >> l >> r;
        l--; r--;
        dp[l]++;
        dp[r + 1]--;
    }
    rep(i, n) dp[i + 1] += dp[i];
    ll ans = 0;
    rep(i, n) {
        if (dp[i] == m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
R, G, B, N = map(int, input().split())
i = 0
for r in range(N // R + 1):
    Rr = r * R
    for g in range(N // G + 1):
        Gg = g * G
        Bb = N-Rr-Gg
        if Bb < 0:
            break
        if Bb % B == 0:
            i += 1
print(i)


Measured memory_bytes: 2940
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextLong

    var min = Long.MaxValue
    for (i <- 1 to math.sqrt(n).toInt) {
      if (n % i == 0) {
        min = math.min(min, i + n / i - 2)
      }
    }
    println(min)
  }
}


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

using namespace std;

long long x;

int main() {
  scanf("%lld", &x);
  long long ans = 2 * (x / (5 + 6));
  long long mod = x % (5 + 6);
  if (mod > 0) {
    mod -= 6;
    ans++;
  }
  if (mod > 0) {
    mod -= 5;
    ans++;
  }
  if (mod > 0) {
    mod -= 4;
    ans++;
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main(){
	int n,k;
	cin >> n >> k;
	int ans=0;
	int tmp=0;
	for(int i=0;i<n;i++){
		cin >> tmp;
		if(tmp>=k){ans++;}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    def modcmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        if r == 0:
            return 1
        over = 1
        under = 1
#        for i in range(n, n-r, -1):
#            over = over * i % mod
#        for i in range(1, r+1):
#            under = under * i % mod

        over = reduce(lambda v1, v2: (v1 * v2) % mod, range(n, n-r, -1))
        under = reduce(lambda v1, v2: (v1 * v2) % mod, range(1, r+1))
        return (over * pow(under, mod - 2, mod)) % mod

    mod = 1000000007
    n, a, b = map(int, input().split())

    count = pow(2, n, mod) - 1
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    while count < 0:
        count += mod
    print(count % mod)


main()


Measured memory_bytes: 3572
import numpy as np

s = input()

d = [ int( 0 ) ] * 2019
d[ 0 ] = int( 1 )
r = int( 0 )
t = int( 1 )

for si in reversed( s ):
#    print( si )

    r = int( si ) * t + r
    r = r % 2019

    t = t * 10
    t = t % 2019

    d[ r ] = d[ r ] + 1

ans = int( 0 )
for di in d:
    ans = ans + di * ( di - 1 ) // 2

print( ans )




Measured memory_bytes: 27200
import sys, re, os
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 S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
L = [LIST() for i in range(M)]

kaburi = []
num = [-1] * N
# saisyo ga 0
# if N > 1:
#     for l in L:
#         s, c = l
#         if s == 1 and c == 0:
#             print(-1)
#             exit()

for l in L:
    s, c = l
    if num[s-1] == -1:
        num[s-1] = c
    elif num[s-1] == c:
        num[s-1] = c
    else:
        print("-1")
        exit()

    # if s in kaburi and :
        # print(-1)
        # exit()
    # kaburi.append(s)
    # print(kaburi)
    # num[s-1] = c
#
if N != 1 and num[0] == 0:
    print(-1)
    exit()

if N == 1 and num[0] < 1:
    print(0)
    exit()
# print(num)
ans = []

for i in range(N):
    if i == 0:
        if num[i] == -1:
            ans.append("1")
        else:
            ans.append(str(num[i]))
    else:
        if num[i] != -1:
            ans.append(str(num[i]))
        else:
            ans.append("0")


# if N != 1 and ans[0] == "0":
#     print(-1)
#     exit()
print("".join(ans))


Measured memory_bytes: 5380
let fs = require('fs');

const yourAnswerFunctionComesHere = data => {
  var Arr=(data.trim()).split(" ").map(Number);
  Arr.sort(function(a,b){return b-a;});
  console.log(Arr.join(" "));
}

const readFile = path => {
  fs.readFile(path, 'utf8', (err, data) => {
    yourAnswerFunctionComesHere(data);
  });
}

const readFileWithoutArg = () => {
  const data = require('fs').readFileSync('/dev/stdin', 'utf8');
  yourAnswerFunctionComesHere(data);
}

let sampleInputPath = "";

if(process.argv.length > 2) {
  sampleInputPath = process.argv[2];
  readFile(sampleInputPath);
} else {
  readFileWithoutArg();
}



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

#define mx 3005
#define ll long long 

void IO()
{
     #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
}

int ar[mx][mx];
ll dp[mx][mx][5];

int m,n,k,ii;

ll func(int i,int j,int cnt)
{
	//cout<<cnt<<endl;
	if(i>n || j>m)return 0;
	if(i==n && j==m)
	{
		if(cnt<3)return ar[i][j];
		return 0;
	}
	ll &val=dp[i][j][cnt];
	if(val!=-1)return val;
	val=0;
	val=max(val,func(i+1,j,0));
	val=max(val,func(i,j+1,cnt));
	if(cnt<3)
	{
		//if(cnt==1)cout<<i<<" "<<j<<endl;
		val=max(val,ar[i][j]+func(i+1,j,0));
		val=max(val,ar[i][j]+func(i,j+1,cnt+1));
	}
	return val;
}


void solve()
{
	scanf("%d%d%d",&n,&m,&k);
	memset(dp,-1,sizeof(dp));
    for(int i=1;i<=k;i++)
    {
    	int x,y,w;
    	scanf("%d%d%d",&x,&y,&w);
    	ar[x][y]=w;
    }
    printf("%lld\n",func(1,1,0) );
}

int main()
{
	IO();

	int t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 392264
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

        int a, b;

        a = scanner.nextInt();
        b = scanner.nextInt();

        int seki;
        seki = a * b;

        //奇数
        if(seki % 2 == 1){
            System.out.println("Odd");
        }
        else{
            System.out.println("Even");
        }
    }
}

Measured memory_bytes: 35488
N=int(input())
S=list(map(int,input().split()))
Q=int(input())
T=list(map(int,input().split()))

cnt=0
for t in T:
    left=0
    right=N
    while left < right:
        mid=round((left+right-0.0001)/2)
#         print(t,mid,S[mid],left,right)
        if S[mid] == t:
            cnt+=1
            break
        elif S[mid] > t:
            right = mid
        elif S[mid] < t:
            left = mid+1
print(cnt)


Measured memory_bytes: 16720
#include<stdio.h>
int main()
{
    int n,c;
    scanf("%d",&n);
    c=n/2;
    if(n==1)
        printf("%lf\n",(double)n);
    else if(n%2==0)
        printf("%lf\n",c/(double)n);
    else
        printf("%lf\n",(c+1)/(double)n);

}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string foo; cin >> foo;
    map<int, int> m;
    for (char c : foo) m[c] += 1;
    if (m.size() == 2 && m.begin()->second == 2) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

#define MOD 1000000007LL

typedef long long int ll;

using namespace std;
int n, a, b;

ll C(int, int);
int xgcd(int, int, int &, int &);
int modinv(int, int);

ll pow2(int);

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

  ll p2= pow2(n);
  ll Ca = C(n, a);
  ll Cb = C(n, b);
  ll ret = p2 - Ca - Cb - 1;
  while (ret<0) ret+=MOD;
//  printf("%lld %lld %lld\n", p2, Ca, Cb);
  ret %= MOD;

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

  return 0;
}

ll pow2(int n) {
  ll ret=1;
  ll r2=2;
  int i;

  for (i=n; i>0; i/=2) {
    if (i%2) ret *= r2;
    ret %= MOD;
    r2 *= r2;
    r2 %= MOD;

  }
  return ret;
}

ll C(int n, int k) {
  ll ret=1;
  int i;
  int a, b;

  a = k;
  b = n-k;
  if (a<b) swap(a,b);

  for (i=n; i>a; i--) {
    ret *= i;
    ret %= MOD;
  }
  for (i=2; i<=b; i++) {
    ret *= modinv(i, MOD);
    ret %= MOD;
  }
  return ret;
}

int modinv(int a, int m) {
  int g, x, y;
  g = xgcd(a, m, x, y);
  if (g != 1) return -1;
  x %= m;
  if (x<0) x+=m;
  return x;
}

int xgcd(int a, int b, int &x0, int &y0) {
  x0=1, y0=0;
  int x1=0, y1=1;
  int q;
  int at, x0t, y0t;
  while (b != 0) {
    q = a/b;
    at = b;
    b = a%b;
    a = at;
    x0t = x1;
    x1 = x0-q*x1;
    x0 = x0t;
    y0t = y1;
    y1 = y0-q*y1;
    y0 = y0t;
  }
  return a;
}

/*
  ��nCi = 2^n


  2^8 = (2^4)^2
  2^(2^n) = (2^n)^2
  */



Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]

can_ans = True
for i in range(1, 4):
    if c[i%3][0]-c[i-1][0] != c[i%3][1]-c[i-1][1] or c[i%3][1]-c[i-1][1] != c[i%3][2]-c[i-1][2]:
        can_ans = False

    if c[0][i%3]-c[0][i-1] != c[1][i%3]-c[1][i-1] or c[1][i%3]-c[1][i-1] != c[2][i%3]-c[2][i-1]:
        can_ans = False

if can_ans:
    print('Yes')
else:
    print('No')


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


Measured memory_bytes: 4844
W,H,x,y = map(int, input().split())
S = W*H/2.0 #長方形内であれば、中心からの対象点を選ぶ事により、2分割できる
flg = (W/2==x and H/2 ==y) #長方形の中心を通れば、2分割できる。そうじゃないとだめ

print(S,int(flg))

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

using namespace std;

int main(){
	int k , n , ans = 0;
	cin>>k>>n;
	vector<int> v(n);
	for(int i = 0 ; i < n ; i++) cin>>v[i];
	int mx = 0;
	for(int i = 0 ; i < n - 1 ; i++) mx = max(mx , v[i+1] - v[i]) , ans += v[i+1] - v[i];
	if(mx < (v[0] - 0 + k - v[n - 1])) cout<<ans<<endl;
	else cout<<ans - mx + (v[0] - 0 + k - v[n-1])<<endl;
}

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve(long long n) 
{ 
    int arr[10000]; 
    int i = 0; 
    while (n) { 
        arr[i] = n % 26; 
        n = n / 26; 
        i++; 
    } 
    for (int j = 0; j < i - 1; j++) { 
        if (arr[j] <= 0) { 
            arr[j] += 26; 
            arr[j + 1] = arr[j + 1] - 1; 
        } 
    } 
    for (int j = i; j >= 0; j--) { 
        if (arr[j] > 0)  cout << char('a' + arr[j] - 1); 
    } 
    cout << endl; 
} 
int main()  
{ 
    FAST_INP;
    long long n;
    cin >> n;
	solve(n);
    return 0;
} 

Measured memory_bytes: 3656
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int D = int.Parse(input[1]);

            int sum = n /(2*D + 1);

            if( n % (2*D + 1) == 0)
                Console.WriteLine(sum);
            else
            {
                sum++;
                Console.WriteLine(sum);
            }

        }
    }

Measured memory_bytes: 11092
def Distance(X,Y,p):
    s=0
    for x,y in zip(X,Y):
        s+=abs(x-y)**p
    print(s**(1/p))

n=int(input())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))

for p in range(1,4):
    Distance(X,Y,p)
print(max(abs(x-y) for x,y in zip(X,Y)))


Measured memory_bytes: 5648
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> R;
	for (int i = 1; i * i <= M; i++) {
		if (M % i == 0) {
			R.push_back(i);
			if (i * i != M) R.push_back(M / i);
		}
	}
	sort(R.begin(), R.end());
	for (int i = R.size() - 1; i >= 0; i--) {
		//cout << R[i] << endl;
		if (M / R[i] >= N) {
			cout << R[i] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String input = br.readLine();
		Main mn = new Main();
		if(mn.isUnique(input)){
			System.out.println("yes");
		}else{
			System.out.println("no");
		}
		
	}
	public boolean isUnique(String s){
		boolean[] alphabet = new boolean[26];
		int a = Character.getNumericValue('a');
		int z = Character.getNumericValue('z');

		for(int i=0; i<26;i++){
			alphabet[i] = false;
		}

		for(int i=0; i<s.length();i++){
			char c = s.charAt(i);
			int idx = Character.getNumericValue(c);
			if(a <= idx && z >= idx){
					if(alphabet[idx-a]){
						return false;
					}else{
					alphabet[idx-a] = true;
					}
			}else{
					return false;
			}			
		}
		return true;
	}
}

Measured memory_bytes: 21460
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a =  sc.nextLong();
        long b =  sc.nextLong();
        long c =  sc.nextLong();
        long d =  sc.nextLong();
        sc.close();
        long ans = Math.max(Math.max(a*c,a*d),Math.max(b*c,b*d));
        System.out.println(ans);
    }
}


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

using namespace std;

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

typedef pair<long,long> pll;

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

 long n,k;
  cin >> n >> k;
  vector<pll> p(n);
  rep(i,0,n) cin >> p[i].second >> p[i].first;
  sort(p.begin(),p.end(),greater<pll>());

  long res=0,kind=0;
  map<long,long> mp;
  priority_queue<pll,vector<pll>,greater<pll>> rest;
  priority_queue<pll> add;
  rep(i,0,k) { 
    res+=p[i].first;
    mp[p[i].second]++;
    if(mp[p[i].second]==1) kind++;
    else if(mp[p[i].second]>1) rest.push(p[i]);
  }
  long num=res;
  res+=kind*kind;
  rep(i,k,n) add.push(p[i]);
  
  while(!rest.empty()&&kind<=n){
   long a,b;
    tie(a,b)=rest.top();
      rest.pop();
    num-=a;
    mp[b]--;
    while(!add.empty()){
     long c,d;
      tie(c,d)=add.top();
       add.pop();
      if(mp[d]!=0) continue;
       num+=c;
       mp[d]++;
       kind++;
       break;
    }
    res=max(res,num+kind*kind);
    if(add.empty()) break;
  }
  
  
cout << res << endl;
  
}


Measured memory_bytes: 6648
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int isPrime(int n){
    if(n==1){
        return 0;
    }
    if(n==2||n==3){
        return 1;
    }
    if(n%2==0||n%3==0){
        return 0;
    }
    for(int i=5;i*i<=n;i+=2){
        if(i%3==0){
            continue;
        }
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

int main(){
    int n;
    scanf("%d", &n);
    int cnt = 0;
    for(int i=11; i<=55555; i+=5){
        if(isPrime(i)){
            printf("%d ", i);
            cnt++;
        }
        if(cnt == n){
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{ int a,b;
 cin>>a>>b;
 //int maxx=1;
 //int minn=2;
 if(a<=13&&b<=13)
 {
   if(a==1&&b==1)
    cout<<"Draw";
   else if(a==1)
   cout<<"Alice";
   else if(b==1)
   cout<<"Bob";

   else if(a>b)
   {cout<<"Alice";}

   else if(a<b)
    {cout<<"Bob";}

   else if(a==b)
     {cout<<"Draw";}

 }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int getCost(int* list,int listNum, int aim){
	int ans = 0;
	for(int i=0; i<listNum; ++i){
		ans += (list[i]-aim)*(list[i]-aim);
	}
	return ans;
}
int main(){
	int N;
	int A[120];
	std::cin >> N;
	for(int i=0; i<N; ++i){
		std::cin >> A[i];
	}
	int cost = getCost(A,N,-100);
	for(int i=-99; i<=100; i++){
		int nowCost = getCost(A,N,i);
		if( cost > nowCost ){
			cost = nowCost;
		}
	}
	std::cout << cost << std::endl;
	return 0;
}

Measured memory_bytes: 256
from typing import List
import sys

n = int(input())
c = list(map(int, input().split()))
c = [x-1 for x in c]
# print(c)
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = tuple(map(int, input().split()))
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


size: List[int] = [1 for i in range(n)]
stack: List[List[int]] = [[] for color in range(n)]
in_time: List[int] = [-1 for i in range(n)]
out_time: List[int] = [-1 for i in range(n)]
timer = 0
total = n*(n+1)//2
ans: List[int] = [total for color in range(n)]
# print(ans)


def dfs(parent: int, root: int):
    global timer
    in_time[root] = timer
    timer += 1

    for child in adj[root]:
        if parent == child:
            continue
        dfs(root, child)
        size[root] += size[child]

        cnt = size[child]
        while stack[c[root]]:
            x = stack[c[root]][-1]
            if in_time[x] > in_time[root] and out_time[x] != -1:
                cnt -= size[x]
                stack[c[root]].pop()
            else:
                break
        ans[c[root]] -= cnt*(cnt+1)//2

    out_time[root] = timer
    timer += 1

    stack[c[root]].append(root)


sys.setrecursionlimit(10**6)

dfs(0, 0)
# print(size)
for color in range(n):
    cnt = n
    while len(stack[color]) > 0:
        x = stack[color][-1]
        cnt -= size[x]
        stack[color].pop()
    # print("node:", -1, "color:", color, "cnt:", cnt)
    ans[color] -= cnt*(cnt+1)//2
    print(ans[color])


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a;  //動的配列aを宣言
	a.resize(n);    //aのサイズをｎに変更
	for (int i = 0;i < n;i++) cin >> a[i];

	int min, max;

	min = a[0];
	max = a[0];
	
	for (int i = 1;i < n;i++)
	{
		if (min > a[i]) min = a[i];
	}

	for (int j = 1;j < n;j++)
	{
		if (max < a[j]) max = a[j];
	}

	cout << max - min << endl;

	return 0;
}

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



long long mod = 1000000007;



int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, k;
	cin >> n >> k;
	
	long long arr[n+1];
	arr[0] = 0;
	for(int i = 1;i <= n;i++){
		cin >> arr[i];
		arr[i] %= k;
		arr[i] += arr[i-1];
	}
	
	
	for(int i = 0;i <= n;i++){
		arr[i] -= (i % k);
		while(arr[i] < 0) arr[i] += k;
		arr[i] %= k;
		
		//cout << arr[i] << " ";
	}
	
	long long ans = 0;
	unordered_map<int,int> m;
	for(int i = 0;i <= n;i++){
		if(i >= k) m[arr[i-k]]--;
		
		ans += m[arr[i]];
		
		m[arr[i]]++;
		
	}
	
	cout << ans;
	
	
}


Measured memory_bytes: 10056