akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
         
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        for (h = 2; h < H; h++) {
            putchar('#');
            for (w = 2; w < W; w++) putchar('.');
            putchar('#');
            putchar('\n');
        }
 
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2096
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int max = Math.max(A, Math.max(B, C));
		
		System.out.println(A*B*C/2/max);
	}
	
}


Measured memory_bytes: 22996
console.log((args=>{
  const [[N,K],P,C] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  let m = P.map((p,i)=>[p-1,BigInt(C[i]),BigInt(C[i])]);
  const op = (x,y) => x.map(([a,b,c])=>[
    y[a][0],
    b + y[a][1],
    (c<b+y[a][2])?b+y[a][2]:c
  ]);
  let x = P.map((p,i)=>[p-1,BigInt(C[i]),BigInt(Math.max(0,C[i]))]);
  let max = BigInt(-2e18);
  let n = K - 1;
  while(n>0) {
    if ( n&1 ) m = op(m,x);
    x = op(x,x);
    n >>= 1;
  }
  for ( let i = 0; i < N; i++ ) if ( max < m[i][2] ) max = m[i][2];
  return `${max}`;
})(require('fs').readFileSync('/dev/stdin','utf8')));


Measured memory_bytes: 51136
import sys
input = sys.stdin.readline

h,n = map(int,input().split())
a = []
b = []
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)

dp = [10**10]*(h+1)
dp[0] = 0

for i in range(n):
    for j in range(h+1):
        dp[j] = min(dp[j],dp[max(0,j-a[i])]+b[i])
print(dp[h])

Measured memory_bytes: 73672
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

bool isOK(int mid,int k,vector<int>& v){
    int cnt=0;
    for(int it:v)cnt+=(it-1)/mid;
    return cnt<=k;
}

int binsearch(int l,int r,int k,vector<int>& v){
    while(r-l>1){
        int mid=(l+r)/2;
        if(isOK(mid,k,v))r=mid;
        else l=mid;
    }
    return r;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    cout<<binsearch(0,1000000001,k,a)<<endl;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
typedef vector<vector<ll> > matrix;
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll f[2000001];



ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}
bool in(float x1,float y1,float x,float y,float r )
{
    if(abs(x1-x)*abs(x1-x)+abs(y1-y)*abs(y1-y)<=r*r) return true;
    return false;
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{

        return (a.second<b.second);
}
//
//vector<vector<int> >matrix;
matrix mul(matrix A,matrix B)
{
    matrix C(3, vector<ll>(3));
    for(int i=1;i<=2;i++)
    for(int j=1;j<=2;j++)
     for(int k=1;k<=2;k++)
         C[i][j] = (C[i][j] + A[i][k] * B[k][j]);
    return C;

}
matrix pow(matrix A, int p)
{
    if (p == 1)
        return A;
    if (p % 2)
        return mul(A, pow(A, p-1));
    matrix X = pow(A, p/2);
    return mul(X, X);
}
ll fib(int N,int a,int b)
{
    vector<ll> F1(3);
    F1[1] = a;
    F1[2] = b;
    matrix T(3, vector<ll>(3));
    T[1][1] = 0, T[1][2] = 1;
    T[2][1] = -1, T[2][2] = 1;
    if (N == 1)
        return a;
    if(N==2) return b;
    T = pow(T, N-1);
    ll res = 0;
    for(int i=1;i<=2;i++)
        res = (res + T[1][i] * F1[i]+ MOD)%MOD ;
    return res;
}

//1 2 3 4 5
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

 int t =1;
 while(t--)
  {
      int n;
      cin>>n;
      vector<int>v;
      map<int,ll>mp;
      set<int>s;
      ll ans=0;
      for(int i=0;i<n;i++)
      {
          ll a;
          cin>>a;
          if(s.find(a)!=s.end()) s.erase(a);
          else s.insert(a);
      }
      cout<<s.size();
  }
}


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

void solve()
{
	string text, pat;
	cin >> text >> pat;

	int match = 0;
	int res = 1e9 + 7;
	for(int i = 0; i <= text.length() - pat.length(); i++)
	{
		match = 0;
		for(int j = 0; j < pat.length();  j++)
		{
			if(text[i + j] == pat[j])
				match++;
		}

		res = min(res, (int)pat.length() - match);
	}

	cout << res << endl;
}

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

	solve();
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int ans=s.size()/2;
    char c=s[(s.size()-1)/2];
    for(int i=(s.size()-1)/2;i>=0;i--){
        if(s[i]==s[s.size()-i-1]&&s[i]==c)ans++;
        else break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int a[15], n, w; bool dp[100020];
bool knapsack(vector<int>x) {
	for (int i = 1; i < 100020; i++)dp[i] = false; dp[0] = true;
	for (int i = 0; i < (int)x.size(); i++) {
		for (int j = w - x[i]; j >= 0; j--) {
			if (dp[j] == true)dp[j + x[i]] = true;
		}
	}
	return dp[w];
}
bool solve(int r) {
	vector<int>J;
	for (int i = 0; i < n; i++) {
		int R = r, t = 0;
		while (R >= (1 << t)) {
			R -= (1 << t); t++;
			J.push_back(a[i] * (1 << (t - 1)));
		}
		if (R >= 1)J.push_back(a[i] * R);
	}
	return knapsack(J);
}
int main() {
	while (true) {
		cin >> n >> w; if (n == 0 && w == 0)break;
		for (int i = 0; i < n; i++)cin >> a[i];
		int L = 1, R = w + 10, M;
		while (true) {
			M = (L + R) / 2;
			bool p1 = solve(M), p2 = solve(M - 1);
			if (p1 == true && p2 == false) { cout << M << endl; break; }
			if (p2 == true)R = M;
			if (p1 == false)L = M;
		}
	}
	return 0;
}

Measured memory_bytes: 3248
import java.util.*;
public class Main {
	 public static long gcd(long x,long y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
    public static long lcm(long x,long y){                                                              
        return x*y/gcd(x,y);                                                                                                                                                                                                                
    }
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long e = b/c;
        long f = b/d;        
        long g = b/lcm(c,d);
        long h = (a-1)/c;
        long i = (a-1)/d;        
        long j = (a-1)/lcm(c,d);
		System.out.println(b-e-f+g-a+1+h+i-j);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    vel A(N); rep(i,N) cin >> A[i];
    ll maxa = maxel(A);
    sort(all(A));

    ll sum = 0; ll ans = 0;
    rep(i,N-1) {
    sum += A[i];
    ans++;
    if (sum*2 < A[i+1]) ans = 0;
  }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
 
int main(void) {
  int K, S, ans = 0;
  cin >> K >> S;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (S - x - y <= K && x + y <= S) {
        ans++;
      }
    }
  }
  
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
function main(p){
  const n = parseInt(p.split('\n')[0], 10)
  let ans = 0
  for(let i=1; i<=n/2; i++){
    if(i !== n-i){
      ans++
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7500
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;



int main(){

	int x;
	int y;
	int z;
	int e;


	cin>>x>>y>>z;

	e=(x-z);

	cout<<e/(y+z)<<endl;



}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [tuple(map(int,input().split())) for _ in range(m)]

bc.sort(key = lambda x: x[1],reverse = True)
i = 0
j = 0
ad = []
while i < n and j < m:
    ad.extend([bc[j][1]]*bc[j][0])
    i += bc[j][0]
    j += 1
    
if len(ad) < n:
    ad.extend([0]*(n-len(ad)))

a.sort(reverse = True)

i = 0
j = 0
k = 0
ans = 0
while k < n :
    if a[i] > ad[j]:
        ans += a[i]
        i += 1
        k += 1
    else:
        ans += ad[j]
        j += 1
        k += 1
  
print(ans)    
  

Measured memory_bytes: 23280
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
using ll = long long;
#define max(a,b) ((a)>(b) ? (a):(b))
#define min(a,b) ((a)<=(b) ? (a):(b))
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

int main(){
  ll N;
  cin >> N;
  vector<int> X(N);
  rep(i,N) cin >> X[i];
  double sum = 0;
  rep(i,N) sum += X[i];
  ll P = round(sum / N);
  ll ans = 0;
  rep(i,N) ans += pow((P - X[i]),2);
  cout << ans;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
const ll MOD = 1000000007;


int main() {
    int h,a;
    cin >> h >> a;
    if(h%a == 0) {
        cout << h/a;
    }else {
        cout << h/a+1;
    }
}

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



using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define tc            int testcases; cin>>testcases; while(testcases--)
#define set            set<int>
#define set1            set<int,greater<int>>
#define ub              upper_bound
#define lb              lower_bound
#define mset            multiset<int>
#define mset1           multiset<int,greater<int>>
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';



void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
}


// Driver Program to test above function

int32_t main()
{
	c_p_c();

	int n, x, t;
	cin >> n >> x >> t;

	if (n % x == 0)
	{
		cout << t*(n / x) << "\n";
	}

	else
	{

		if (n > x)
		{
			cout << t*(n / x + 1) << "\n";
		}

		else
		{
			cout << t << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <limits>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
int n,t,a;
  cin >> n >> t >> a;
  double b[n];
  rep(i,n){
    cin >> b[i];
  }
  double p = 100000;
  int ans = 1;
  rep(j,n){
    if(fabs(a-(t-b[j]*0.006)) < p){
    p=fabs(a-(t-b[j]*0.006));
    ans = j;
    }  
  }
  cout << ans+1;
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0, sum = 1;
	if (sum == b) {
		cout << "0" << endl;
		system("pause");
		return 0;
	}
	for (int i = 1; i < 100; i++) {
		sum += a - 1;
		if (sum >= b) {
			cout << i << endl;
			system("pause");
			return 0;
		}
	}

	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#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(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(ALL(h), greater<int>());
    ll ans = 0;
    rep(i, n)
    {
        if (i < k)
        {
            continue;
        }
        else
        {
            ans += h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  REP(i, N) ans = min(2 * ans, ans + K);
  cout << ans << endl;
  return 0;
}

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

int main() {
  int G[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> G[i][j];
    }
  }

  int minA = 1000;
  for (int i = 0; i < 3; ++i) {
    minA = min(minA, G[0][i]);
  }

  int A[3], B[3];
  int a1 = 0;
  bool ok = false;
  while (!(ok || a1 > minA)) {
    ok = true;
    for (int i = 0; i < 3; ++i) {
      B[i] = G[0][i] - a1;
    }
    for (int i = 1; i < 3; ++i) {
      A[i] = G[i][0] - B[0];
      if (A[i] < 0) ok = false;
    }
    for (int i = 1; i < 3; ++i) {
      for (int j = 1; j < 3; ++j) {
        if (G[i][j] != A[i] + B[j]) ok = false;
      }
    }
    ++a1;
  }

  if (ok) {
    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 = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  int s;
  cin>>s;
  int ans=0;
  rep(i,3){
    int q=s%10;
    if(q==1)ans++;
    s/=10;
  }
  cout<<ans<<endl;
  return 0;
}

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

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

lis = [a,b,c,d,e]
mod = [a%10, b%10, c%10, d%10, e%10]

try:    
    hasu = min([i for i in mod if i%10 != 0])
    ishasu = True
except:
    hasu = 0
    ishasu = False

ans = 0
for i in range(5):
    if lis[i]%10 == 0:
        ans += lis[i]//10
    else:
        ans += (lis[i]//10 + 1)


if (not ishasu):
    print(ans*10+hasu)
else:
    print(ans*10+hasu -10)


Measured memory_bytes: 3064
package main

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

func main() {
	var n, sum, S1, S2 int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	W := make([]int, n)
	for i := range W {
		sc.Scan()
		W[i], _ = strconv.Atoi(sc.Text())

		sum += W[i]
	}

	ans := 10000
	for i := 0; i < n; i++ {
		S1 += W[i]
		S2 = sum - S1

		ans = int(math.Min(float64(ans), math.Abs(float64(S1-S2))))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int N = 0;
int memo[10][1 << 10][331];
int dfs(int used, int sum, int n) {
    if (sum < 0) return 0;
    if (n == N) return sum == 0;

    if (~memo[n][used][sum]) return memo[n][used][sum];

    int res = 0;

    for (int i = 0; i < 10; i++) {
        if ((used >> i) & 1) {
            res += dfs(used&~(1 << i), sum - ((1 + n) * i), n + 1);
        }
    }
    memo[n][used][sum] = res;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;
    while(1) {
        cin >> n >> s;
        if (cin.eof()) break;
        N = n;
        memset(memo, -1, sizeof(memo));
        cout << dfs((1 << 10) - 1, s, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 16336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String az = "abcdefghijklmnopqrstuvwxyz";
		for(int i = 0; i < az.length(); i++ ) {
			String f =  az.substring(i,i+1);
			if(s.indexOf(f)==-1) {
				System.out.println(f);
				System.exit(0);
			}
		}
		System.out.println("None");
	}

}


Measured memory_bytes: 24020
#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 INF = 1 << 30;
 
int main() {
	int n, k;
	cin >> n >> k;
	int ans = k;
	if (n==1) {
		cout << ans << endl;
		return 0;
	}
	rep(i, n-1) ans *= (k-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>
#include <vector>
#include <array>

using std::cout;
using std::cin;
using std::string;


int main()
{
  std::array<int, 2> vec;
  cin >> vec[0] >> vec[1];
  auto it = std::max_element(vec.begin(), vec.end());
  int sum = *it;
  *it -= 1;
  sum += *std::max_element(vec.begin(), vec.end());
  std::cout << sum << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, n, v, x, y, z, dx, dy, x0, y0;
  char *p, buf[32];
  buf[31]=0;
  buf[30]='\n';
  fgets(buf, 32, stdin);
  for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0'); 
  int s[n], d[n];
  for (i=0; i<n; s[i]=i,d[i++]=0);
  while (fgets(buf, 32, stdin)) {
    for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
    for (y=0,p++; *p>='0'; y=y*10+*(p++)-'0');
    if (buf[0]=='0') { // relate x y z
      for (z=0,p++; *p!='\n'; z=z*10+*(p++)-'0');
      for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
      for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
      s[x0]=x;
      d[x0]=dx;
      s[y0]=y;
      d[y0]=dy;
      if (x<y) {
	s[y] = x;
	d[y] = z + dx - dy;
      }	else if (x>y) {
	s[x] = y;
	d[x] = -z - dx + dy;
      } else continue;
    } else { // diff
      for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
      for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
      s[x0]=x;
      d[x0]=dx;
      s[y0]=y;
      d[y0]=dy;
      v=-dx+dy;
      if (x!=y) {
	putc_unlocked('?', stdout);
	putc_unlocked('\n', stdout);
      } else {
	i=30;
	if (v>0)  for (; v>0; buf[--i]='0'+v%10,v/=10);
	else if (v<0) {
	  for (; v<0; buf[--i]='0'-v%10,v/=10);
	  buf[--i] = '-';
	} else  buf[--i] = '0';
	fputs(buf+i, stdout);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2440
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a[3],s[3],d[5],f[3],g,h,j,i;
	scanf("%d %d",&a[0],&a[1]);
	scanf("%d %d",&s[0],&s[1]);
	for(i=0;i<4;i++) scanf("%d",&d[i]);
	f[0]=a[0]*d[0]+a[1]*d[1]+(a[0]/10)*d[2]+(a[1]/20)*d[3];
	f[1]=s[0]*d[0]+s[1]*d[1]+(s[0]/10)*d[2]+(s[1]/20)*d[3];
	if(f[0]>f[1]) printf("hiroshi\n");
	else if(f[0]<f[1]) printf("kenjiro\n");
	else if(f[0]==f[1]) printf("even\n");
	return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
 using namespace std;
int main(){
  long n,t,s,i,j;
  bool f;
  cin >> n;
  vector<long> d(n);
  for(i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  s = d[0];
  f = false;
  j = 1;
  for(i=2;i<n;i++){
    s += d.at(j);
    if (f) {
      j++;
      f = false;
    }
    else
      f = true;
  }
  cout << s << endl;
}

Measured memory_bytes: 4844
#include <stdio.h>

int main(void){
	char S[3];
	for(int i=0;i<3;i++){
		scanf("%c \n",&S[i]);
	}
	char T[3];
	for(int i=0;i<3;i++){
		scanf("%c \n",&T[i]);
	}
	int ans=0;
	for(int i=0;i<3;i++){
		if( S[i]==T[i])ans++;
	}
	printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

int main(){
    int A,B;
    cin >> A >> B;
    if(A==1){
        if(B==2) cout << 3 << endl;
        else cout << 2 << endl;
    }else if(A==2){
        if(B==1) cout << 3 << endl;
        else cout << 1 << endl;
    }else{
        if(B==1) cout << 2 << endl;
        else cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n;
    cin >> n ;
    vector<int>A(n),B(n);
    map<int,int>mp;
    for(int i=0;i<n;i++){
        cin >> A[i];
        B[i] = A[i];
        mp[ A[i] ] ++;
    }
    sort(B.begin() , B.end());
    reverse(B.begin() , B.end());
    int cnt = 0;
    for(int i=0;i<n;i++){
        int x = A[i];

        for(int j=0;j<n;j++){
            if(B[j] != x){
                cout << B[j] << '\n';
                break;
            }
            else if(B[j] == x && mp[x]>1){
                cout << B[j] << '\n';
                break;
            }
        }

    }
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

vector<int>v;


int CeilIndex(std::vector<int>& v, int l, int r, int key) 
{ 
    while (r - l > 1) { 
        int m = l + (r - l) / 2; 
        if (v[m] >= key) 
            r = m; 
        else
            l = m; 
    } 
  
    return r; 
} 
  
int LIS(std::vector<int>& v) 
{ 
    if (v.size() == 0) 
        return 0; 
  
    std::vector<int> tail(v.size(), 0); 
    int length = 1;  
  
    tail[0] = v[0]; 
    for (size_t i = 1; i < v.size(); i++) { 
  
         
        if (v[i] < tail[0]) 
            tail[0] = v[i]; 
        else if (v[i] > tail[length - 1]) 
            tail[length++] = v[i]; 
        else
            tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i]; 
    } 
  
    return length; 
} 

int main(){
   int n,k;
   cin>>n>>k;
   int cnt=0;
   while(n){
      cnt+=1;
      n/=k;
   }
   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  intl X,N;
  cin >>X>>N;
  set<intl> num;
  intl p;
  Rep(i,102){
    num.insert(i);
  }
  
  Rep(i,N){
    cin >>p;
    num.erase(p);
  }

  intl bestn = 0;
  for(auto n: num){
    if(abs(bestn - X) > abs(n -X) ){
      bestn = n;
    }
    else if(abs(bestn - X) == abs(n -X) ){
      bestn = min(bestn , n);
    }
  }
  cout <<bestn;
}
  

  

Measured memory_bytes: 3640
#include <cstdint>
#include <iostream>

using namespace std;

static uint8_t colors = 0;

int32_t main()
{
  uint32_t num;
  cin >> num;

  uint8_t num_max_rate = 0;

  for (uint32_t i = 0; i < num; i++) {
    uint32_t val;
    cin >> val;

    int8_t shift = 0;
    if (val <= 399) {
      shift = 0;
    } else if (val <= 799) {
      shift = 1;
    } else if (val <= 1199) {
      shift = 2;
    } else if (val <= 1599) {
      shift = 3;
    } else if (val <= 1999) {
      shift = 4;
    } else if (val <= 2399) {
      shift = 5;
    } else if (val <= 2799) {
      shift = 6;
    } else if (val <= 3199) {
      shift = 7;
    } else {
      shift = -1;
      num_max_rate++;
    }

    if (shift != -1) {
      colors |= (1 << shift);
    }
  }

  uint8_t count = 0;
  for (uint8_t i = 0; i < 8; i++) {
    if ((colors >> i) & 0x01) {
      count++;
    }
  }

  int32_t ma = count;
  int32_t mi = count;

  ma += num_max_rate;

  if ((count == 0) && num_max_rate) {
    mi = 1;
  }

  cout << mi << " " << ma << endl;

  return 0;
}


Measured memory_bytes: 256
import math
n, x = [int(w) for w in input().split()]
la = [int(w) for w in input().split()]+[x]
la.sort()
if la[0] < 0:
    m = la[0]
    la = [w+m for w in la]

diff = [0]*n
for i in range(n):
    diff[i] = la[i+1]-la[i]
g = diff[0]
for i in diff[1:]:
    g = math.gcd(g, i)

print(g)


Measured memory_bytes: 20488
from bisect import *
a, b, q = map(int, input().split())
s = [-float('inf')] + [int(input()) for _ in range(a)] + [float('inf')]
t = [-float('inf')] + [int(input()) for _ in range(b)] + [float('inf')]
Q = [int(input()) for _ in range(q)]
for x in Q:
    i = bisect_left(s, x)
    j = bisect_left(t, x)
    r = max(s[i]-x, t[j]-x)
    k = bisect_right(s, x)-1
    l = bisect_right(t, x)-1
    r = min(r, max(x-s[k], x-t[l]))
    r = min(r, min(x-s[k]+t[j]-s[k], t[j]-x+t[j]-s[k]))
    r = min(r, min(x-t[l]+s[i]-t[l], s[i]-x+s[i]-t[l]))
    print(r)

Measured memory_bytes: 17408
import sys
def sieve(m):
    N=range(1,m+2,2)
    r=int(m**.5)
    h=len(N)
    N[0]=0
    for i in range(h):
        x=N[i]
        if x>r: break
        if x and i+x<h: N[i+x:h:x]=[0] * ((h-1-i-x)/x+1)
    return N
def f0056(n):
    x=0
    if n<4 : x=0
    elif n==4: x=1
    elif n%2==1:
        if SIEVES[(n-2)/2]!=0:
            x=1
    else:
        a=n/2
        for e in PRIMES:
            if e>a:break
            if SIEVES[(n-e)/2]!=0:
                x+=1
    return x

SIEVES=sieve(50000)
PRIMES=filter(None,SIEVES)
for n in sys.stdin:
    n=int(n)
    if n==0: break
    print f0056(n)

Measured memory_bytes: 5832
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

bool cmp(pair<double, string> p, pair<double, string> q) 
{
    return (p.first > q.first) || (p.first == q.first && p.second < q.second);
}


int main()
{
    int n;

    while (cin >> n) {
        if (!n)
            break;

        vector<pair<double, string> > crop;

        for (int i = 0; i < n; i++) {
            int p, a, b, c, d, e, f, s, m;
            string l;
            double income = 0.0;

            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            
            income = (double)(m * s * f - p) / ((a + b + c) + (d + e) * m);

            crop.push_back(pair<double, string>(income, l));
        }
        sort(crop.begin(), crop.end(), cmp);

        for (int i = 0; i < crop.size(); i++) 
            cout << crop[i].second << endl;
        cout << "#\n";
    }

    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,M; cin>>N>>M;
    vector<int> A(M);
    REP(i,M) cin>>A[i];
    int ans = N;
    REP(i,M) ans -= A[i];
    cout<<max(ans,(long long)-1)<<endl;
}

Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int num;
		int compare;

		while(true){

			try{
				compare=Integer.parseInt(br.readLine());
				System.out.println(compare/3600 +":"+ (compare%3600)/60+":"+compare%60);
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

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

int m, d, ans = 0;
int main(){
	scanf("%d%d",&m,&d);
	for(int i=1;i<=d;i++){
		int a = i % 10, b = i / 10;
		if(a < 2 || b < 2) continue;
		int c = a * b;
		if(c <= m) ans ++;
	}
	printf("%d",ans);
	return 0;
}

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 = new int[1000000];
		a[0] = sc.nextInt();

		for (int i = 0; i < a.length - 1; i++) {
			if (a[i] % 2 == 0) {
				a[i + 1] = a[i] / 2;
			} else {
				a[i + 1] = 3 * a[i] + 1;
			}

			for (int j = 0; j < i; j++) {
				if (a[j] == a[i]) {
					System.out.println(i + 1);
					System.exit(0);
				}
			}

		}

	}
}

Measured memory_bytes: 25684
#include <iostream>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    tot ^= a[i];
  }
  for (int i = 0; i < n; ++i)
    a[i] ^= tot;
  for (int i : a)
    cout << i << " ";
}

Measured memory_bytes: 3608
using System;
using System.ComponentModel.DataAnnotations;
using System.IO.Pipes;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var t = Console.ReadLine();
			var ans = t.Length;
			for (var i = 0; i + t.Length <= s.Length; i++)
			{
				var min = 0;
				for (var j = 0; j < t.Length; j++)
				{
					if (s[i + j] != t[j]) min++;
				}
				ans = Math.Min(ans, min);
			}

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 25768
N,M=map(int,input().split())
L=[]
R=[]
for i in range (M):
	X,Y=map(int,input().split())
	L.append(X)
	R.append(Y)
if min(R)-max(L)+1>0:
	print(min(R)-max(L)+1)
else:
	print(0)

Measured memory_bytes: 10996
while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  
  if op == '?':
    break
  elif op == '+':
    print(a + b)
  elif op == '-':
    print(a - b)
  elif op == '*':
    print(a * b)
  elif op == '/':
    print(a // b)



Measured memory_bytes: 5596
#include<stdio.h>

int main()
{
    int w;
    int h;
    int a[1000] = {};
    int b[1000] = {};
    int sum_a = 0;
    int sum_b = 0;
    int tmp;
    int i;
    int j;
    int k;
    
    scanf("%d%d", &w, &h);

    for(i = 0; i < w; i++)
    {
        scanf("%d", &a[i]);
        sum_a += a[i];
    }
    
    for(i = 0; i < h; i++)
    {
        scanf("%d", &b[i]);
        sum_b += b[i];
    }
    
    if(sum_a != sum_b)
    {
        puts("0");
        return 0;
    }

    for(i = 0; i < w; i++)
    {
        for(j = 0; j < h; j++)
        {
            for(k = j + 1; k < h; k++)
            {
                if(b[j] < b[k])
                {
                    tmp = b[j];
                    b[j] = b[k];
                    b[k] = tmp;
                }
            }
        }
        
        for(j = 0; j < h; j++)
        {
            if(!a[i] || !b[j])
            {
                break;
            }
            a[i]--;
            b[j]--;
        }
        
        if(a[i] > 0)
        {
            puts("0");
            return 0;
        }
    }
    
    puts("1");

    return 0;
}


Measured memory_bytes: 2112
a,b,h,m = map(int, input().split())

import math
zishin = 30 * h + 0.5 * m 
tanshin = 6 * m

kakudo = abs(zishin - tanshin)

if kakudo >= 180:
    kakudo = 360 - kakudo

cos = math.cos(math.radians(kakudo))
dis = a ** 2 + b ** 2 - 2 * a * b * cos

print(math.sqrt(dis))

Measured memory_bytes: 9444
while True:
    m, f, r = [int(x) for x in input().split(" ")]
    if m == f == r == -1:
        break

    sum = m + f
    if m == -1 or f == -1:
        res = "F"
    elif sum >= 80:
        res = "A"
    elif 65<= sum < 80:
        res = "B"
    elif 50<= sum < 65:
        res = "C"
    elif 30<= sum < 50:
        res = "D"
    else:
        res = "F"

    if res == "D" and r >= 50: res = "C"

    print(res)

Measured memory_bytes: 7756
s = int(input())
A = []
A.append(s)


def has_duplicates(seq):
	return len(seq) != len(set(seq))
itr = 1
while True:
	#print(itr,A)
	itr += 1
	if A[-1] % 2 == 0:
		A.append(int(A[-1] / 2))
	else:
		A.append(int(3*A[-1]+1))
	#print(A)
	if has_duplicates(A):
		print(itr)
		break
	

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {

    int n, m;
    int e[10][10];

    cin>>n>>m;

    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            cin>>e[i][j];


    for (int k = 0; k < 10; k++)
    for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
    if (e[i][j] > e[i][k] + e[k][j]) {
        e[i][j] = e[i][k] + e[k][j];
    }


    int sol = 0;

    for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
        int nr;
        cin>>nr;

        if(nr != -1) sol += e[nr][1];
    }

    cout<<sol;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

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

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


std::vector<pii> A, B, C, D;

int main(void){
    int n; scanf("%d", &n);
    A.resize(n); REP(i, n) scanf("%d%d", &A[i].first, &A[i].second), A[i].second++;
    std::sort(A.begin(), A.end(), std::greater<pii>());

    B.reserve(n), C.reserve(n), D.reserve(n);
    FOR(i, 1, n){
        if(A[i].second >= A[0].second) D.push_back(A[i]);
        else if(A[i].second > A[0].first) C.push_back(A[i]);
        else B.push_back(A[i]);
    }

    std::sort(C.begin(), C.end(), [](pii& a, pii& b){
        if(a.second != b.second) return a.second < b.second;
        return a.first < b.first;
    });
    const int b = B.size(), c = C.size(), d = D.size();
    int res = 0;
    if(b > 0){
        REP(i, c) chmax(res, C[i].second - C[i].first);
        REP(i, d) chmax(res, D[i].second - D[i].first);
        if(b > 1) REP(i, b) chmax(res, B[i].second - B[i].first);
    }

    int l = 0, r = 1e9 + 2;
    REP(i, b){
        if(l < B[i].first) l = B[i].first;
        if(r > B[i].second) r = B[i].second;
    }

    REP(i, c){
        if(l > 0) chmax(res, C[i].second - A[0].first + 
            ((r > l) ? r - l : 0)
        );
        else{
            FOR(j, 1, c) chmax(res, C[0].second - A[0].first + C[j].second - C[j].first);
            REP(j, d) chmax(res, C[0].second - A[0].first + D[j].second - D[j].first);
        }

        if(l < C[i].first) l = C[i].first;
        if(r > C[i].second) r = C[i].second;
    }

    if(l == 0) REP(i, d) chmax(res, A[0].second - A[0].first + D[i].second - D[i].first);
    else chmax(res, A[0].second - A[0].first + ((r > l) ? r - l : 0));
    printf("%d\n", res);


    return 0;
}


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


int main() {
  int n,d,answer,temp;
  scanf("%d%d",&n,&d);
  temp=n/(2*d+1);
  if (n%(2*d+1)!=0) answer=temp+1;
  else answer=temp;
  printf("%d",answer);
  return 0;
}

Measured memory_bytes: 256