akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
        }
        int ans = 0;
        while (isEven(b)) {
            ans++;
            b = divide(b);          
        }
		System.out.println(ans);
	}
    private static boolean isEven(int[] b) {
        for (int i = 0; i < b.length; i++) {
            if (b[i] % 2 == 1) {
                return false;
            }
        }
        return true;
    }
    private static int[] divide(int[] b) {
        for (int i = 0; i < b.length; i++) {
            b[i] /= 2; 
        }
        return b;
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 10004, MAXM = 102, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

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

    multiset<int> last;
    for (int i = 0; i < n; i++) {
        multiset<int>::iterator it = last.lower_bound(arr[i]);
        if (it == last.begin())
            last.insert(arr[i]);
        else {
            it--;
            last.erase(it);
            last.insert(arr[i]);
        }
    }


    cout << last.size() << '\n';


    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main() {
    ll n;
    cin >> n;
    ll odd=0;
    rep(i,n){
        ll a;
        cin >> a;
        if(a%2==1) odd++;
    }
    if(odd%2==1) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;

string S;

int main(){
  cin>>S;
  sort(S.begin(),S.end());
  unique(S.begin(),S.end());
  
  string res;

  int k=0;
  int temp=0;
  for(char i='a';i<='z';i++, k++){
    if(S[k]!=i){
      res=i;
      temp=1;
      break;
    }
  }
  
  if (temp==1) cout<<res<<endl;
  else cout<<"None"<<endl;
  
  return 0;
}



Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var S = ReadString();
            int countR = 0, countB = 0;
            foreach (var c in S)
            {
                if (c == 'R') countR++;
                else countB++;
            }

            Out(countR > countB ? "Yes" : "No");
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }
}

Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int n = sc.nextInt();
		
		ArrayDeque<Integer> q = new ArrayDeque<>();
		for(int i=0; i<n; i++) {
			if(i%2 == 0) {
				q.add(sc.nextInt());
			} else {
				q.push(sc.nextInt());
			}
		}
		
		StringBuilder ans = new StringBuilder();
		if(n%2 == 0) {
			while(!q.isEmpty()) {
				ans.append(q.pollFirst());
				if(!q.isEmpty()) {
					ans.append(" ");
				}
			}
		} else {
			while(!q.isEmpty()) {
				ans.append(q.pollLast());
				if(!q.isEmpty()) {
					ans.append(" ");
				}
			}
		}
		
		System.out.println(ans);
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

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

int main(){

    int n,k;
    cin >> n >> k;

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

    int dp[k+1] = {};
    dp[0] = 0;
    for(int i=1;i<=k;i++)
    {
        dp[i] = 0;
        for(int j=0;j<n;j++)
        {
            if(i-a[j]>=0 && dp[i-a[j]] == 0)
                dp[i] = dp[i]||1;
            else
               dp[i] = dp[i]||0; 
        }
        //cout << i << " " << dp[i] << endl;
    }

    if(dp[k])
        cout << "First\n";
    else
        cout << "Second\n";
}

Measured memory_bytes: 3992
#!/usr/bin/env python
# coding: utf-8

# In[32]:


from collections import deque


# In[37]:


def func():
    N,Q = map(int, input().split())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = map(int, input().split())
        a,b = a-1,b-1
        graph[a].append(b)
        graph[b].append(a)
    cnt = [0]*N
    for j in range(Q):
        p,x = map(int, input().split())
        cnt[p-1] += x
    q = deque([[0,-1,cnt[0]]])
    d = [-1]*N
    while q:
        cur,fr,p = q.popleft()
        d[cur] = p
        for nex in graph[cur]:
            if nex == fr:
                continue
            q.append([nex,cur,p+cnt[nex]])
    ans = []
    for i in range(N):
        ans.append(d[i])
    print(*ans)


# In[38]:


if __name__ == "__main__":
    func()


# In[ ]:






Measured memory_bytes: 75404
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace Atcoder_0403
{
    class Program
    {
        static void Main(string[] args)
        {
            double _fullLength =(double) GetInput_int()[0];

            double _oneLine = _fullLength / 3.0d;
            double result = Math.Pow(_oneLine, 3);

            Console.WriteLine(result);
        }

        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        #endregion
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int x;
  cin >> x;

  ll ans = 2;
  while (x--) {
    ans = 2 * ans + 2;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
typedef int keytype;

void quicksort_des(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] > x) i++;
        while (x > a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort_des(a, first , i - 1);
    if (j + 1 < last) quicksort_des(a, j + 1, last);
}

int main(){
    int n;
    int d[100000];

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &d[i]);
    }

    quicksort_des(d, 0, n-1);
    int ans = d[(n/2)-1] - d[(n/2)];

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 2080
#include <iostream>

using namespace std;



int main()
{
  string s;
  
  cin >> s;
  
  int ans = 0;
  
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
  {
    ans = 3;
  }
  else if (s[0] == 'R' && s[1] == 'R')
  {
    ans = 2;
  }
  else if (s[2] == 'R' && s[1] == 'R')
  {
    ans = 2;
  }
  else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
  {
    ans = 1;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int A[3][3];
bool a[3][3];

bool bingo() {
  return (
    a[0][0] && a[0][1] && a[0][2]
  ) || (
    a[1][0] && a[1][1] && a[1][2]
  ) || (
    a[2][0] && a[2][1] && a[2][2]
  ) || (
    a[0][0] && a[1][0] && a[2][0]
  ) || (
    a[0][0] && a[1][0] && a[2][0]
  ) || (
    a[0][1] && a[1][1] && a[2][1]
  ) || (
    a[0][2] && a[1][2] && a[2][2]
  ) || (
    a[0][0] && a[1][1] && a[2][2]
  ) || (
    a[2][0] && a[1][1] && a[0][2]
  );
}

int main() {
  rep(i,0,2) {
    rep(j,0,2) cin >> A[i][j];
  }

  int N;
  cin >> N;

  int b;
  rep(i,0,N-1) {
    cin >> b;
    rep(p,0,2) {
      rep(q,0,2) {
        if (A[p][q] == b) a[p][q] = true;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int n;
    cin >> n;
    
    for (int i = 1; i <= 9; i++)
    {
        for (int j = i; j <= 9; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 105
using namespace std;
 
int main(){
  int n, p[105][105], mx[105][105], x, y, h;
  bool ok[105][105];
  scanf("%d", &n);
  
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      p[i][j] = -1;
      mx[i][j] = 1000001000;
      ok[i][j] = true;
    }
  }
  for(int i = 0; i < n; i++){
    scanf("%d%d%d", &x, &y, &h);
    if(h){
      for(int j = 0; j <= 100; j++){
        for(int k = 0; k <= 100; k++){
          if(p[j][k] == -1) p[j][k] = h + abs(x-j) + abs(y-k);
          else if(p[j][k] != h + abs(x-j) + abs(y-k)){
            ok[j][k] = false;
          }
        }
      }
    }else{
      ok[x][y] = false;
      for(int j = 0; j <= 100; j++){
        for(int k = 0; k <= 100; k++){
          mx[j][k] = min(mx[j][k], abs(x-j) + abs(y-k));
        }
      }
    }
  }
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      if(ok[i][j] && (mx[i][j] >= p[i][j]))
        printf("%d %d %d\n", i, j, p[i][j]);
    }
  }
}



Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,k,n,x,y,z,a[100],b[100],c[100],flg,cnt;
	flg=0;
	cin>>n>>x;
	for(i=0;i<x;i++){
		cin>>a[i];
	}
	cin>>y;
	for(i=0;i<y;i++){
		cin>>b[i];
	}
	cin>>z;
	for(i=0;i<z;i++){
		cin>>c[i];
	}
	cnt=z;
	for(i=0;i<x;i++){
		for(j=0;j<z;j++){
			if(a[i]==c[j]) cnt=cnt-1;
			for(k=0;k<y;k++){
				if(c[j]==b[k] && a[i]==c[j]) cnt=cnt+1;
			}
		}
	}

	
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long

int main(void)
{
    int n, m, a, i;
    scanf("%d%d", &n, &m);
    int count = 0;
    for (i = 0; i < m; i++)
    {
        scanf("%d", &a);
        count += a;
    }
    if (count > n)
    {
        printf("-1\n");
    }
    else
        printf("%d\n", n - count);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

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

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

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll ans=b-(b/c+b/d-b/lcm(c,d));
    ans-=a-1-((a-1)/c+(a-1)/d-(a-1)/lcm(c,d));

    cout<<ans<<endl;
}

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

const int MAX_N = 1007;
int N;
int a[MAX_N], b[MAX_N];

void solve()
{
	ll x = a[0], y = b[0];
	for(int i=1;i<N;++i){
		ll c = (x+a[i]-1)/a[i], d = (y+b[i]-1)/b[i];
		x = max(c,d)*a[i], y = max(c,d)*b[i];
	}
	cout << x + y << endl;
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i)cin >> a[i] >> b[i];
	solve();
	return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().split()))
ok = set(list(range(1, M + 1)))

for _ in range(N):
    row = list(map(int, sys.stdin.buffer.readline().split()))
    row = set(row[1:])
    ok &= row
print(len(ok))


Measured memory_bytes: 13592
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //N,Mの入力を受け取る
          var S = Console.ReadLine();
          var result = "Yes";
          for(int i = 0; i < S.Length; i++){
            if(i%2 == 1 && S[i] == 'R'){
              result = "No";
              
              break;
            }else if(i%2 == 0 && S[i] == 'L'){
              result = "No";
              
              break;
            }
          }
          Console.WriteLine(result);

        }
 }
 


Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] split = sc.nextLine().split(" ");
        
        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int K = Integer.parseInt(split[2]);
        
        List<Integer> list = new ArrayList<Integer>();
        
        for(int i = 1; i < 101; i++){
            if(A % i == 0 && B % i == 0){
                list.add(i);
            }
        }
        
        System.out.println(list.get(list.size() - K));
    }
}

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

int main(){
    int V, E;
    cin >> V >> E;
    vector<vector<int> > edge(10001);
    vector<int> state(V, 0);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
        state[t]++;
    }
    vector<int> ans;
    for (int i = 0; i < V; i++) {
        if (state[i] == 0) ans.push_back(i);
    }
    for (int i = 0, s = ans.size(); i < s; i++) {
        for (int j = 0; j < edge[ans[i]].size(); j++) {
            int t = edge[ans[i]][j];
            state[t]--;
            if (state[t] == 0) {
                ans.push_back(t);
                s++;
            }
        }
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
 
  int num=0;
  for(int j=0; j<n; j++){
    if(h[j] >= k){
      num++;
    }
  }
  
  cout << num << endl;
  
  
}

Measured memory_bytes: 640
N = int(input())
a = list(map(int,input().split()))
suma = sum(a)
ans = abs(suma - a[0])
sumb = a[0]
if N == 2:
    print(abs(a[0]-a[1]))
else:
    for i in range(1,N-1):
        sumb += a[i]
        ans = min(ans,abs(suma - 2*sumb))
    print(ans)

Measured memory_bytes: 24832
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class BIT(object):
    def __init__(self,A,dot,e,inv=None):
        n=len(A)
        self.__n=n
        self.__dot=dot
        self.__e=e
        self.__inv=inv
        self.__node=['$']+A # 1-indexed
        for i in range(1,n+1):
            j=i+(i&-i)
            if(j<=n): self.__node[j]=dot(self.__node[i],self.__node[j])

    def add(self,i,w=1):
        i+=1
        while(i<=self.__n):
            self.__node[i]=self.__dot(self.__node[i],w)
            i+=i&-i

    def sum(self,i):
        res=self.__e
        while(i>0):
            res=self.__dot(res,self.__node[i])
            i-=i&-i
        return res

    def range_sum(self,l,r):
        assert(self.__inv)
        return self.__inv(self.sum(r),self.sum(l))

    def bisect_left(self,w,increase=True):
        n=self.__n
        k=2**((self.__n-1).bit_length())
        res=0
        now=self.__e
        while(k):
            if(res+k<=n and self.__dot(now,self.__node[res+k])<w and increase):
                now=self.__dot(now,self.__node[res+k])
                res+=k
            elif(res+k<=n and self.__dot(now,self.__node[res+k])>w and (not increase)):
                now=self.__dot(now,self.__node[res+k])
                res+=k
            k//=2
        return res

def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    idx=[0]*n
    for i,a in enumerate(A):
        idx[a-1]=i

    from operator import add
    bit=BIT([0]*n,add,0)

    ans=0
    for k in range(n,0,-1):
        i=idx[k-1]
        bit.add(i)
        s=bit.sum(i+1)
        l0=bit.bisect_left(s-1)-(s<=1)
        l1=bit.bisect_left(s-2)-(s<=2)
        r0=bit.bisect_left(s+1)
        r1=bit.bisect_left(s+2)
        ans+=k*((i-l0)*(r1-r0)+(l0-l1)*(r0-i))
    print(ans)
resolve()

Measured memory_bytes: 65072
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
 
using namespace std;
 
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main(void) {
  string a, b, c;
  cin >> a >> b >> c;

  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL x, n, sum = 0; cin >> x >> n;
    for (int i = 0 ; i < n ; i++) {
        LL v; cin >> v;
        sum += v;
    }
    cout << max((LL)-1, x - sum) << '\n';

}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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 (b<a) { a=b; return 1; } return 0; }




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  cout<<fixed<<setprecision(10);

  ll n,i; cin>>n>>i;

  cout<<n+1-i<<endl;


}






Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	
	public static final long MOD = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		boolean[] isRight = new boolean[n*2];
		
		if (s.charAt(0)=='W') {
			System.out.println(0);
			return;
		} else {
			isRight[0]=false;
		}
		
		for (int i=1;i<2*n;i++) {
			isRight[i]=isRight[i-1]^(s.charAt(i)==s.charAt(i-1));
		}
		

		
		long ans = 1;
		long stock = 0;
		for (int i=0;i<2*n;i++) {
			if (isRight[i]) {
				if (stock <= 0) {
					System.out.println(0);
					return;
				}
				ans = (ans*stock)%MOD;
				stock--;
			} else {
				stock++;
			}
		}
		
		if (stock!=0) {
			System.out.println(0);
			return;
		}
		
		for (int i=1;i<=n;i++) {
			ans = (ans*i)%MOD;
		}
		
		System.out.println(ans);
	}
}

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

int main()
{
	int a,b,ans=0;
	cin >> a >> b;
	
	if (a < b)
	{
		ans = 0;
	}
	else
	{
		if (a - b*2 < 0)
		{
			ans = 0;
		}
		else
		{
			ans = a - b*2;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{  long int n;
 cin>>n;
 long int sum=0;
 long int temp=n;
 while(temp>0)
 { sum+=(temp)%10;
   temp=temp/10;
 }
 if(n%sum==0)
    cout<<"Yes";
 else
 cout<<"No";
}

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

typedef long long LL;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int N = 20;
const int oo = 0x3f3f3f3f;
const int mod = 1e9 + 7;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m, k;
int f[(1 << N) + 5];
int ban[N + 5][N + 5];

void input() {
    scanf("%d%d%d", &n, &m, &k);

    -- n;
    while(k--) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c); 
        -- a, -- b; ban[a][b] |= 1 << c;
    }
}

void calc(int id) {
    int t0 = 0, t1 = 0;
    for(int i = 0; i < n; ++i) {
        if(ban[id][i] & 1) t0 |= 1 << i;
        if(ban[id][i] & 2) t1 |= 1 << i;
    }

    static int g[(1 << N) + 5];
    for(int i = 0; i < n; ++i) {
        memcpy(g, f, sizeof g);
        for(int s = 0; s < (1 << n); ++ s) {
            if(!(s >> i & 1) || !f[s]) continue;
            int t = s ^ (1 << i);
            for(int j = i - 1; j >= 0; --j) if(s >> j & 1) break; else (g[t | (1 << j)] += f[s]) %= mod;
        }
        memcpy(f, g, sizeof f);
    }

    for(int i = 0; i < n; ++i) {
        memcpy(g, f, sizeof g);
        for(int s = 0; s < (1 << i); ++ s) (g[s | (1 << i)] += f[s]) %= mod;
        memcpy(f, g, sizeof f);
    }
    for(int s = 0; s < (1 << n); ++s) if((s & t0) || ((s & t1) != t1)) f[s] = 0;
}

void solve() {
    f[0] = 1;
    for(int i = 0; i < m; ++i) calc(i);

    int ans = 0;
    for(int i = 0; i < (1 << n); ++i) (ans += f[i]) %= mod;
    printf("%d\n", (ans + mod) % mod);
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
    input();
    solve();
    return 0;
}


Measured memory_bytes: 8576
n,m,q=map(int, input().split())
lr=[list(map(int,input().split())) for _ in range(m)]
pq=[list(map(int,input().split())) for _ in range(q)]
x=[[0 for _ in range(n)] for _ in range(n)]
for t in lr:
    x[t[0]-1][t[1]-1]+=1
for i in range(n):
    k=False
    for j in range(n):
        if k:
            x[i][j]+=x[i][j-1]
        elif x[i][j]>0:
            k=True
            
for i in range(n-1,0,-1):
    for j in range(n-1,-1,-1):
        x[i-1][j]+=x[i][j]
for t in pq:
    print(x[t[0]-1][t[1]-1])

Measured memory_bytes: 73352
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

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

int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    bool ok = false;
    if (abs(a - c) <= d) {
        ok = true;
    } else if (abs(a - b) <= d && abs(c - b) <= d) {
        ok = true;
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

pll reduce(ll d, ll c){
  ll ret = 0;
  while(c>=10){
    ll a = c/10;
    ll b = c%10;
    ret += a*(d+9);
    c = a+b;
  }
  ll tmp = 0;
  REP(i,c){
    tmp += d;
    if(i!=0) ret ++;
    if(tmp>=10){
      ret ++;
      tmp = tmp/10 + tmp%10;
    }
  }
  //cout << d << "," << c << "-> " << tmp << "," << ret << endl; 
  return {tmp,ret};
}
int main() {
  ll n;
  cin >> n;
  vl input(n);
  ll ans = 0;
  REP(i,n){
    ll c,d;
    cin >> d >> c;
    pll ret = reduce(d,c);
    input[i] = ret.first;
    ans += ret.second;
  }
  ll tmp = 0;
  REP(i,n){
    tmp += input[i];
    if(i!=0) ans ++;
    if(tmp>=10){
      ans ++;
      tmp = tmp/10 + tmp%10;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int gcd(int x, int y){
    if (x < y){
        swap(x, y);
    }
    int r = x % y;
    while (r != 0){
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main(){
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
AC;
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a+b>c+d){
    printf("Left");
}
else if(a+b<c+d){
    printf("Right");
}
else{
    printf("Balanced");
}




    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[13][32];
void day(void)
{
    int check=3;
    for(int i=1;i<13;i++){
        for(int j=1;j<32;j++){
            a[i][j]=check;
            check++;
            if(check==7)check=0;
            if((i==4||i==6||i==9||i==11)&&j==30)break;
            else if(i==2&&j==29)break;
        }
    }
}
int main()
{
    int mon,date;
    day();
    while(1){
        cin>>mon>>date;
        if(mon==0&&date==0)break;
        if(a[mon][date]==0)cout<<"Monday\n";
        else if(a[mon][date]==1)cout<<"Tuesday\n";
        else if(a[mon][date]==2)cout<<"Wednesday\n";
        else if(a[mon][date]==3)cout<<"Thursday\n";
        else if(a[mon][date]==4)cout<<"Friday\n";
        else if(a[mon][date]==5)cout<<"Saturday\n";
        else cout<<"Sunday\n";
    }

}

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

typedef long long ll;

const int mod = 1e9 + 7;

ll N;
vector<int> A;

int cc[62][2][2][2];
int dp(int n, int t, int d, int c) {
    if(n == A.size()) return t == 0 && d == 0 && c == 0;
    int &ret = cc[n][t][d][c];
    if(ret != -1) return ret;

    ret = 0;
    int x = A[n];
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            if(i == 0 && j == 1) continue;

            int nt = ((i ^ j) > x) || (t & (i ^ j) == x);
            int nd = ((i + j + c) % 2 > x) || (d & (i + j + c) % 2 == x);

            ret += dp(n + 1, nt, nd, (i + j + c) / 2);
            ret %= mod;
        }
    }
    return ret;
}

int main() {
    cin >> N;

    while(N) {
        A.push_back(N % 2);
        N /= 2;
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, 0, 0, 0));
}


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

int main() {
  int a,b,c,d;
  int count1=0,count2=0;
  cin>>a>>b>>c>>d;
  while(a>0){
    a-=d;
    count1++;
  }
  while(c>0){
    c-=b;
    count2++;
  }
  
  if(count2<=count1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import static java.lang.System.out;

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

    public static void main(String[] args) {
        int N = in.i();
        int K = in.i();
        int[] h = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            h[i] = in.i();
        }
        int[] dp = new int[N + 1];
        h[0] = dp[0] = Integer.MAX_VALUE / 2;
        for (int i = 2; i <= N; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = Math.max(1, i - K); j < i; j++) {
                min = Math.min(min, dp[j] + Math.abs(h[i] - h[j]));
            }
            dp[i] = min;
        }
        out.println(dp[N]);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36256
#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>;

const int M = 1000005;

int main() {
  char n, ans;
  cin >> n;
  ans = (n >= 'a')? 'a' : 'A';
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
struct BellmanFordMax {
	BellmanFordMax() {}
	BellmanFordMax(int n) { init(n); }
	vector<vector<pair<int, int>>> E; int N;
	void init(int n) { N = n; E.resize(0); E.clear(); E.resize(n); }
	void add(int a, int b, int c) { E[a].push_back({ b, c }); }
	vector<ll> solve(int s) {
		vector<ll> res(N, -infl);
		res[s] = 0;

		rep(i, 0, N - 1) {
			rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
				chmax(res[p.first], res[cu] + p.second);
			}
		}

		vector<bool> pos(N);
		rep(i, 0, N) {
			rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
				if (chmax(res[p.first], res[cu] + p.second)) {
					pos[p.first] = true;
				}
				if (pos[cu]) pos[p.first] = true;
			}
		}

		rep(cu, 0, N) if (pos[cu]) res[cu] = infl;

		return res;
	}
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













int N, M, P;
vector<pair<int, int>> E[2500];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> P;

	BellmanFordMax bf(N);

	rep(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		bf.add(a, b, c - P);
	}

	ll ans = bf.solve(0)[N - 1];

	if (ans == infl) ans = -1;
	else if (ans < 0) ans = 0;

	cout << ans << endl;
}









Measured memory_bytes: 512
#include<stdio.h>

int main(){
   int a, b;
   scanf("%d %d", &a, &b);
   if (a < b){
       printf("a < b\n");
   } else if(a ==b){
       printf("a == b\n");
   } else {
       printf("a > b\n");
   }
    return 0;
    
    
    
}


Measured memory_bytes: 2048
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 21/01/2018 12:14:52
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	string a, b;
	cin>>a>>b;
	string c = a+b;
	long long cc = stol(c);
	if(sqrtl(cc) == (long long) sqrtl(cc)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  int d;
  if(s=="SUN") d=0;
  if(s=="MON") d=1;
  if(s=="TUE") d=2;
  if(s=="WED") d=3;
  if(s=="THU") d=4;
  if(s=="FRI") d=5;
  if(s=="SAT") d=6;
  cout<<7-d<<endl;
}

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

#define swap(x, y) {ll tmp = (x); (x) = (y); (y) = tmp;}

typedef long long ll;

ll n, X;
ll x[100005];

ll gcd(ll a, ll b);
ll lcd(ll a, ll b);

int main()
{
    ll i, j;
    ll ans;
    
    scanf("%lld %lld", &n, &X);

    for (i = 0; i < n; i++) {
        scanf("%lld", &x[i]);

        x[i] = abs(x[i] - X);
    }


    ans = x[0];
    for (i = 1; i < n; i++) {
        ans = gcd(x[i], ans);
    }

    printf("%lld\n", ans);

    return 0;
}

ll gcd(ll a, ll b)
{
    if (a < b) {
        swap(a, b);
    }

    while (a != 0) {
        ll r = b % a;
        b = a;
        a = r;
    }

    return b;
}

ll lcd(ll a, ll b)
{
    return a * b / gcd(a, b);
}


Measured memory_bytes: 896
function main() {
  var input = getInput();
  var ls = input.split('\n');

  var n = parseInt(ls[0])
  var nums = ls.slice(1, n+1).map(function(s) {
    return parseInt(s);
  })
  
  console.log(lis(nums))
}

function lis(xs) {
  var table = [xs[0]];
  for (var i = 1; i < xs.length; i++) {
    var x = xs[i];
    table[search(table, x) + 1] = x;
    debug(table)
  }
  return table.length;
}
 

/**
 * Returns i s.t. table[i] < x && x <= table[i+1]
 */
function search(table, x) {
  var l = 0, h = table.length;
  
  if (table.length == 0 || x <= table[0]) {
    return -1;
  }
  
  while (l + 1 < h) {
    var pivot = Math.floor((l + h + 1) / 2);
    if (table[pivot] < x) {
      l = pivot;
    } else {
      h = pivot;
    }
    debug({l: l, h: h})
  }
  return l;
}

nodeJS = typeof require != 'undefined';

function getInput() {
  if (!nodeJS) {
    return document.getElementById('input').value
  }
  return require('fs').readFileSync('/dev/stdin').toString();
}

function debug(x) {
  if (!nodeJS) {
    console.error(x)
  }
}

if (nodeJS) {
  main()
}

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

int main () {
  int n;
  cin >>n;
  vector<int>a(n);

  for (int i=0;i<n;i++){
    cin >>a[i];
  }
  int cnt =1;
  for (int i=0;i<n;i++){
    if(a[i]%2 ==0){
      if(a[i]%3 ==0 || a[i]%5==0){
        cnt =1;
      }else{
      cnt =0;
      break;
      }
    }
  }
  if (cnt ==1){
    cout <<"APPROVED"<<endl;
  }else if(cnt ==0){
    cout <<"DENIED"<<endl;
  }
}


Measured memory_bytes: 256
def main():
    
    n = int(input())
    a = [int(e) for e in input().split()]


    b = sorted(a)
    c = (b[0]+b[1])/2
    

    for i in range(2,n):

        c = (c + b[i])/2
     
      
    print(c)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll n;
cin>>n;
ll arr[n];
for(ll i=0;i<n;i++)
    cin>>arr[i];
ll max=INT_MAX;
ll count=0;
for(ll i=0;i<n;i++)
{
    if(max>=arr[i])
    {
        count++;
        max=arr[i];
    }
}
cout<<count<<endl;

}


Measured memory_bytes: 1792
/*
 *Author : zsenshi
 DP Knapsack  
 *
 */
#include <bits/stdc++.h> //Only for gcc compilers
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define dg(x) cout << #x << ":"<<x<<endl
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl
#define rep(i,begin,end) for(__typeof(end) i = (begin)-((begin) > (end)); i != (end) - ((begin) > (end)); i += 1-2*((begin) > (end)))
#define ll long long 
using namespace std;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vector<pii>> vvpi;
const ll INF = 1e18L+5;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s,t;
  cin >> s >> t;
  vector<vector<int>> dp(s.length()+1,vector<int>(t.length()+1,0));
  for(int i = 1; i <= (int)s.length(); i++){
    for(int j = 1; j <= (int)t.length(); j++){
      if(s[i-1] == t[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else 
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    }
  }

  int i = (int)s.length(), j= (int)t.length();
  string answer;
  while(i > 0 && j > 0){
    if(s[i-1] == t[j-1]){
      answer += s[i-1];
      i = i-1;
      j = j-1;
    }
    else{
      if(dp[i-1][j] >= dp[i][j-1]){
        i = i - 1;
      }
      else j = j - 1;
    }
  }
  reverse(answer.begin(),answer.end());
  cout << answer << "\n";
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n,y;
  cin >> n >> y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      int k = n - i - j;
      if(k < 0) continue;
      if(10000*i + 5000*j + 1000*k == y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A_hp = sc.nextInt();
		int A_atk =sc.nextInt();
		int B_hp = sc.nextInt();
		int B_atk =sc.nextInt();
		
		for(;;) {
			B_hp -= A_atk;
			if(B_hp <= 0) {
				System.out.println("Yes");
				return;
			}
			A_hp -= B_atk;
			if(A_hp <= 0) {
				System.out.println("No");
				return;
			}

		}

	}

}


Measured memory_bytes: 35788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define FORI(n) for(int i = 0; i < n; i++)
#define FORJ(n) for(int j = 0; j < n; j++)
#define FORK(n) for(int k = 0; k < n; k++) 
#define FOR2I(a, B) for(int i = 0; i < a; i ++) for(int j = 0; j < b; j++)
#define FORIT(S) for(auto it = S.begin(); it != S.end(); it++)

using namespace std;

int main(){
	int n; 
	cin >> n; 
	int x[n], y[n], t[n];
	FORI(n){
		cin >> t[i];
		cin >> x[i];
		cin >> y[i];
	}
	int init_x = 0; 
	int init_y = 0;
	int delta_x = 0;
	int delta_y = 0; 

	bool flag = false; 
	FORI(n){
		if(flag) break;
		delta_x = -init_x + x[i];
		delta_y = -init_y + y[i];

		if(((t[i] - delta_x - delta_y) % 2) == 1 || ((t[i] - delta_x + delta_y) % 2) == 1){
			flag = true; 
			break;
		}
		
		if(t[i] - delta_x - delta_y < 0){
			flag = true;
			break; 
		}
		if(t[i] - delta_x + delta_y < 0){
			flag = true; 
			break;
		}
		init_x = x[i]; 
		init_y = x[i]; 
		
	}
	if(flag) cout << "No" << endl;
	else cout << "Yes" << endl; 
	return 0;
}

Measured memory_bytes: 1408
import numpy as np
N = int(input())
list_ai = list(map(int,input().split()))
list1 = [x-(i+1) for i,x in enumerate(list_ai)]
a1 = np.array(list1)
median1 = int(np.floor(np.median(a1)))
ans = sum(abs(x-median1) for x in list1)
print(ans)

Measured memory_bytes: 34172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
#define fr(a,b) for(long long i=a;i<b;i++)
#define vi vector<ll>
const ll MAX=1e4;
const ll mod=1e9+7;
const ll INF=1e18+12;
set< pair<ll,ll> >ss;
ll dp[MAX][MAX];

                                    //SAMEER KUMAR SINGH//
// ================================================================================================================================//
// ================================================================================================================================//
// ================================================================================================================================//


int main(){
   FASTIO;
   ll tt=1;
   //cin>>tt;

   while(tt--){
      ll n;
      cin>>n;
      ll a[n];
      ll sum=0;
      fr(0,n){
       cin>>a[i];
      }


      for(ll i=0;i<n;i++){
        dp[i][i]=a[i];
      }


      for(ll len=2;len<=n;len++){

         for(ll i=0;i<n-len+1;i++){
           ll j=i+len-1;
           dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
         }
      }



      cout<<dp[0][n-1]<<"\n";
   }
}


Measured memory_bytes: 234496