akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,fl;
struct node{int x,y;}a[N];
void solve(int x,int y){
	for (int i=30;i>=0;i--)
	if (abs(x)>abs(y)){
		if (x>=0) {putchar('R');x-=1<<i;}
		else {putchar('L');x+=1<<i;}
	}
	else{
		if (y>=0) {putchar('U');y-=1<<i;}
		else {putchar('D');y+=1<<i;}
	}
}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		int x=read(),y=read();
		if (i==1) fl=(x+y)&1;
		if (((x+y)&1)!=fl){puts("-1");return 0;}
		if (!fl) x--;
		a[i]=(node){x,y};
	}
	puts((fl) ? "31" : "32");
	if (!fl) printf("1 ");
	for (int i=30;i>=0;i--) printf("%d ",1<<i);
	printf("\n");
	for (int i=1;i<=n;i++){
		if (!fl) putchar('R');
		solve(a[i].x,a[i].y);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	int a[n+1],b[n+1],sum=0,mix=99999,p;
	int c=0,d=0,e=0;
	for(int i=1;i<=n;i++)
	{
		a[i]=i+l-1;
		sum+=a[i];
		if(a[i]<0)
		{
			c=1;
		}
		if(a[i]>0)
		{
			d=1;
		}
		if(a[i]==0)
		{
			e=1;
		}
	}
	if(e==1)
	{
		cout<<sum;
		return 0;
	}
	if(c==1)
	{
		cout<<sum-a[n];
		return 0;
	}
	if(d==1)
	{
		cout<<sum-a[1];
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


int main() {
	int K, N;
	cin >> K >> N;
	int a[N];
	REP(i, 0, N) cin >> a[i];
	
	sort(a, a+N);
	int index_i = N-1;
	int index_j = 0;
	int max_diff = a[0] + K - a[index_i];
	int diff;
	REP(i, 0, N-1){
		diff = a[i+1] - a[i];
		if(diff > max_diff){
			max_diff = diff;
			index_i = i;
			index_j = i+1;
		}
	}
	
	if(index_i+1 == index_j){
		cout << a[index_i] + K - a[index_j] << "\n";
	}
	else cout << a[index_i] - a[index_j] << "\n";
}


Measured memory_bytes: 1024
N, x = map(int, input().split())
A = list(map(int, input().split()))

answer = 0
if A[0] > x:
    answer += A[0] - x
    A[0] = x
    
for i in range(N-1):
    diff = A[i] + A[i+1] - x
    if diff > 0:
        answer += diff
        A[i+1] -= diff

print(answer)


Measured memory_bytes: 14068
#include <iostream>

using namespace std;

int rs(int n, int dn, int d, int x) {
	if (d == dn) {
		if (x > n) {
			return 0;
		}
		
        int tx = x;
        bool c[3] = {0};
        while (tx > 0) {
            c[tx%10/2-1] = true;
            tx /= 10;
        }
        return c[0] && c[1] && c[2];
	}
	
	int ret = 0;
	for (int i = 3; i <= 7; i += 2) {
		ret += rs(n, dn, d + 1, x * 10 + i);
	}
	
	return ret;
}

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

    int ans = 0;
    for (int i = 3; i <= 9; i++) {
        ans += rs(n, i, 0, 0);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc083/tasks/abc083_a
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left";
  } else if (A + B < C + D) {
    cout << "Right";
  } else {
    cout << "Balanced";
  };
  return 0;
}


Measured memory_bytes: 256
temp=input().split()
N=int(temp[0])
K=int(temp[1])

r=[]
for i in range(1, N+1):
  temp=i
  counter=0
  while temp<K:
    temp*=2
    counter+=1
    
  r.append(counter)
    
print(sum([pow(0.5, r[i]) for i in range(N)])/N)

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;
const int MAX_VAL = 1000000000, INF = MAX_VAL + 1;

int sgn(int x) {
    if (x == 0) {
        return 0;
    }

    return x / abs(x);
}

int n, a[MAX_N + INDEX];

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

    cin >> n;

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

    a[0] = 0;

    int ans = 0, currentSgn = -1;
    for (int i = 1; i <= n; i++) {
        if (sgn(a[i] - a[i - 1]) != 0 && currentSgn != 0 && sgn(a[i] - a[i - 1]) != currentSgn) {
            ans++;

            currentSgn = 0;
        } else {
            if (currentSgn == 0) {
                currentSgn = sgn(a[i] - a[i - 1]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
	float n,max=0.0,min=0.0;
	
	while(cin>>n){
		if(max<n){
			max=n;
		}
		if(min==0){
			min=n;
		}else if(min>n){
			min=n;
		}
	}
	
	cout << max - min;
	
	return 0;
}

Measured memory_bytes: 1276
n = int(input())
ans = [0 for i in range(n)]
for x in range(1, n+1):
    if x ** 2 >= n:
        break
    for y in range(x, n+1):
        if x**2 + y**2 >= n:
            break
        for z in range(y, n+1):
            val = (x+y+z)**2 - x*y - y*z - z*x
            if val > n:
                break
            if x == y == z:
                ans[val-1] += 1
            elif x == y or y == z:
                ans[val-1] += 3
            else:
                ans[val-1] += 6
                
for i in ans:
    print(i)

Measured memory_bytes: 68856
from collections import defaultdict

n, m = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
cnt = defaultdict(int)

for x in a:
    cnt[x] += 1

for i in range(m):
    b, c = [int(item) for item in input().split()]
    cnt[c] += b

values = []
for x in cnt:
    values.append((x, cnt[x]))
values.sort(reverse=True)

ans = 0
tot = 0
for i in range(len(values)):
    c = min(n - tot, values[i][1])
    ans += values[i][0] * c
    tot += c

print(ans)


Measured memory_bytes: 104068
#include <iostream>
#include <string>
#include <set>

using namespace std;

int a_num, b_num, c_num;

multiset<string> st;

int main()
{
	cin >> a_num >> b_num >> c_num;
	for (int i = 1; i <= a_num; i++) st.insert("a");
	for (int i = 1; i <= b_num; i++) st.insert("b");
	for (int i = 1; i <= c_num; i++) st.insert("c");
	
	while (st.size() > 1)
	{
		string s = *st.begin(), t = *st.rbegin();
		st.erase(st.lower_bound(s)), st.erase(st.lower_bound(t));
		st.insert(s + t);
	}
	
	cout << *st.begin();
	
	return 0;
}

Measured memory_bytes: 3104
from math import sqrt
import heapq

def calc(arr, i, j):
    d = sqrt((arr[i][0] - arr[j][0])**2 + (arr[i][1] - arr[j][1])**2)
    if arr[i][2] + arr[j][2] <= d:
        return d - arr[i][2] - arr[j][2]
    else:
        return 0

def main():
    xs, ys, xt, yt = map(int, input().split())
    n = int(input())
    arr = [list(map(int, input().split())) for _ in range(n)]
    arr.append([xs, ys, 0])
    arr.append([xt, yt, 0])
    n += 2
    st = set()
    for i in range(n):
        st.add(i)
    dist = [float("inf")]*n
    dist[n-2] = 0
    dist[n-1] = calc(arr, n-2, n-1)
    hq = []
    heapq.heappush(hq, [0, n-2])
    while len(hq) > 0:
        _, p = heapq.heappop(hq)
        if p in st:
            st.remove(p)
            for nxt in st:
                d = calc(arr, p, nxt)
                if dist[nxt] > dist[p] + d:
                    dist[nxt] = dist[p] + d
                    heapq.heappush(hq, [dist[nxt], nxt])
    print(dist[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 130644
n = int(input())
s = []

for num in range(1, n//2+1):
    a = num
    b = n - num
    a_s = sum(list(map(int, str(a))))
    b_s = sum(list(map(int, str(b))))
    c = a_s + b_s
    s.append(c)

print(min(s))

Measured memory_bytes: 3464
H,W=list(map(int, input().split()))

grid=[]
S=""
for i in range(W+2):
    S = S+'#'
grid.append(S)
for i in range(H):
    grid.append('#'+input()+'#')
grid.append(S)

reached=[]
for i in range(H+2):
    reached.append([0*j for j in range(W+2)])

number_of_black_grid=0
for row in grid:
    number_of_black_grid += row.count('#')
s_x=1
s_y=1
g_x=W
g_y=H

def isGoal(x,y,g_x,g_y):
    if x==g_x and y==g_y:
        return True
    else:
        return False

def BFS_search(s_x, s_y, g_x, g_y):
    queue=[]
    queue.append([s_y, s_x, 0])
    reached[s_y][s_x]=0
    while len(queue)>0:
        v=queue.pop(0)
        if grid[v[0]+1][v[1]]=='.' and reached[v[0]+1][v[1]]==0 and [v[0]+1, v[1]]!=[s_y, s_x]:
            reached[v[0]+1][v[1]]=v[2]+1
            if isGoal(v[1], v[0]+1, g_x, g_y):
                break
            else:
                queue.append([v[0]+1, v[1], v[2]+1])
        if grid[v[0]][v[1]+1]=='.' and reached[v[0]][v[1]+1]==0 and [v[0], v[1]+1]!=[s_y, s_x]:
            reached[v[0]][v[1]+1]=v[2]+1
            if isGoal(v[1]+1, v[0], g_x, g_y):
                break
            else:
                queue.append([v[0], v[1]+1, v[2]+1])
        if grid[v[0]-1][v[1]]=='.' and reached[v[0]-1][v[1]]==0 and [v[0]-1, v[1]]!=[s_y, s_x]:
            reached[v[0]-1][v[1]]=v[2]+1
            if isGoal(v[1], v[0]-1, g_x, g_y):
                break
            else:
                queue.append([v[0]-1, v[1], v[2]+1])
        if grid[v[0]][v[1]-1]=='.' and reached[v[0]][v[1]-1]==0 and [v[0], v[1]-1]!=[s_y, s_x]:
            reached[v[0]][v[1]-1]=v[2]+1
            if isGoal(v[1]-1, v[0], g_x, g_y):
                break
            else:
                queue.append([v[0], v[1]-1, v[2]+1])

BFS_search(s_x, s_y, g_x, g_y)
if reached[g_y][g_x] == 0:
    print(-1)
else:
    maximum_score = ((H+2)*(W+2)-number_of_black_grid)-(reached[g_y][g_x]+1)
    print(maximum_score)


Measured memory_bytes: 3276
package main

import (
	"fmt"
)

func main() {
	var n, k int
	var d int
	fmt.Scan(&n, &k)
	//嫌いな数字は最小0から最大9のためスライス宣言は10まで
	flag := make([]bool, 10)
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		//ここで無視された値は初期値のfalseのままとなる
		flag[d] = true
	}
	var price int
	//値が存在しているかどうか
	for {
		//払うお金を代入最低金額は商品金額(n)
		price = n
		flagMin := true
		for flagMin && price > 0 {
			//一桁目のスライスの値が嫌いな数字の場合
			if flag[price%10] {
				flagMin = false
			}
			//一桁目を切り詰める
			//priceはint型のため小数点を切り捨てられる
			//最後は0になる
			price /= 10
		}
		//全桁嫌いな数字出なかった場合
		if flagMin {
			fmt.Println(n)
			break
		}
		//誤まっていた場合の払う金額カウントアップ
		n++
	}
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,d,x;cin>>n>>d>>x;
    int cnt=0;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        int day=1;
        while(day<=d){
            cnt++;
            day += a;
        }
    }
    cout<<cnt+x<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<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 all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


template<typename Monoid,typename OperatorMonoid=Monoid>
struct Segtree{
	using F=function<Monoid(Monoid,Monoid)>;
	using G=function<Monoid(Monoid,OperatorMonoid,int)>;
	using H=function<OperatorMonoid(OperatorMonoid,OperatorMonoid)>;
	int size=1;
	vector<Monoid>dat;
	vector<OperatorMonoid>lazy;
	const F f;
	const G g;
	const H h;
	Monoid M;
	OperatorMonoid OM;
	void set(int a,Monoid x){
		dat[a+size-1]=x;
	}
	void init(){
		for(int i=size-2;i>=0;i--){
			dat[i]=f(dat[i*2+1],dat[i*2+2]);
		}
	}
	void eval(int k,int l,int r){
		if(lazy[k]!=OM){
			dat[k]=g(dat[k],lazy[k],(r-l));
			if(r-l>1){
				lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2],lazy[k]);
			}
			lazy[k]=OM;
		}
	}
	void update(int a,int b,OperatorMonoid M,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			lazy[k]=h(lazy[k],M);
			eval(k,l,r);
			return;
		}
		update(a,b,M,k*2+1,l,(l+r)/2);
		update(a,b,M,k*2+2,(l+r)/2,r);
		dat[k]=f(dat[k*2+1],dat[k*2+2]);
	}
	Monoid query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return M;
		if(a<=l&&r<=b)return dat[k];
		Monoid lv=query(a,b,k*2+1,l,(l+r)/2);
		Monoid rv=query(a,b,k*2+2,(l+r)/2,r);
		return f(lv,rv);
	}
	Segtree(int x,F f,G g,H h,Monoid M,OperatorMonoid OM)
	:f(f),g(g),h(h),M(M),OM(OM){
		while(size<x)size*=2;
		dat.resize(size*2-1,M);
		lazy.resize(size*2-1,OM);
	}
};

int N,M;
vector<P>v[200005];
signed main(){
	cin>>N>>M;
	auto f=[](int a,int b){return max(a,b);};
	auto g=[](int a,int b,int sz){return a+b;};
	auto h=[](int a,int b){return a+b;};
	Segtree<int>segtree(N,f,g,h,0,0);
	rep(i,M){
		int l,r,m;cin>>l>>r>>m;l--;r--;
		v[r].pb({l,m});
	}
	rep(i,N){
		segtree.update(i,i+1,max(0ll,segtree.query(0,i)));
		for(P j:v[i]){
			segtree.update(j.first,i+1,j.second);
		}
	}
	cout<<max(0ll,segtree.query(0,segtree.size))<<endl;
}


Measured memory_bytes: 22544
#include <iostream>
#include <cstring>
#include <cstdlib>
#define MAXN 55
using namespace std;
char a[MAXN], b[MAXN];
int main() {
    cin >> a >> b;
    int len, mx = -1, loc = -1, l1, l2, loc1 = -1;
    l1 = strlen(a), l2 = strlen(b);
    if(l1 < l2) {
        cout << "UNRESTORABLE\n";
        return 0;
    }
    for(int i = 0; i < l1; i++) {
        if(a[i] == '?') len ++;
        else len = 0;
        if(len > mx) {
            mx = len; 
            loc1 = i;
        }
    }
    for(int i = 0; i < l1-l2+1; i++) {
        int k = i, flag = 1;
        for(int j = 0; j < l2; j++, k++) {
            if(a[k] == '?') continue;
            if(a[k] != b[j]) {
                flag = 0;
                break;
            }
        }
        if(flag) 
            loc = i;
    }
    if(loc != -1) {
        for(int i = 0; i < loc; i++) {
            if(a[i] == '?') cout << 'a';
            else cout << a[i];
        }
        cout << b;
        for(int i = loc+l2; i < l1; i++) {
            if(a[i] == '?') cout << 'a';
            else cout << a[i];
        }
    }else {
        if(mx < l2 || loc1 == -1) 
            cout << "UNRESTORABLE\n";
        else {
            for(int i = 0; i <= l1-loc1; i++) {
                if(a[i] == '?') cout << 'a';
                else cout << a[i];
            }
            cout << b;
            for(int i = loc1+1; i < l1; i++) {
                if(a[i] == '?') cout << 'a';
                else cout << a[i];
            }
        }
    }
    // system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int a[21],b[21],c[19];
	int i,j,k,sum;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(j=1;j<=n;j++){
		scanf("%d",&b[j]);
	}
	for(k=1;k<=n-1;k++){
		scanf("%d",&c[k]);
	}
	sum=0;
	for(i=1;i<=n;i++){
		sum+=b[a[i]];
	}
	for(i=1;i<=n-1;i++){
		if(a[i]+1==a[i+1]){
			sum+=c[a[i]];
		}
	}
	printf("%d\n",sum);
	return 0;
}


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

#define sz(a) int(a.size())
typedef long long ll;

int main(){
	int a,b;
	cin >> a >> b;
	vector<int>x,y;
	int c = b/0.1;
	for(int i = c;i < c+10;i++){
		x.emplace_back(i);
	}
	c = a/0.08;
	for(int i = c+(a%2);i < c + 12;i++){
		y.emplace_back(i);
	} 
	sort(y.begin(),y.end());
	for(int i = 0;i< x.size();i++){
		for(int j = 0;j < y.size();j++){
			if(x[i] == y[j]){
				cout << x[i] << endl;
				return 0;
			}
		}
	}
	cout << -1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    ll sum = a[0];
    ll ans1 = 0;
    if(sum <= 0){
        ans1 += 1+abs(sum);
        sum = 1;
    }
    rep(i,n-1){
        if(sum < 0){ // 次は正に
            if(a[i+1]+sum > 0) sum += a[i+1];
            else{
                ans1 += abs(1-(a[i+1]+sum));
                sum = 1;
            }
        }else{  // 次は負に
            if(a[i+1]+sum < 0) sum += a[i+1];
            else{
                ans1 += abs(-1-(a[i+1]+sum));
                sum = -1;
            }
        }
    }
    sum = a[0];
    ll ans2 = 0;
    if(sum >= 0){
        ans2 += a[0]+1;
        sum = -1;
    }
    rep(i,n-1){
        if(sum < 0){ // 次は正に
            if(a[i+1]+sum > 0) sum += a[i+1];
            else{
                ans2 += abs(1-(a[i+1]+sum));
                sum = 1;
            }
        }else{  // 次は負に
            if(a[i+1]+sum < 0) sum += a[i+1];
            else{
                ans2 += 1+(a[i+1]+sum);
                sum = -1;
            }
        }
    }
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
 
struct block {
    int w, s, v;
};
 
bool cmp(const block &x, const block &y) {
    return x.w + x.s > y.w + y.s;
}
 
const int N = 2e4+10;
int memo[N];
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<block> arr(n);
    for(int i = 0; i < n; ++i) {
        cin >> arr[i].w >> arr[i].s >> arr[i].v;
    }
    sort(arr.begin(), arr.end(), cmp);
    int res = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < N; ++j) {
            if(j <= arr[i].s) {
                memo[j] = max(memo[j], arr[i].v + memo[j+arr[i].w]);
                res = max(res, memo[j]);
            }
        }
    }
    cout << res << '\n';
}
 
 
 
 
 

Measured memory_bytes: 384
import collections

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

As.sort(reverse = True)

#print(As)

circle_que = collections.deque()

circle_que.append(As[0])

ans = 0
for A in As[1:]:
    circle_que.append(A)
    circle_que.append(A)

    ans += circle_que.popleft()
    #print(ans)

print(ans)

Measured memory_bytes: 32352
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        long[][] memo = new long[n+1][5];

        for(int i=0; i<n; i++) {
            int d0 = a[i];
            int d2 = a[i] == 0 ? 2 : (a[i]%2);
            int d1 = (a[i]+1) % 2;
            memo[i+1][0] = memo[i][0] + d0;
            memo[i+1][1] = Math.min(memo[i][0], memo[i][1]) + d2;
            memo[i+1][2] = Math.min(memo[i][0], Math.min(memo[i][1], memo[i][2])) + d1;
            memo[i+1][3] = Math.min(memo[i][0], Math.min(memo[i][1], Math.min(memo[i][2], memo[i][3]))) + d2;
            memo[i+1][4] = Math.min(memo[i][0], Math.min(memo[i][1], Math.min(memo[i][2], Math.min(memo[i][3], memo[i][4])))) + d0;
        }
        Arrays.sort(memo[n]);
        System.out.println(memo[n][0]);

    }

}


Measured memory_bytes: 101080
from math import *

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]
xy.sort(key=lambda t: atan2(t[1], t[0]))
ans = 0

for i in range(N):
    nx, ny = 0, 0
    
    for j in range(i, i+N):
        nx += xy[j%N][0]
        ny += xy[j%N][1]
        ans = max(ans, (nx**2+ny**2)**0.5)

print(ans)

Measured memory_bytes: 39024
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String a=sc.next();
    String b=sc.next();
    String c=sc.next();
    if (a.charAt(a.length()-1)==b.charAt(0)&&b.charAt(b.length()-1)==c.charAt(0)) {
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

int main(){
  string S;
  cin>>S;
  ll K;
  cin>>K;
  char j='1';
  for(int i=0;i<K;i++){
    if(S[i]!='1'){
      j=S[i];break;
    }
  }
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
LL ans;
pa a[555];
int n;
bool cmp(pa x,pa y){
	return (x.se-x.fi>y.se-y.fi);
}
int main(){
	cin>>n;
	FOR(i,1,3) cin>>a[i].fi;
	FOR(i,1,3) cin>>a[i].se;
	sort(a+1,a+3+1,cmp);
	ans=n;
	if (a[3].se>a[3].fi){
		FOR(i,0,n/a[1].fi)
			FOR(j,0,(n-a[1].fi*i)/a[2].fi){
				LL k=(n-a[1].fi*i-a[2].fi*j)/a[3].fi;
				ans=max(ans,1ll*n+i*(a[1].se-a[1].fi)+j*(a[2].se-a[2].fi)+k*(a[3].se-a[3].fi));
			}
	}
	else if (a[2].se>a[2].fi){
		FOR(i,0,n/a[1].fi)
			FOR(j,0,(n-a[1].fi*i)/a[2].fi){
				LL t=n+i*(a[1].se-a[1].fi)+j*(a[2].se-a[2].fi);
				LL k=t/a[3].se;
				ans=max(ans,t+k*(a[3].fi-a[3].se));
			}
	}
	else if (a[1].se>a[1].fi){
		LL t=n+n/a[1].fi*(a[1].se-a[1].fi);
		FOR(j,0,t/a[2].se){
			LL k=(t-1ll*a[2].se*j)/a[3].se;
			ans=max(ans,t+1ll*j*(a[2].fi-a[2].se)+k*(a[3].fi-a[3].se));
		}
	}
	else{
		FOR(i,0,n/a[1].se)
			FOR(j,0,(n-a[1].se*i)/a[2].se){
				LL k=(n-a[1].se*i-a[2].se*j)/a[3].se;
				ans=max(ans,1ll*n+i*(a[1].fi-a[1].se)+j*(a[2].fi-a[2].se)+k*(a[3].fi-a[3].se));
			}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong ios_base::sync_with_stdio(0); cin.tie(0);

using namespace std;
int n;
int ans=1e9;

int getsum(int x)
{
    int res=0;
    while(x>0)
    {
        res+=x%10;
        x/=10;
    }
    return res;
}

int main()
{
    Phuong;
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for(int i=1; i<n; ++i)
    {
        int sumA=getsum(i);
        if (sumA > ans) continue;
        int sumB=getsum(n-i);
        if (sumB+sumA < ans) ans=sumB+sumA;
    }
    cout << ans;

    return 0;
}


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

int main(int argc, const char * argv[]) {
    
    int jikan[4];
    int sec=0;
    int min=0;
    
    for(int i=0;i<4;i++){
        cin >> jikan[i];
    }
    
    
    
    for(int i=0;i<4;i++){
        sec+=jikan[i];
        while(sec>=60){
            min++;
            sec-=60;
        }
    }
    
    cout << min << endl;
    cout << sec << endl;
    
    return 0;
}

Measured memory_bytes: 3068
/*****include*****/
#include <iostream>
#include <fstream>
#include <math.h>

/*****デバッグ定義*****/
//#define DEBUG
#define PI 3.14
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	int walk=0,degree=0,last_degree;
	double x_ax,y_ax;
	/*****処理部*****/
	last_degree = 90;
	x_ax = 0;
	y_ax = 0;
	while(1){
		scanf("%d,%d",&walk,&degree);
		if(walk == 0 && degree == 0)	break;
		//printf("%d\n%d\n",walk,degree);
		x_ax += (double)walk * cos((double)last_degree * PI / 180);
		y_ax += (double)walk * sin((double)last_degree * PI / 180);
		last_degree = last_degree - degree;
	}
	printf("%d\n%d\n",(int)x_ax,(int)y_ax);
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

Measured memory_bytes: 1192
// https://atcoder.jp/contests/dp/tasks/dp_e
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll n, w;
    cin >> n >> w;
    ll weight[n + 1], value[n + 1];
    for (ll i = 1; i <= n; i++)
        cin >> weight[i] >> value[i];
    ll sum = accumulate(value + 1, value + n + 1, 0);
    ll dp[n + 1][sum + 1];
    for (ll i = 0; i <= sum; i++)
        dp[0][i] = infinity;
    for (ll i = 0; i <= n; i++)
        dp[i][0] = 0;
    for (ll i = 1; i <= n; i++)
        for (ll j = 1; j <= sum; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j - value[i] >= 0)
                dp[i][j] = min(dp[i][j], weight[i] + dp[i - 1][j - value[i]]);
        }
    for (ll j = sum; j >= 0; j--)
        if (dp[n][j] <= w)
        {
            cout << j << endl;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int n;
	 cin>>n;
	 vector<int>h(n);
	 for(int i=0;i<n;i++)
	 	cin>>h[i];
	 vector<int>dp(n);
	 dp[0]=0;
	 dp[1]=abs(h[1]-h[0]);
	 for(int i=2;i<n;i++)
	 {
	 	   dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	 }
	 cout<<dp[n-1]<<endl;
	 return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pb push_back
#define pii pair<int,int>
using namespace std;
int n,a[16][16];
ll val[1<<16],dp[1<<16];
main() {
    cin >> n;
    for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
        cin >> a[i][j];
    for (int mask = 0; mask < (1<<n); mask++) {
        for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++)
            if ( (1<<i)&mask && (1<<j)&mask)
                val[mask] += a[i][j];
    }
    for (int mask = 0; mask < (1<<n); mask++) {
        for (int sub = mask; sub; sub = (sub-1)&mask) {
            dp[mask] = max(dp[mask],val[sub] + dp[mask^sub]);
        }
    }
    cout << dp[(1<<n)-1];
}


Measured memory_bytes: 4600
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct edge{
	int t,next;
}g[400001];
int a[200001],i,j,k,n,m,tot,h[200001],w[200001][3],v[200001][12],tq;
void addedge(int x,int y){
	g[++tot].t=y;g[tot].next=h[x];h[x]=tot;
	g[++tot].t=x;g[tot].next=h[y];h[y]=tot;
}
void work(int x,int y,int z){
	int i;
	v[x][y]=1;
	if (!a[x]) a[x]=z;
	if (!y) return;
	for (i=h[x];i;i=g[i].next)
	 if (!v[g[i].t][y-1]) work(g[i].t,y-1,z);
}
int main(){
	scanf("%d%d",&n,&m);tot=0;memset(h,0,sizeof(h));memset(a,0,sizeof(a));memset(v,0,sizeof(v));
	for (i=1;i<=m;i++) scanf("%d%d",&j,&k),addedge(j,k);
	scanf("%d",&tq);
	for (i=1;i<=tq;i++) scanf("%d%d%d",&w[i][0],&w[i][1],&w[i][2]);
	for (i=tq;i;i--) work(w[i][0],w[i][1],w[i][2]);
	for (i=1;i<=n;i++) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 16896
#include <stdio.h>
#include <math.h>

typedef struct point {
    double x, y;
} point;

double distance(const point *p1, const point *p2) {
    double x1, y1, x2, y2;
    x1 = p1->x;
    y1 = p1->y;
    x2 = p2->x;
    y2 = p2->y;
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main(void) {

    point p1, p2;

    scanf("%lf %lf %lf %lf",
          &p1.x, &p1.y, &p2.x, &p2.y);

    printf("%lf\n", distance(&p1, &p2));

    return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

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

	vector<int> p(N);
	for(int i=0; i<N; i++)
	{
		cin>>p[i];
	}

	vector<int> answer = p;
	sort(answer.begin(),answer.end());
	int correct = 0;
	for(int i=0; i<N; i++)
	{
		if(p[i]==answer[i])
		{
			correct++;
		}
	}

	if(correct>=answer.size()-2)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.nextLine();
			int ab = Integer.parseInt(s.replaceAll(" ", ""));
			int sqrt = (int) Math.sqrt(ab);
			System.out.println((sqrt * sqrt == ab) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 21844
L,R=map(int, input().split())
m = 2020
for i in range(L,R+1):
    for j in range(L+1,R+1):
        if i == j:
            continue
        if i*j%2019 < m:
            m = i*j%2019
        if m == 0:
            break
    if m == 0:
        break
print(m)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int sum = 0;
  int i;
  for (i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  cout << max(-1, n - sum) << endl;
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
const ll INF = 1000000000000007;

using namespace std;

int main(){
    string S,res = "";
    cin >> S;
    ll K;
    cin >> K;
    ll kazu;

    ll S_Size = S.size();
    if(S_Size % 2 == 1)
    {
      kazu = S_Size * (S_Size/2 + 1);
    }
    else
    {
      kazu = (S_Size+1) * S_Size/2;
    }

    vector <string> v(kazu);

    ll cnt = 0;

    for(ll i = 1; i <= 5; i++)
    {
      for(ll j = 0; j + i <= S_Size; j++)
      {
        //Kは5以下のため、K以下の値を格納すればよい
        if(cnt > 0 && v[cnt-1] == S.substr(j,i))continue;
        v[cnt] = S.substr(j, i);
        cnt++;
      }
    }

    sort(v.begin(),v.end());

    cnt = 0;
    string b4t = "";
    // find K
    for(auto t:v)
    {
      if(b4t == t)continue;
      cnt++;
      b4t = t;
      if(cnt == K)
      {
        res = t;
        break;
      }
    }
    cout << res << endl;

    return 0;

}

Measured memory_bytes: 99072
#include<bits/stdc++.h>
using namespace  std;
#define ll long long int
ll num(ll n)
{
  ll count=0;
  while(n>0)
  {
    count++;
    n=n/10;
  }
  return count;
}
int main()
{
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++)
  {
    if(num(i)%2!=0)
    {
      ans++;
    }
  }
  cout<<ans;
}
  

Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val s = in.readLine
  val digit = s.size
  val N = s.toInt

  def dfsEnum(d:Int, n:Int):Int = {
    // d進 n個列挙
    val enum = Array.ofDim[Int](n)
    var ret = 0
    var terms = true //仮変数 実装時置き換える
  
    def evalute():Unit = {
      if(!n753.indices.forall(i => enum.exists(_ == n753(i)))) return
      val num = enum.mkString.toInt
      if(num <= N) {
        ret += 1
        // println(num)
      }
    }
  
    def dfs(cnt:Int):Unit = {
      if(cnt == n) evalute
      else {
        for(i <- n753) {
          enum(cnt) = i
          dfs(cnt+1)
        }
      }
    }
  
    dfs(0)
    ret
  }

  val n753 = Array(3,5,7)
  val ans = (3 to digit).map(i => dfsEnum(n753.size, i)).sum
  println(ans)
}

Measured memory_bytes: 39792
n = int(input())
a = [num for num in map(int, input().split())]
a.insert(0, 0)

# print(n)
# print(a)

ans = 0
m = {}

for j in range(1, n+1):
  # j - A[j] = A[i] + i となるペアがあれば ans に加算
  j_val = j - a[j]
  if j_val in m:
    ans += m[j_val]
  
  # A[i] + i となる数をインクリメント
  i_val = a[j]+j
  if i_val in m:
    m[i_val] += 1
  else:
    m[i_val] = 1
print(ans)

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

int main() {
  int n,m; cin>>n>>m;
  vector<int> p(n+1);
  for(int i=0;i<m;i++) {
    int a,b; cin>>a>>b; a--;b--;
    p[a]++; p[b]++;
  }
  for(int i=0;i<n;i++) {
    if (p[i]%2 == 1) {
      cout<<"NO"<<endl; return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 1152
N = int(input())
l = list(map(int,input().split()))
cost = [0] * N
cost[1] = abs (l[1] - l[0])

for i in range(2,N):
    cost[i] = min(cost[i-1]+abs(l[i]-l[i-1]), cost[i-2]+abs(l[i]-l[i-2]))
print(cost[N-1])        

Measured memory_bytes: 20508
while True:
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r == -1:
		break
	if m == -1 or f == -1:
		print("F")
	elif m + f >= 80:
		print("A")
	elif m + f >= 65:
		print("B");
	elif m + f >= 50:
		print("C")
	elif m + f >= 30:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")


Measured memory_bytes: 5592
#include <cstdio>

typedef long long ll;

const ll mod = 1000000007;

ll pow(ll n, ll r)
{ // n^r % mod
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if ((r % 2) == 0)
    {
        ll a = pow(n, r / 2);
        return (a * a) % mod;
    }
    else
    {
        ll a = pow(n, r / 2);
        return (((a * a) % mod) * n) % mod;
    }
}

ll C(ll n, ll r)
{
    ll A = 1;
    ll B = 1;

    for (ll i = 1; i <= n; i++)
    {
        A = (A * i) % mod;
    }
    for (ll i = 1; i <= n - r; i++)
    {
        B = (B * i) % mod;
    }
    for (ll i = 1; i <= r; i++)
    {
        B = (B * i) % mod;
    }

    return (A * pow(B, mod - 2)) % mod;
}

ll H(ll n, ll r)
{
    return C(n + r - 1, r);
}

int main(void)
{
    ll S;
    scanf("%lld", &S);

    ll sum = 0;

    for (ll i = 1; i <= S / 3; i++)
    {
        sum = (sum + H(i, S - (3 * i))) % mod;
    }
    printf("%lld\n", sum);

    return 0;
}

Measured memory_bytes: 1732
from math import floor
def myAnswer(A:int,B:int) -> int:
   price = 1
   while True:
      if(floor(price*0.08)==A and floor(price*0.1)==B):
         return price
      elif(floor(price*0.08)>A or floor(price*0.1)>B):
         return -1
      else:
         price+=1
   

def modelAnswer():
   tmp=1
def main():
   A,B = map(int,input().split())
   print(myAnswer(A,B))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
array = gets.split.map{|a|a.to_i}
n,m = array[0], array[1]
ki =[]
for i in(0..n-1)
  ki[i] = gets.split.map{|a|a.to_i}
  ki[i].shift
end
ans =0

for i in(1..m)
  num = 0
  for j in(0..n-1)
  if ki[j].include?(i)
    num +=1
  end
  if num== n then
    ans +=1
  end
end
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll a,b,c,k; cin >> a >> b >> c >> k;

    ll ans=0, cnt=0;
    if(a>=k){
        ans+=k;
        cout << ans << endl;
        return 0;
    }else{
        if(a+b>=k){
            ans+=a;
            cout << ans << endl;
        }else{
            ans+=a;
            ans-=(k-a-b);
            cout << ans << endl;
            return 0;
        }
    }
    
    return 0;
}


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

int N, Y;
int n10000 = -1, n5000 = -1, n1000 = -1;
// n10000 = n5000 = n1000 = -1;

int main(int argc, char *argv[]){
    cin >> N >> Y;

    rep(i, N+1){
        rep(j, N+1){
            if(i + j > N) break;
            int k = N - i - j;
            if(k < 0) break;

            int n = 10000 * i + 5000 * j + 1000 * k;
            if(n == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        } 
    }
    cout << n10000 << " " << n5000 << " " << n1000 << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
MOD=10**9+7
fac=[0]*2*10**5
finv=[0]*2*10**5
inv=[0]*2*10**5
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,2*10**5):
    fac[i]=(fac[i-1]*i)%MOD
    inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD
def COM(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
ans=0
for i in range(n):
    ans+=a[i]*COM(i,k-1)
    ans-=a[i]*COM(n-i-1,k-1)
    ans=ans%MOD
    #print(ans)
print(ans)

Measured memory_bytes: 31448
<?php
fscanf(STDIN, "%d%d%d", $N, $M, $Q);
for($i = 1; $i <= $N; $i++){
  for($j = 0; $j <= $N; $j++){
    $map[$i][$j] = 0;
  }
}
for($i = 0; $i < $M; $i++){
  fscanf(STDIN, "%d%d", $L, $R);
  $map[$L][$R] += 1;
}
for($i = 1; $i <= $N; $i++){
  for($j = 1; $j <= $N; $j++){
    $map[$i][$j] = $map[$i][$j] + @$map[$i][$j-1];
  }
}
for($i = 1; $i <= $Q; $i++){
  fscanf(STDIN, "%d%d", $L, $R);
  if(!isset($q[$L][$R])){
    $sum = 0;
    for($j = $L; $j <= $R; $j++){
      $sum += $map[$j][$R] - @$map[$j][$L-1];
    }
    $q[$L][$R] = $sum;
  }
  echo $q[$L][$R],"\n";
}



function o($val){
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 21496
#include<stdio.h>

int main(){
    int N, X;
    scanf("%d %d", &N, &X);
    int m[N];
    int min = 1000;
    for(int i = 0; i < N; i++){
        scanf("%d", &m[i]);
        X = X - m[i];
        if(m[i] < min){
            min = m[i];
        }
    }
    int res = N;
    res = N + X/min;
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 128
S = [[], [], []]
S[0] = list(input())
S[1] = list(input())
S[2] = list(input())
i = 0
while True:
    if len(S[i]) == 0:
        print(chr(i + 97 - 32))
        break
    j = ord(S[i][0]) - 97
    del S[i][0]
    i = j


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int p[55];
    REP(i, N) cin >> p[i];
    int count = 0;
    REP(i,N){
        if(p[i] != i+1) count ++;
    }
    if(count == 2 || count == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int h,w,ans=2000000,a[30][30];
int main(void){
      cin>>h>>w;
      for(int i=0;i<h;i++){
          for(int j=0;j<w;j++){
              cin>>a[i][j];
          }
      }
      for(int i=0;i<h;i++){
          for(int j=0;j<w;j++){
              int s=0;
              for(int x=0;x<h;x++){
                  for(int y=0;y<w;y++){
                      s+=min(abs(i-x),abs(j-y))*a[x][y];
                  }
              }
              ans=min(ans,s);
          }
      }
      cout<<ans<<endl;
}



Measured memory_bytes: 3140
#include <cstdio>

int main() {
    int i, a, b, c;
    int div = 0;
    scanf("%d %d %d", &a, &b, &c);

    for (i = a; i <= b; i++) {
        if (c % i == 0) ++div;
    }
    printf("%d\n", div);
    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
S = set()
for i in range(K):
    INT()
    S |= set(LIST())
ans = N - len(S)
print(ans)


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,k; cin>>n>>k;
  ll ans=n-k+1;
  if(ans<0) ans=0;
  cout<<ans<<endl;
  
}

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

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  multiset<int> st;
  for(int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    st.insert(a);
  }

  int ans = 0;
  while (!st.empty())
  {
    int last = *(--st.end());
    st.erase(--st.end());
    int two = 1;
    while (two <= last)
      two <<= 1;
    auto itr = st.find(two - last);
    if (itr == st.end())
      continue;
    ++ans;
    st.erase(itr);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 13036
s = input()
if s[0] == s[1] and s[0] == s[2]:
	print('No')
elif (s[0] == s[1] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2]):
	print('Yes')
else:
	print('No')

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

int N,K;
const int MAX_N = 5005;
int a[MAX_N];
int dp[MAX_N][MAX_N],dp2[MAX_N];

int main(){
	ios::sync_with_stdio(false);

	cin >> N >> K;
	for(int i=1;i<=N;i++){
		cin >> a[i]; 
	}

	dp[0][0] = 1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<K;j++){
			dp[i][j] = dp[i-1][j];
			if(j>=a[i])dp[i][j] |= dp[i-1][j-a[i]];
		}
	}
	for(int i=0;i<=N;i++){
		for(int j=1;j<K;j++){
			dp[i][j] += dp[i][j-1];
		}
	}

	int ans = 0;
	dp2[0] = 1;
	for(int i=N;i>=1;i--){
		bool ok = a[i]<K;
		if(a[i]<K){
			for(int j=0;j<K;j++){
				if(!dp2[j])continue;
				if(dp[i-1][K-j-1]-(K>=j+a[i]+1?dp[i-1][K-j-a[i]-1]:0) > 0){
					ok = false;
					break;
				}
			}
		}
		if(ok)ans++;
		for(int j=K-1;j>=a[i];j--){
			dp2[j] |= dp2[j-a[i]];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 98048
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	public void run(){
		n = sc.nextInt();
		solve();
	}
	public void solve(){
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
const int INF = 1 << 30;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi d(n+1, 0);
    rep(i, n){
        d.at(i+1) += d.at(i);
        if(s.at(i) == 'W') d.at(i+1)++;
    }
    int min_ = INF;
    int left, right;
    rep(i, n){
        left = d.at(i);
        right = (n-i-1)-(d.at(n)-d.at(i+1));
        min_ = min(left+right, min_);
    }
    cout << min_ << endl;
    return 0;
}

Measured memory_bytes: 1796
s = input()
ss = s[::-1]
s3 = ""
for i,j in enumerate(ss):
  if j == "p":
      s3 += "q"
  elif j == "q":
      s3 += "p"
  elif j == "b":
      s3 += "d"
  else:
      s3 += "b"
if s == s3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
        int a,b;

        scanf("%d %d",&a,&b);

        if(a > b){
                printf("a > b\n");
        }else if(a == b){
                printf("a == b\n");
        }else if(a < b){
                printf("a < b\n");
        }
        return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(ll a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,x;
	cin>>n>>x;
	ll x1=x;
	vector<ll>a(n);
	ll sum=0;
	rep(i,n){cin>>a[i];sum+=a[i];}
	Sort(a);
	ll till=0;
	rep(i,n){
		if(x<a[i]){till=i;break;}
		x-=a[i];
		if(i==n-1){till=n;}
	}
	if(sum<x1){till--;}
	cout<<till<<endl;
	return 0;
}

Measured memory_bytes: 256