akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31)-1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;

int m[60][60];
int d[60][60];
int h, w;

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

int main(){
	cin >> h >> w;
	int count = 0;
	queue<pii> bfs;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c == '.') {
				m[i][j] = 0;
				count++;
			}
			else {
				m[i][j] = 1;
			}
			d[i][j] = 100000;
		}
	}
	d[0][0] = 0;
	bfs.push(make_pair(0, 0));
	while (!bfs.empty()) {
		int x, y;
		x = bfs.front().fst; y = bfs.front().snd; bfs.pop();
		for (int i = 0; i < 4; i++) {
			int nx, ny;
			nx = x + dx[i]; ny = y + dy[i];
			if (nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
			if (m[nx][ny] == 1)continue;
			if (d[nx][ny] > d[x][y] + 1) {
				d[nx][ny] = d[x][y] + 1;
				bfs.push(make_pair(nx, ny));
			}
		}
	}
	if (d[h - 1][w - 1] == 100000) {
		cout << -1 << endl;
		return 0;
	}
	cout << count - d[h - 1][w - 1] - 1 << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> p;
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        p.push_back(make_pair(a, b));
    }
    ll ans = 0;
    for (ll i = n - 1; i >= 0; i--)
    {
        p[i].first += ans;
        if (p[i].first % p[i].second != 0)
        {
            ans += (p[i].second - p[i].first % p[i].second);
            p[i].first += (p[i].second - p[i].first % p[i].second);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int mod = a % 1000;
    
    int result;
    if (mod == 0) {
      result = 0;
    } else {
      result = 1000 - mod;
    }
    
    System.out.println(result);
  }
}

Measured memory_bytes: 35728
#include<stdio.h>
int main(void){
	long long int number;
	int a10[10];
	int a9[9];
	int a8[8];
	int a7[7];
	int a6[6];
	int a5[5];
	int a4[4];
	int a3[3];
	int a2[2];
	int ans;
	int i;
	while(scanf("%lld",&number) != EOF){
		for(i = 9;i >= 0;i--){
			a10[i] = number % 10;
			number = number /10;
		}
		for(i = 0;i < 9;i++){
			a9[i] = (a10[i] + a10[i+1]) % 10;
		}
		for(i = 0;i < 8;i++){
			a8[i] = (a9[i] + a9[i+1]) % 10;
		}
		for(i = 0;i < 7;i++){
			a7[i] = (a8[i] + a8[i+1]) % 10;
		}
		for(i = 0;i < 6;i++){
			a6[i] = (a7[i] + a7[i+1]) % 10;
		}
		for(i = 0;i < 5;i++){
			a5[i] = (a6[i] + a6[i+1]) % 10;
		}
		for(i = 0;i < 4;i++){
			a4[i] = (a5[i] + a5[i+1]) % 10;
		}
		for(i = 0;i < 3;i++){
			a3[i] = (a4[i] + a4[i+1]) %10;
		}
		for(i = 0;i < 2;i++){
			a2[i] = (a3[i] + a3[i+1]) % 10;
		}
		ans = (a2[0] + a2[1]) % 10;
		printf("%d\n",ans);
		i = 0;
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    int n;
    cin>>n;

    vector<int> a(n);

    for ( int i = 0 ; i < a.size() ; i++ )
    {
        cin>>a[i];
    }

    vector<int> dp(n,0);

    dp[1] = abs(a[1]-a[0]);

    for ( int i = 2 ; i < a.size() ; i++ )
    {
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]) );
    }

    cout<<dp[a.size()-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> e(n + 1, 0);
  REP(i, n) { e[i + 1] = e[i] + (s[i] == 'E'); }

  ll ans = 1e18;
  FOR(i, 1, n + 1) {
    ll t;
    t = i - 1 - e[i - 1] + e[n] - e[i];
    // DUMP(t);
    ans = min(ans, t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int W=sc.nextInt();
		int H=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		int r=sc.nextInt();
		if(r>0 && x>=r && y>=r && W>=x+r && H>=y+r) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}



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

// https://atcoder.jp/contests/abc122/tasks/abc122_b
namespace BATCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ACGT = new[] { 'A', 'C', 'G', 'T' };

            // 入力の取得
            var inputs = Console.ReadLine().ToCharArray();

            var acgtSummary = new List<Tuple<bool, int>>();
            var current = ACGT.Contains(inputs[0]);
            var sum = 0;
            foreach (var c in inputs)
            {
                if (current != ACGT.Contains(c))
                {
                    acgtSummary.Add(Tuple.Create(current, sum));
                    current = !current;
                    sum = 0;
                }
                sum++;
            }
            acgtSummary.Add(Tuple.Create(current, sum));

            var maxLength = 0;
            if (acgtSummary.Any(t => t.Item1))
            {
                maxLength = acgtSummary.Where(t => t.Item1).Max(t => t.Item2);
            }

            // 解答の出力
            Console.WriteLine(maxLength);
        }
    }
}


Measured memory_bytes: 13524
#include<cstdio>
#include<algorithm>
using namespace std;
long long w[220], P[61];
int n;
char p[220];
bool OK(int pv){
    long long x = w[pv];
    for(int i=60;i>=0;i--){
        if((x>>i)&1){
            if(!P[i]){
                if(p[pv]=='1')return false;
                P[i]=x;
                return true;
            }
            x^=P[i];
        }
    }
    return true;
}
void Solve(){
    int i;
    for(i=0;i<=60;i++)P[i]=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%lld",&w[i]);
    scanf("%s",p);
    for(i=n-1;i>=0;i--){
        if(!OK(i)){
            puts("1");
            return;
        }
    }
    puts("0");
}
int main(){
    int TC;
    scanf("%d",&TC);
    while(TC--){
        Solve();
    }
}


Measured memory_bytes: 1608
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n); i++)
#define sz(x) int(x.size())
using namespace std;

int main(){
    int n, ans = 0;
    string s;
    cin >> n;

    for(;n!=0;n--){
    s = to_string(n);
    if(s.size()%2!=0) ans++;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    long long n,k,i;
    string s;
    cin>>k;
    cin>>s;
    n=s.size();
    if(n<=k)
    {
        cout<<s<<endl;
    }
    else
    {
        for(i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
 string s;int k;
 cin>>s>>k;
 int a=0;while(a<s.size()&&s[a]=='1')a++;
 if(k-1<a)cout<<'1';
 else cout<<s[a];

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 S = sc.nextInt();
		int W = sc.nextInt();
		sc.close();
		if(S <= W) {
			System.out.println("unsafe");
			} 
		else 
		System.out.println("safe");
		
	}
}

Measured memory_bytes: 35716
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <queue>
#include <stack>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

typedef pair<int,int> P;
queue<P> q;

int static const N_MAX = 1000 * 1000;
int N;
int y[N_MAX][3];
int dp[N_MAX][3];


void bfs(){

  for(int i=0; i<N; i++){
    rep(now, 3){
      rep(next, 3){
        if(now == next) continue;
        dp[i+1][next] = max(dp[i+1][next], dp[i][now] + y[i+1][next]);
      }
    }
  }

}


int main(){

  cin>>N;
  rep(i,N){
    cin>>y[i][0]>>y[i][1]>>y[i][2];
    dp[i][0] = 0;
    dp[i][1] = 0;
    dp[i][2] = 0;
  }

  dp[0][0] = y[0][0];
  dp[0][1] = y[0][1];
  dp[0][2] = y[0][2];
  bfs();

  int ans = max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2]);
  cout<< ans <<endl;

}

Measured memory_bytes: 5504
#include<iostream>
#include<string>
using namespace std;
int main()
{
    long long a,b,n,sum,num=-1,i;
    cin>>a>>b>>n;
    if(n<b){
        cout<<a*n/b<<endl;
        return 0;
    }
    if(a==b&&b==n){
        cout<<n-1<<endl;
        return 0;
    }
    if(a>b&&b==n){
        i=b-1;
    sum=a*i/b-a*(i/b);
    cout<<sum<<endl;
    return 0;
    }
    if(a<b&&b==n){
        cout<<a-1<<endl;
        return 0;
    }
    if(a<=b&&b<=n){
        cout<<a-1<<endl;
        return 0;
    }
    if(a>=b&&b<=n){
    i=b-1;
    sum=a*i/b-a*(i/b);
    cout<<sum<<endl;
    return 0;
    }
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int n,k;
    cin>>n>>k;
    ll m=0,dif=-1e15,b=0,w=0;
    vector<ll>x(n);
    
    rep(i,n){
        cin>>x[i];
        if(x[i]>=0)m+=x[i];
    }
    
    rep(i,k){
        if(x[i]>=0)w-=x[i];
        else b+=x[i];
    }
    
    dif=max(dif,w);
    dif=max(dif,b);
    
    forx(i,1,n-k+1){
        if(x[i-1]>=0)w+=x[i-1];
        else b-=x[i-1];
        
        if(x[i+k-1]>=0)w-=x[i+k-1];
        else b+=x[i+k-1];
        
        dif=max(dif,w);
        dif=max(dif,b);
    }
    
    cout<<m+dif<<endl;
        
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[5000];

ll comb(ll a, ll b) {
  ll ans = frac[a];
  ll sh1, sh2;
  ll h = mod-2;
  ll two;
  while(h>0) {
    two = 1;
    sh1 = frac[b];
    sh2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      sh1 *= sh1;
      sh1 %= mod;
      sh2 *= sh2;
      sh2 %= mod;
    }
    h -= two;
    ans *= sh1*sh2%mod;
    ans %= mod;
  }
  return ans;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<5000;++i) frac[i] = frac[i-1]*i%mod;
  ll S;
  cin>>S;
  ll ans = 0;
  for(ll i=1;i<=S/3;++i) {
    ans += comb(S-3*i+i-1, i-1);
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;

int knapsack(int n, int W, vi w, vi v){
    vvi dp(n + 1, vi (W + 1, 0));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= W; j++) {
            if(j - w[i] >= 0) {
                chmax(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
            chmax(dp[i][j], dp[i - 1][j]);
        }
    }
    return dp[n][W];
}

int main() {

    int n,W;
    cin>>n>>W;
    vi w(n+1),v(n+1);
    vi dp(W+1,-1);
    rep(i,n)cin>>v[i]>>w[i];
    dp[0]=0;
    rep(i,W){
        if(dp[i]>=0){
            rep(j,n){
                if(i+w[j]<W+1)chmax(dp[i+w[j]],dp[i]+v[j]);
            }
        }
    }
    int ans=0;
    rep(i,W+1){
        chmax(ans,dp[i]);
    }
    fin(ans);
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=s.length(),c=0;
    ll ans=0;
    ifr(i,n){
        if(s[i]=='C'){
            if(i>0&&s[i-1]=='B'){
                --i;
                ++c;
                continue;
            }
            else{
                c=0;
            }
        }
        if(s[i]=='B'){
            c=0;
        }
        if(s[i]=='A'){
            ans+=c;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){

    string S, T; cin >> S >> T;
    int sn = S.size();
    int tn = T.size();

    int match = 0;

    rep(i,sn){
        if (i + tn > sn) continue;
        int tmp = 0;
        rep(j,tn){
            if (S[i+j] == T[j]){
                tmp++;
            }
        }

        match = max(match, tmp);
    }

    cout << max(0, tn - match) << endl;

}

Measured memory_bytes: 3600
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut n: usize = sc.read();
    if n % 2 == 1 {
        println!("{}", "No");
        return;
    }
    let h = n / 2;
    let s: String = sc.read();
    let mut ok: bool = true;
    for i in 0..h {
        if &s[i..i+1] != &s[i + h..i + h + 1] {
            ok = false;
        }
    }
    if ok {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}

Measured memory_bytes: 2060
import java.util.Scanner;

public class Main{


	public static void main(String[] args){

		//?¨??????\???
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		result(a,b,c);

	}

	//???????????¨?????????????????????
	private static void result(int a, int b, int c){
		if(a<b&&b<c){
			System.out.println("Yes");}
		else{System.out.println("No");}
	}


}

Measured memory_bytes: 26268
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,m; cin >> n >> m;
    vc<bool> list(200007,false);
    vi ca;
    rep(i,m){
        int x,y; cin >> x >> y;
        if(x == 1) ca.eb(y);
        else if(y == n) list[x] = true;
    }
    for(int i: ca) if(list[i]){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main(){
int a=0,b=0;
char cha,chb;
cin>>cha>>chb;
//cout<<cha<<chb;
if(cha=='H')
	a=1;
if(chb=='H')
	b=1;
if((a+b)%2)
	cout<<'D';
else
	cout<<'H';
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, M, C;
int B[21];
int ans;

int main()
{
  scanf( "%d%d%d", &N, &M, &C );
  rep( i, M )
    scanf( "%d", B+i );
  
  rep( i, N )
  {
    int A[21];

    rep( j, M )
      scanf( "%d", A+j );

    int sum = C;
    rep( j, M )
      sum += A[j]*B[j];

    if( sum > 0 )
      ++ans;
  }

  printf( "%d\n", ans );
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        char c = Cin.Next().First();
        Console.WriteLine(new char[] { 'a', 'i', 'u', 'e', 'o' }.Any(ch => ch == c) ? "vowel" : "consonant");
    }
}

public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define maxn 200005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m, sum[maxn * 44], rt, a[maxn], cnt, L = -200000, R = (1e9) + 200000, ls[maxn * 44], rs[maxn * 44];
il void insert(int &k, int l, int r, int ll) {
	if(!k) k = ++ cnt; ++ sum[k];
	if(l == r) return;
	int mid = (l + r) >> 1;
	if(ll <= mid) insert(ls[k], l, mid, ll);
	else insert(rs[k], mid + 1, r, ll);
}
il int query(int k, int l, int r, int ll) {
	if(l == r) return sum[k];
	int mid = (l + r) >> 1;
	if(ll <= mid) return query(ls[k], l, mid, ll);
	else return query(rs[k], mid + 1, r, ll);
}
signed main() {
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n) {
		m += query(1, L, R, i - a[i]);
		insert(rt, L, R, i + a[i]);
	}
	cout << m;
	return 0;
}

Measured memory_bytes: 45980
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N;
  string S;
  cin>>N>>S;
  if(N>3199){
  cout<<S<<endl;
  }else{
  cout<<"red"<<endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    int B[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    int out=0;
    for (int i=0;i<N;i++){
        if(A[i]-B[i]>0){
            out += A[i]-B[i];
        }
    }
    cout << out;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
 
// prototype
int SortDescendNum(const void *num1, const void *num2);
int main(void)
{
    int N;
  	int K;
  	long int count=0;
  	int i=0;
    // 整数の入力
    scanf("%d %d\n",&N,&K);
  	long int H[N];
  	for(i=0;i<N;i++){
      	scanf("%ld\n",&H[i]);
    }
 	qsort(H, N, sizeof(*H), SortDescendNum);
   	for(i=K;i<N;i++){
    	count+=H[i];
    }
      printf("%ld\n",count);
    return 0;
}
int SortDescendNum(const void *num1, const void *num2)
{
    return *(int *)num2 - *(int *)num1;
}

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

int main(){
	int h[10];
	
	for(int i = 0; i < 10; i++){
		cin >> h[i];
	}
	sort(h,h+10,greater<int>());
	
	for(int i = 0; i < 3; i++){
		cout << h[i] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  string s,os;
  cin >> s;
  while(s.size()>0){
    os = s;
    if (s.size()>=7) {
      if (s.substr(s.size()-7,7)=="dreamer"){
        s = s.substr(0,s.size()-7);
      }
    }
    if (s.size()>=6) {
      if (s.substr(s.size()-6,6)=="eraser"){
        s = s.substr(0,s.size()-6);
      }
    }
    if (s.size()>=5) {
      if (s.substr(s.size()-5,5)=="dream"){
        s = s.substr(0,s.size()-5);
      } else if (s.substr(s.size()-5,5)=="erase"){
        s = s.substr(0,s.size()-5);
      }
    }
    if (os==s) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 672
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))


def binarySearch(data, value):
    left = 0
    right = len(data) - 1
    while left <= right:
        mid = (left + right) // 2
        if data[mid] == value:
            return mid
        elif data[mid] < value:
            left = mid + 1
        else:
            right = mid - 1
    return -1


ans = []
for j in range(q):
    if binarySearch(S, T[j]) > -1:
        ans.append(binarySearch(S, T[j]))
print(len(ans))



Measured memory_bytes: 16708
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void) {
	int N, a[5];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		if (pow(a[2], 2) == pow(a[1], 2) + pow(a[0], 2)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("unroll-loops, no-stack-protector")
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll dist[100005];
vpll adj[100005];
void bfs01(ll src){
	for (ll i = 0; i < 100005; i++) dist[i] = 1e18;
	dist[src] = 0;
	deque <ll> dq; dq.push_front(src);
	while (!dq.empty()){
		ll u = dq.front(); dq.pop_front();
		for (ll i = 0; i < (ll) adj[u].size(); i++){
			ll v = adj[u][i].fi, w = adj[u][i].se;
			if (dist[u] + w < dist[v]){
				dist[v] = dist[u] + w;
				if (w == 1) dq.pb(v); 
				else dq.push_front(v);
			}
		}
	}
}
int main(){
	fastio;
	ll k; cin >> k;
	for (ll i = 0; i < k; i++){
		adj[i].eb(mp((i + 1) % k, 1LL));
		adj[i].eb(mp((i * 10) % k, 0LL));
	}
	bfs01(1); cout << dist[0] + 1 << endl;
}

Measured memory_bytes: 11844
#include <stdio.h>

int Pay(int N){
  int i, X;
  X = (int) N / 1.08;
  for(i = X;;i++){
    if((int)(i * 1.08) == N) return i;
    if(i * 1.08 > N) break;
  }
  return -1;
}
int main(void){
  int X, N;
  scanf("%d", &N);
  X = Pay(N);
  if(X != -1) printf("%d\n", X);
  else printf(":(\n");
  return 0;
}


Measured memory_bytes: 128
n=int(input())
ans=[]
tes=[[] for _ in range(n)]

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

for i in range(2**n):
    f=0
    m=0
    rel=[0 for _ in range(n)]
    for j in range(n):
        if (i>>j)&1:
            rel[j]=1
            m+=1
            
    
    for j in range(n):
        
        for q in range(len(tes[j])//2):
            if rel[j]==1 and tes[j][2*q+1]!=rel[tes[j][2*q]-1]:
                f=1
    if f==0:
        ans.append(m)
print(max(ans))
            
    
        
    
    
    
        
        
    
    
    
    
        


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

int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if (a + W < b) cout << b - W - a << endl;
    else if (b + W < a) cout << a - W - b << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define N 100010
using namespace std;

int n,dp[3][3],hp[3];

int main()
{
    cin>>n;
    FOR(i,0,n)
    {
        FOR(j,0,3) cin>>hp[j];
        FOR(j,0,3)
        {
            FOR(k,0,3)
            {
                if(j!=k) dp[(i+1)%3][k]=max(dp[(i+1)%3][k],dp[i%3][j]+hp[k]);
            }
        }
    }
    cout<<max(dp[n%3][0],max(dp[n%3][1],dp[n%3][2]))<<'\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int DP[101][100100];
int main()
{
	int N,K;
	cin>>N>>K;
	DP[0][0]=1;
	for(int i=0;i<N;i++)
	{
		int A;
		cin>>A;
		int X=0;
		for(int j=0;j<=K;j++)
		{
			X=(X+DP[i][j])%1000000007;
			if(j>A)
				X=(X+1000000007-DP[i][j-A-1])%1000000007;
			DP[i+1][j]=X;
		}
	}
	cout<<DP[N][K]<<endl;
	return 0;
}

Measured memory_bytes: 39296
X, K, D = map(int, input().split())

absX = abs(X)
a = absX - K * D
minX = absX % D

if a > 0:
    print(a)

elif a <= 0:

    Kmin = (absX - minX) / D
    Krem = K - Kmin

    if Krem % 2 == 0:
        print(min(abs(minX), abs(minX - 2 * D)))
    else:
        print(min(abs(minX + D), abs(minX - D)))


Measured memory_bytes: 9240
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  for(auto&& e:a)cin>>e;
  int j = 0;
  ll ans = 0;
  int acc = 0;
  for(auto&& i:irange(0,n)) {
    while (j < n && (acc & a[j]) == 0) {
      acc ^= a[j];
      ++j;
    }
    ans += j-i;
    acc ^= a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#define INF 1000000000
using namespace std;
int main(){
	int m[]={380,550,850,1520,1870,2244},
	dp[100010],
	w[]={2,3,5,10,12,15};
	for(int i=0;i<=100005;i++)
		dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<6;i++)
	for(int j=w[i];j<=100005;j++){
		//if(dp[j-w[i]]==INF)
		//dp[j]=min(m[i],dp[j]);
		//else
		dp[j]=min(dp[j],dp[j-w[i]]+m[i]);
	//	if(j==22)
		//cout<<i<<' '<<dp[j]<<endl;
	}
	//for(int i=0;i<=2500;i++)
	//cout<<' '<<dp[i]<<endl;
	int n;
	while(cin>>n,n){
		n/=100;
		int ans=dp[n];
		/*for(int i=n;i<=100005;i++){
			if(dp[i]!=INF)
			ans=min(ans,dp[i]);
		}*/
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    char ch;
    int num;
    int alphabet[26] = {};
    while(cin >> ch) {
        num = ch - 'a';
        if (0 <= num && num < 26) alphabet[num]++;
        num = ch - 'A';
        if (0 <= num && num < 26) alphabet[num]++;
    }
    for (int i = 0; i < 26; i++) {
        ch = 'a' + i;
        cout << ch << " : " << alphabet[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N;
    cin >> N;

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

    map<int, int>  m;
    for(int i=0; i<N; i++){
        int t = i - A[i];
        if(m.count(t) == 0) m[t] = 1;
        else m[t]++;
    }
    ll ans = 0;
    for(int i=0; i<N; i++){
        int t = A[i] + i;
        if(m.count(t) != 0) ans = ans + m[t];
    }

    cout << ans << endl;

    return 0;
}


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


int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int sita=max(a,c);
  int ue=min(b,d);
  if(ue-sita<=0) cout << "0" << endl;
  else cout << ue-sita << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll n,k,a[200010],s[200010],i;
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  s[0]=0;
  for(i=0;i<n;i++){
    s[i+1]=s[i]+a[i];
    s[i+1]=s[i+1]%k;
  }
  ll x[200010];
  map<ll,ll> mp;
  for(i=0;i<n+1;i++){
    x[i]=s[i]+n-i;
    x[i]=x[i]%k;
    mp[x[i]]++;
  }
  ll ans=0;
  for(i=0;i<n;i++){
    if(mp[x[i]]!=0){
      ans+=mp[x[i]]*(mp[x[i]]-1)/2;
      mp[x[i]]=0;
    }
  }
  if(n<k){
    cout << ans << endl;
    return 0;
  }
  ll ans1=0;
  map<ll,ll> mp1;
  for(i=k;i<n+1;i++){
    mp1[x[i]]++;
  }
  for(i=0;i<=n-k;i++){
    if(mp1[x[i]]!=0){
      ans1+=mp1[x[i]];
    }
    mp1[x[i+k]]--;
  }
  cout << ans-ans1 << endl;
}

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


#define ll long long
#define pb push_back
#define mp make_pair

int main() {
    ll n,a,b;
    cin >> n>> a>>b;
    
    if(n%(a+b) >=a)
    cout << (n/(a+b))*a + a << endl;
    else
    cout << (n/(a+b))*a + n%(a+b) << endl;
    
}

Measured memory_bytes: 256
export class Main {
  static main(input): string {
    const [a, b, k]: number[] = input.split(" ").map(Number);
    const gcd = Main.gcd(a, b);
    let result: number | null = null;
    let count: number = 0;
    let list: number[] = [];
    const len = Math.floor(Math.sqrt(gcd));
    for (let i: number = 1; i <= len; i++) {
      if (gcd % i === 0) {
        count++;
        if (count === k) {
          result = gcd / i;
          break;
        } else {
          if (i * i !== gcd) {
            list.unshift(i);
          }
        }
      }
    }
    return `${result === null ? list[k - count - 1] : result}`;
  }

  static gcd(a: number, b: number): number {
    if (a == 0 || b == 0) {
      return 0;
    }
    let r = Math.abs(a);
    let tmp = Math.abs(b);
    while (tmp > 0) {
      let t = r % tmp;
      r = tmp;
      tmp = t;
    }
    return r;
  }
}

console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Space-Time Sugoroku Road - Accepted
 */
public class Main {

	static final int INF = 1 << 29;
	static int min = INF;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		Main main = new Main();

		int N = parseInt(br.readLine());
		Map<Integer, List<Integer>> G = new HashMap<>();

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

			G.put(i, new ArrayList<>());
			int p = parseInt(br.readLine());

			if (p == 0) {
				for (int j = 6; j >= 1; j--) {
					G.get(i).add(i + j < N ? i + j : N);
				}
			} else {
				G.get(i).add(i + p);
			}
		}

		//solve
		Queue<int[]> pq = new PriorityQueue<>(1, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[1], o2[1]);
			}
		});
		Log loop = main.new Log();

		pq.offer(new int[]{1, 0});
		while (!pq.isEmpty()) {

			int[] s = pq.poll();
			int c = s[1];

			if (s[0] == N) {
				min = Math.min(min, s[1]);
				continue;
			}

			if (c >= min) {
				continue;
			}

			//
			if (G.get(s[0]).size() != 1) c++;

			for (int t : G.get(s[0])) {
				if (!loop.detect(s[0], t, c)) {
					pq.add(new int[]{t, c});
				}
			}
		}
		System.out.println(min);
	}

	class Log {

		Map<Integer, Map<Integer, Integer>> data;

		Log() {
			data = new HashMap<>();
		}

		boolean detect(int s, int t, int c) {

			data.putIfAbsent(s, new HashMap<>());
			data.get(s).putIfAbsent(t, INF);

			if (c < data.get(s).get(t)) {
				data.get(s).put(t, c);
				return false;
			} else {
				return true;
			}
		}
	}
}

Measured memory_bytes: 143572
#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 long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,k; cin>>n>>k;
    cout<<n-k+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> a(n), b(n);
	long long total_readiness = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		total_readiness += a[i];
	}

	vector<int> surplus;
	long long needed = 0, deficit = 0;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		needed += b[i];
		if (a[i] >= b[i]) {
			surplus.push_back(a[i] - b[i]);
		} else {
			++ans;
			deficit += b[i] - a[i];
		}
	}

	if (total_readiness < needed) {
		cout << "-1\n";
		return 0;
	}

	sort(surplus.rbegin(), surplus.rend());

	int i = 0;
	while (deficit > 0) {
		deficit -= surplus[i];
		++i;
		++ans;
	}

	cout << ans << "\n";

	return 0;

}

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

  vector<pair<int,int>>dp[100005];
  int vis[100005];
  int col[100005];

  void dfs(int index)
  {
   /* if(vis[index]==1)return;
    vis[index]=1;*/
    int temp=col[index];
    for(auto it:dp[index])
    {
      if(!vis[it.first])
      {
         col[it.first]=(it.second%2==0)?temp:(temp^1);
         vis[it.first]=1;
         dfs(it.first);
      }
    }

  }



  int main()
  {


       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
     /* #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
      #endif*/
     int t;
     cin>>t;
     for(int i=0;i<t-1;i++)
     {
      int first,second,third;
      cin>>first>>second>>third;
      dp[first].push_back({second,third});
      dp[second].push_back({first,third});
     }

     for(int i=1;i<=t;i++)
     {
       if(!vis[i])
        dfs(i);
     }


     for(int i=1;i<=t;i++)
     {
      cout<<col[i]<<endl;
     }
      return 0;
      
  }

Measured memory_bytes: 11868
#include <iostream>

using namespace std;
int main()
{
    string a;
    unsigned long long k;
    int position=0;
    cin>>a>>k;
    for (int n=0; n<a.size(); n++)
    {
        if (a[n]!='1')
        {
            position=n;
            break;
        }
    }
    
    if (position<k)
    {
        cout<<a[position];
    }
    else if(position>=k)
    {
        cout<<"1";
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {

  ll n,m,x;
  cin >> n>>m>>x;
  
  vector<ll> p(n);
  vector<vector<ll>> q(n,vector<ll>(m));
  vector<ll> r(m,0);
  
  rep(i,n){
  cin>>p[i];
    rep(j,m){
    cin>>q[i][j];
      r[j]+=q[i][j];
    }
  }

  rep(i,m){
    if(r[i]<x){
    cout << -1 << endl;
    return 0;
    } 
  }
  
  ll ans = 50000000;
  rep(i,(1<<12)){
    rep(z,m){
    r[z]=0;
    }
    ll sum = 0;
    rep(j,n){
      if(i & (1<<j)) {
      sum+=p[j];
        rep(k,m){
        r[k]+=q[j][k];
        }
        bool memo=true;
        rep(k,m){
        if(r[k]<x) memo=false;
        }
        if(memo) ans=min(ans,sum);
      }
    }
  }
  
  
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include<cstdio>
int main(){
	int n;
	double a[100],sum_inv=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf",&a[i]);
		sum_inv+=1.0/a[i];
	}
	printf("%.10lf",1.0/sum_inv);
	return 0;
}

Measured memory_bytes: 128
H, W, N = gets.split.map(&:to_i)
w2h = Array.new(W+1){[]}
N.times do |i|
    x, y = gets.split.map(&:to_i)
    w2h[y].push(x)
end

ans = H
loss = 0
(1..W).each do |w|
    w2h[w].sort.each do |h|
        if h-loss == w
            loss += 1
        elsif h-loss > w
            ans = h-1 if ans > h-1
            break
        end
    end
end
puts ans

Measured memory_bytes: 19452
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

extension Array {
    func dump(){
        for x in 0..<self.count-1{
            print(self[x], terminator: " ")
        }
        print(self.last!)
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}

func distance(p1:CGPoint, p2:CGPoint) -> Double {
    let diffp = CGPoint(x:p1.x - p2.x, y:p1.y - p2.y)
    return Double(sqrt(diffp.x*diffp.x + diffp.y * diffp.y))
}

func distance(p1:[Double], p2:[Double]) -> Double{
    let diff = [p1[0] - p2[0], p1[1] - p2[1]]
    return sqrt(diff[0] * diff[0] + diff[1] * diff[1])
    
}

func lotate(theta:Double, point:[Double]) -> [Double] {
    let matrix = [
        [cos(theta), -sin(theta)],
        [sin(theta), cos(theta)]
    ]
    let x = point[0]
    let y = point[1]
    
    let rx = matrix[0][0]*x + matrix[0][1]*y
    let ry = matrix[1][0]*x + matrix[1][1]*y
    
    return [rx, ry]
}






func b() -> Int{
    let ND = readLine()!.toSepIntList()
    let D = ND[1].toD()
    var ans = 0
    for _ in 1...ND[0] {
        let xy = readLine()!.toSepDoubleList()
        let d = distance(p1: [0,0], p2:xy)
        if d <= D {
            ans += 1
        }
    }
    
    return ans
}

print(b())


Measured memory_bytes: 13740
A=[0]*5
for i in range(5):
    A[i]=int(input())
que=10
que_num=0
ans=0
for i in range(5):
    if que>A[i]%10 and A[i]%10!=0:
        que=A[i]%10
        que_num=i
for i in range(5):
    if i==que_num:
        ans+=A[i]
    else:
        if A[i]%10!=0:
            ans+=A[i]-A[i]%10+10
        else:
            ans+=A[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  cout << a-(s==u) << ' ' << b-(t==u) << "\n";
  return 0;
}


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

int h , w , count ;
int dx[] = { -1,0,1,-1,1,-1,0,1 } ;
int dy[] = { -1,-1,-1,0,0,1,1,1 } ;
int map[51][51] = {} ;

void destroy( int ny , int nx ){
	map[ny][nx] = 0 ;
	
	for( int k=0 ; k<8 ; k++ ){
		if( ny+dy[k] >= 0 && ny+dy[k] < h &&
			nx+dx[k] >= 0 && nx+dx[k] < w &&
			map[ny+dy[k]][nx+dx[k]] == 1 ){
			destroy( ny+dy[k] , nx+dx[k] ) ;
		}
	}
}

int main(){
	
	while(1){
		cin >> w >> h ;
		if( h==0 && w==0 ) break ;
		
		count = 0 ;
		for( int i=0 ; i<h ; i++ ){
			for( int j=0 ; j<w ; j++ ){
				cin >> map[i][j] ;
			}
		}
		
		for( int i=0 ; i<h ; i++ ){
			for( int j=0 ; j<w ; j++ ){
				if( map[i][j] == 1 ){
					destroy(i,j) ;
					count++;
				}
			}
		}
		
		cout << count << endl ;
	}
	
return 0;
}

Measured memory_bytes: 1240