akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

string s;

int main() {
	cin >> s;
	
	bool ans = true;
	inc(i, SI(s)) {
		if(i % 2 == 0 && s[i] == 'L') { ans = false; }
		if(i % 2 == 1 && s[i] == 'R') { ans = false; }
	}
	
	cout << (ans ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//SET PRECIOSION   cout << fixed ;  cout << setprecision(n) << ans << endl;
#define ll long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a,b,c,sum,ans,total,t,cnt,n,m,k,p,kase;
string inp[1011];
ll dp[1011][1011];

ll findAns(ll i, ll j)
{
     if(i==n-1 && j== m-1)
        return 1;
    if(i>=n|| j>=m)
        return 0;
    if(i<0|| j<0)
        return 0;
    if(inp[i][j]=='#')
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll ans1 = 0, ans2 = 0,ans3=0, ans4 = 0;
    ans2 = findAns(i+1,j);
    ans3 = findAns(i, j+1);
    return dp[i][j]= (ans1+ans2+ans3+ans4)%(1000000007);

}
int main()
{
	FAST;
	cin>>n>>m;
	for(ll i=0; i<n; i++)
        cin>>inp[i];
    memset(dp,-1,sizeof(dp));

    cout<<findAns(0,0)<<endl;
	//clear vectors and maps you idiot
	// check array size dumb
	// use long long instead of int too
	return 0;
}


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

#undef int
int main()
{
#define int long long int

	int s;
	cin>>s;
	cout<<"0 0 1000000000 1 "<<(1000000000-s%1000000000)%1000000000<<" "<<(s+(1000000000-s%1000000000)%1000000000)/1000000000<<endl;

	return 0;
}


Measured memory_bytes: 256
def o():return map(int,input().split())
n,q=o();a=[[]for i in range(n)];x=[0]*n;p=[[0,0]]
for i in range(n-1):u,v=o();a[u-1]+=[v-1];a[v-1]+=[u-1]
for i in range(q):u,v=o();x[u-1]+=v
while p:
  r,s=p.pop()
  for i in a[r]:
    if i!=s:
      p+=[[i,r]]
      x[i]+=x[r]
print(*x)

Measured memory_bytes: 116352
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N = i_i()

ans = len(str(N))
arr = []
for i in range(1, int(N**0.5)+1):
    if N % i != 0:
        continue
    
    j = int(N / i)
    tmp = max(len(str(i)), len(str(j)))
    if ans > tmp:
        ans = tmp
    
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>

using namespace std;

#define endl '\n'

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    n--;

    vector<int> val(n);

    bool is_one = false;

    for (int i = 0; i < n; ++i)
    {
        val[i] = abs(s[i] - s[i + 1]);
        is_one |= val[i] == 1;
    }

    if (n == 1)
    {
        cout << val[0] << endl;
        return 0;
    }

    int x = 0;

    for (int i = 0; i < n; ++i)
    {
        if (is_one)
            val[i] &= 1;
        else
            val[i] >>= 1;

        if (val[i] == 1 && (i & (n - 1)) == i)
        {
            x ^= 1;
        }
    }

    if (!is_one)
        x *= 2;

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 5276
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, q = MAP()
graph = [[] for i in range(n)]
point = [0]*n
for i in range(n-1):
    a, b = MAP()
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
for i in range(q):
    p, x = MAP()
    point[p-1] += x

# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now, prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next, now)

dfs(0)
print(*point)

Measured memory_bytes: 283540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] array = new long[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextLong();
		}
		sc.close();

		long ans = 0L;
		for(int i=1;i<n;i++) {
			long tmp = array[i-1];
			long sa = tmp-array[i];
			if(sa>0) {
				ans = ans + tmp-array[i];
				array[i] = sa + array[i];
			}
		}

		System.out.println(ans);


	}
}


Measured memory_bytes: 61192
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int x=sc.nextInt();
 
  		int[] l=new int[n];
  		int d=0;
  		int ans=0;
		for(int c=0;c<n;c++){
    		l[c]=sc.nextInt();
          	d+=l[c];
            if(d<=x){
            	ans++;
            }else{
            	break;
            }
    	}
    
    	System.out.println(ans+1);
    }
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(void){
    char c;
    int ans = 0;

    while((c=getchar()) != '\n'){
        ans += c - '0';
    }

    if(ans % 9 == 0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int tot = 0;
    rep(i,n-1) tot += l[i];
    if (l[n-1] < tot) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640
import copy
S=raw_input()
M=list("abcdefghijklmnopqrsqtuvwxyz")


if len(S)==26:
	if S=="zyxwvutsrqponmlkjihgfedcba":
		print -1
		quit()
	else:
		S2=list(S)
		for i in S2[::-1]:
			idx=S2.index(i)
			for j in M:
				if j>i:
					j_idx=S2.index(j)
					S2[idx]=j
					S2[j_idx]=i
					str="".join(S2)
					if str>S:
						print str[:idx+1]
						quit()
					else:
						S2=list(S)
else:
	for i in S:
		M.remove(i)
	print S+M[0]




Measured memory_bytes: 2692
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

// IntHeap ...
type IntHeap []int

func (h *IntHeap) Len() int           { return len(*h) }
func (h *IntHeap) Less(i, j int) bool { return (*h)[i] > (*h)[j] }
func (h *IntHeap) Swap(i, j int)      { (*h)[i], (*h)[j] = (*h)[j], (*h)[i] }

// Push is pointer receiver
func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

// Pop is pointer receiver
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h *IntHeap) discount(m int) {
	for i := 0; i < m; i++ {
		maxPrice := heap.Pop(h).(int)
		heap.Push(h, maxPrice/2)
	}
}

func (h *IntHeap) sum() (price int) {
	for _, p := range *h {
		price += p
	}
	return
}

func main() {
	n, m := nextInt(), nextInt()
	prices := make(IntHeap, n)
	for i := 0; i < n; i++ {
		prices[i] = nextInt()
	}
	heap.Init(&prices)
	prices.discount(m)
	r := prices.sum()
	fmt.Println(r)
}


Measured memory_bytes: 4608
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        int n = ni();
        int a[] = new int[n];
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            a[i] = ni();
            set.add(a[i]);
        }
        if (set.size() == 1) {
            out.println(0);
            return;
        }
        int ans = Integer.MAX_VALUE;
        for (int i = -100; i <= 100; i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                sum += (a[j] - i) * (a[j] - i);
            }
            if (sum < ans)
                ans = sum;

        }
        out.println(ans);
    }
}

Measured memory_bytes: 21332
#include<stdio.h>

int main(){
  long long n = 0;
  long long a[100000] = {};
  long long b[100000] = {};
  long long i = 0;
  long long press = 0;
  scanf("%lld",&n);
  
  for(i=0;i<n;i++){
    scanf("%lld %lld",&a[i],&b[i]);
  }
  
  for(i=0;i<n;i++){
    if((a[n-1-i]+press)%b[n-1-i] != 0){
      press += b[n-1-i] - ((a[n-1-i]+press)%b[n-1-i]);
      //printf("%lld",press);
    }
  }
  printf("%lld",press);
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;
int main() {
    ll n;cin >> n;
    ll k; cin >> k;
    vector<ll> h(n);
    for(ll i=0;i<n;i++){
        cin >> h[i];
    }
    vector<ll> cost(n,INF);
    cost[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<k+1;j++){
            if(i+j<n)cost[i+j]=min(cost[i+j],cost[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << cost[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
from heapq import*
def g(n,E,s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
def s():
 for e in iter(input,'0 0'):
  n,k=map(int,e.split())
  E=[[]for _ in[0]*-~n]
  for _ in[0]*k:
   f=[*map(int,input().split())]
   if f[0]:
    c,d,e=f[1:]
    E[c]+=[(e,d)];E[d]+=[(e,c)]
   else:print(g(n,E,*f[1:]))
if'__main__'==__name__:s()


Measured memory_bytes: 5976
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> A(N);

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

    int R = 0;
    ll ans = 0;
    ll count = 0;

    for(int i = 0; i < N; i++) {

        if(A[i] & R) {
            ans += count * (count + 1LL) / 2LL;
            count = 1LL;
            R = A[i];
            ll c = 0;
            for(int j = i - 1; !(R & A[j]); j--) {
                c++;
                count++;
                R |= A[j];
            }
            ans -= c * (c + 1LL) / 2LL;
        } else { 
            R |= A[i];
            count++;
        }
    }

    ans += count * (count + 1LL) / 2LL;

    cout << ans << endl;
}

Measured memory_bytes: 1024
N,M=map(int,input().split())
a=[0 for i in range(N)]
b=[0 for i in range(N)]
c=[0 for j in range(M)]
d=[0 for j in range(M)]
for i in range(N):
  a[i],b[i]=map(int,input().split())
for j in range(M):
  c[j],d[j]=map(int,input().split())
for i in range(N):
  k=0
  for j in range(M):
    if abs(a[i]-c[k])+abs(b[i]-d[k])>abs(a[i]-c[j])+abs(b[i]-d[j]):
      k=j
  print(k+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;


struct Dice
{
    vector<int> faces;

    Dice(vector<int>& f)
        : faces(f) {}

    int top() {
        return faces[0];
    }

    int front() {
        return faces[1];
    }

    int at(int n) {
        return faces[n];
    }

    void roll(char direction) {
        int tmp;
        switch (direction) {
        case 'E': // 1,4,6,3 -> 4,6,3,1
            tmp = faces[0];
            faces[0] = faces[3];
            faces[3] = faces[5];
            faces[5] = faces[2];
            faces[2] = tmp;
            break;
        case 'N': // 1,2,6,5 -> 2,6,5,1
            tmp = faces[0];
            faces[0] = faces[1];
            faces[1] = faces[5];
            faces[5] = faces[4];
            faces[4] = tmp;
            break;
        case 'S': // 1,5,6,2 -> 5,6,2,1
            tmp = faces[0];
            faces[0] = faces[4];
            faces[4] = faces[5];
            faces[5] = faces[1];
            faces[1] = tmp;
            break;
        case 'W': // 1,3,6,4 -> 3,6,4,1
            tmp = faces[0];
            faces[0] = faces[2];
            faces[2] = faces[5];
            faces[5] = faces[3];
            faces[3] = tmp;
            break;
        }
    }
};


int main()
{
    vector<int> faces;
    for (int i = 0; i < 6; ++i) {
        int x;
        cin >> x;
        faces.push_back(x);
    }
    Dice dice(faces);

    int q;
    cin >> q;

    for (int i = 0; i < q; ++i) {
        int top, front;
        cin >> top >> front;

        string r("EEEENN");
        for (string::iterator it = r.begin(); it != r.end(); ++it) {
            dice.roll(*it);
            if (dice.top() == top)
                break;
        }
        // cerr << dice.top() << "-" << dice.front() << endl;
        int d[4] = {1,2,4,3};
        int j;
        for (j = 0; j < 4; j++) {
            // cerr << "front: " << dice.at(d[j]) << endl;
            if (dice.at(d[j]) == front)
                break;
        }
        if (j < 3) {
            cout << dice.at(d[j+1]);
        } else {
            cout << dice.at(d[0]);
        }
        cout << endl;
    }
    return 0;
}

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

def cake(cnt):
    if cnt == 0:
        return 1
    if cnt < 0:
        return 0
    #4を買う場合 
    return cake(cnt-4) or  cake(cnt-7)

if (cake(n) == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut v: [usize; n]
    }
    v.sort();
    let mut c = 1;
    let mut ps = vec![(0, v[0], 1)];
    for i in 1..n {
        if v[i] == v[i - 1] {
            ps[c - 1].2 += 1;
        } else {
            ps.push((i, v[i] - v[i - 1], 1));
            c += 1;
        }
    }
    for i in 0..c - 1 {
        if v[ps[i].0] != n - ps[i + 1].0 {
            continue;
        }
        if ps[i].2 % 2 == 1 || ps[i + 1].1 % 2 == 1 {
            println!("First");
        } else {
            println!("Second");
        }
        return;
    }
    for &(i, a, b) in &ps {
        if v[i] - a >= n - i || n - i - b >= v[i] {
            continue;
        }
        if (v[i] + n - i) % 2 == 1 {
            println!("First");
        } else {
            println!("Second");
        }
        return;
    }
}


Measured memory_bytes: 8444
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		System.out.println(n + n * n + n * n * n);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] a = new int[abc];
			for (int i = 0; i < abc; i++)
				a[i] = nextInt();
			return a;
		}
	}
}





Measured memory_bytes: 25376
#include <iostream>
#include <string>
#define L '('
#define R ')'

int main(void) {
    using std::cin;
    using std::cout;
    using std::string;
    int n;
    cin >> n;
    string s;
    cin >> s;

    int nest   = 0;
    int need_l = 0;
    for (auto &se : s) {
        if (se == L)
            nest++;
        else if (nest == 0)
            need_l++;
        else
            nest--;
    }
    int need_r = nest;

    for (int i = 0; i < need_l; ++i) cout << L;
    cout << s;
    for (int i = 0; i < need_r; ++i) cout << R;
    cout << '\n';

    return 0;
}


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

int main(){
  int N,a,x;
  double y;
  cin >> N;
  for(int i = 0;i < N;i++){
    a = N - i;
    if(a % 2 == 1)
      x++;
  }
  cout << (double)x / (double)N << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cmath>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int modinv(Int a, Int m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

Int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int root_sum(int target, vi &parents, vi &nodes_value, vi &memo, int sum){
    if(memo[target] != -1){
        sum += memo[target];
        return sum;
    }
    if (parents[target] == target){
        sum+=nodes_value[target];
        return sum;
    }else{
        sum+=nodes_value[target];
        return root_sum(parents[target],parents, nodes_value, memo, sum);
    }
}

// memoには数え上げた素数を入れていく
bool is_prime(Int n, map<Int,Int> &memo){
    if(memo[n] == 1){
        return false;
    }else if(memo[n] == 2){
        return true;
    }

    bool prime = true;
    for(Int i =2; i<=sqrt(n)+2; i++){
        if(memo[i]==2 && n%i==0){
            prime = false;
        }
    }
    if(prime){
        memo[n] = 2;
    }else{
        memo[n] = 1;
    }

    return prime;
}



int main() {
    Int H;
    cin >> H;

    Int ans = 1;
    while(H>0){
        ans *=2;
        H=H/2;
    }

    cout << ans-1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int D,T,S;cin>>D>>T>>S;
    if(D<=T*S){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }

#define int long long

using namespace std;

signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int num = 0;
  // int n; cin >> n;
  // vector<int> v(n);
  // for (auto it = v.begin(); it < v.end(); ++it) cin >> *it;
  // for (auto it = v.begin(); it < v.end(); ++it) num += *it;
  // cout << num << endl;

  int n;
  int m;

  cin >> n >> m;

  vector<pair<int, int>> pairs(n);

  for (auto it = pairs.begin(); it < pairs.end(); ++it) {
    int a; int b;
    cin >> a >> b;
    *it = make_pair(a, b);
  }

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

  int tmp = 0;
  for (int i = 0; i < n; ++i) {
    int a = pairs[i].first;
    int b = pairs[i].second;
    if (tmp == m) {
      break;
    }
    if (b + tmp > m) {

      num += a * (m - tmp);
      break;
    } else {
      tmp += b;
      num += a * b;
    }
  }

  cout << num << endl;
  return 0;
  
}


Measured memory_bytes: 1792
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [w, h, x, y] = li()
    area = w * h / 2
    multi = w // 2 == x and w % 2 == 0 and h // 2 == y and h % 2 == 0
    if multi:
        print(area, "1")
    else:
        print(area, "0")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001007;

int main(){
    int n, m; cin >> n >> m;
    vector<int> ar(n);
    int sou = 0;
    rep(i,n){
        cin >> ar[i];
        sou += ar[i];
    }
    sort(ar.begin(), ar.end());
    bool t = true;
    rep(i,m){
        if (ar[n-1-i] * 4 * m < sou){
            t = false;
            break;
        }
    }
    if (t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int[] A = nextInts();
		Arrays.sort(A);
		long x =0;
		long y =0;
		for(int i=A.length-1;i>0;i--){
			if(A[i]==A[i-1]){
				if(x==0){
					x=A[i];
					i--;
				}else{
					y=A[i];
					break;
				}
			}
		}
		System.out.println(x*y);


	}



	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 41556
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N = parseInt(arg[0]);
    const AP = arg.slice(1, N + 1);
    
    const shop = [];
    
    for(let i in AP) {
        let n  = AP[i].split(" ")[0];
        let s  = parseInt(AP[i].split(" ")[1]);

        const temp = {name: n, score: s, originIdx: parseInt(i)};
        shop.push(temp);
    }
    
    shop.sort((a,b)=>{
        if(a.name < b.name) {
            return -1;
        }
        
        if(a.name > b.name) {
            return 1;
        }
        
        if(a.score > b.score) {
            return -1;
        }
        
        if(a.score < b.score) {
            return 1;
        }
        
        return 0;
    });

    for(let i in shop) {
        console.log(shop[i].originIdx + 1);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7620
#include <string.h>
#include <stdio.h>
int main()
{
	int i;
	char nowshin[100];
	gets(nowshin);
	for(i=strlen(nowshin)-1;i>=0;i--){
		printf("%c",nowshin[i]);
	}
	printf("\n");
	return 0;
}

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

t, a = map(int, input().split())
h = list(map(int, input().split()))

mini = abs(1000 * t - 6 * h[0] - 1000 * a)
ans = 1

for i in range(1, n):
    if mini > abs(1000 * t - 6 * h[i] - 1000 * a):
        mini = abs(1000 * t - 6 * h[i] - 1000 * a)
        ans = i + 1
        
print(ans)

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

int main(){
  
  int a,b,result;
  char op;
  
  
  while(1){
    
    cin >> a >> op >> b ;
 
    if(op == '?') break ;
    
    
    if(op == '+'){
      result = a+b;
      cout << result <<"\n";
    }
    else if(op == '-'){
      result = a-b ;
      cout << result <<"\n";
    }
    else if(op == '*'){
	result = a*b  ;
	cout <<result <<"\n";
      }
    else if(op == '/'){
      result = a/b;
      cout <<result <<"\n";
    }
   
  }
    return 0;
  }

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<string> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	vector<int> MARCH(5);
	for(int i = 0;i < N;i++) {
		if(vec[i].at(0) == 'M') {
			MARCH.at(0)++;
		}
		if(vec[i].at(0) == 'A') {
			MARCH.at(1)++;
		}
		if(vec[i].at(0) == 'R') {
			MARCH.at(2)++;
		}
		if(vec[i].at(0) == 'C') {
			MARCH.at(3)++;
		}
		if(vec[i].at(0) == 'H') {
			MARCH.at(4)++;
		}
	}
	int answer = 0;
	for(int i = 0;i < 3;i++) {
		for(int j = i + 1;j < 4;j++) {
			for(int k = j + 1;k < 5;k++) {
				answer += MARCH.at(i) * MARCH.at(j) * MARCH.at(k);
			}
		}
	}
	cout << answer << endl;
}

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

int sum(int N){
  int s = 0;
  while(N > 0){
    s += N % 10;
    N /= 10;
  }  
  return s;
}


    
int main(){
  
  int N;
  cin >> N;
  
  int minisum = 10000;
  
  for(int i = 1; i < N; i++){    
    if(sum(i) + sum(N - i) < minisum){
      minisum = sum(i) + sum(N - i);
    }
  }
  
  cout << minisum << endl;
}
    
    

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll A, B, H[int(1e5+5)];

bool Judge(ll num){
  ll ans = 0;
  for (int i = 0; i < N; i++){
    ll now = H[i] - B * num;
    if (now <= 0) continue;
    ans += (now - 1) / (A - B) + 1;
  }
  if (ans <= num) return true;
  else return false;
}

int main(){
  cin >> N >> A >> B;
  for (int i = 0; i < N; i++) cin >> H[i];

  ll L = 0, R = 1e9;
  while (R - L > 1){
    ll now = (L + R) / 2;
    if (Judge(now)) R = now;
    else L = now;
  }
  cout << R << endl;

  return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    int a, b;
    char op;
    while(true) {
        cin>>a>>op>>b;
        if(op=='+') cout<<a+b<<'\n';
        else if(op=='-') cout<<a-b<<'\n';
        else if(op=='*') cout<<a*b<<'\n';
        else if(op=='/') cout<<a/b<<'\n';
        else break;
    }
    return 0;
}

Measured memory_bytes: 1196
alph = 'abcdefghijklmnopqrstuvwxyz'
def acc_seq(i):
  return 26 * (pow(26, i) - 1) // 25

def name_dog(digit, at, name):
  if digit ==1:
    return name + alph[at]
  else:
    group = at // pow(26, digit - 1)
    at -= pow(26, digit - 1) * group
    name += alph[group]
    return name_dog(digit-1, at, name)

n = int(input())
digit = 1
while(n > acc_seq(digit)):
  digit += 1

at = abs(n - acc_seq(digit - 1) - 1)
print(name_dog(digit, at, ''))

Measured memory_bytes: 9168
package main

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

type Row []string

type Data []Row

func main() {
	nextReader = newScanner()
	S := nextInt()
	W := nextInt()
	if S > W {
		fmt.Printf("safe")
		return
	}
	fmt.Printf("unsafe")
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	// r.Split(bufio.ScanLines)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func CustomScan(data []byte, atEOF bool) (advance int, token []byte, err error) {
	for i := 0; i < len(data); i++ {
		if data[i] == ' ' {
			return i + 1, data[:i], nil
		}
	}
	fmt.Println(data)
	return 0, data, bufio.ErrFinalToken
}

func nextStrings() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// r.Split(bufio.ScanWords)
	r.Split(CustomScan)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 1760
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

a = LIST()
flag = 0
for el in a:
    if(el%2==0):
        if(el%3==0 or el%5==0):
            continue
        else:
            flag = 1
            break
if(flag==0):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 70924
#include <iostream>
#include <queue>

using namespace std;

int main(void){
    int n, x;
    cin >> n >> x;
    queue<int> q;
    for(int i = 0; i < n; ++ i){
        int tmp;
        cin >> tmp;
        q.push(tmp);
    }
    while(x > 0 && !(q.empty())){
        x -= q.front();
        q.pop();
    }
    cout << n - q.size() + (x >= 0) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll cnt = 0,now = N;
    map<ll,bool> ma;
    ma[N] = 1;
    while(true){
        if(now % 2 == 0){
            now /= 2;
            cnt++;
            if(ma[now]){
                cout << cnt + 1 << "\n";
                return 0;
            }
            ma[now] = 1;
        }
        else{
            now = now * 3 + 1;
            cnt++;
            if(ma[now]){
                cout << cnt + 1 << "\n";
                return 0;
            }
            ma[now] = 1;
        }
        //cout << now << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define PI acos(-1.0)
#define MOD 2520
#define E 1e-12
using namespace std;
typedef long long ll;
const int MAXN=500000+5;//最大元素个数
ll  n,m;
int main()
{
    scanf("%lld%lld",&n,&m);
    if(2*n>=m)
	{
		cout<<min(n,m/2)<<endl;
	}
	else
	{
		ll cha=m-2*n;
		//cout<<2*n<<" "<<cha<<endl;
		cout<<n+cha/4<<endl;
	}
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000+500];
int main(){
	int n;
	cin>>n;
	int cnt=1;
	while(1){
		a[n]=1;
		if(n%2==0)
			n/=2;
		else 
			n=n*3+1;
		cnt++;
		if(a[n]){
			cout<<cnt<<endl;
			break;
		}
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    int n;
    cin >> n;
    vector<int> l;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        l.push_back(x);
    }
    sort(l.begin(), l.end());
    int longest = l[n-1];
    int sum_rest = 0;

    for(int i=0; i<n-1; i++){
        sum_rest += l[i];
    }

    if(longest < sum_rest){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define FF first.first
#define FS first.second
#define S second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e16;
 
ll n, q=1, m, a[N], b[N], f[N], o, k, t, x, y, z, u, h, mx, mn, ans, Ans;
pair<ll,ll> p[N];
string s;
vector<int> v[N];
 
main(){ios_base::sync_with_stdio(false), cin.tie(0);
   	
//	cin>>q;
   	
   	while(q--){ans=o=0,u=1;
   		cin>>n>>x>>y;
   		if((x-1)/n<y/n)cout<<"OK";
   		else cout<<"NG";
   		
	}
	
}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
#define MOD 1e9+7

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

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

//struct edge {int to, cost;};
//vector< vector<edge> > es;
const int MAX_N = 100000;
bool is_prime[MAX_N];
int n;

void sieve() {
    REP(i, MAX_N) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    FOR(i, 2, (int)(sqrt(MAX_N)+1)) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX_N; j+=i) {
            is_prime[j] = false;
        }
    }
}

void solve() {
    cout << n << ':';
    int sqrt_n = (int)sqrt(n);
    sieve();
    FOR(i, 2, sqrt_n+1) {
        if (!is_prime[i]) continue;
        if (n % i != 0) continue;
        cout << ' ' << i;
        n /= i;
        while (n % i == 0) {
            cout << ' ' << i;
            n /= i;
        }
    }
    if (n != 1) cout << ' ' << n;
    cout << endl;
}

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

    return 0;
}


Measured memory_bytes: 3192
s = input()
s = list(s)

t = input()
t = list(t)

ans = 0
temp = ''

for i in range(len(s)):
	if s == t :
		ans = 1
	else:
		temp = t[0]
		for j in range(len(s)):
			if j == len(s)-1:
				t[j] = temp
				#print(j,t[j],temp)
			else:
				t[j] = t[j+1]
		#print(t)

print('Yes' if ans==1 else 'No')
	


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N >> M;
    ll ret = 0;
    priority_queue<ll> prices;
    
    for (int i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        ret += tmp;
        prices.push(tmp);
    }

    while (M > 0) {
        ll tmp = prices.top();
        ret -= tmp;
        prices.pop();

        ret += tmp / 2;
        prices.push(tmp / 2);
        M--;
    }
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main (void) {
  int before[50], after[50];
  int n, r, p, c;
  int i, j, k;


  while(1) {
    cin >> n;
    
    for(i = 0; i < n; i++) {
      before[i] = n - i;
      //    cout << before[i] << endl;
    }
    //    cout << endl;
    
    cin >> r;
    
    if (n == 0 && r == 0) break;
    
    for(i = 0; i < r; i++) {
      cin >> p; cin >> c;
      
      for(j = 0; j < c; j++) {
	after[j] = before[p-1+j];
      }
      for(k = 0; k < p-1; j++, k++) {
	after[j] = before[k];
      }
      for(; j < n; j++) {
	after[j] = before[j];
      }
      
      for(j = 0; j < n; j++) {
	before[j] = after[j];
	//	cout << after[j] << endl;
      }

      //cout << endl;
    }

    cout << after[0] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
S = input()
T = input()
sofar = len(T)
ans = 0
for i in range(len(S)):
    if len(S[i:]) >= len(T):
        count = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                count += 1
        sofar = min(count, sofar)
ans = sofar
print(ans)

Measured memory_bytes: 9120
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize 2
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define pb push_back
#define mp make_pair
#define IT set<int> :: iterator 
#define pa pair<int,int>
#define fir first
#define sec second


using namespace std;

inline ll read()
{
	ll t=0,dp=1;char c=getchar();
	while(!isdigit(c))	{if(c=='-')	dp=-1;c=getchar();}
	while(isdigit(c))	t=t*10+c-48,c=getchar();
	return t*dp;
}
inline void write(ll x){if(x<0)	{putchar('-');x=-x;}	if(x>=10)	write(x/10);putchar(x%10+48);}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
/*------------------------------------------------------------------------------------------------------*/

const int N=100005;
int n,Fa[N];
set<int> to[N];
map<pa,int> cnt;
queue<pa> que;
inline int Get(int x){return x==Fa[x]?Fa[x]:Fa[x]=Get(Fa[x]);}
int main()
{
	n=read();
	For(i,1,n)	Fa[i]=i;
	For(i,1,2*(n-1))
	{
		int x=read(),y=read();
		to[x].insert(y);to[y].insert(x);
		cnt[mp(x,y)]++;cnt[mp(y,x)]++;
		if(cnt[mp(x,y)]==2)	que.push(mp(x,y));
	}	
	while(!que.empty())
	{
		pa tmp=que.front();que.pop();
		int x=tmp.fir,y=tmp.sec;
		int tx=Get(x),ty=Get(y);
		x=tx;y=ty;
		to[x].erase(y);to[y].erase(x);
		if(to[x].size()<to[y].size())	swap(x,y);//x<-y
		IT it;
		for(it=to[y].begin();it!=to[y].end();++it)
		{
			int mid=(*it);
			cnt[mp(mid,y)]=0;cnt[mp(y,mid)]=0;
			to[mid].erase(y);
			cnt[mp(mid,x)]++;cnt[mp(x,mid)]++;
			to[mid].insert(x);to[x].insert(mid);
			if(cnt[mp(mid,x)]==2)	que.push(mp(mid,x));
		}
		Fa[y]=x;
//		cout<<tx<<' '<<ty<<endl;
		to[y].clear();
	}
	int sum=0;
	For(i,1,n)	if(Fa[i]==i)	++sum;
	if(sum==1)	puts("YES");else	puts("NO");
}

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

int main() {
  int x, y;
  while(1){
      cin >> x >> y;
      if ( x == 0 && y == 0 ) break;
      if (x <= y) {
        cout << x << " " << y << endl;
      } else {
        cout << y << " " << x << endl;
      }
  }

}



Measured memory_bytes: 3088