akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
	static void Main()
	{
	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      if((nums[0]<nums[1]&&nums[1]<nums[2]&&nums[2]<nums[3])
        ||(nums[2]<nums[3]&&nums[3]<nums[0]&&nums[0]<nums[1]))
        Console.WriteLine(0);
      else
      {
        Array.Sort(nums);
        Console.WriteLine(nums[2]-nums[1]);
      }

	}
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll inf = 3e18;
const char sp = ' ';

int N, p[20], c;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	for (int i = 1; i < N - 1; i++) {
		if (min(p[i - 1], p[i + 1]) < p[i] && p[i] < max(p[i - 1], p[i + 1]))c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Text.Printf

main :: IO ()
main = do
  xs <- map (map toDbl . words) . lines <$> getContents
  mapM_ (\(x, y) -> printf "%.3f %.3f\n" x y) $ solve xs

solve :: [[Double]] -> [(Double, Double)]
solve xs = map smeqn xs

toDbl :: String -> Double
toDbl s = read s

smeqn :: [Double] -> (Double, Double)
smeqn xs = (round3 x, round3 y)
  where
    a : b : c : d : e : f : _ = xs
    ma = toMat a b d e
    mb = toMat c 0 f 0
    (Mat x _ y _) = mulMat (revMat ma) mb

round3 :: Double -> Double
round3 = (/ 1000) . fromIntegral . round . (* 1000)

data Mat = Mat Double Double Double Double deriving Show

mulMat :: Mat -> Mat -> Mat
mulMat (Mat a b c d) (Mat e f g h) = Mat (a * e + b * g) (a * f + b * h) (c * e + d * g) (c * f + d * h)

revMat :: Mat -> Mat
revMat (Mat a b c d) = Mat (d / det) (b * (-1) / det) (c * (-1) / det) (a / det)
  where det = a * d - b * c

toMat :: Double -> Double -> Double -> Double -> Mat
toMat a b c d = Mat a b c d

inp :: (String -> a) -> IO a
inp f = f <$> getLine

inps :: Int -> (String -> a) -> IO [a]
inps n f = map f <$> replicateM n getLine

Measured memory_bytes: 4520
#include<stdio.h>

int main(){
  int i,j,v,n,m,k;
  int V[107][110];
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&m);
    if(m != 0){
      for(j = 0; j < m; j++){
	scanf("%d",&k);
	V[v-1][k-1] = 1;
      }
    }
  }

  for(i = 0; i < n; i++){
    j = 0;
    printf("%d",V[i][j]);
    for(j = 1; j < n; j++){
      printf(" %d",V[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<cstring>
  using namespace std;
  char s[100010];
  int main(){
      cin>>s;
      int ans1=0,ans2=0;
      char a='0';
    for(int i=0;i<strlen(s);i++){
          if(s[i]!=a) ans1++;
          a='0'+'1'-a;
      }
      a='1';
   for(int i=0;i<strlen(s);i++){
          if(s[i]!=a) ans2++;
          a='0'+'1'-a;
      }
      cout<<(ans1<ans2?ans1:ans2);
      return 0;
  }

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 



int main(){
	int n;
	string str;
	vi v(8, 0);
	int m;
	while(cin>>n && n>0){
		map<double,vector<string> > mp;
		for(int i= 0; i < n; i++){
			cin>>str;
			//cout<<str<<endl;
			for(int j = 0; j < 8; j++) cin>>v[j];
			cin>>m;

			int s = 0, t = 0, u = v[6] * m;
			s = v[1]+v[2]+v[3];
			t = v[4] + v[5];


			mp[(double)(u * v[7] - v[0])/(s + t * m)].pb(str);
		}
		for(auto it = mp.rbegin(); it != mp.rend(); ++it){
			sort(all(it->se));
			for(int i = 0; i < it->se.size(); i++){
				cout<<it->se[i]<<endl;
			}
		}
		cout<<"#"<<endl;
		
	}
}

Measured memory_bytes: 3108
N, K = map(int, input().split())
V = list(map(int, input().split()))
result = 0
for a in range(N + 1):
    for b in range(N + 1):
        if a + b > K or a + b > N:
            break
        out = V[:a] + V[N-b:]
        out.sort()
        sum_val = sum(out)
        for i in range(min(a + b, K - a - b)):
            if out[i] >= 0:
                break
            sum_val -= out[i]
        result = max(result, sum_val);
print(result)

Measured memory_bytes: 9124
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
string s, t;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s >> t;
    vector<int> counts(s.size() + 1, 0), countt(t.size() + 1, 0);
    int counta = 0;
    int countb = 0;
    rep(i, s.size())
    {
        if (s[i] == 'A')
        {
            counta++;
        }
        else
        {
            countb++;
        }
        counts[i + 1] = countb - counta;
    }
    counta = 0;
    countb = 0;
    rep(i, t.size())
    {
        if (t[i] == 'A')
        {
            counta++;
        }
        else
        {
            countb++;
        }
        countt[i + 1] = countb - counta;
    }
    //debug(counts);
    //debug(countt);
    int q;
    cin >> q;
    vector<bool> ans(q);
    rep(i, q)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        c--;
        int countss = counts[b] - counts[a];
        int counttt = countt[d] - countt[c];
        if ((countss - counttt) % 3 == 0)
        {
            ans[i] = true;
        }
        else
        {
            ans[i] = false;
        }
    }
    rep(i, q)
    {
        if (ans[i])
            YES;
        else
            NO;
    }
}

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


def maximum_profit(profits):
    max_v = profits[1] - profits[0]
    min_v = profits[0]

    for j in range(1, len(profits)):
        max_v = max(max_v, profits[j]-min_v)
        min_v = min(min_v, profits[j])

    print(max_v)


def to_int(v):
    return int(v)


if __name__ == '__main__':
    l = to_int(input())
    profits = [to_int(input()) for i in range(l)]

    maximum_profit(profits)

Measured memory_bytes: 15592
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = x/500;
        int b = (x%500)/5;
        int ans = 1000*a + 5*b;
        System.out.println(ans);

    }
}

Measured memory_bytes: 22996
using System;

namespace test
{
    class Program
    {
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = ReadNumList();
            Console.WriteLine(Exec(a));
        }
        static long X2InLong(long num)
        {
            if (num > long.MaxValue / 2)
            {
                return long.MaxValue;
            }
            return num * 2;
        }
        static long Exec(int[] a)
        {
            var maxAn = 1L;
            var points = new long[a.Length];
            // 各深さに存在しうる最大頂点数
            for (var d = 0; d < a.Length - 1; ++d)
            {
                points[d] = maxAn;
                maxAn -= a[d];
                if (maxAn < 0)
                {
                    return -1;
                }
                maxAn = X2InLong(maxAn);
            }
            if (a[a.Length - 1] > maxAn)
            {
                return -1;
            }
            // 下から、条件を満たす中で最大の頂点数を設定
            points[a.Length - 1] = a[a.Length - 1];
            long total = points[a.Length - 1];
            for (var d = a.Length - 2; d >= 0; --d)
            {
                points[d] = Math.Min(points[d + 1] + a[d], points[d]);
                total += points[d];
            }
            return total;
        }
    }
}

Measured memory_bytes: 37556
s = input()
t = input()

maxsame = 0

for i in range(len(s)-len(t)+1):
  same = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      same += 1
  if same > maxsame:
    maxsame = same
    
print(len(t)-maxsame)

Measured memory_bytes: 67504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

long double check(long double theta) {
	if (theta > PI / 2 - EPS) {
		return 0;
	}
	long double ret;
	if (a * tan(theta) <= b) {
		ret = a * a * b - a * a * a * tan(theta) / 2;
	}
	else {
		ret = b * b * tan(PI / 2 - theta) * a / 2;
	}
	return ret;
}

int main() {

	cin >> a >> b >> x;

	long double ng = 0;
	long double ok = PI / 2;

	rep(_, 100000) {
		long double mid = (ok + ng) / 2;

		if (check(mid) < x) ok = mid;
		else ng = mid;
	}

	cout << fixed << setprecision(10) << ok * 180 / PI << endl;

	return 0;
}

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

using namespace std;

#define MAX_N 3005

char s[MAX_N], t[MAX_N];
int dp[MAX_N][MAX_N];

int f_imp(int, int);

int f(int sp, int tp)
{
	if (dp[sp][tp] == 0)
		dp[sp][tp] = f_imp(sp, tp) + 1;
	return dp[sp][tp] - 1;
}

int f_imp(int sp, int tp)
{
	if (s[sp] == 0 || t[tp] == 0)
		return 0;
	if (s[sp] == t[tp])
		return f(sp + 1, tp + 1) + 1;
	return max(f(sp + 1, tp), f(sp, tp + 1));
}

void g(int sp, int tp)
{
	if (s[sp] == 0 || t[tp] == 0)
		return;
	if (s[sp] == t[tp])
	{
		printf("%c", s[sp]);
		g(sp + 1, tp + 1);
	}
	else if (dp[sp + 1][tp] >= dp[sp][tp + 1])
		g(sp + 1, tp);
	else
		g(sp, tp + 1);
}

int main()
{
	scanf("%s\n%s", s, t);
	f(0, 0);
	g(0, 0);
	printf("\n");
}


Measured memory_bytes: 35712
import math
A, B, H, M = map(int, input().split())
h = 360 / 12 * H + 0.5 * M
m = 6 * M
hm = abs(h - m)
if hm > 180:
    hm = 360 - hm
rad = math.radians(hm)
ans = A*A + B*B - 2*A*B*math.cos(rad)
print(ans**0.5)

Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
    ll res=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
    return res*f;
}
void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10|'0');
}
const int N=1e5+7;
int n;
int b[N];
int sum;
signed main(){
    n=read();
    for(int i=1;i<=n-1;i++) b[i]=read();
    b[0]=b[n]=9999999;
    for(int i=1;i<=n;i++)
    sum+=min(b[i],b[i-1]);
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

void read(int &x,int &y){read(x),read(y);}

void read(int &x,int &y,int &z){read(x,y);read(z);}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
	while(z[++Z]=x%10+48,x/=10);
	while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int a,s,d;
	read(a,s,d);
	if (a==s) cout<<d;
	else
	if (a==d) cout<<s;
	else cout<<a;
	return 0;
}










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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[3333][3333];
bool used[3333][3333];

int main(){
	
	int n;cin >> n;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	
	queue<pair<int,int>> q;
	REP(i,n){
		if(n % 2)dp[i][i] = v[i];
		else dp[i][i] = -v[i];
	}
	REP(i,n-1)q.push(MP(i,i+1));
	
	while(!q.empty()){
		auto now = q.front();q.pop();
		int l = now.FI;
		int r = now.SE;
		if(used[l][r])continue;
		used[l][r] = true;		
		if(((r - l + 1) % 2) == (n % 2)){
			dp[l][r] = max(dp[l+1][r] + v[l], dp[l][r-1] + v[r]);
		}
		else {
			dp[l][r] = min(dp[l+1][r] - v[l], dp[l][r-1] - v[r]);
		}
		if(l > 0)q.push(MP(l-1,r));
		if(r < n - 1)q.push(MP(l,r+1));
	}
	
	cout << dp[0][n-1] << endl;
	
	return 0;
}


Measured memory_bytes: 90368
from collections import defaultdict
N, K = map(int,input().split())
A = list(map(int,input().split()))

a = [0]

for i in A:
    a.append((a[-1]+i-1)%K)

d = defaultdict(int)
ans = 0
for i in range(N+1):
    if i >= K:
        d[a[i-K]] -= 1
    ans += d[a[i]]
    d[a[i]] += 1

print(ans)


Measured memory_bytes: 115080
#include <iostream>

using namespace std;

int main(){
	int i, j, n, m;
	cin >> n >> m;
	int a[n][m];
	int b[m];
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for(i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int i = 0; i < n; i++){
		int sum = 0;
		for(int j = 0; j < m; j++){
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

double abcd(int a) {
    double x = 0;
    for (int i = 1; i <= a; i++) {
        x+=i;
    }
    return x;
}

int main() {
    int N, K;

    cin >> N >> K;
    double p[N];
    double x[N];
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        x[i] = abcd(p[i])/p[i];
    }

    //for (int i = 0; i < N-K+1; i++) {
    //    float ch = 0;
    double ch = 0;
    for (int j = 0; j < K; j++) {
        ch += x[j];
    }
    double max = ch;
    for(int i = 0; i < N-K; i++) {
        ch = ch - x[i]+x[i+K];
        if (max < ch) {
            max = ch;
        }  
    }
    std::cout << std::setprecision(10) << max;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
//#define rep(i,a,b) for(int i=a;i<b;i++)
//#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
//typedef unsigned long long ull;
int main()
{
    ll a;
    ll s=7,sum=0;
    scanf("%lld",&a);
    if(a%2==0||a%5==0)
        cout<<-1<<endl;
    else
    {
        while(1)
        {
            sum++;
            if(s%a==0)
                break;
            s=s*10+7;
            s%=a;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3724
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long K, long long A, long long B){
  ll x = K;
  ll i = 1;
  
  while(x<=B) {
    if(A<=x) {
      std::cout << "OK" << std::endl;
      return;
    }
    i++;
    x = K*i;
  }
  std::cout << "NG" << std::endl;
}

int main(){
  long long K;
  scanf("%lld",&K);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(K, A, B);
  return 0;
}



Measured memory_bytes: 3168
#include<iostream>
using namespace std;
int main(){
	int n,a,cnt=0,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;a--;
		if(i==a){
			cnt++;
		}
		else{
			ans+=(cnt+1)/2;
			cnt=0;
		}
	}
	ans+=(cnt+1)/2;
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	int n,m,i,j,k,ans,cur,res;
	cin >> n >> m;
	ans=n;
	for(i=0; i<m; i++){
		cin >> cur;
		ans-=cur;
	}
	cout << max(-1,ans) << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 1;
	for(int i = 1; i < n; ++i) {
		if(s[i] != s[i - 1]) ++ans;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;
using PD = std::tuple<double,int>;

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

double sx, sy, tx, ty;
double cx[1010], cy[1010], cr[1010];
int N;
vector<PD> G[1010];
double d[1010];

void generate(double x, double y, int idx){
    for(int i=1;i<=N;++i){
        double dx = x - cx[i], dy = y - cy[i],
            dist = max(sqrt(dx * dx + dy * dy) - cr[i], 0.0);
        G[idx].emplace_back(dist, i);
        G[i].emplace_back(dist, idx);
    }
}

void generate2(){
    for(int i=1;i<=N;++i){
        for(int j=1;j<=N;++j){
            if(j == i){continue;}

            double dx = cx[i] - cx[j], dy = cy[i] - cy[j],
                dist = max(sqrt(dx * dx + dy * dy) - cr[i] - cr[j], 0.0);
            G[i].emplace_back(dist, j);
            G[j].emplace_back(dist, i);
        }
    }
}

void dijkstra(){
    fill(d, d+1010, 1e300);
    priority_queue<PD, std::vector<PD>, std::greater<PD>> q;
    d[0] = 0;
    q.emplace(0.0, 0);

    while(!q.empty()){
        double dd;
        int idx;
        tie(dd, idx) = q.top();
        q.pop();

        if(dd > d[idx]){continue;}

        for(auto &p : G[idx]){
            double cost;
            int v;
            tie(cost, v) = p;
            
            if(d[v] > dd + cost){
                d[v] = dd + cost;
                q.emplace(d[v], v);
            }
        }
    }
}

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

    std::cin >> sx >> sy >> tx >> ty;
    std::cin >> N;

    for(int i=1;i<=N;++i){
        std::cin >> cx[i] >> cy[i] >> cr[i];
    }

    generate(sx, sy, 0);
    generate(tx, ty, N+1);
    generate2();

    // for(int i=0;i<=N+1;i++){
    //     printf("# %d\n", i);
    //     for(auto &p : G[i]){
    //         printf("%.6f %d\n", fst(p), snd(p));
    //     }
    // }
    // exit(0);
    
    dijkstra();

    {
        double dx = sx - tx, dy = sy - ty,
            dist = sqrt(dx * dx + dy * dy);
        
        printf("%.10f\n", min(d[N+1], dist));
    }
    // std::cout << d[N+1] << std::endl;
}


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
/*int main()
{
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
//	for(int i=0;i<n;i++) cout<<a[i];
	int sum=0;
	for(int i=n-1;i>1;i--)
	{
		for(int j=i-1;j>0;j--)
		{
			if(a[i]==a[j]) continue;
			for(int k=j-1;k>=0;k--)
			{
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] < (a[k] + a[j])) 
				{
					sum++;
				}
				
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] >= (a[k] + a[j])) 
				{
					break;
				}
				
			}
		}
	}
	
	cout<<sum;
}

int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	while(n--)
	{
		int a,b; cin>>a>>b;
		long long int fl=a*a + b*b;
		float sum=sqrt(fl);
		if(sum<=d) ans++;
		
	}
	cout<<ans;
}*/
int main()
{
	string s,ss; cin>>s>>ss;
	int ans=0;
	for(int i=0;s[i];i++) if(s[i]!=ss[i]) ans++;
	cout<<ans;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string a,b,c;
	cin>>a>>b>>c;
	cout<<(a.back()==b.front()&&b.back()==c.front()?"YES"s:"NO"s)<<"\n"s;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
#define PI 3.14159265358979323846

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll k;
	cin>>k;
	if(k%2 == 0||k%5 == 0)
	{
		cout<<"-1\n";
		return 0;
	}
	ll tmp = 7%k;
	ll ans = 1;
	while(tmp!=0)
	{
		tmp = tmp*10+7;
		tmp = tmp%k;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
int n,m;
int a[100];
long long fac[1<<16],inv[1<<16];
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
void get_fac(){
	fac[0]=1;
	for(int i=1;i<(1<<n);i++)
		fac[i]=fac[i-1]*i%md;
	inv[(1<<n)-1]=powd(fac[(1<<n)-1],md-2);
	for(int i=(1<<n)-1;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
}
long long dp[17][1<<16];
long long C(int x,int y){
	if(x<0||y<0||x-y<0) return 0;
	return fac[x]*inv[y]%md*inv[x-y]%md;
}
void Add(long long &x,long long y){
	(x+=y)%=md;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	get_fac();
	dp[m][0]=1;
	for(int i=m;i>=1;i--)
		for(int j=0;j<(1<<n);j++){
			for(int k=0;k<n;k++)
				if(!(j&(1<<k)))
					Add(dp[i-1][j|(1<<k)],dp[i][j]*C((1<<n)-a[i]-j,(1<<k)-1)%md*fac[1<<k]);
			Add(dp[i-1][j],dp[i][j]);
		}
	long long ans=0;
	for(int i=0;i<(1<<n);i++){
		if(__builtin_popcount(i)&1)
			Add(ans,md-dp[0][i]*fac[(1<<n)-1-i]%md);
		else
			Add(ans,dp[0][i]*fac[(1<<n)-1-i]%md);
	}
	printf("%lld\n",ans*(1<<n)%md);
	return 0;
}


Measured memory_bytes: 9472
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


#define FOR(i, n) for (int i = 0; i < (n); ++i)


#define all(c) c.begin(), c.end()


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto sumW = next<int>(in);
  vec<int> w(n), v(n);
  FOR(i, n) {
    w[i] = next<int>(in);
    v[i] = next<int>(in);
  }
  vec<int64_t> f(sumW + 1, -1);
  f[0] = 0;
  int mx = 0;
  FOR(i, n) {
    for (int cw = mx; cw >= 0; --cw) {
      if (f[cw] != -1) {
        if (cw + w[i] <= sumW) {
          f[cw + w[i]] = max(f[cw + w[i]], f[cw] + v[i]);
          mx = max(cw + w[i], mx);
        }
      }
    }
  }
  int64_t res = *max_element(all(f));
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
vi win[5001];
int lose[5001];
bool visited[5001];
vi ans;
int main()
{
	int n;
	cin >> n;
	int m;
	cin >> m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		win[a].pb(b);
		lose[b]++;
	}
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(lose[j]==0&&!(visited[j]))
			{
				ans.pb(j);
				lose[j]=-1;
				if(!flag)
				{
					for(int k=j+1;k<=n;k++)
					{
						if(lose[k]==0)
						{
							flag=1;
							break;
						}
					}
				}
				for(int k=0;k<win[j].size();k++)
				{
					lose[win[j][k]]--;
				}
				break;
			}
		}
	}
	for(int i=0;i<sz(ans);i++)
	{
		cout << ans[i] << endl;
	}
	cout << flag << endl;
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    string A[N], B[M];
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i];
    bool found = false;
    for(int i = 0; !found && i < N - M + 1; i++) {
        for(int j = 0; !found && j < N - M + 1; j++) {
            for(int k = 0; k < M; k++) {
                if(A[i+k].substr(j, M) != B[k]) break;
                found = k == M-1;
            }
        }
    }
    if(found) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    exit()
 
for i in range(len(a)):
    x=a[i]*x
    if x>10**18:
        print(-1)
        exit()
print(x if x<=10**18 else -1)

Measured memory_bytes: 84732
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <iomanip>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main()
{
    ll m, k;
    cin >> m >> k;
    if (k == 0)
    {
        rep(i, (1ll << m))
        {
            cout << i << " " << i << " ";
        }
        cout << endl;
    }
    else
    {
        if (k >= (1ll << m) || (m == 1))
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            rep(i, (1ll << m))
            {
                if (i != k)
                    cout << i << " ";
            }
            cout << k << " ";
            for (ll i = (1ll << m) - 1; i >= 0; i--)
            {
                if (i != k)
                    cout << i << " ";
            }
            cout << k << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9+7;
ll fastpower(ll a, ll b){
    ll res = 1;
    a %= mod;
    while(b){
        if(b&1) res = (res * a) % mod;
        a *= a; a %= mod;
        b >>= 1;
    }
    res %= mod;
    return res;
}
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);
	freopen("error.txt","w", stderr);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n, k;
	cin>>n>>k;

	ll gcd[k + 1], l;
	memset(gcd, 0, sizeof(gcd));
	ll ans = 0;
	for(ll i = k; i >= 1; i--) {
		l = k/i;
		gcd[i] = fastpower(l, n);
		gcd[i] %= mod;
		gcd[i] %= mod;
		for(ll j = i * 2; j <= k; j += i) {
			gcd[i] -= gcd[j];
		}
		ans += ((i)*gcd[i])%mod;
	}	
	ans = ans%mod;
	cout<<"\n";
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4356
N, Y = map(int, input().split())
for x in range(N + 1):
	for y in range(N - x + 1):
		z = N - x - y
		if 10000 * x + 5000 * y + 1000 * z == Y:
			print(x, y, z)
			quit()
print(-1, -1, -1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

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

    int a,b,k; cin >> a >> b >> k;
    for(int i=0; i<k; i++){
        if(i%2==0){
            if(a%2==1) a--;
            a/=2; b+=a;
        }else{
            if(b%2==1) b--;
            b/=2; a+=b;
        }
    }
    cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 3560
n = gets.chomp.to_i
s = gets.chomp

hash = {}
s.each_char do |c|
  hash[c] ||= 1
  hash[c] += 1
end

MAX = 10 ** 9 + 7
count = 1
hash.each do |k, v|
  count *= v
  count %= MAX
end

puts count - 1


Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int A, B, ans = 0;
	char num[6];
	cin >> A >> B;

	for (int i = A; i <= B; i++) {
		int temp = i;
		int j = 0;
		while (temp > 0) {
			num[j++] = temp % 10;
			temp /= 10;
		}
		if (num[0] == num[4] && num[1] == num[3]) ans++;
	}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class27
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var B = new long[M];
            var C = new long[M];
            for(int i = 0; i < M; i++)
            {
                var r = Console.ReadLine().Split().Select(long.Parse).ToArray();
                B[i] = r[0];
                C[i] = r[1];
            }
            Array.Sort(C, B);
            
            Array.Sort(A);
            bool frag = false;
            for(int i = 0,k = M-1; i < N&&k>=0;k--)
            {
                for(int j=0;j<B[k]&&i<N;j++,i++)
                {
                    if (A[i] < C[k])
                    {
                        A[i] = C[k];
                    }
                    else
                    {
                        frag = true;
                        break;
                    }
                }
                if (frag) break;
            }

            Console.WriteLine(A.Sum());
        }
    }
}


Measured memory_bytes: 30432
// Aizu Vol-2 0256: Points for a Perfect Scorer
// 2017.8.7

#include <stdio.h>

int main()
{
	int s, i = 10, k = 0;
	
	while (i-- > 0) { scanf("%d", &s); k += s; }
	printf("%d\n", k);
	return 0;
}

Measured memory_bytes: 600
;; #!/usr/bin/env sbcl --script

(declaim (optimize (speed 3) (safety 0) (debug 0)))

(deftype int32 () '(signed-byte 32))

(defun main ()
  (let* ((n (the int32 (read)))
         (k (the int32 (read)))
         (a (make-array n :element-type 'int32))
         (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
    (dotimes (i n)
      (setf (aref a i) (the int32 (read))))
    (setf (aref dp 0) 0)
    (loop for i of-type int32 from 0 below n do
      (loop with from-val of-type int32 = (aref dp i)
         for j of-type int32 from (1+ i) to (+ i k)
         while (< j n)
         for nval of-type int32 = (+ from-val (abs (- (aref a i) (aref a j))))
         if (< nval (aref dp j))
         do
           (setf (aref dp j) nval)))
    (format t "~a~%" (aref dp (- n 1)))))

;; (defun main2 ()
;;   (let* ((n (the int32 (read)))
;;          (k (the int32 (read)))
;;          (a (make-array n :element-type 'int32))
;;          (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
;;     (let ((stream (make-string-input-stream (read-line))))
;;       (loop for i from 0
;;          for j = (read stream nil) until (null j)
;;          do (setf (aref a i) (the int32 j)))
;;     (setf (aref dp 0) 0)
;;     (loop for i of-type int32 from 0 below n do
;;       (loop with from-val of-type int32 = (aref dp i)
;;          for j of-type int32 from (1+ i) to (+ i k)
;;          while (< j n)
;;          do
;;            (let ((nval (the int32 (+ from-val (abs (- (aref a i) (aref a j)))))))
;;              (setf (aref dp j) (min (aref dp j) nval)))
;;     (format t "~a~%" (aref dp (- n 1)))))

(main)



Measured memory_bytes: 59876
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_E = 1005;
const int MAX_V = 105;
const int INF = 1e9;

struct edge { int from, to, cost; };
edge es[MAX_E];
int d[MAX_V], V, E;

//負閉路が存在する場合にfalseを返す
bool bellman_ford(int s){
  REP(i, V) d[i] = INF;
  d[s] = 0;
  REP(i, V + 1){
    bool update = false;
    REP(j, E){
      edge e = es[j];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        if(i == V) return false;
        update = true;
      }
    }
  }
  return true;
}

int main() {
  cin >>V >>E;
  REP(i, E){
    cin >>es[i].from >>es[i].to;
    es[i].cost = -1;
  }
  bool ans = false;
  REP(i, V) ans = max(ans, !bellman_ford(i));
  cout <<ans <<endl;
  return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MAX_N = 100000, MAX_M = 100000;
int N, M;
int L[MAX_M], R[MAX_M];
int C[MAX_M];


struct edge {
    int to;
    ll cost;
};
const int MAX_V = MAX_N;
const ll INF = INFLL;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s) {
    fill(d, d + V, INF);
    priority_queue<Pll, vector<Pll>, greater<> > pque;
    d[s] = 0;
    pque.push(Pll(0, s));


    while (!pque.empty()) {
        Pll p = pque.top();
        pque.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < (int) G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pque.push(Pll(d[v] + e.cost, e.to));
            }
        }
    }
}

int main() {
    cin >> N >> M;
    rep(i, M) cin >> L[i] >> R[i] >> C[i];
    rep(i, M) {
        --L[i];
        --R[i];
        G[L[i]].push_back((edge) {R[i], C[i]});
    }
    V = N;
    for (int i = 1; i < N; ++i) {
        G[i].push_back((edge) {i - 1, 0});
    }

    dijkstra(0);

    if (d[N-1] == INFLL) {
        cout << -1 << endl;
    } else {
        cout << d[N-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 10492
row = input();
n = int(row.split(" ")[0])
m = int(row.split(" ")[1])

if 2 * n ==  m :
	print(n) 
elif 2 * n > m :
	print(int(m / 2))
elif 2 * n < m :
	print( n + int((m - 2*n ) / 4))



Measured memory_bytes: 3060
function main(input) {
    var nums = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));

    var count = 0;
    while(nums.every((n) => (n % 2) === 0)) {
        count++;
        nums = nums.map((n) => n / 2);
    }

    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=200005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
PR a[MAXN];
int b[MAXN];
char Ans[MAXN];
int main()
{
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	int n=read(),flag0=0,flag1=0;
	for (int i=1;i<=n;i++) 
	{
		a[i].fi=read(),a[i].se=read();
		flag0|=((a[i].fi+a[i].se)%2==0);
		flag1|=((a[i].fi+a[i].se)%2==1);
	}
	if (flag0&&flag1) { puts("-1"); return 0; }
	if (flag0)
	{
		printf("%d\n",32);
		for (int i=0,t=1;i<=30;i++,t<<=1) b[i]=t,printf("%d ",t); 
		puts("1");
		for (int i=1;i<=n;i++)
		{			
			int x=-1,y=0;
			for (int j=30;j>=0;j--)
			{
				int t=min(min(abs(x+b[j]-a[i].fi),abs(x-b[j]-a[i].fi)),min(abs(y+b[j]-a[i].se),abs(y-b[j]-a[i].se)));
				if (t==abs(x+b[j]-a[i].fi)) Ans[j]='R',x+=b[j];
				else if (t==abs(x-b[j]-a[i].fi)) Ans[j]='L',x-=b[j];
				else if (t==abs(y+b[j]-a[i].se)) Ans[j]='U',y+=b[j];
				else if (t==abs(y-b[j]-a[i].se)) Ans[j]='D',y-=b[j];
			}
			for (int j=0;j<=30;j++) putchar(Ans[j]);
			puts("L");
		}
	}
	else
	{
		printf("%d\n",31);
		for (int i=0,t=1;i<=30;i++,t<<=1) b[i]=t,printf("%d ",t); 
		puts("");
		for (int i=1;i<=n;i++)
		{
			int x=0,y=0;
			for (int j=30;j>=0;j--)
			{
				int t=min(min(abs(x+b[j]-a[i].fi),abs(x-b[j]-a[i].fi)),min(abs(y+b[j]-a[i].se),abs(y-b[j]-a[i].se)));
				if (t==abs(x+b[j]-a[i].fi)) Ans[j]='R',x+=b[j];
				else if (t==abs(x-b[j]-a[i].fi)) Ans[j]='L',x-=b[j];
				else if (t==abs(y+b[j]-a[i].se)) Ans[j]='U',y+=b[j];
				else if (t==abs(y-b[j]-a[i].se)) Ans[j]='D',y-=b[j];
			}
			for (int j=0;j<=30;j++) putchar(Ans[j]);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
int t=1;
int g[105][105],d[105],f[105];

void DFS(int i){
  int j;
  if(d[i]==0){
    d[i]=t;
    t++;
    for(j=1;g[i][j]!=-1;j++) if(d[g[i][j]]==0) DFS(g[i][j]);
    f[i]=t;
    t++;
  }
}

int main(){
  int n,i,j,u,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++) scanf("%d",&g[i][j]);
    g[i][j]=-1;
  }
  for(i=1;i<=n;i++) DFS(i);
  for(i=1;i<=n;i++) printf("%d %d %d\n",i,d[i],f[i]);
  return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> div(10000005, 1);
  ll ans = 0;
  for(int i=1; i<=n; ++i){
    ans += (ll)i * (ll)div[i];
    for(int j=i*2; j<=n; j += i){
      ++div[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 42320
<?php
$n = trim(fgets(STDIN));

if(in_array($n, [10, 100, 1000, 10000, 100000])){
    echo 10; 
}else{
    $sum = 0;
    while($n > 0){$sum += $n % 10; $n = floor($n / 10);}
    echo $sum;
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define MAX 3005
long long dp[MAX][MAX];
int main()
{
    long long n;
    cin>>n;
    vector<long long> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    for(int R=n-1;R>=0;R--)
    {
        for(int L=R;L<n;L++){
            if(L==R)
                dp[R][L]=arr[L];
            else
                dp[R][L]=max(arr[R]-dp[R+1][L],arr[L]-dp[R][L-1]);
        }
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 49732
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
 
void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}
 
const int N=2e6+3,M=5e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;
 
int n,m,k,tc,ans,a[N];
 
int main(){
    scanf("%d%d",&n,&k);
    for(int i = 0 ; i < n ; i++){
        scanf("%d",&a[i]);
        if (i >= k){
            if (a[i] > a[i - k])
                printf("Yes\n");
            else
                printf("No\n");
        }
    }

}


Measured memory_bytes: 4544