akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T ll
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}


int main(){
    IOS

    int n;
    cin>>n;
    int c=0;
    FOR(i,1,n){
    	int x;
    	cin>>x;
    	if(x!=i){
    		c++;
    	}
    }
    if(c>2){
    	cout<<"NO";
    }
    else{
    	cout<<"YES";
    }
    
    return 0;
}

Measured memory_bytes: 256
S = input()
yes = True
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            yes = False
            break
    else:
        if S[i] == "R":
            yes = False
            break
            
if yes:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    long long a, b, k;

    scanf("%lld %lld %lld", &a, &b, &k);

 
    if(a>k){
        a-=k;
    }else{
        k-=a;
        a=0;
    }

    if(a==0){
        if(b>k){
            b-=k;
        }else{
            k-=a;
            b=0;
        }
    }


    printf("%lld %lld", a, b);
    
    return 0;
}

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

cnt = 0
BA = 0
B_ = 0
_A = 0
for _ in range(n):
    s = input()
    cnt += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        BA += 1
    elif s[0] == 'B':
        B_ += 1
    elif s[-1] == 'A':
        _A += 1

if BA:
    cnt += BA - 1
    if B_:
        cnt += 1
        B_ -= 1
    if _A:
        cnt += 1
        _A -= 1
cnt += min(max(0, B_), max(0, _A))

print(cnt)


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

int main() {
	int n, m;
	cin >> n >> m;
	int ans = n*(n-1)/2 + m*(m-1)/2;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
isBroken = [0] * (N+1)

for i in range(M):
    a = int(input())
    isBroken[a] = 1

dp = [0 for _ in range(N+2)]
#幻のN+1段目まで生やして、そこの組み合わせをゼロにする

dp[N] = 1
for i in range(N-1, -1, -1):
    if isBroken[i]:
        dp[i] = 0
        continue
    dp[i] = dp[i+1] + dp[i+2]
print(dp[0] % (10**9 + 7))


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

#define int long long
typedef long double ld;

int n, k;
ld ans, p;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	p = 1.0 / (ld)n;
	for (int i = 1; i <= n; i++) {
		int j = i;
		ld tmp = p;
		while (j < k)
			j *= 2, tmp = (ld)tmp / (ld)2.0;
		ans += tmp;
	}
	cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e;
  cin>>k;
  
  int i=e-a;
  
  if(i>k)
    cout<<":(";
  else
    cout<<"Yay!";
  
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s,s1;
  cin >> s;
  cin >> s1;
  long long int i,f=0,c=0,l=0;
  l=s.size();
  for(i=0;i<l;i++)
  {
    if(s[i]!=s1[i])
    {
      f=1;
      break;
    }
  }
  if(f==1)
  {
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

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

using namespace std ;

long long int a[500009]={} ;

int main () {

    long long int x[5] ;

    for(long long int i=0;i<4;i++)
    {
        cin>>x[i] ;
        a[x[i]]++ ;
    }

    if(a[1]==1 and a[9]==1 and a[7]==1 and a[4]==1 )
        cout <<"YES\n";
    else
        cout<< "NO\n" ;



}


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

using namespace std;

int H, W;
string F[600];

bool isgrid(int x, int y)
{
  return (0 <= x && x < W && 0 <= y && y < H && F[y][x] == '#');
}


int main()
{
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> F[i];
  }

  vector< pair< pair< int, int >, int > > Event;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(isgrid(j, i) && !isgrid(j, i - 1) && !isgrid(j - 1, i))
        Event.push_back({{j, H - i}, 1});
      else if(!isgrid(j, i) && isgrid(j, i - 1) && isgrid(j - 1, i))
        Event.push_back({{j, H - i}, 1});
      else if(isgrid(j, i) && !isgrid(j, i + 1) && !isgrid(j + 1, i))
        Event.push_back({{j + 1, H - i - 1}, -1});
      else if(!isgrid(j, i) && isgrid(j, i + 1) && isgrid(j + 1, i))
        Event.push_back({{j + 1, H - i - 1}, -1});
    }
  }

  sort(begin(Event), end(Event), [](auto &a, auto &b)
  {
    int c = a.first.first * b.first.second;
    int d = a.first.second * b.first.first;
    if(c == d) return (a.second < b.second);
    return (c < d);
  });


  int proc = 1, ret = 1;
  for(auto &k : Event) {
    proc += k.second;
    ret = max(ret, proc);
  }

  cout << ret << endl;

}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x,ll y,ll m) 
{
    ll res = 1; 
    x = x % m;                
    if (x == 0)
        return 0; 
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

void solve()
{
    int n,k;
    cin>>n>>k;
    map<int,int> m;
    for(int i=0;i<k;i++) {
        int d;
        cin>>d;
        for(int j=0;j<d;j++) {
            int a;
            cin>>a;
            m[a]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++) {
        if(m[i]==0) {
            ans++;
        }
    }
    cout<<ans;
    
}

int main()
{
    fastio;
    int t;
    t=1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

Measured memory_bytes: 3628
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var m = int.Parse(Console.ReadLine().Trim());
            if (m == 0) break;
            var a = new int[m, 2];
            for (int i = 0; i < m; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                a[i, 0] = int.Parse(line[0]);
                a[i, 1] = int.Parse(line[1]);
            }
            var dp =   getAns(a, m );
            var q = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < q; i++)
            {
                var b = int.Parse(Console.ReadLine().Trim());
                Console.WriteLine( dp[m,b]  );
            }
        }
    }
    static  int[,] getAns(int[,] a, int m )
    {
        var dp = new int[m + 1, 1001];
        dp[0, 0] = 1;
        for (int i = 0; i < m; i++)
            for (int j = 0; j <= 1000; j++)
                for (int k = 0; k <= a[i, 1]; k++)
                {
                    var w = j + a[i, 0] * k;
                    if (w > 1000) continue;
                    dp[i + 1, w] += dp[i, j];
                }
        return dp;
    }
}



Measured memory_bytes: 17832
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict

H, W, D = map(int, input().split())
A = [list(map(int, input().split()))  for _ in range(H)]

dic = defaultdict(list)

for h in range(H):
    for w in range(W):
        dic[A[h][w]] = [h, w]

def calc(l, r):
    return abs(dic[l][0] - dic[r][0]) + abs(dic[l][1] - dic[r][1])

lst = [0] * (H * W + 1)
for d in range(1, D + 1):
    tmp = d
    while tmp + D <= (H * W):
        lst[tmp + D] = lst[tmp] + calc(tmp, tmp + D)
        tmp += D

# print (lst)
Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = lst[R] - lst[L]
    print (ans)


Measured memory_bytes: 26760
def resolve():
    N = int(input())
    B = list(map(int, input().split()))
    B = [10**9] + B + [10**9]
    curr_sum = 0
    for i in range(1, len(B)):
        curr_sum += min(B[i-1], B[i])
    print(curr_sum)

resolve()

Measured memory_bytes: 3060
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])
# print(h)

inf = 10**9
min_height = inf
for i in range(N-K+1):
    # print(i+(K-1), h[i+(K-1)], i, h[i])
    min_height = min(min_height, h[i+(K-1)] - h[i])

print(min_height)


Measured memory_bytes: 8280
l = list(range(1, 100000))
tri_num = set(i*(i+1)//2 for i in range(1, 100000))

while True:
    N = int(input())
    
    if N==0:
        break
    
    b = list(map(int, input().split()))
    
    if sum(b) not in tri_num:
        print(-1)
        continue
    
    ans = 0
    
    while True:
        flag = True
        
        for i in range(len(b)):
            if b[i]!=l[i]:
                flag = False
        
        if flag:
            print(ans)
            break
        
        for i in range(len(b)):
            b[i] -= 1
    
        b.append(len(b));
        b = [bi for bi in b if bi!=0]
        ans += 1
        
        if ans>10000:
            print(-1)
            break


Measured memory_bytes: 18228
import java.util.Scanner;

class Main{

    static long[] factorial;
    static long[] invfac;

    static long mod = (long)1e9+7;
    static long inverse(long m){
        long res =1;
        for(int i=0;i<32;++i){
            if((((mod-2)>>i)&1)==1)res=(res*m)%mod;
            m = (m*m)%mod;
        }
        return res;
    }
    static long C(int i, int j){
        return (((factorial[i]*invfac[i-j])%mod)*invfac[j])%mod;
    }

    static long func(int N, int j){
        //Nをj回以上で埋める
        if(N==j)return factorial[N];
        return ((C(j-1,N-j-1)*factorial[j])%mod*factorial[N-j-1])%mod;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        factorial = new long[N+1];
        factorial[0]=1;
        for(int i=1;i<=N;++i)factorial[i]=(factorial[i-1]*i)%mod;
        invfac = new long[N+1];
        for(int i=0;i<=N;++i)invfac[i]=inverse(factorial[i]);
        long ans = (func(N, (N+1)/2)*((N+1)/2))%mod;
        for(int j=(N+1)/2+1;j<N;++j){
            ans = (ans + j*((func(N, j) - func(N, j-1) + mod)%mod)%mod)%mod;
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 38868
def maxHeapify(T,i):
    l=2*i+1
    r=2*(i+1)
    H=len(T)
    left=l<H and T[i]<T[l]
    right=r<H and T[i]<T[r]
    if left and right:
        if T[r]<T[l]:
            right=0
        else:
            left=0
    if left:
        T[i],T[l]=T[l],T[i]
        maxHeapify(T,l)
    elif right:
        T[i],T[r]=T[r],T[i]
        maxHeapify(T,r)
        


H=int(input())
Nodes=[int(i) for i in input().split()]
for i in range(H-1,-1,-1):
    maxHeapify(Nodes,i)
print('',*Nodes)


Measured memory_bytes: 63968
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

vector<int> g[100005];
int lvl[100005];
int vis[100005];

void dfs(int x){
    vis[x] = 1;

    for(int node:g[x]){
        if(!vis[node])
            dfs(node);
    }
}

void bfs(int x){
    queue<int> q;
    q.push(0);
    vis[0] = 1;
    lvl[0] = -1;
    while(!q.empty()){
        int curr = q.front();
        q.pop();

        for(int node:g[curr]){
            if(!vis[node]){
                q.push(node);
                vis[node] = 1;
                lvl[node] = curr;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n , m;
    cin >> n>> m;

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        --a,--b;
        g[a].pb(b);
        g[b].pb(a);
    }

    for(int i=0;i<=n;i++)vis[i] = 0;

    dfs(0);
    int f1=0;
    for(int i=0;i<n;i++){
        if(vis[i] == 0)
        {
            f1 = 1;
            break;
        }
    }

    if(f1 == 1){
        cout<<"No";
    }
    else{
        for(int i=0;i<=n;i++)vis[i] = 0;
        bfs(0);
        cout<<"Yes"<<endl;
        for(int i=1;i<n;i++){
            cout<<lvl[i]+1<<endl;
        }
    }
}


Measured memory_bytes: 12884
import itertools

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
citys = [i for i in range(n)]
roots = list(itertools.permutations(citys))

sum = 0
for root in roots:
    for i in range(n-1):
        sum += ((xy[root[i]][0] - xy[root[i+1]][0])**2 + (xy[root[i]][1] - xy[root[i+1]][1])**2)**(0.5)


print(sum/len(roots))



Measured memory_bytes: 80788
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    if max(a, b) <= 9 {
        println!("{}", a*b);
    } else {
        println!("-1");
    }
}

Measured memory_bytes: 4352
import Control.Applicative

main :: IO ()
main = solve <$> readLn >>= print

solve :: Int -> Int
solve k = ls !! (k - 1)
  where
    ls = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
using namespace std;
long long n, x;
long long ans;

long long solve ( long long a, long long b ) {
    if ( a > b ) { swap( a, b ); }
    if ( a == b ) { return a; }

    long long r = b%a;
    long long d = b/a;
    if ( r == 0 ) {
        r += a;
        d --;
    }

    return 2*a*d + solve( a, r );
}

int main () {
    cin >> n >> x;
    ans = n;
    ans += solve ( x, n-x );
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	char a[n][n],b[m][m];
	rep(i,n)rep(j,n)cin>>a[i][j];
	rep(i,m)rep(j,m)cin>>b[i][j];
	bool ans=false;
	for(int i=0;i<n-m+1;i++){
		for(int j=0;j<n-m+1;j++){
			bool check=true;
			rep(k,m){
				rep(l,m){
					if(a[i+k][j+l]!=b[k][l]){
						check=false;
						break;
					}
				}
			}
			if(check){
				ans=true;
				break;
			}
		}
		if(ans)break;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defun main ()
  (let* ((s1 (map '(simple-array uint8 (*)) (lambda (c) (- (char-code c) 97)) (read-line)))
         (s2 (map '(simple-array uint8 (*)) (lambda (c) (- (char-code c) 97)) (read-line)))
         (table1 (make-array 26 :element-type 'fixnum :initial-element -1))
         (table2 (make-array 26 :element-type 'fixnum :initial-element -1)))
    (write-line
     (dotimes (i (length s1) (return "Yes"))
       (if (= -1 (aref table1 (aref s1 i)))
           (setf (aref table1 (aref s1 i)) (aref s2 i))
           (unless (= (aref table1 (aref s1 i)) (aref s2 i))
             (return "No")))
       (if (= -1 (aref table2 (aref s2 i)))
           (setf (aref table2 (aref s2 i)) (aref s1 i))
           (unless (= (aref table2 (aref s2 i)) (aref s1 i))
             (return "No")))))))

#-swank(main)


Measured memory_bytes: 26212
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int lli;
const double EPS = 1e-10;

int main(){
    int w,h,v,t,sx,sy,gx,gy;
    cin>>w>>h>>v>>t>>sx>>sy>>gx>>gy;
    lli rad = v*t;

    long long int ans=0;
    double diff = gx;
    for(int x=-gx-2*w*(rad/(2*w)+1); x<=sx+rad; x+=2*diff, diff=w-diff){
        if(sx-x>rad) continue;
        double d = sqrt((double)rad*rad -(double)(sx-x)*(sx-x));
        double lub[2]={d-sy, d+sy};
        for(int i=0; i<2; i++){
            if(lub[i]-gy+EPS > 0){ 
                ans += (lli)( (lub[i]-gy+EPS)/(2*h) +1 );
            }
            if(lub[i]-(2*h-gy)+EPS > 0){
                ans += (lli)( (lub[i]-(2*h-gy)+EPS)/(2*h) +1 );
            }
        }
        if(gy<lub[1] && gy<-lub[0]) ans -= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3092
h, w, a, b = map(int,input().split())
A = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        A[i][j] = int((j < a) ^ (i < b))

for i in range(h):
    print("".join([str(j) for j in A[i]]))

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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N; i++) {
      cin >> w.at(i) >> v.at(i);
  }
  
  vector<vector<int64_t>> DP(N+1, vector<int64_t>(W+1, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      int64_t before = DP[i][j];
      if (j + w[i] <= W) {
        chmax(DP[i+1][j+w[i]], before + v[i]);
      }
      chmax(DP[i+1][j], before);
    }
  }
  cout << DP[N][W] << endl;
  /*
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= W; j++) {
      cout << DP[i][j] << " ";
    }
    cout << endl;
  }
  */
}

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

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a,b;
		cin >> a >> b;
		cout  << a+b<< endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i;
	int max = 0;
	int sum = 0;
	int n;
	int l[101];
	
	scanf("%d" , &n);
	
	for(i = 0 ; i != n ; i++){
		scanf("%d" , &l[i]);
		if(l[i] > max){
			sum += max;
			max = l[i];
		} else {
			sum += l[i];
		}
	}
	
	if(sum > max) printf("Yes\n");
	else printf("No\n");
		
	return 0;
}

Measured memory_bytes: 128
import sys, math
#import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.buffer.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = 998244353
#from decimal import Decimal

x,y=mdata()
if 4*x<y or y<2*x or y%2!=0:
    out("No")
else:
    out("Yes")




Measured memory_bytes: 65256
N, K = map(int, input().split())
V = [int(i) for i in input().split()]

ans = -1
for i in range(min(N + 1, K + 1)): #i個ゲット
    for l in range(i + 1): #左からいくつのindexまでとるか
        a = V[0:l] + V[N - (i - l):N]
        a.sort()

        # K- i 個負のvalueを捨てれる
        t = 0
        s = sum(a)
        while i > t and K - i > t:
            if a[t] >= 0:
                break
            s -= a[t] #負の減算なので加算
            t += 1
        ans = max(ans, s)

print(ans)


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

int main() {

  int N, K;
  cin >> N >> K;
  int A = 1;
  for (int i; i  < N; ++i){
  if (A*2 <= A+K ) A*= 2;
  else if ( A*2 > A+K) A+= K;
  
  }
cout << A << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main() {
	
	int n;
	cin>>n;
	int r=n%10;
	if(r==3)
	cout<<"bon";
	else if(r==0 || r==1 || r==6 || r==8)
	cout<<"pon";
	else
	cout<<"hon"	;
	

	
	return 0;
}


Measured memory_bytes: 3624
// ~zaletaet~

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0)
    cout << 1;
  if (b == 0)
    cout << 2;
  if (c == 0)
    cout << 3;
  if (d == 0)
    cout << 4;
  if (e == 0)
    cout << 5;

  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
int f[105][100005];
int N,W;
int w[105],v[105];
int main()
{
	scanf("%d%d",&N,&W);
	for(int i=1;i<=N;++i) 
	    scanf("%d%d",&w[i],&v[i]);
	for(int i=0;i<=N;++i)
	   for(int j=1;j<=100000;++j) 
	       f[i][j]=1e9+1;
	for(int i=1;i<=N;++i)
	{
		for(int j=0;j<=100000;++j)
	    {
		    f[i][j]=f[i-1][j];
		    if(j >=v[i]) f[i][j]=min(f[i][j],f[i-1][j-v[i]] + w[i]);
 	    }
	}
	int ans=0;
	for(int i=0;i<=100000;++i)
	   if(f[N][i] <= W) ans=i;//cout<<f[N][i]<<endl;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 43184
#include <stdio.h>
#define REP(i, n) for (i=0;i<n;i++)
int n, s;

int solve(int idx, int value, int *A) {
    if (value == 0) return 1;
    if (idx >= n) return 0;

    s = solve(idx+1, value - A[idx], A) || solve(idx+1, value, A);
    return s;
}

int main(void) {
    int q, i, value;
    scanf("%d", &n);
    int A[n];
    REP(i, n) scanf("%d", &A[i]);
    scanf("%d", &q);
    REP(i, q) {
        scanf("%d", &value);
        if (solve(0, value, A)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = Integer.valueOf(sc.nextLine());
		int[] array = new int[count];
		for (int i = 0; i < count; i++) {
			array[i] = sc.nextInt();
		}
		sc.close();
		
		int[] resultArray = new int[count];
		int indexForward = 0;
		int indexBackward = array.length -1 ;
		for (int j = array.length - 1; j >= 0; j -= 2) {
			resultArray[indexForward++] = array[j];
		}
		for (int j = array.length - 2; j >= 0; j -= 2) {
			resultArray[indexBackward--] = array[j];
		}
 
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < count; i++) {
			sb.append(resultArray[i]);
			if (i != count - 1) {
				sb.append(" ");
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 73804
#include <iostream>
#include <unordered_set>

int main()
{
  int n;
  std::cin >> n;
  std::unordered_set<int> pool;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int val;
    std::cin >> val;
    auto it = pool.find(val);
    if (it == pool.end()) {
      pool.insert(val);
      cnt++;
    }
  }
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int head[N],d[N]; bool vis[N],flag=false;
int n,m,x,y,z,kk=0;
struct Edge{int nxt,to,step;}e[N];
void link(int x,int y,int z){e[++kk].nxt=head[x];e[kk].to=y;e[kk].step=z;head[x]=kk;}
void dfs(int u)
{
	if (flag) return; vis[u]=true;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to; if (flag) return;
		if (d[u]+e[i].step<d[v]){
			d[v]=d[u]+e[i].step;
			if (vis[v]){flag=true;return;}
			else dfs(v);
		}
	} vis[u]=false;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&z);
		link(x,y,z);link(y,x,-z);
	} flag=false;
	for (int i=1;i<=n;i++){
		dfs(i); if (flag) break;
	} if (flag) puts("No"); else puts("Yes");
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int dp[2000][1<<12];
int a[300000];
int c[300000];

int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		int b;scanf("%d%d",&a[i],&b);
		rep(j,b){
			int d;scanf("%d",&d);d--;
			c[i]|=1<<d;
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	rep(i,m)rep(j,1<<n){
		dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		dp[i+1][j|c[i]]=min(dp[i+1][j|c[i]],dp[i][j]+a[i]);
	}
	if(dp[m][(1<<n)-1]==INF)puts("-1");
	else cout<<dp[m][(1<<n)-1]<<endl;
}

Measured memory_bytes: 32640
#include <bits/stdc++.h>
using namespace std;
const int Z = 2500, BASE = 1e9 + 7;

int n, k;
long long f[55][55][5050];

long long dp(int i, int j, int sum)
{
  if (i > n)
    return j == 0 && sum == k;
  long long &res = f[i][j][sum + Z];
  if (res >= 0)
    return res;

  res = dp(i + 1, j, sum);
  if (j)
  {
    res = (res + dp(i + 1, j - 1, sum + i * 2) * j * j) % BASE;
    res = (res + dp(i + 1, j, sum) * j * 2) % BASE;
  }
  res = (res + dp(i + 1, j + 1, sum - i * 2)) % BASE;
  return res;
}

int main()
{
  cin >> n >> k;
  memset(f, -1, sizeof f);
  cout << dp(1, 0, 0) << endl;
}


Measured memory_bytes: 119552
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N;
int a[50];

signed main()
{
	cin >> N;
	REP(i, N) cin >> a[i];

	int cnt = 0;
	while (true)
	{
		int cc = 0;
		for (int i = 0; i < N; i++)
		{
			int c = a[i] / N;
			cc += c;
			a[i] -= c * N;
			a[i] -= c;
		}
		for (int i = 0; i < N; i++)
		{
			a[i] += cc;
		}
		cnt += cc;
		if (cc == 0)
		{
			break;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {bool F=K=0;char C=getchar();while(C<'0'||C>'9')
{if(C=='-')F=1;C=getchar();}while(C<='9'&&C>='0')K=(K<<1)+(K<<3)+C-'0',C=getchar();if(F)K=-K;}
template < class R > inline bool Checkmax( R &A , R B ) { return A > B ? A = B , 1 : 0 ; }
template < class R > inline bool Checkmin( R &A , R B ) { return A < B ? A = B , 1 : 0 ; }
int main() {
	int N ;
	long long Ans = 0 , Last = 0 , Now ;
	Readin( N ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		Readin( Now ) ;
		if( Last and Now ) {
			++Ans ;
			--Now ;
		}
		Last = Now & 1 ;
		Ans += Now >> 1 ;
	}
	return not printf( "%lld\n" , Ans ) ;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#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;
const ll mod=1e9+7;
const int inf=1<<30;

struct unionfind{
  vector<int> par;
  unionfind(int n):par(n,-1){}
  void init(int n){par.assign(n,-1);}
  int root(int x){
    if(par[x]<0) return x;
    else return par[x]=root(par[x]);
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(par[x]>par[y]) swap(x,y);
    par[x]+=par[y];
    par[y]=x;
    return true;
  }
  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  int n,m; cin >> n >> m;
  unionfind uf(n);
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    uf.merge(a,b);
  }
  map<int,int> mp;
  rep(i,n){
    mp[p[i]]=i;
  }
  int ans=0;
  rep(i,n){
    if(uf.issame(mp[i],i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

typedef struct{
	int no;
	int score;
} Info;

void sortInfo(int n,Info t[]){
	int i,j;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(t[i].score < t[j].score ||
			   t[i].score == t[j].score && t[i].no > t[j].no){
				Info tmp = t[i];
				t[i] = t[j];
				t[j] = tmp;
			}
		}
	}
}

int scoring(void){
	int i, x, total, frame, time, sum, flgSpare, flgStrike;
	
	total = sum = 0;
	frame = time = 1;
	flgSpare = flgStrike = 0;
	
	while(frame < 10){
		scanf("%d",&x);
		sum += x;
		
		if(flgSpare){
			total += x;
			flgSpare = 0;
		}
		else if(flgStrike){
			if(flgStrike == 3){
				total += x;
				flgStrike--;
			}
			total += x;
			flgStrike--;
		}
		
		if(time == 2){
			total += sum;
			if(sum == 10){
				flgSpare = 1;
			}
			sum = 0;
			time = 1;
			frame++;
		}
		else if(time == 1){
			time++;
			if(x == 10){
				total += 10;
				flgStrike += 2;
				sum = 0;
				time = 1;
				frame++;
			}
		}
	}
	
	for(i=0;i<3;i++){
		if(i == 2 && sum < 10) break;
		
		scanf("%d",&x);
		total += x;
		sum += x;
		
		if(flgSpare){
			total += x;
			flgSpare = 0;
		}
		else if(flgStrike){
			if(flgStrike == 3){
				total += x;
				flgStrike--;
			}
			total += x;
			flgStrike--;
		}
	}

	return total;
}

int main(void){
	int i, n;
	Info info[40];
	
	while(scanf("%d",&n) && n){
		for(i=0;i<n;i++){
			scanf("%d",&info[i].no);
			info[i].score = scoring();
		}
		sortInfo(n,info);
		for(i=0;i<n;i++){
			printf("%d %d\n",info[i].no,info[i].score);
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
    map < string , int > mp;
typedef long long int ll;
const int N = 1e5 + 5;
ll arr[N];
int main(){
   ll i, j , n , m , x, ans = 0, res(0);
    cin >> n ;
    for(i = 0 ; i < n; i ++)cin >> arr[i];;
    
    for(i = 0 ; i < n; ){
        ll curr = arr[i];ans = 0;
        while(i < n and curr == arr[i])ans++, i++;
        res += ans / 2;
    }
    cout << res;
    
    return 0;
}

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

typedef long long ll;


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

    double W, H, x, y;

    cin >> W >> H >> x >> y;

    if(x * 2 == W && y * 2 == H) {
        cout << fixed << setprecision(30) << W * H / 2.0 << " " << 1 << endl;
    } else {
        cout << fixed << setprecision(30) << W * H / 2.0 << " " << 0 << endl;
    }

}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
signed main() {
	int a, b, x; cin >> a >> b >> x;
	cout << b / x - max(a - 1, 0ll) / x + !a << endl;
	system("pause");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, a) {
        cin >> p[i];
    }
    rep(i, b) {
        cin >> q[i];
    }
    rep(i, c) {
        cin >> r[i];
    }
    sort(all(p), greater<int>()); sort(all(q), greater<int>()); sort(all(r), greater<int>());
    vector<int> el;
    rep(i, x) {
        el.push_back(p[i]);
    }
    rep(i, y) {
        el.push_back(q[i]);
    }
    rep(i, c) {
        el.push_back(r[i]);
    }
    sort(all(el), greater<int>());
    ll sum = 0;
    rep(i, x+y) {
        sum += el[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3572
A, B, K = gets.split(' ')

if A.to_i < B.to_i then
    n = A.to_i
else
    n = B.to_i
end

i = 1
array = []
(n/2).floor.times do
    if A.to_i % i == 0 && B.to_i % i == 0 then
        array << i
    end
    i = i + 1
end

if A.to_i % n == 0 && B.to_i % n == 0 then
    array << n
end

print array[-K.to_i]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    5256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );

using namespace std;
ll n;
string s;
ll h[N][N];
map < ll, bool > m;
bool ok;
void solve()
{
    cin >> n >> s;
    for( ll i = 0; i < n; i ++ )
    {
        h[i][i] = s[i] - 'a' + 1;
        for( ll j = i + 1; j < n; j ++ )
            h[i][j] = ( ( h[i][j-1] * 31LL ) + ( s[j] - 'a' + 1LL ) ) % M;
    }
    ll l = 1, r = n - 1, ans = 0;
    while( l <= r )
    {
        ll len = l + r >> 1;
        ok = 0;
        m.clear();
        for( ll i = 0; i + len - 1 < n; i ++ )
        {
            if( m[ h[i][i + len - 1] ] )
            {
                ok = 1;
                break;
            }
            if( i - len + 1 >= 0 )
                m[ h[i - len + 1][i] ] = 1;
        }
        if( ok )
        {
            ans = len;
            l = len + 1;
        }
        else r = len - 1;
    }
    cout << ans;
}

int main()
{
    int tt = 1;
    //sc( "%d", &tt );
    for( int i = 1; i <= tt; i ++ )
        solve();
}












Measured memory_bytes: 207360
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  ll x, y;
};
bool operator<(const ST& a, const ST& b){
  int sa = -1;
  if(a.x>=0 && a.y>=0) sa = 1;
  else if(a.x<=0 && a.y>=0) sa = 2;
  else if(a.x<=0 && a.y<=0) sa = 3;
  else if(a.x>=0 && a.y<=0) sa = 4;
  int sb = -1;
  if(b.x>=0 && b.y>=0) sb = 1;
  else if(b.x<=0 && b.y>=0) sb = 2;
  else if(b.x<=0 && b.y<=0) sb = 3;
  else if(b.x>=0 && b.y<=0) sb = 4;

  if(sa != sb) return sa < sb;

  return a.x * b.y - b.x * a.y > 0;
}

int main(){
  int N;
  cin >> N;
  vector<ST> v;
  rep(i,N){
    ll x, y;
    cin >> x >> y;

    v.push_back((ST){x,y});
  }
  sort(ALLOF(v));

  double ret = 0;
  int M = v.size();
  rep(i,M){
    ll X = 0, Y = 0;
    rep(j,M){
      X += v[(i+j)%M].x;
      Y += v[(i+j)%M].y;
      double dist = sqrt(X*X+Y*Y);
      ret = max(ret, dist);
    }
  }

  printf("%.12lf\n", ret);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int tmp = -1, idx = -1, sign = 0;
	rep(i, n) if (chmax(tmp, abs(a[i]))) {
		if (a[i] < 0) sign = -1;
		else sign = 1;
		idx = i;
	}
	vector<P> ans;
	rep(i, n) {
		if (i == idx) continue;
		ans.pb({ idx,i });
	}
	if (sign == 1) rep(i, n - 1) ans.pb({ i,i + 1 });
	else for (int i = n - 2; i >= 0; i--) ans.pb({ i + 1,i });
	cout << ans.size() << '\n';
	for (P p : ans) cout << p.first + 1 << ' ' << p.second + 1 << '\n';
}

Measured memory_bytes: 3668
local n,x=io.read("n","n")
local b,p={[0]=1},{[0]=1}
for i=1,n do
    b[i]=b[i-1]*2+3
    p[i]=p[i-1]*2+1
end

local function patty(n,x)
    if n==0 then
        return (x>0 and 1 or 0)
    elseif x<=b[n-1]+1 then
        return patty(n-1,x-1)
    else
        return p[n-1]+1+patty(n-1,x-2-b[n-1])
    end
end

print(string.format("%d",patty(n,x)))

Measured memory_bytes: 2740
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        Arrays.sort(a);
        int total = 0;
        for(int i = 0; i < n-1; i++){
            total += a[i];
        }
        pw.println(total > a[n-1] ? "Yes" : "No");
        pw.flush();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25420
n,k,q=gets.split.map(&:to_i)
aNs = Hash.new
q.times do
  a = gets.to_i
  if aNs.has_key?(a)
  	aNs[a] += 1
  else
    aNs[a] = 1
  end
end
n.times do |count|
  index = count + 1
  correctNumbers = aNs.has_key?(index) ? aNs[index] : 0
  if 0 >= (k-q+correctNumbers)
  	puts "No"
  else
    puts "Yes"
  end
end

Measured memory_bytes: 6524
#include<stdio.h>
#include<stdlib.h>
#define INF 1001001001
int main(void){
	int n,a,b;
	int h[100100]={0};
	int i,j;
	long need;
	long ok,ng,mid;
	scanf("%d%d%d",&n,&a,&b);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	ok=INF;ng=0;
	while(ok-ng>1){
		mid=(ok+ng)>>1;
		need=0;
		for(j=0;j<n;j++){
			if(h[j]-mid*b>=0){
				need+=(int)ceil(((double)(h[j]-mid*b)/(a-b)));
			}
		}
		if(need<=mid){
			ok=mid;
		}else{
			ng=mid;
		}
	}
	printf("%ld\n",ok);
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
char s[3];
int main(){
  rep(i,3)scan(s[i]);
  int cnt=0;
  rep(i,3){
    if(s[i]=='1'){
      cnt++;
    }
  }
  prin(cnt);
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextLong();
        }


        System.out.println(solve(N, A));
    }

    private static long solve(int N, long[] A) {
        int[] bit = new int[61];

        for (int i=0; i<N; i++) {
            int k= 0;
            while (A[i] > 0) {
                bit[k++] += A[i]&1;
                A[i] /= 2;
            }
        }

        long ans = 0;
        long p = 1;
        for (int i=0; i<=60; i++) {
            ans += ((long)bit[i] * (N-bit[i]) % MOD) * p;
            ans %= MOD;
            p = p * 2 % MOD;
        }

        return (ans+MOD)%MOD;
    }
}

Measured memory_bytes: 98320
#include <iostream>
#include <ctime>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include<cstring>
#include <set>
using namespace std;
typedef long long ll;
int a[200005];
bool compare(int a,int b){
    return a>b;
}
int main(){

    int n,k,x;
    cin>>n>>k;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++){
        cin>>x;
        a[x]++;
    }
    int ans=0;
    sort(a,a+n,compare);
    for(int i=k;i<=n;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<bool> b(n);
    vector<int> num(n,1);
    for(int i=0;i<n;i++)b[i]=false;
    b[0]=true;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        num[x]--;
        num[y]++;
        if(b[x])b[y]=true;
        if(num[x]==0)b[x]=false;
    }
    int res=0;
    for(int i=0;i<n;i++){
        if(b[i]&&num[i])res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024