akhauriyash/Code-Regression huggingface dataset:
import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt
 
solve :: [Int] -> Int
solve arr = minimum $ map f [minimum arr .. maximum arr]
    where f k = sum $ map (\x -> (x-k) * (x-k)) arr

main :: IO ()
main = do
    [n] <- getInts
    arr <- getInts
    print (solve arr)

Measured memory_bytes: 508
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let a: Vec<i64> = readnc();

    let mut sum = 0;
    for i in 0..n {
        sum += a[i];
    }
    let mut best: i64 = 1e18 as i64;
    let mut snuke = 0;
    for i in 0..n-1 {
        snuke += a[i];
        let araisan = sum - snuke;
        best = min(best, (snuke - araisan).abs());
    }
    println!("{}", best);
}

Measured memory_bytes: 10492
N, M, K = map(int, input().split())

MOD = 998244353
# 組み合わせ②-1
# nCk % MOD
# n巨大で固定、kは10 ** 5くらいまで
# 前処理O(MAX)、計算O(1)
NN = N-1
MAX = K + 1
com = [0] * MAX
def COM2init():
    com[0] = 1
    for i in range(1, MAX):
        if i > NN: break
        com[i] = (com[i-1] * (NN-i+1) % MOD) * pow(i, MOD-2, MOD) % MOD
COM2init()

ans = 0
for k in range(K + 1):
    ans = (ans + M * pow(M-1, N-k-1, MOD) * com[k]) % MOD
print(ans)

Measured memory_bytes: 16920
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
  int A,B;
  scanf("%d %d", &A,&B);
  
  if(A>9 || B>9)
  {
    printf("%d",-1);
  }else{
  	printf("%d",A*B);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define slld(t) scanf("%lld",&t)
#define plld(t) printf("%lld\n",t)
#define For(i,n) for(ll i=0;i<n;i++)
#define bll __builtin_popcountll
#define speed ios::sync_with_stdio(false); cin.tie(0)



using namespace std;




int main()
{
	speed;
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll b[n]={0};
    b[0]=0;
    b[1]=abs(a[0]-a[1]);
    for(ll i=2;i<n;i++)
    {
        b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
    }

    // for(ll i=0;i<n;i++)
    // {
    //     cout<<b[i]<<" ";
    // }
    cout<<b[n-1];

    
    

    
    return 0;
           
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!


class HashTable:
    def __init__(self):
        self.Max = 1046527
        self.hashTable = [""] * self.Max
        
    def getChar(self, ch):
        if ch == "A":
            return 1
        elif ch == "G":
            return 2
        elif ch == "C":
            return 3
        elif ch == "T":
            return 4
        else:
            return 0
    
    def getKey(self, str):
        charList = list(str)
        sum = 0
        p = 1
        for ch in charList:
            sum += p * self.getChar(ch)
            p *= 5
        return sum

    def hash1(self, key):
        return key % self.Max
        
    def hash2(self, key):
        return key % (self.Max - 1)

    def find(self, str):
        key = self.getKey(str)
        i = 0
        while True:
            h = (self.hash1(key) + i * self.hash2(key)) % self.Max
            if str == self.hashTable[h]:
                return True
            elif len(self.hashTable[h]) == 0:
                return False
            i += 1
        return False

    def insert(self, str):
        key = self.getKey(str)
        i = 0
        while True:
            h = (self.hash1(key) + i * self.hash2(key)) % self.Max
            if str == self.hashTable[h]:
                return True
            elif len(self.hashTable[h]) == 0:
                self.hashTable[h] = str
                return False
            i += 1
        return False
        

hTable = HashTable()

lenA = int(input())
A = []
for i in range(lenA):
    tmp = list(input().split())
    A.append(tmp)

for i in range(lenA):
    if A[i][0] == "insert":
        hTable.insert(A[i][1])
    elif A[i][0] == "find":
        if hTable.find(A[i][1]):
            print("yes")
        else:
            print("no")
    
    

















Measured memory_bytes: 241112
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	map<string, int> m;
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n){
		cin >> s[i];
		m[s[i]]++;
		if(m[s[i]] > 1){
			cout << "No" << endl;
			return 0;
		}
		if(i){
			if(s[i][0] != s[i - 1][s[i - 1].size() - 1]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000009
#define int long long
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
	return ans;
}
signed main() {
	 garou;
	 int x=0;
for(int i=0;i<5;i++){
	int a;
  cin>>a;
  if(a==0)
  x=i+1;
}
cout<<x;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> h(60, 0), b(60, 0);
ll func(ll n, ll x) {
  if(n == 0) {
    if(x <= 0) {
      return 0;
    } else {
      return 1;
    }
  } else if(x <= h[n - 1] + 1) {
    return func(n - 1, x - 1);
  } else {
    return h[n - 1] - b[n - 1] + 1 + func(n - 1, x - h[n - 1] - 2);
  }
}

int main() {
  ll n, x;
  cin >> n >> x;
  h[0] = 1;
  for(int i = 0; i < n; i++) {
    b[i + 1] = b[i] * 2;
    h[i + 1] = h[i] * 2;
    h[i + 1] += 3;
    b[i + 1] += 2;
  }
  cout << func(n, x) << endl;
  return 0;
}

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

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

    unsigned long long a[n+1];
    a[0] = 2;
    a[1] = 1;
    for(int i=2;i<n+1;i++)a[i] = a[i-1] + a[i-2];

    cout << a[n];
}


Measured memory_bytes: 256
import math
x = int(input())

a = []
b = []
for i in range(8):
    a.append(math.floor(math.pow(x,(1.0/(i+2)))))

for i in range(8):
    b.append(math.pow(a[i],(i+2)))
tmp = 0
for i in range(8):
    if tmp < b[i]:
        tmp = b[i]
if x != 1000:
    print(math.floor(tmp))
else:
    print(1000)


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

enum version{
  fleft,
  fright,
};

version check(char c){
  switch(c){
  case 'q':
  case 'w':
  case 'e':
  case 'r':
  case 't':
  case 'a':
  case 's':
  case 'd':
  case 'f':
  case 'g':
  case 'z':
  case 'x':
  case 'c':
  case 'v':
  case 'b':
    return fleft;
  default:
    return fright;
  }
}

int main(){
  string input;
  while(cin>>input && input!="#"){
    version v=check(input[0]);
    int count=0;
    for(int i=1;i<(int)input.size();i++){
      version ver=check(input[i]);
      if(ver!=v){
	count++;
	v=ver;
      }
    }
    cout<<count<<endl;
  }
  return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int p, q, r;
    cin >> p >> q >> r;

    int min = INF;
    if(min > (p + q)) min = p + q;
    if(min > (q + r)) min = q + r;
    if(min > (p + r)) min = p + r;
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B;
  cin>>A>>B;
  string S;
  cin>>S;
  bool ans=true;
  for(int i=0;i<A+B+1;i++){
  if(i==A){
  if(S.at(i)!='-'){
    ans=false; break;
  }
  }else{
  if(S.at(i)=='-'){
  ans=false; break;
  }
  }
  
  }if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    cin >> A;
    A.emplace_back(X);
    SORT(A);
    vector<int> S(N);
    REP(i, N) {
        S[i] = A[i + 1] - A[i];
    }

    int ans = S[0];
    FOR(i, 1, N) {
        ans = GCD(ans, S[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
MOD = 10**9+7

n, m = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(n+1):
  for j in range(m+1):
    if i == 0 or j == 0:
      dp[i][j] = 1
    else:
      dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1]
      if S[i-1] == T[j-1]:
        dp[i][j] += dp[i-1][j-1]
      dp[i][j] %= MOD
ans = dp[n][m]
print(ans)

Measured memory_bytes: 98792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;
ll memo[10005][105][2];
string str;
ll solve(int idx,ll m,int safe,int n,ll k)
{
    if(idx==n)
    {
        if(m==0) return 1;
        return 0;
    }
    
    if(memo[idx][m][safe]!=-1) return memo[idx][m][safe];
    ll ret=0;
    if(idx==0)
    {
        for(int i=0;i<(str[idx]-'0');i++)
        {
            ret=(ret%M+solve(idx+1,(m%k+i%k)%k,0,n,k)%M)%M;
        }
        ret=(ret%M+solve(idx+1,(m%k+(str[idx]-'0')%k)%k,1,n,k)%M)%M;
    }
    
    else
    {
        if(safe==0)
        {
            for(int i=0;i<=9;i++)
            {
                ret=(ret%M+solve(idx+1,(m%k+i%k)%k,0,n,k)%M)%M;
            }
        }
        
        else
        {
            for(int i=0;i<(str[idx]-'0');i++)
            {
                ret=(ret%M+solve(idx+1,(m%k+i%k)%k,0,n,k)%M)%M;
            }
            ret=(ret%M+solve(idx+1,(m%k+(str[idx]-'0')%k)%k,1,n,k)%M)%M;
        }
    }
    
    return memo[idx][m][safe]=ret;
}
int main()
{
    memset(memo,-1,sizeof(memo));
    cin>>str;
    ll k;
    cin>>k;
    ll ans=solve(0,0,0,str.size(),k);
    cout<<((ans%M - 1)%M+M)%M<<endl;
    
    
}

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

int main() {
    int a, b; string s; cin >> a >> b >> s;
    bool flag = true;
    if (s[a] == '-') {
        if (a == b) b += 1;
        string front = s.substr(0, a);
        string back = s.substr(b);
        //cout << "front: " << front << endl;
        //cout << "back: " << back << endl;
        for (int i = 0; i < front.size(); i++) {
            if ('0' > front[i] && front[i] > '9' || front[i] == '-') {
                flag = false;
            }
            
        }
        for (int i = 0; i < back.size(); i++) {
            if ('0' > back[i] && back[i] > '9' || back[i] == '-') {
                flag = false;
            }   
        }
    }

    else flag = false;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = [ int(v) for v in input().split() ]
dice = [ int(v) for v in input().split() ]
dice = [ (1+v)/2 for v in dice ]

s = sum(dice[:k])
dice2 = [s]

for i in range(n - k):
    s += dice[i+k] - dice[i]
    dice2.append(s)
print(max(dice2))

Measured memory_bytes: 77448
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, X; cin >> N >> X;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int sum=0;
  int count=0;
  for(int i=0;i<N;i++){
    sum+=MY.at(i);
    count++;
    if (sum > X) break;
  }
  if(sum <= X) cout << count+1 << endl;
  else cout << count << endl;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)

const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool check_prime(int n)
{
    if(n<2)
        return false;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int setbits(int n)
{
    int count=0;
    while(n)
    {
        if(n%2==1)
            count++;
        n>>=1;
    }
    return count;
}

int lcm(int a,int b)
{
    return (a*b)/__gcd(a,b);
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=0;

    for(int i=0;i<=n-3;i++)
    {
        if(s.substr(i,3)=="ABC")
        c++;
    }
    cout<<c;

    return 0;
}


Measured memory_bytes: 256
import sys
n, m = map(int, input().split())
s = input()[::-1]
ans = []
tmp = 0
while tmp < n:
	for i in range(min(m, n-tmp), 0, -1):
		if s[tmp+i] == "0":
			tmp += i
			ans.append(str(i))
			break
	else:
		print(-1)
		sys.exit()
print(" ".join(ans[::-1]))

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

int main() {
    double a,b,c,d,e,f;
    double x,y;
    
    while(cin >> a >> b >> c >> d >> e >> f){
        x = (double)((e*c-b*f) / (a*e-b*d));
        y = (double)((-(d*c)+a*f) / (a*e-b*d));
        if(x==0){
            x=0;
        }
        if(y==0){
            y=0;
        }
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int64 f(int64 n,int b){
  int64 res=0;
  while(n>0){
    res+=n%b;
    n/=b;
  }
  return res;
}

void run(void){
  int64 n,s;
  scanf("%lld%lld",&n,&s);
  int b;
  for(b=2;(int64)b*b<=n;b++){
    if(f(n,b)==s){
      printf("%d\n",b);
      return;
    }
  }
  //n=xp+y
  int64 x;
  for(x=n/b;x>=1;x--){
    int64 y=s-x;
    if(!(y>=0 && n-y>0 && (n-y)%x==0)) continue;
    int64 p=(n-y)/x;
    if(x<p && y<p && n==x*p+y){
      printf("%lld\n",p);
      return;
    }
  }
  if(n==s){
    printf("%lld\n",n+1);
  } else {
    printf("-1\n");
  }
}

int main(void){
  run();
  return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < 16; i++)
	{
		if (i & 1)a--;
		else b--;
	}
	if (a > 0 || b > 0)cout << ":(";
	else cout << "Yay!";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  
  int f=0;
  while(a!=0 || c!=0)
  {
    if(c>0) c-=b;
    if(c<=0) {
      f=1;
      break;
    }
    if(a>0) a-=d;
    if(a<=0) {
      f=0; 
      break;
    }
  }
  if(f==1) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main() {
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF&&(a!=0||b!=0)) {
		for(int i=0; i<a; i++) {
			for(int j=0; j<b; j++)
				cout<<"#";
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3236
days_sum={1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,
          10:31,11:30,12:31}
days2month={1:'Thursday',2:'Friday',3:'Saturday',4:'Sunday',
            5:'Monday',6:'Tuesday',0:'Wednesday'}

while True:
    month,day=map(int,raw_input().split(" "))
    if month==0 and day==0:
        break
    keika=0
    for i in range(1,month):
        keika += days_sum[i]
    keika+=day
    print days2month[keika%7]

Measured memory_bytes: 4232
h,w=gets.chomp.split(" ").map(&:to_i)
maths = []
h.times do
  tempArray = []
  tempArray = gets.chomp.split("")
  maths << tempArray if tempArray.uniq != ["."]
end

maths = maths.transpose
(0..(maths.length-1)).sort.reverse.each do |index|
  maths.slice!(index) if maths[index].uniq == ["."]
end

puts maths.transpose.map(&:join)

Measured memory_bytes: 2428
import numpy as np

def isPrime(n):
  s = int(np.sqrt(n))
  for i in range(2, s+1):
    if n % i == 0:
      return False
  return True

def sum_devisor(n):
  s = int(np.sqrt(n))
  while(n % s != 0):
    s -= 1
  return s + n/s

n = int(input())
if isPrime(n) == True:
  print(n-1)
else:
  print(int(sum_devisor(n)-2))

Measured memory_bytes: 21244
#include <stdio.h>
#define mod 1000000007

int main(){

  long long int i,j,n,tmp,ans=1,c;
  int prime[1001]={0};

  scanf("%lld",&n);

  if(n==1){
    printf("1\n");
    return 0;
  }
  for(i=2;i<=n;i++){
    tmp=i;
    c=2;
    while(tmp>=c*c){
      if(tmp%c==0){
        prime[c]++;
        tmp/=c;
      }else{
        c++;
      }
    }
    prime[tmp]++;
  }
  for(i=2;i<1000;i++){
    if(prime[i]!=0){
      ans*=(prime[i]+1);
      ans%=mod;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


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

int main()
{
	int n,a,b,t;
	scanf("%d%d%d",&n,&a,&b);
	t=a+b-n;
	printf("%d %d\n",max(t,min(a,b)),max(0,t));
	return 0;
}

Measured memory_bytes: 764
N = int(input())
h = list(map(int, input().split()))

def split_list(l, number=0):    
    if len(l) == 0:
        return []
    elif number not in l:
        return [l]
    first_occurance = l.index(number)
    result = []
    if first_occurance != 0:
        result.append(l[0:first_occurance])
    for s in split_list(l[first_occurance + 1:]):
        result.append(s)

    return result

queue = split_list(h)
count = 0
score = 0
while len(queue) != count:
    target = queue[count]
    mizu = min(target)
    target = [x - mizu for x in target]
    score += mizu

    for s in split_list(target):
        queue.append(s)
    count += 1

print(score)

Measured memory_bytes: 3064
x = int(input())

if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 1000 <= x < 1200:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif 1800 <= x < 2000:
    print(1)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

ll N, Q;
string s;
char t[MAX*2], d[MAX*2];

ll L(ll now) {
    ll i;
    for(i=0; i<Q; i++) {
        if(s[now]==t[i]) {
            if(d[i]=='L') now--;
            if(d[i]=='R') now++;
            
            if(now<0) return 1;
        }
    }
    
    return 0;
}

ll R(ll now) {
    ll i;
    for(i=0; i<Q; i++) {
        if(s[now]==t[i]) {
            if(d[i]=='L') now--;
            if(d[i]=='R') now++;
            
            if(now>=N) return 1;
        }
    }
    
    return 0;
}

int main(void) {
    cin >> N >> Q;
    cin >> s;
    ll i, j;
    
    for(i=0; i<Q; i++)
        cin >> t[i] >> d[i];
    
    ll l=0, r=N;
    while(l+1<r) {
        ll mid=(l+r)/2;
        if(L(mid)) l=mid;
        else r=mid;
    }
    
    ll le=l;
    
    l=0; r=N;
    while(l+1<r) {
        ll mid=(l+r)/2;
        if(R(mid)) r=mid;
        else l=mid;
    }
    ll ri=l;
    
    pt(max(0, ri-le));
    
}



Measured memory_bytes: 900
//Problem: DP_G from Educational DP Contest
//Progress: Working
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

const ll maxN = 1e5 + 11;

ll n, m;
vector<ll> adjlist[maxN];
ll dp[maxN];
bool vis[maxN];
ll i1, i2;

void init(){
	memset(vis, false, sizeof(vis));
	memset(dp, 0, sizeof(dp));
}

ll dfs(ll x){
	if(dp[x] != 0)
		return dp[x];
	vis[x] = true;
	ll mx = 0;
	for(ll i=0; i<adjlist[x].size(); i++)
		mx = max(mx, 1 + dfs(adjlist[x][i]));
	dp[x] = mx;
	return dp[x];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	init();
	cin >> n >> m;
	for(ll i=0; i<m; i++){
		cin >> i1 >> i2;
		adjlist[i1].push_back(i2);
	}
	ll maxx = 0;
	for(ll i=1; i<=n; i++){
		if(!vis[i]){
			maxx = max(dfs(i), maxx);
		}
		else
			maxx = max(dp[i], maxx);
	}
	cout << maxx;
	return 0;
}

Measured memory_bytes: 11924
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}



Measured memory_bytes: 37324
def have_ABC_string(n, str):
    count = 0
    for i in range(n-2):
        if str[i] == 'A' and str[i+1] == 'B' and str[i+2] == 'C':
            count += 1
    return count

N = int(input())
S = input()
result = have_ABC_string(N, S)
print(result)

Measured memory_bytes: 9128
function Main(input){
    input = input.split("\n")
    var s=input[0];
    var t=input[1];
    
    if(s===t.substr(0,s.length)){
    var t_end=t.substr(t.length-1,t.length);
      if(isUpperCase(t_end)===true){
      console.log('Yes');
      }
      else{
      console.log('No');
      }
    }
  else{
    console.log('No');
  }
}
const isUpperCase = c => {
  return /^[a-z]+$/g.test(c)
}        

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 29632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<long long>a(n),b(n);
	for(int i=0; i<n; i++)
		cin>>a[i];
	for(int i=0; i<n; i++)
		cin>>b[i];
	long long ans = 0;
	for(int i=0; i<30; i++)
	{
		vector<long long>ord_a(n),ord_b(n);
		for(int j=0; j<n; j++)
		{
			ord_a[j]=a[j] % (1 << (i+1));
			ord_b[j]=b[j] % (1 << (i+1));
		}
		sort(ord_b.begin(),ord_b.end());
		long long res=0;
		long long low=1<<i;
		for(auto& v:ord_a)
		{
			res+=lower_bound(ord_b.begin(), ord_b.end(), low*2 - v) - lower_bound(ord_b.begin(), ord_b.end(), low - v);
			res+=lower_bound(ord_b.begin(), ord_b.end(), low*4 - v) - lower_bound(ord_b.begin(), ord_b.end(), low*3 - v);
		}
		ans+=res%2<<i;
	}
	cout<<ans<<"\n";
	return 0;
}


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

int n;

struct Celldata {
    double x; double y; double z; double r;
};

struct pqdata {
    int from; int to; double corridor;
    bool operator<(const pqdata &r) const { return corridor > r.corridor; }
};

// UnionFindの実装
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }

    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        //要素数の少ない方を多い方に繋げる
        if(data.at(y) < data.at(x)) swap(x, y);
        data.at(x) += data.at(y);
        data.at(y) = x;
        return true;
    }

    // ある要素がどの集合に属しているかを返す
    int root(int x) {
        // 根に直接つなぎ直す
        return data.at(x) < 0 ? x : (data.at(x) = root(data.at(x)));
    }

    // ある集合の大きさを答える
    int size(int x) {
        return -data.at(root(x));
    }

    // ある二つの要素が同じ集合か判定
    bool same(int x, int y) {
        x = root(x); y = root(y);
        return x == y;
    }
};

int main() {
    while(1) {
        cin >> n;
        if(n == 0) break;
        vector<Celldata> cells(n);
        for(int i = 0; i < n; ++i) {
            cin >> cells.at(i).x >> cells.at(i).y >> cells.at(i).z >> cells.at(i).r;
        }
        priority_queue<pqdata> pque;
        UnionFind tree(n);
        for(int i = 0; i < n; ++i) {
            for(int j = i+1; j < n; ++j) {
                pqdata indata;
                indata.from = i; indata.to = j;
                double xx = powl(cells.at(i).x-cells.at(j).x, 2);
                double yy = powl(cells.at(i).y-cells.at(j).y, 2);
                double zz = powl(cells.at(i).z-cells.at(j).z, 2);
                double xyz = xx+yy+zz;
                double len = sqrtl(xyz) - (cells.at(i).r+cells.at(j).r);
                if(len <= 0.0) {
                    tree.merge(i, j);
                }else {
                    indata.corridor = len;
                    pque.push(indata);
                }
            }
        }

        double ans = 0.0;
        while(!pque.empty()) {
            pqdata now = pque.top();
            pque.pop();
            if(!tree.same(now.from, now.to)) {
                ans += now.corridor;
                tree.merge(now.from, now.to);
            }
        }

        printf("%.3lf\n", ans);
    }
}


Measured memory_bytes: 3456
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = 1e+3;
const int MAX_M = 1e+2;
ll a, b;
void input()
{
	scanf("%lld%lld", &a, &b);
}

ll euclid(ll x, ll y) {
	if (y == 0) return x;
	return euclid(y, x%y);
}
int main() {
	while (cin >> a >> b) {
		ll gcd = euclid(a, b);
		ll lcm = a*b / gcd;
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
from bisect import bisect_left
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    b = [0]*(n+1)
    for i in range(n):
        b[i+1] = a[i] + b[i]
    ok = 0; ng = 2 * 10**5 + 5
    while ok+1 < ng:
        mid = (ok + 1 + ng) // 2
        buf = 0
        for i in range(n):
            p = mid - a[i]
            buf += n - bisect_left(a, p)
        if buf >= m:
            ok = mid
        else:
            ng = mid
    ans = 0
    num = 0
    tot = 0
    for i in range(n):
        p = ok - a[i]
        index = bisect_left(a, p)
        num += n - index
        tot += b[n] - b[index]
        tot += a[i] * (n-index)
    ans = tot - (num - m) * ok
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14268
A,B,M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

XYC = [list(map(int, input().split())) for _ in range(M)]

min_val = min(a) + min(b)


for x,y,c in XYC:
    min_val = min(min_val,
                  a[x-1]+b[y-1]-c)
print(min_val)

Measured memory_bytes: 38560
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    vector<int> w;
    for(int i = 1; i < v.size(); i++)
    {
        string s = to_string(v[0]);
        string t = to_string(v[i]);
        w.push_back(stoi(s + t));
        w.push_back(stoi(t + s));
    }
    sort(w.begin(), w.end());
    cout << w[2] << endl;
    return 0;
}




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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

ll comb(ll n, ll r) {
	ll ans = 1;
	rep(i, r) {
		ans *= (n - i);
	}
	rep(i, r) {
		ans /= (i + 1);
	}
	return ans;
}



int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n;
	ll ans;
	ll sum = 0;
	cin >> n;
	vector<ll> a(n + 1);
	vector<ll> b(n);
	ll in;
	rep(i, n) {
		cin >> b[i];
		a[b[i]] += 1;
	}
	rep(i, n) sum += comb(a[i+1],2);
	rep(i, n) {
		ans = sum - comb(a[b[i]], 2) + comb(a[b[i]] - 1,2);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 6328
import bisect


def m():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = [abs(i) for i in a]
    right = bisect.bisect_right(a,0)
    left = right-1
    ans = 99999999999
    for i in range(n-k+1):
        s = 0
        if left >= i+k-1:
            s = b[i]
        elif right <= i:
            s = b[i+k-1]
        else:
            s = min(b[i] + b[i+k-1]*2, b[i]*2 + b[i+k-1])
        ans = min(ans, s)
    return ans

print(m())

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

def func(b):
    return sum([abs(val - b) for val in I])

#y seppen wo motomeru

I=[A[i]-i-1 for i in range(N)]
I.sort()

if N % 2 ==1:
    print(func(I[N//2]))
else:
    print(func(I[N//2]))



Measured memory_bytes: 99668
// Teleporter
// * frank_c1
// * 2017 / 10 / 01

#include <bits/stdc++.h>
using namespace std;

const int maxn = (int)(1e5) + 5;
vector<int> nxt[maxn];
int K, res;

int dfs(int x, int f) {
	int now = 1;
	for (int i = 0; i < (int)nxt[x].size(); ++i) if (nxt[x][i] != f) now = max(now, dfs(nxt[x][i], x) + 1);
	if (now == K && f > 1) now = 0, ++res; return now;
}

int main() {
	int n;
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x); 
		if (i == 1) res += (x != 1);
		else nxt[i].push_back(x), nxt[x].push_back(i);
	} dfs(1, 0);
	return printf("%d\n", res), 0;
}

Measured memory_bytes: 13568
#include <stdio.h>
#include <stdlib.h>


int compare(int *a, int *b){
  return *a - *b;
}

int main(){
  int n,k,
      a[500],b[500],sum=0,l,t,y,count,
      i,j;
  
  scanf("%d%d", &n, &k);
  
  for(i=0;i<n;i++){
	scanf("%d", &a[i]);
    sum += a[i];
  }
  
  l = sum;
  while(1){
    if(sum%l == 0){
      for(i=0;i<n;i++){
        b[i] = a[i] % l;
      }
      qsort(b, n, sizeof(int), compare);
      if(b[n-1] != 0){
        i = 0;
      	j = n-1;
      	while(b[i] == 0){
          i++;
      	}
        y=0;
        t=0;
        count=0;
      	while(i <= j){
          if(0 >= y){
            y += b[i];
            t += b[i];
            i++;
          }else{
            y -= (l - b[j]);
            j--;
          }
        }
        if(k<t){
          l--;
          continue;
        }
      }
      printf("%d", l);
      return 0;
    }else{
      l--;
    }
  }
}

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

const int INF = 2e9;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-k){
        if(a[i] < a[i+k])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

using namespace std;

const int maxN = 5000;
const int maxK = 5000;

int N, K;
int a[maxN];
bool vis[maxK];

int answer() {
	if (accumulate(a, a + N, 0ll) < K)
		return N;

	sort(a, a + N);
	vis[0] = true;
	int ans = N;
	for (int i = N - 1; i >= 0; i--) {
		for (int j = max(0, K - a[i]); j < K; j++) {
			if (vis[j]) {
				ans = i;
				break;
			}
		}
		for (int j = K - a[i] - 1; j >= 0; j--)
			vis[j + a[i]] |= vis[j];
	}
	return ans;
}

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

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

	cout << answer() << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); i ## op ## op)
#define cout(val) cout << val << endl

using namespace std;  

int main(){
    int n, k, d, a, count = 0;
    cin >> n >> k;
    vector<bool> data(n, true);
    rep(i, k){
        cin >> d;
        rep(j, d){
            cin >> a;
            data[a - 1] = false;
        }
    }
    rep(i, n){
        if(data[i]){
            ++count;
        }
    }
    cout(count);
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int[] array = new int[x];
		int min = 0;
		int max = 0;
		long sum = 0;

		for(int i=0;i<x;i++) {
			array[i] = sc.nextInt();
		}

		int tmp;
		for(int i=0;i<x;i++) {
			for(int j=i+1;j<x;j++) {
				if(array[j]<array[i]) {
					tmp = array[j];
					array[j] = array[i];
					array[i] = tmp;
				}
			}
			if(x>1) {
				if(i==0) {
					min = array[i];
				}else if(i==x-1) {
					max = array[i];
				}
			}else {
				min = array[i];
				max = array[i];
			}
			sum+=array[i];
		}

		System.out.println(min + " " + max + " " + sum);

		sc.close();
	}
}



Measured memory_bytes: 43148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		if(sc.nextInt() < 1000) {
			System.out.println("ABC");
		}else {
			System.out.println("ABD");
		}
		sc.close();
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    int pos=1;
    int cnt=0;
    while(true){
        if(pos>N){
            cout << cnt << endl;
            break;
        } 
        pos*=M;
        cnt++;
    }
}

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

int main(){
  double A,B,H,M;
  const double PI=acos(-1);
  cin >> A >> B >> H >> M;
  double x=H*30+M*0.5;
  double y=M*6;
  double ang=min(abs(x-y),360-abs(x-y));
  ang*=PI;
  ang/=180;
  double ans=pow(A,2)+pow(B,2)-2*A*B*cos(ang);
  ans=sqrt(ans);
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}


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

int main(){
	char m1, m2;
	char ball;
	
	ball = 'A';
	while((scanf("%c,%c", &m1, &m2)) != EOF){
		if(ball == m1) ball = m2;
		else if(ball == m2) ball = m1;
	}
	
	printf("%c\n", ball);
	
	return 0;
}

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

int main(){
    using namespace std;

    int N;
    long enemy_num =0;
    cin >> N;
    int A[N+1],B[N];
    for (int i = 0; i<=N;i++) cin >> A[i];
    for (int i = 0; i<N;i++) cin >> B[i];

    for (int j =0;j<N;j++){
        if(B[j] <= A[j]){
            A[j] -= B[j];
            enemy_num += B[j];
            B[j] = 0;
        }else{
            B[j] -= A[j];
            enemy_num += A[j];
            A[j] = 0;
            if(B[j] <= A[j+1]){
                A[j+1] -= B[j];
                enemy_num += B[j];
                B[j] = 0;
            }
            else{
                B[j] -=A[j+1];
                enemy_num += A[j+1];
                A[j+1] = 0;
            }
    }
}

cout << enemy_num << endl;
return 0;
}

Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()])

    def judge(i):
        m = A[i]
        for j, a in enumerate(A):
            if i == j:
                continue
            if a <= 2 * m:
                m += a
            else:
                return False
        return True
    
    l = -1
    r = N
    while l + 1 < r:
        m = (l + r) // 2
        if judge(m):
            r = m
        else:
            l = m
    
    print(N - (l + 1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

vector<int> w; vector<ll> v;
vector<vector<ll>> dp;

int main() {
	int n, W; cin >> n >> W; w.resize(n); v.resize(n);
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	dp.resize(n + 1, vector<ll>(W + 1, 0));
	for(int i = 1; i <= n; i++)
		for (int j = 1; j <= W; j++) {
			dp[i][j] = max({ dp[i][j], dp[i - 1][j], dp[i][j - 1] });
			if (j >= w[i - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
		}
	cout << dp[n][W] << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 83088
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=long long;
using namespace std;
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=1LL<<60;

int k,n,ans;
vector<ll> a(200100);
vector<ll> cnt(200100);

int main(){
    cin>>n>>k;
    rep(i,0,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    sort(cnt.begin(),cnt.end(),greater<ll>());

    int num=0;
    rep(i,0,k) num+=cnt[i];
    cout<<n-num<<"\n";
    return 0;
}

Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int x, a;
   cin >> x >> a;
   if (x < a)
      cout << 0 << endl;
   else
      cout << 10 << endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Long> nos = Arrays.asList(0L, 1L, 32L, 243L, 1024L, 3125L, 7776L, 16807L, 32768L, 59049L, 100000L, 161051L, 248832L, 371293L, 537824L, 759375L, 1048576L, 1419857L, 1889568L, 2476099L, 3200000L, 4084101L, 5153632L, 6436343L, 7962624L, 9765625L, 11881376L, 14348907L, 17210368L, 20511149L, 24300000L, 28629151L, 33554432L, 39135393L, 45435424L, 52521875L, 60466176L, 69343957L, 79235168L, 90224199L, 102400000L, 115856201L, 130691232L, 147008443L, 164916224L, 184528125L, 205962976L, 229345007L, 254803968L, 282475249L, 312500000L, 345025251L, 380204032L, 418195493L, 459165024L, 503284375L, 550731776L, 601692057L, 656356768L, 714924299L, 777600000L, 844596301L, 916132832L, 992436543L, 1073741824L, 1160290625L, 1252332576L, 1350125107L, 1453933568L, 1564031349L, 1680700000L, 1804229351L, 1934917632L, 2073071593L, 2219006624L, 2373046875L, 2535525376L, 2706784157L, 2887174368L, 3077056399L, 3276800000L, 3486784401L, 3707398432L, 3939040643L, 4182119424L, 4437053125L, 4704270176L, 4984209207L, 5277319168L, 5584059449L, 5904900000L, 6240321451L, 6590815232L, 6956883693L, 7339040224L, 7737809375L, 8153726976L, 8587340257L, 9039207968L, 9509900499L, 10000000000L, 10510100501L, 11040808032L, 11592740743L, 12166529024L, 12762815625L, 13382255776L, 14025517307L, 14693280768L, 15386239549L, 16105100000L, 16850581551L, 17623416832L, 18424351793L, 19254145824L, 20113571875L, 21003416576L, 21924480357L, 22877577568L, 23863536599L, 24883200000L, 25937424601L, 27027081632L, 28153056843L, 29316250624L, 30517578125L, 31757969376L, 33038369407L, 34359738368L, 35723051649L, 37129300000L, 38579489651L, 40074642432L, 41615795893L, 43204003424L, 44840334375L, 46525874176L, 48261724457L, 50049003168L, 51888844699L, 53782400000L, 55730836701L, 57735339232L, 59797108943L, 61917364224L, 64097340625L, 66338290976L, 68641485507L, 71008211968L, 73439775749L);
        List<Long> temp = new ArrayList<>();
        for (Long no : nos) {
            temp.add(-no);
        }
        temp.add(0L);
        temp.addAll(nos);
        long x = Long.parseLong(scanner.next());
        for (Long no : temp) {
            if (temp.contains(no - x)) {
                long b = no - x;
                long outA;
                long outB;
                if (no < 0) {
                    outA = (long)-Math.pow(-no,0.2);
                } else {
                    outA = (long)Math.pow(no,0.2);
                }
                if (b < 0) {
                    outB = (long)-Math.pow(-b,0.2);
                } else {
                    outB = (long)Math.pow(b,0.2);
                }
                System.out.println(outA + " " + outB);
                return;
            }
        }
    }

}

Measured memory_bytes: 27016
#include <bits/stdc++.h>
using namespace std;
int main (){
  int i,co=0,flag=0;
  string s;
  cin>>s;
  for(i=0;i<s.length();i++){
    if(i%2==0){
      if(s[i]=='h')
      co++;
      flag=1;
    }
    else{
      if(s[i]=='i')
      co++;
      flag=0;
    }
  }
  if(co==s.length()&&flag==0)
  cout<<"Yes";
  else
  cout<<"No";
  return 0;
}


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

map<long long, long long> soinsu(long long n)
{
    map<long long, long long> ret;
    long long a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            ret[a]++;
            n /= a;
        } else {
            a++;
        }
    }
    if(n != 1) ret[n]++;

    return ret;
}

void solve(long long N){
  auto mysoinsu = soinsu(N);
  long long count = 0;

  for(auto x: mysoinsu){
    count += (sqrt(8*x.second+1)-1)/2;
  }

  cout << count << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
	if (l >= r) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve(){
	pos = 0;
	rec(0, pre.size());
	for (int i = 0; i < n; i++){
		if (i) cout << " ";
		cout << post[i];
	}
	cout << endl;
}

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

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

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

	solve();

	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
long int max(long int a, long int b) { return a > b ? a : b; }

int main(){
  long int a,b,k;
  scanf("%ld%ld%ld",&a,&b,&k);
  if(a<=k){
    printf("%ld %ld",0,max(0,a+b-k));
  }
  else{
    printf("%ld %ld",a-k,b);
  }
  return 0;
}


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

int32_t main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    if(a > b) swap(a, b);
    if((b - a) % 2 == 0) return cout << (b - a) / 2 << '\n', 0;

    long long cnt1 = a + (b - a - 1) / 2;
    
    long long x = n - b + 1;
    a += x;
    b = n;
    
    long long cnt2 = x + (b - a) / 2;
    cout << min(cnt1, cnt2) << '\n';


    return 0;
}

Measured memory_bytes: 256