akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
b = list(set(a))

if len(b) != 3:
    if sum(a) == 0:
        pass
    elif a.count(max(b)) == 2*n/3 and a.count(0) == n/3:
        pass
    else:
        print("No")
        exit()
else:
    if b[0] ^ b[1] == b[2] and a.count(b[0]) == a.count(b[1]) == a.count(b[2]):
        print("Yes")
        exit()
    else:
        print("No")
        exit()
        
print("Yes")

Measured memory_bytes: 60916
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,d,k;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&k);
	int a1=a*60+b;
	int c1=c*60+d;
	int k1=c1-a1-k;
	printf("%d",k1);
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,cnt=0;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  for(ll i=0;i<n;i++){
    cnt += a[i]/2;
    a[i]=a[i]%2;
    if(a[i]==1){
      if(i!=0&&a[i-1]>=1){
        a[i-1]=a[i]=0;
        cnt++;
      }else if(i!=n-1&&a[i+1]>=1){
        a[i]=0;
        a[i+1]--;
        cnt++;
      }
    }
  }
  cout << cnt<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main()
{
    ll n;
    cin>>n;
    rep(i,9)rep(j,9)if((i+1)*(j+1)==n){
        yn(1);
        exit(0);
    }
    yn(0);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (1e18)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[110][100010];

int32_t main() {
	INIT();
	//code...
	int n,k; cin>>n>>k;
	dp[0][0]=1; For(i,1,k) dp[0][i]=0;
	For(i,1,n){
		int t; cin>>t;
		int now=0;
		For(j,0,k){
			now=(now+dp[i-1][j])%MOD;
			dp[i][j]=now;
			if(j>=t) now=(now-dp[i-1][j-t]+MOD)%MOD;
		}
	}
	cout<<dp[n][k]<<"\n";
	return 0;
}

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

N = int(raw_input())
A = map(int, raw_input().split())
B = [A[0]]
for ai in A[1:]:
    if B[-1] != ai:
        B.append(ai)
A = B[:]
N  = len(A)

ans = 1
i = 0
while i < N - 2:
    if A[i] <= A[i + 1] <= A[i + 2]:
        i += 1
    elif A[i] >= A[i + 1] >= A[i + 2]:
        i += 1
    else:
        ans += 1
        i += 2

print ans


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

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int n, m, q, ans;
vector<int> a, b, c, d;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  // cout << "n = " << n << ", "
  //   << "m = " << m << endl;
  ans = 0;
  dfs(vector<int>(1, 1));
  // vector<int> h(2);
  // h[1]=2;
  // cout<<h.back()<<endl;;
  cout << ans << endl;
}

Measured memory_bytes: 3588
# M=int(input())
# N,K=list(map(int,input().split()))
# inl = [int(input()) for i in range(N)]

s = input()
cnt = 0
for i in range(len(s)):
    if s[i] == 'x':
        cnt+=1


if cnt >= 8:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1480
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

#include<unordered_set>

ll N;

// N = K^a * (1+bK) の形か？ (a=0) も OK

signed main(){
    cin >> N;

    if(N == 2){
        cout << 1 << endl;
        return 0;
    }

    // a >= 1 の場合
    // 約数を列挙
    unordered_set<ll> st;
    for(ll i=2; i*i<=N; i++){
        if(N%i != 0) continue;
        
        ll n = N;
        while(n%i == 0) n /= i;
        n--;
        if(n%i == 0) st.insert(i);

        i = N/i;

        n = N;
        while(n%i == 0) n /= i;
        n--;
        if(n%i == 0) st.insert(i);

        i = N/i;
    }

    st.insert(N);

    // a = 0 の場合
    // N-1 の約数を列挙
    N--;
    for(ll i=2; i*i<=N; i++){
        if(N%i != 0) continue;

        st.insert(i);
        st.insert(N/i);
    }

    st.insert(N);

    cout << st.size() << endl;
    //for(auto itr=st.begin(); itr!=st.end(); itr++) cout << *itr << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[2][100][2];
int main() {
	string K;
	int D;
	cin >> K >> D;
	int N = K.size();
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		int d = K[i] - '0';
		for (int j = 0; j < D; j++) {
			for (int k = 0; k <= d; k++) {
				(dp[(i + 1) & 1][(j + k) % D][k < d] += dp[i & 1][j][0]) %= MOD;
			}
			for (int k = 0; k < 10; k++) {
				(dp[(i + 1) & 1][(j + k) % D][1] += dp[i & 1][j][1]) %= MOD;
			}
		}
		for (int j = 0; j < D; j++) dp[i & 1][j][0] = dp[i & 1][j][1] = 0;
	}
	ll ans = dp[N & 1][0][0];
	(ans += dp[N & 1][0][1]) %= MOD;
	(ans += MOD - 1) %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
n = int(input())
lst1 = list(map(int,input().split()))

for i in range(n):
    lst1[i] = lst1[i] - (i+1)
lst1.sort()



service = bisect.bisect_left(lst1,0)
limit = len(lst1)//2

b = lst1[limit]

ans = 0
for i in range(n):
    ans += abs(lst1[i] - b)

print(ans)

Measured memory_bytes: 86612
// Problem : C - Maximum Volume
// Contest : AtCoder - AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli l;
	double dd;
	cin>>l;
	l=l*l*l;
	dd=l/27.0;
	cout<<fixed<<setprecision(12)<<dd;	
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;


void solve() {
	int m, d; cin >> m >> d;
	int ans = 0;
	rep1(i, m) {
		rep1(j, d) {
			if (j < 10)continue;
			int d0 = j % 10;
			int d1 = j / 10;
			if (d0 >= 2 && d1 >= 2 && d0*d1 == i) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 256
N, X, Y = [int(i) for i in input().split()]

counts = [0 for _ in range(N-1)]

for n1 in range(1, N):
  for n2 in range(n1+1, N+1):
    if n2 >= Y:
      upper = n2 - Y
    else:
      upper = Y - n2
    if n1 <= X:
      lower = X - n1
    else:
      lower = n1 - X
    diff = min(n2 - n1, upper + lower + 1)
    counts[diff-1] += 1
for c in counts:
  print(c)
    
    

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

int main() {
	// your code goes here
	double a[105],x=1,y=0;
	int i,n;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> a[i];
		x=x*a[i];
	}
	for(i=1;i<=n;i++){
		y=y+x/a[i];
	}
	printf("%.10f\n",x/y);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n;
	cin>>n;
	ll A[n];
	for(int i=0;i<n;i++){
		ll h;
		cin>>h;
		A[i]=h;
	}
	ll dp[n]={0};
	dp[0]=0;
	dp[1]=abs(A[1]-A[0]);
	for(int i=2;i<n;i++){
		dp[i]=min( dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 5108
#include <stdio.h>

int main(int argc, char *argv[])
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
	if(y >= r && H - y >= r && x >= r && W - x >= r){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2104
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Tuple (swap)
import Data.List (sortBy)
import Data.Function (on)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    initialize :: [(Int, Int)] -> (IS.IntSet, Int, Int, [Int], [(Int, Int)])
    initialize = go k IS.empty 0 0 []
      where
        go :: Int -> IS.IntSet -> Int -> Int -> [Int] -> [(Int, Int)] -> (IS.IntSet, Int, Int, [Int], [(Int, Int)])
        go 0 us0 dp0 tp0 ds0 cs0 = (us0, dp0, tp0, ds0, cs0)
        go c us dp tp ds ((d, t) : dts)
            | IS.member t us = go c' us dp' tp ds' dts
            | otherwise      = go c' us' dp' tp' ds dts
          where
            c' = pred c :: Int
            us' = IS.insert t us :: IS.IntSet
            dp' = dp + d :: Int
            tp' = succ tp :: Int
            ds' = d : ds :: [Int]
    maxSP ::  (IS.IntSet, Int, Int, [Int], [(Int, Int)]) -> Int
    maxSP (us0, dp0, tp0, ds0, cs0) = go cs0 us0 ds0 dp0 tp0 sp0
      where
        sp0 = dp0 + tp0 ^ 2 :: Int
        go :: [(Int, Int)] -> IS.IntSet -> [Int] -> Int -> Int -> Int -> Int
        go ((d, t) : cs') us ds@(d' : ds') dp tp sp
            | IS.member t us = go cs' us ds dp tp sp
            | otherwise      = go cs' us' ds' dp' tp' sp'
          where
            us' = IS.insert t us :: IS.IntSet
            dp' = dp - d' + d :: Int
            tp' = succ tp :: Int
            sp' = max sp (dp' + tp' ^ 2) :: Int
        go [] _ _ _ _ sp = sp
        go _ _ [] _ _ sp = sp
  tds <- sequence . replicate n $ unsafeListToPair . map unsafeTextToInt . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    dts = sortBy (flip compare `on` fst) . map swap $ tds :: [(Int, Int)]
  print . maxSP . initialize $ dts

unsafeListToPair :: [a] -> (a, a)
unsafeListToPair [x, y] = (x, y)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 58748
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
int a,b,c,d; 

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d);
	return 0;
}



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

sunuke=A[0]
araiguma=sum(A)-sunuke
ans=abs(sunuke-araiguma)

for i in range(1,N-1):
    sunuke+=A[i]
    araiguma-=A[i]
    ans=min(ans,abs(sunuke-araiguma))

print(ans)

Measured memory_bytes: 24832
l1 = input()
l2 = input()

line1 = [l1[i] for i in range(len(l1))]
line2 = [l2[i] for i in range(len(l2))]

count = 0

for i in range(len(line1)):
    if line1[i] == line2[i]:
        count += 1
    
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

#define DOLL long double
#define LOLI long long int
using namespace std;

const long C_10PW9 = 1000000000;
const int ULCODE = 32;

int main()
{
	int H, W, M;
	cin >> H >> W >> M;
	vector<int> Height(H), Width(W);
	vector<pair<int, int>> BOM;
	for (int i = 0; i < M; i++) {
		int hi, wi;
		cin >> hi >> wi;
		Height[hi - 1]++;
		Width[wi - 1]++;
		BOM.push_back(make_pair<int, int>(hi - 1, wi - 1));
	}
	auto Hbeg = Height.begin();
	auto hinx = distance(Hbeg, max_element(Hbeg, Height.end()));
	auto Wbeg = Width.begin();
	auto winx = distance(Wbeg, max_element(Wbeg, Width.end()));
	int HM = Height[hinx], WM = Width[winx];
	LOLI HC = 0, WC = 0;
	for (int i = 0; i < H; i++) { if (Height[i] == HM) { HC++; } }
	for (int i = 0; i < W; i++) { if (Width[i] == WM) { WC++; } }
	LOLI HWC = HC * WC;
	for (int i = 0; i < M; i++) {
		int h = BOM[i].first, w = BOM[i].second;
		if (Height[h] == HM && Width[w] == WM) { HWC--; }
	}
	int vec = 0;
	if (HWC <= 0) { vec = -1; }
	cout << HM + WM + vec << endl;

	return 0;
}

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

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

int main() {
    int64_t n;
    cin >> n;
    int64_t ans = 0;
    map<pair<int, int>, int> count;
    for (int64_t m = 1; m <= n; m++) {
        int64_t d = log10(m);
        int64_t l = m / (int64_t) pow(10, d), r = m % 10;
        if (r == 0) continue;
        count[{l, r}]++;
    }

    for (int64_t m = 1; m <= n; m++) {
        int64_t d = log10(m);
        int64_t l = m / (int64_t) pow(10, d), r = m % 10;
        if (r == 0) continue;
        ans += count[{r, l}];
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int i = A; i <= B; i++) {
			String n = Integer.toString(i);
			boolean flag = true;
			for(int j = 0; j < n.length() / 2; j++) {
				char c1 = n.charAt(j);
				char c2 = n.charAt(n.length() - j - 1);
				if(c1 != c2) {
					flag = false;
					break;
				}
			}
			if(flag) cnt++;
		}
		System.out.println(cnt);
	}
}

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

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> b(9);
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		b[min(x / 400, 8)]++;
	}
	int cnt = 0;
	for(int i = 0; i < 8; i++){
		if(b[i] > 0) cnt++;
	}
	int min_ans = cnt, max_ans = cnt + b[8];
	if(min_ans == 0) min_ans++;
	cout << min_ans << " " << max_ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

int main(){
    int n, m; cin >> n >> m;
    vector<int> flag(n+1, 0), count(n+1, 0);
    int p = 0, ac = 0;
    REP(i, 0, m){
        int a; cin >> a;
        string s; cin >> s;
        if(flag[a] == 0){
            if(s == "WA"){
                count[a]++;
            }else{
                ac++;
                flag[a] = 1;
            }
        }
    }
    REP(i, 1, n+1){
        //cout << i <<flag[i] <<  count[i] << endl;
        if(flag[i] == 1){
            p += count[i];
        }
    }
    cout << ac << " " << p << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;

ll N;
lf A[3005], dp[3005][3005];

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

	cin >> N;
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}

	dp[0][1] = A[0];
	dp[0][0] = 1 - A[0];

	for (ll i = 1; i < N; i++) {
		for (ll j = 0; j <= N; j++) {
			dp[i][j] = dp[i-1][j] * (1 - A[i]) + dp[i-1][j-1] * A[i];
		}
	}

	lf ans = 0;
	for (ll i = N/2+1; i <= N; i++) {
		ans += dp[N-1][i];
	}

	cout << fixed << setprecision(12) << ans << "\n";

}

Measured memory_bytes: 141056
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if all([a > 0 for a in A]):
        pre = A[0]
        M = sum(A) - 2 * min(A)
        print(M)
        for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
    elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
    else:
        cnt = 0
        M = 0
        for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
        print(M)
        if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                

if __name__ == "__main__":
    main()

Measured memory_bytes: 96120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int c = 0; int d = 1e9;
  for (int i = 0; i < n; i++){
    int k; cin >> k;
    c = max(c, k); d = min(d, k);
  }
  cout << c - d << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x;
    
    cin >> x;
    
    if (x == 3 || x == 5 || x == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return (0);
}


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

using namespace std;

int main() {
    const int n = 3;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());

    int cost = 0;
    for (int i = 0; i < n - 1; ++i)
        cost += abs(a[i] - a[i + 1]);
    cout << cost << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,cnt;
	cin >> N;
	int A[N] = {};
	for(int i = 0;i < N;i++){
		cin >> A[i];
	}
	cnt = -1;
	bool flag = true;

	while(flag){
		cnt++;
		for(int i = 0;i < N;i++){
			if(A[i] % 2 !=0){
				flag = false;
				break;
			} else {
				A[i] /= 2;
			}
		}
	}
  cout << cnt << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

broken = [False for it in range(n)]
for it in a:
    broken[it] = True

how_many = [0 for it in range(n)]
for i in range(0, n)[::-1]:
    if broken[i]:
        continue
        
    if i==n-1:
        how_many[i] = 1
    elif i==n-2:
        how_many[i] =  how_many[i+1] + 1
    else:
        how_many[i] = (how_many[i+1] + how_many[i+2])% 1000000007
print(how_many[0])

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

const int MOD = 1e9+7;

int main()
{
    int N;
    cin >> N;
    long long res = 1;
    for (int i=1; i<N+1; ++i)
    {
        res = (res*i % MOD);
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
S = str(input())
a_ind = 99999999
z_ind = 0
for i in range(len(S)):
  if S[i] == 'A':
    a_ind = min(i, a_ind)
  elif S[i] == 'Z':
    z_ind = max(i, z_ind)
print(z_ind - a_ind + 1)

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(int i=0;i<(int)n;++i)
#define _rep1(i,k,n) for(int i=k;i<(int)n;++i)
#define _rep2(i,k,n,d) for(int i=k;d>0?i<(int)n:i>(int)n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll a, b; cin >> a >> b;
    if(a <= 0 and 0 <= b){
        puts("Zero");
    } else if(a > 0){
        puts("Positive");
    } else {
        ll d = b - a + 1;
        if(d & 1){
            puts("Negative");
        } else {
            puts("Positive");
        }
    }
}

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

using namespace std;

#define REP(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define DREP(i, a, n) for (int i = a, _n = n; i >= _n; --i)
#define FOR(i, a, n) for (int i = a, _n = n; i < _n; ++i)
#define EREP(i, a) for (int i = first[a]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

const int SIZE = 100005;

int n, q;

int first[SIZE], ecnt;
struct Edge {
  int v, d, c, nxt;
} edge[SIZE << 1];
void Add_Edge (int u, int v, int c, int d) {
  ++ecnt;
  edge[ecnt].v = v;
  edge[ecnt].c = c;
  edge[ecnt].d = d;
  edge[ecnt].nxt = first[u];
  first[u] = ecnt;
}

struct Query {
  int x, y, k;
  int id;
};
vector<Query> V[SIZE];

int dep[SIZE], dp[SIZE][17];

void dfs (int u) {
  EREP (i, u) {
    Edge& e = edge[i];
    if (e.v == dp[u][0]) continue;
    dep[e.v] = dep[u] + 1;
    dp[e.v][0] = u;
    dfs (e.v);
  }
}

int ans[SIZE], cnt[SIZE], sum[SIZE];

void Up (int& u, int step) {
  REP (i, 0, 16) if (1 << i & step)
    u = dp[u][i];
}

int LCA (int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  Up (u, dep[u] - dep[v]);
  if (u == v) return u;
  DREP (i, 16, 0) if (dp[u][i] != dp[v][i])
    u = dp[u][i], v = dp[v][i];
  return dp[u][0];
}
int dis;

void DFS (int u) {
  FOR (i, 0, V[u].size()) {
    Query& q = V[u][i];
    ans[q.id] += (dis - sum[q.x] + cnt[q.x] * q.y) * q.k;
  }
  EREP (i, u) {
    Edge& e = edge[i];
    if (e.v == dp[u][0]) continue;
    dis += e.d;
    sum[e.c] += e.d;
    ++cnt[e.c];
    DFS (e.v);
    dis -= e.d;
    sum[e.c] -= e.d;
    --cnt[e.c];
  }
}

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

  FOR (i, 1, n) {
    int u, v, c, d;
    scanf ("%d%d%d%d", &u, &v, &c, &d);
    Add_Edge (u, v, c, d);
    Add_Edge (v, u, c, d);
  }

  dfs (1);
  REP(i, 1, 16) REP (j, 1, n)
    dp[j][i] = dp[dp[j][i - 1]][i - 1];

  REP (i, 1, q) {
    int x, y, u, v;
    scanf ("%d%d%d%d", &x, &y, &u, &v);
    int lca = LCA (u, v);
    V[u].push_back((Query) <% x, y, 1, i%>);
    V[v].push_back((Query) <% x, y, 1, i%>);
    V[lca].push_back((Query) <% x, y, -2, i%>);
  }
  DFS (1);

  REP (i, 1, q) printf ("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 25588
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const ll inf=1ll<<60;

int n;
struct edge{int to,cost;};
const int MAX_N=100010;
vector<edge> G[MAX_N];
ll dist[MAX_N];
vector<edge> G2[MAX_N];
ll dist2[MAX_N];

void dijkstra(int s){
  priority_queue<pii,vector<pii>,greater<pii> > que;
  fill(dist,dist+n,inf);
  dist[s]=0;
  que.push(pii(0,s));
  while(!que.empty()){
    pii p=que.top(); que.pop();
    int v=p.second;
    if(dist[v]<p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(dist[e.to]>dist[v]+e.cost){
        dist[e.to]=dist[v]+e.cost;
        que.push(pii(dist[e.to],e.to));
      }
    }
  }
}
void dijkstra2(int s){
  priority_queue<pii,vector<pii>,greater<pii> > que2;
  fill(dist2,dist2+n,inf);
  dist2[s]=0;
  que2.push(pii(0,s));
  while(!que2.empty()){
    pii p=que2.top(); que2.pop();
    int v=p.second;
    if(dist2[v]<p.first) continue;
    for(int i=0;i<G2[v].size();i++){
      edge e=G2[v][i];
      if(dist2[e.to]>dist2[v]+e.cost){
        dist2[e.to]=dist2[v]+e.cost;
        que2.push(pii(dist2[e.to],e.to));
      }
    }
  }
}

int main(){
  int m,s,t; cin >> n >> m >> s >> t;
  s--; t--;
  rep(i,m){
    int a,b,c1,c2;
    cin >> a >> b >> c1 >> c2;
    a--; b--;
    G[a].push_back({b,c1});
    G[b].push_back({a,c1});
    G2[a].push_back({b,c2});
    G2[b].push_back({a,c2});
  }
  vector<ll> ans(n);
  dijkstra(s);
  dijkstra2(t);
  for(int i=n-1;i>=0;i--){
    ans[i]=dist[i]+dist2[i];
    if(i<n-1) chmin(ans[i],ans[i+1]);
  }
  rep(i,n){
    cout << (ll)1e15-ans[i] << endl;
  }
  
}

Measured memory_bytes: 16316
S = list(map(int, input()))

m_dfr = 9999999999999999

for i in range(len(S) - 2):
	foo = abs(753 - int(S[i]) * 100 - int(S[i + 1]) * 10 - int(S[i + 2]))
	if foo < m_dfr:
		m_dfr = foo
		if m_dfr == 0:
			break
		
print(m_dfr)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int64_t n;
  cin >> n;

  int r = sqrt(n);
  for (int64_t i = r + 1; i >= 1; --i) {
    if (n % i == 0) {
      cout << to_string(n / i).size() << '\n';
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 4000020
using namespace std;
struct que
{
	int tr, id;
};
int nxt[maxn], pos[maxn], c[maxn], res[maxn], tag[maxn], sum[maxn];
vector<que> Q[maxn];
int read()
{
	int x = 0; char c = getchar();
	while (c < '0' || c > '9') c++;
	while (c >= '0' && c <= '9')
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x;
}
void pushdown(int now)
{
	int x = tag[now];
	tag[now * 2] += x;
	tag[now * 2 + 1] += x;
	tag[now] = 0;
}
void modify(int now, int l, int r, int left, int right)
{
	if (l == left && r == right)
	{
		tag[now]++;
		return;
	}
	pushdown(now);
	int mid = (l + r) / 2;
	if (left <= mid) modify(now * 2, l, mid, left, min(right, mid));
	if (right >= mid + 1) modify(now * 2 + 1, mid + 1, r, max(left, mid + 1), right);
}
int query(int now, int l, int r, int x)
{
	if (l == r) return sum[x] - tag[now];
	pushdown(now);
	int mid = (l + r) / 2;
	if (x <= mid) return query(now * 2, l, mid, x);
	else return query(now * 2 + 1, mid + 1, r, x);
}
int main()
{
	int n = read(), q = read();
	for (int i = 1; i <= n; i++)
		c[i] = read();
	for (int i = 1; i <= q; i++)
	{
		int tl = read(), tr = read();
		Q[tl].push_back((que){tr, i});
	}
	for (int i = n; i >= 1; i--)
	{
		if (pos[c[i]] == 0) nxt[i] = n + 1;
		else nxt[i] = pos[c[i]];
		pos[c[i]] = i;
	}
	for (int i = 1; i <= n; i++)
		pos[i] = 0;
	for (int i = 1; i <= n; i++)
	{
		if (pos[c[i]] == 0) sum[i] = sum[i - 1] + 1;
		else sum[i] = sum[i - 1];
		pos[c[i]] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		int len = Q[i].size();
		for (int j = 0; j <= len - 1; j++)
			res[Q[i][j].id] = query(1, 1, n, Q[i][j].tr);
		modify(1, 1, n, i, nxt[i] - 1);
	}
	for (int i = 1; i <= q; i++)
		printf("%d\n", res[i]);
	return 0;
}

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

    int func(int a,int b, int c){
        if(a%2==1 || b%2==1 || c%2==1)return 0;
        if(a==b && b==c)return -1;

    return func((b+c)/2,(a+c)/2,(a+b)/2)+1;
    }


    int main (){
        int a, b ,c ;
        cin >> a >> b >> c;
        
        int ans =func(a,b,c);
        cout << ans << endl;
        return 0;

    }

Measured memory_bytes: 3548
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int aka = Integer.parseInt(sc.next());
		int midori = Integer.parseInt(sc.next());
		int ao = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());

		int count = 0;
		while(true) {
			count++;
			if(ao<=midori) {
				ao = ao*2;
			} else if(midori <= aka) {
				midori = midori *2;
			}
			if(count == K) break;
		}
		if(ao > midori && midori > aka) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

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

int main() {
  int N, a, b, c, d, i, j;
  cin >> N;
  a = N;
  d = 0;
  for (i = 0; 0 < a; i++){
      a /= 10;
  }
  a = N;
  while (i > 0) {
    b = 1;
    for (j = 0; j < i - 1; j++){
      b *= 10;
    }
    c = a / b;
    d += c;
    a -= c * b;
    i--;
  }
  if (N % d == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int u,v;
// struct Edge{
// 	int u,v;
// };
vector<int> edge[10]; 
bool vis[100];
int cnt=0;

bool dfs(int st){
	for(int i=0;i<edge[st].size();i++){
		int to=edge[st][i];
		if(vis[to]) continue;
		vis[to]=true;
		cnt++;
		// printf("st:%d to:%d cnt:%d\n",st,to,cnt);
		dfs(to);
		break;
	}
	if(cnt<4) return false;
	return true;
}

int main(){
		memset(edge,0,sizeof(edge));
		memset(vis,0,sizeof(vis));
		for(int i=0;i<3;i++){
		scanf("%d %d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
		}
		vis[1]=true;
		cnt=1;
		if(dfs(1)) printf("YES\n");
		else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	S := readString()

	if S == "AAA" || S == "BBB" {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")

}


Measured memory_bytes: 640
using System;
using System.Linq;

class Program {
    private static int Main() {
        while( true ) {
            var cards = Console.ReadLine();
            if( cards == "-" ) { break; }

            var input = Console.ReadLine();
            int count = int.Parse( input );

            int index = 0;
            for( int i = 0; i < count; ++i ) {
                input = Console.ReadLine();
                index += int.Parse( input );
            }

            index %= cards.Length;

            var output = cards.Substring( index ) + cards.Substring( 0, index );
            Console.WriteLine( output );
        }

        return 0;
    }
}

Measured memory_bytes: 5296
(let* ((n (read))
       (m (read))
       (h (make-array (1+ n)))
       (flags (make-array (1+ n) :initial-element t)))
  (setf (aref flags 0) nil)
  (loop for i from 1 to n
        do (setf (aref h i) (read)))
  (loop for i from 1 to m
        do (let ((a (read))
                 (b (read)))
             (when (>= (aref h a)
                      (aref h b))
               (setf (aref flags b) nil))
             (when (>= (aref h b)
                      (aref h a))
               (setf (aref flags a) nil))))
  (format t "~A~%" (count t flags)))

Measured memory_bytes: 78776
a = int(input())
h_list = list(map(int,input().split()))
max_w = 0
sum_w = 0
for index,h in enumerate(h_list):
	if index != a-1:
		if h_list[index+1] <= h_list[index]:
			sum_w += 1
		else:
			max_w = sum_w if max_w<sum_w else max_w
			sum_w = 0
	else:
		max_w = sum_w if max_w<sum_w else max_w
print(max_w)

Measured memory_bytes: 64124
import collections
import math
import re
import numpy
from operator import itemgetter
def ai():return input()#s
def a():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
kind=[]
l = []
f = 0
s=0
c=0
e =1
n,k=ma()
for i in range(n):
    a,b = ma()
    l.append([a,b])
l.sort()
for i in range(n):
    s+=l[i][1]
    if s >=k:
        c = l[i][0]
        break
print(c)

Measured memory_bytes: 30920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        
        int ans;
        if(a+b > c*2){
            if(x > y){
                ans = y*c*2 + Math.min((x-y)*a, (x-y)*c*2);
            }else if(x < y){
                ans = x*c*2 + Math.min((y-x)*b, (y-x)*c*2);
            }else{
                ans = x*c*2;
            }
        }else{
            ans = a*x + b*y;
        }
        
        System.out.println(ans);
    }
}

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

struct Rect {
    int l, r, h;

    Rect(){}
    ~Rect(){}

    Rect (int a, int b, int c):
        l(a), r(b), h(c) {}

    bool operator < (const Rect& o) const {
        return r == o.r ? l < o.l : r < o.r;
    }
};

int main() {
    while (true) {
        int r, n;
        cin >> r >> n;

        if (r == 0 && n == 0){
            break;
        }

        vector<Rect> rects(n);

        for (int j = 0; j < n; ++j) {
            cin >> rects[j].l >> rects[j].r >> rects[j].h;
        }

        int dum[90];
        int* heights = dum + 45;
        fill(dum, dum + 90, 0);

        for (int j = 0; j < n; ++j) {
            for (int x = 2 * rects[j].l; x <= 2 * rects[j].r; ++x) {
                heights[x] = max(heights[x], rects[j].h);
            }
        }

        heights[-2*r-1] = numeric_limits<int>::max();
        heights[2*r+1] = numeric_limits<int>::max();

        double ret = numeric_limits<double>::max();

        for (int x = -2 * r; x <= 2 * r; x += 2) {
            int h = min(heights[x], min(heights[x-1], heights[x+1]));
            ret = min(ret, h + r - sqrt(r * r - x * x / 4));
        }

        printf("%.4f\n", ret);
    }
    return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

LL k, t[51];

int main()
{
    cin >> k;
    LL n = 50;
    for(int i = 0; i < 50; i++)
        t[i] = 49 - i;
    for(int i = 0; i < 50; i++)
        t[i] += k / 50;
    for(int i = 0; i < k % 50; i++)
        t[i]++;
    cout << n << "\n";
    for(int i = 0; i < 50; i++)
        cout << t[i] << " ";
    return 0;
}


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

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

    ll ans;
    cin >> ans;
    rep(i, n - 1) {
        ll t;
        cin >> t;
        ans = ans / __gcd(ans, t) * t;
    }

    cout << ans << endl;
    return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
N,M,R = map(int,input().split())
r = list(map(int,input().split()))

d = [[float('inf') for _ in range(N)] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
for i in range(N):
    d[i][i]=0
from scipy.sparse import csgraph
d = csgraph.floyd_warshall(d)
ans = float('inf')
for seq in permutations(r):
    s = 0
    for j in range(R-1):
        s += d[seq[j]-1][seq[j+1]-1]
    ans = min(ans,s)
print(int(ans))


Measured memory_bytes: 16092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=7;
int n, m,k,ans, tot, cnt;
int a[MAXN][MAXN], b[MAXN][MAXN];
string s;

void re() 
{
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= m; j++) 
			a[i][j] = b[i][j];
}

int count() 
{
	int res = 0;
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= m; j++) 
			if (a[i][j] == 1) 
				res++;
	return res;
}

int main()
{	int T;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) 
	{
		cin >> s;
		for (int j = 0; j < s.size(); j++) 
			if (s[j] == '#') 
			a[i][j + 1] = 1;
	}
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= m; j++) 
			b[i][j] = a[i][j];
	for (int i = 0; i < (1 << n); i++) 
	{
		for (int j = 0; j < (1 << m); j++) 
		{
			int x = i, y = j, num = 1;
			while (num <= n) 
			{
				if (x & 1) 
					for (int k = 1; k <= m; k++) 
						a[num][k] = 2;
				x >>= 1;
				++num;
			}
			num = 1;
			while (num <= m) 
			{
				if (y & 1) 
					for (int k = 1; k <= n; k++) 
						a[k][num] = 2;
				y >>= 1;
				++num;
			}
			num = count();
			if (num == k) 
				ans++;
			re();
		}
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3824
a = gets.chomp.split("")
b = Array.new()
a.length.times do |x|
  if a[x] == "0" then
    b.push 0
  elsif a[x] == "1" then
    b.push 1
  elsif a[x] == "B" then
    if b.length != 0
      b.delete_at(-1)
    end
  else
  end
end
puts b.join

Measured memory_bytes: 1788
use std::collections::HashSet;

fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

fn main(){
    let n:i32 = getline().trim().parse::<i32>().unwrap();
    let mut hs = HashSet::new();
    for i in 0..n{
        let a:i32 = getline().trim().parse().unwrap();
        hs.insert(a);
    }

    println!("{}",hs.len());
}



Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int N; cin >> N;
    cout << (N+1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
def is_approved(num):

    if num % 2 == 1:
        return True
    elif num % 3 == 0 or num % 5 == 0:
        return True
    
    return False

def main():

    n = int(input())
    an = list(map(int,input().split()[:n]))

    for num in an:
        if not is_approved(num):
            print('DENIED')
            exit()
    print('APPROVED')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        w: i64,
        h: i64,
        x: i64,
        y: i64,
    }

    println!(
        "{} {}",
        (w as f64) * (h as f64) / 2.0,
        if x + x == w && y + y == h { "1" } else { "0" }
    );
}


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

int dp[3001][3001];

int main()
{
	int n, t, s;
	scanf("%d %d %d", &n, &t, &s);
	for (int i = 1; i <= n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		for (int j = 1; j <= t; j++){
			if ((j - b < s ^ s < j) && j - b >= 0){
				dp[i][j] = max(dp[i][j], dp[i - 1][j - b] + a);
			}
			dp[i][j] = max(dp[i][j], dp[i][j - 1]);
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
		}
	}
	/*
	int maxi = 0;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= t; j++){
			maxi = max(maxi, dp[i][j]);
		}
	}
	*/
	printf("%d\n", dp[n][t]);
	
	return 0;
}

Measured memory_bytes: 36360
#include <bits/stdc++.h>
using namespace std;
int main()
{
		int N;
		cin >> N;
		char str[10];
		cin >> str;
		if (N >= 3200) {
			cout << str << endl;
		
		}
		else {
			cout << "red" << endl;
		}
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::cmp::{max, min};

fn main() {
    let n: i64 = read();
    let s: String = read();

    let s_char: Vec<char> = s.chars().collect();

    let mut prev = s_char[0];
    let mut ans = 1;
    for i in s_char {
        if i != prev {
            ans += 1;
        }
        prev = i;
    }

    println!("{}", ans)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a * b > c * d) cout << a * b << endl;
  else cout << c * d << endl;
}

Measured memory_bytes: 256