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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int N, T;

int main(){
  int h1, m1, h2, m2;
  char st[51], ar[51];

  char s[10][51];
  scanf("%d%d", &N, &T);
  vector<pair<int, int> >time(N);
  rep(i, N){
    scanf("%d:%d%s%d:%d%s", &h1, &m1, s[i], &h2, &m2, ar);
    time[i] = make_pair(h1*60+m1, h2*60+m2);
  }
  int M = 0;
  vector<pair<string, int> >res(N);
  REP(i, 1, N){
    int trip = time[i].first - time[i-1].second;
    if(trip < T) continue;
    res[M] = make_pair(string(s[i]), trip);
    M++;
  }

  printf("%d\n", M);
  rep(i, M) printf("%s %d\n", res[i].first.c_str(), res[i].second);

  return 0;
}

Measured memory_bytes: 1224
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (a, b, c) = {
      let v: Vec<i64> = read_vec();
      (v[0], v[1], v[2])
    };
    let ans = max(0, c - (a - b));
    println!("{}", ans);
}


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

bool check(char c){
  if(c=='A'||c=='C'||c=='G'||c=='T'){
    return true;
  }else{
    return false;
  }
}

int main() {
  string s;
  int ans = 0,tmp_ans = 0;
  cin >> s;
  
  for(int i = 0; i < s.size();i++){
    int j = i;
    tmp_ans= 0 ;
    while(check(s[j])){
      tmp_ans++;
      j++;
      if(j >s.size())break;
    }
    if(tmp_ans>ans)ans = tmp_ans;
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n;
        cin>>n;
        lld ar[2005]={0};
        for(i=3;i<=n;i++)
        {
            ar[i]=1;
            for(j=i-3;j>=0;j--)
                ar[i]=add(ar[j],ar[i]);
        }
        cout<<ar[n]<<endl;
    }
}





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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n,m;
    string s;
    cin>>n>>m>>s;
    
    if(n<=m){
        cout<<n<<endl;
        return 0;
    }
    
    vi ans;    

    int i=n;
    while(i>0){
        if(i<=m){
            ans.push_back(i);
            i=0;
        }
        else{
            int idx=i-m;
            while(s[idx]=='1')idx++;
            if(idx==i){
                cout<<"-1\n";
                return 0;
            }else{
                ans.push_back(i-idx);
                i=idx;
            }
        }
    }

    reverse(all(ans));

    rep(i,ans.size()){
        cout<<ans[i]<<" ";
    }
    
    return 0;
}

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

int main() {

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

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

    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    else {
        for (int i = 0; i < n; i++) {
            if (s[i] % 10 == 0) continue;
            if (s[i] % 10 != 0) {
                sum -= s[i];
            }
            if (sum % 10 != 0) {
                break;
            }
        }
        if (sum % 10 == 0) sum = 0;

        cout << sum << endl;
        return 0;
    }

}

Measured memory_bytes: 256
//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,flag,k,z;
    int countt,i,j;
    cin>>x;
    flag=x/500;
    k=x%500;
    z=k/5;
    cout<<(flag*1000)+(z*5);
    
    return 0;



}

Measured memory_bytes: 256
#include <stdio.h>
#define INFTY 2000000000
#define MAX 500000


int L[MAX/2+2];
int R[MAX/2+2];
long mergesort(int A[], int left,int right);
long merge(int A[], int left,int mid,int right);

int main(void){
	int A[MAX];
	int n,i;
	long cnt = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	cnt=mergesort(A,0,n);
	printf("%ld\n",cnt);
	return 0;
}

long merge(int A[],int left,int mid,int right){
	int n1=mid-left;
	long cnt = 0;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
	
		R[i]=A[mid+i];
	}
	
	L[n1]=R[n2]=INFTY;
	int i=0,j=0;
	
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}
		else{
			A[k]=R[j];
			j++;
			cnt+=n1-i;
		}
	}
	return cnt;
}

long mergesort(int A[],int left,int right){
	long c1=0,c2=0,c3=0;
	if(left+1<right){
		int mid=(left+right)/2;
		c1=mergesort(A,left,mid);
		c2=mergesort(A,mid,right);
		c3=merge(A,left,mid,right);
	}
	return c1+c2+c3;
}




Measured memory_bytes: 3288
mod = 10 ** 9 + 7
n, m = map(int, input().split())
print((sum(map(lambda x, y: (2 * y - n + 1) * int(x), input().split(), range(n))) * sum(map(lambda x, y: (2 * y - m + 1) * int(x), input().split(), range(m))) % mod + mod) % mod)

Measured memory_bytes: 82916
let () =
  let f x =
    if x = 0 then print_endline "-"
    else
      begin
        for i = 1 to x do
          print_string "*"
        done;
        print_newline ()
      end
  in
  let rec read () =
    let n = read_int () in
    if n = 0 then ()
    else
      begin
        let a = Array.make 10 0 in
        for i = 1 to n do
          let m = read_int () in
          a.(m) <- a.(m)+1
        done;
        Array.iter f a;
        read ()
      end
  in read ()
;;

Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    ll cnt=0;
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        if(X[i]*X[i]+Y[i]*Y[i]<=D*D) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

ll cnt[60][60];
ll h, w, n, k;

ll ppow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = (res*a) % k;
		a = (a*a) % k;
		b >>= 1;
	}
	return res;
}
int main() {
	cin >> h >> w >> n >> k;
	int c = 0;
	rep(i, h)for (ll j = 0; j < w; j += 2) {
		cout << "? " << i << ' ' << j << ' ' << i << ' ' << j + 1 << endl;
		ll d; cin >> d;
		c += d;
		if (!d)continue;
		cout << "? " << i << ' ' << j << ' ' << i << ' ' << j << endl;
		cin >> cnt[i][j];
		cnt[i][j + 1] = d - cnt[i][j];
		if (c >= 250)goto goal;
	}
goal:;
	ll ans = 0;
	rep(i, h)rep(j, w) {
		ans = (ans + cnt[i][j] * ppow(2, i*w + j)) % k;
	}
	cout << "! " << ans << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = n;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				n /= i;
			}
			ans = ans  - ans / i;
		}
	}
	if (n > 1) ans = ans - ans / n;
	cout << ans<<endl;
}


Measured memory_bytes: 3104
N=int(input())
T=list(map(int,input().split()))
A=list(map(int,input().split()))
Tr,Ar=[0]*N,[0]*N

ct,ca=0,0
for i in range(N):
    if T[i] > ct:
        ct=T[i]
        Tr[i]=[ct,ct]
    else:
        Tr[i]=[1,ct]

    if A[N-1-i] > ca:
        ca=A[N-1-i]
        Ar[N-1-i]=[ca,ca]
    else:
        Ar[N-1-i]=[1,ca]

MOD=1000000007
ans=1
for tr,ar in zip(Tr,Ar):
    l = max(tr[0],ar[0])
    r = min(tr[1],ar[1])
    if r<l:
        print(0)
        exit()
    ans = (ans*(r-l+1))%MOD
print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    int m = 0;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] < 0) {
            m++;
            sum += -A[i];
        } else {
            sum += A[i];
        }
    }

    if (m % 2 == 1) {
        long long minv = 1e9 + 1;
        for (int i = 0; i < N; i++) {
            minv = min(abs(A[i]), minv);
        }
        cout << sum - 2 * minv << endl;
    } else {
        cout << sum << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#include <cmath>
#include <bitset>
#include <string>
#include <queue>

using namespace std;

#define int long long

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    int cnt_a = 0;
    int cnt_b = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'a' && cnt_a + cnt_b < a + b) {
            cout << "Yes" << endl;
            cnt_a++;
        } else if(s[i] == 'b' && cnt_a + cnt_b < a + b && cnt_b < b) {
            cout << "Yes" << endl;
            cnt_b++;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

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

int main() {
    int n, sum = 0, last = INT_MAX;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int cur;
        cin >> cur;
        sum += min(last, cur);
        last = cur;
    }
    cout << sum + last << endl;
}



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

typedef long long ll;

int main() {
    int N, ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (to_string(i).size() % 2) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3752
a,b,c,x,y = map(int,input().split())

ans = 0

if a+b > c*2:
    ans += c*min(x,y)*2
    if x>y:
        ans += min(a*(x-y), c*(x-y)*2)
    else:
        ans += min(b*(y-x), c*(y-x)*2)
        
else:
    ans += a*x + b*y
    
print(ans)
    
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
//#define INF 1145141919810893//810114514
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define rollcall cout<<"I'm Sucu."<<endl
#define int long long 




signed main(){
    int N;int Ans=114514;
    cin >> N;
    int M=N;
    for(int i=0;i<=M;i++){//6円型でi円、9円型でN-i円払う
        N=M;
        int a=i,b=M-i,c=1,d=1;
        int sum=0;
        while(a>0){
            while(c*6<=a){c*=6;}
            sum++;
            a-=c;
            c=1;
        }
        while(b>0){
            while(d*9<=b){d*=9;}
            sum++;
            b-=d;
            d=1;
        }
        Ans=min(Ans,sum);
    }
    cout <<Ans << endl;
	return 0;
}


Measured memory_bytes: 256
map$q[$_]+=$q[$N]/@$N,@{/ /,push@
$`,$' for<>;$N=$_}for++$q[1]..<>;$e[$N]=1+${$b=0;$b+=$_ for@@=@e[@$N];b}/@@,$a<($~=$q[$N]*=$#@&&($b-(sort@@)[-1])/$#@-$b/@@)or$a=$~while--$N;print"@e"+$a

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}
int co[3];
int main()
{
  string s[3];
  rep(i, 0, 3) cin>>s[i];
  int st = 0;
  while(true)
  {
    if(co[st] == s[st].length())
    {
      char ans = st + 'A';
      cout<<ans<<endl;
      return 0;
    }
    char curr = s[st][co[st]];
    co[st]++;
    st = curr - 'a';
  }
  return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
} 
void solve()
{
    int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    // cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u){
    V[u] = true;
    for(int i=0; i<G[u].size(); i++){
        int v = G[u][i];
        if(!V[v]) dfs(v);
    }
    out.push_front(u);
}

int main(){
    int s,t,M;
    
    cin >> N >> M;
    for(int i=0; i<N; i++) V[i] = false;
    for(int i=0; i<M; i++){
        cin >> s >> t;
        G[s].push_back(t);
    }
    
    for(int i=0; i<N; i++){
        if(!V[i]) dfs(i);
    }
    
    for(list<int>::iterator it=out.begin(); it!=out.end(); it++){
        cout << *it << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6188
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	if (S.length()==2){
		cout<<S<<endl;
	}else{
		for (int i=S.length()-1;i>=0;i--){
			cout<<S[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* In the name of Allah */
#include <bits/stdc++.h>
using namespace std;

const int MAX = 200 * 1000 + 10;
int arr[MAX], p[MAX], n ,q;
vector <int> adj[MAX];
bool vis[MAX];

void dfs(int v, int s);

int main() {
	cin >> n >> q;
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		int pp, xp;
		cin >> pp >> xp;
		p[pp] += xp;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++)
		cout << arr[i] << " ";
	cout << endl;
	//cout << p[1];
	return 0;
}

void dfs(int v, int s) {
	vis[v] = true;
	s += p[v];
	arr[v] += s;
	for (int u: adj[v])
		if (!vis[u])
			dfs(u, s);
}



Measured memory_bytes: 21376
function main()
  
  N = parse(Int,readline())
  S = split(readline(), "")
  
  x = 0
  ans = 0
  
  for i in 1:N
    
    if S[i] == "I"
      x += 1
      
      if x > ans
        ans = x
      end
      
    elseif S[i] == "D"
      x -= 1
    end
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 109600
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();

        int[] a = new int[n];
        int[] b = new int[n];

        int i = 0;
        while(i<n){
            a[i] = sc.nextInt();
            i++;
        }

        i = 0;
        while(i<n){
            b[i] = sc.nextInt();
            i++;
        }

        int max = a[0];
        for(int j = 0; j<n; j++) {
            max += b[j];
        }
        
        int sum;
        for(int j = 1; j<n; j++) {
            sum = 0;
            for(i = 0; i<n; i++) {
                if(i<=j)
                   sum+= a[i];
                if(i>=j)
                    sum += b[i];
            }
            if(sum > max) {
                max = sum;
            }
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> p;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		p.push_back(tmp);
	}
	int ans = 0;
	for (int i = 0; i < n-2; i++)
	{
		if ( ((p[i]<p[i+1]) && (p[i+1]< p[i + 2]))||
			((p[i+2] < p[i+1]) && (p[i + 1] < p[i])))
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int tmp=k;
    k-=a;
    if(k<=0)cout<<tmp<<endl;
    else{
        k-=b;
        if(k<=0)cout<<a<<endl;
        else{
            while(k>0){
                k--;
                a--;
            }
            cout<<a<<endl;
        }
    }
    
    return 0;
}

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

#define MAX_N 1299709+1

bool prime[MAX_N];

void init() {
    memset(prime, 1, sizeof(prime));
    prime[0] = prime[1] = false;
    for (int i = 2; i <= MAX_N; i++) 
        if (prime[i]) 
            for (int j = i+i; j <= MAX_N; j+=i) 
                prime[j] = false;
}

int main() {
    init();
    int n;
    while (cin >> n, n != 0) {
        int lb = n;
        int ub = n;
        while (!prime[lb]) 
            lb--;
        while (!prime[ub])
            ub++;
        cout << ub - lb << endl;
    }
    return 0;
}

Measured memory_bytes: 2436
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int ans[3];
	ans[0] = ans[1] = ans[2] = 0;
	vector<int> p(n);
	REP(i, n){
		cin >> p[i];
		if (p[i] <= a) ans[0]++;
		else if (p[i] <= b) ans[1]++;
		else ans[2]++;
	}

	int min = INF;

	REP(i, 3){
		if (min > ans[i]){
			min = ans[i];
		}
	}

	cout << min << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(vector<int> &xi: X) for(int &xij: xi) cin >> xij;
  int ret = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      int dd = 0;
      for(int k=0; k<D; k++) dd += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      int d = sqrt(dd);
      if(d*d==dd) ret++;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * 
 * Created by SharpDevelop.
 * User: yog-sothoth
 * Date: 2017/03/20
 * Time: 13:33
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace DefaultNamespace
{
	/// <summary>
	/// Description of Class1.
	/// </summary>
	public class BinarySearch
	{
		/*
		 *  n????????´??°???????????°???  S??¨???q ????????°????????´??°???????????°???  T??????????????????T ?????????????????´??°????????§ 
		 *  S?????????????????????????????° C  ???????????????????????°????????????????????????????????????
		 * ??\???  :???????????? n???????????????S  ?????¨??? n ????????´??°??????????????? q??????????????? T ?????¨??? q ????????´??°????????????????????????
		 * ?????? C???????????????????????????????????????
		 */
		
		public static void Main(String[] args)
		{
			//????????????
			int n = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			string[] sTarget =s.Split();
			
			int q = int.Parse(Console.ReadLine());
			string t = Console.ReadLine();
			string[] tSearch = t.Split();
			
			
			var search = new Searcher(n, sTarget, q, tSearch);
			Console.WriteLine(search.counter);
		}
		
	}
	public class Searcher
	{
		//??????????????£???????????????
		public int counter{ get; private set; }
		int num;//??????????´???°
		int qnum;//??????????´???°
		string[] target;
		string[] searchThis;
		
		public Searcher(int n, string[] s, int q, string[]t)
		{
			counter = 0;
			num = n;
			target = s;
			qnum = q;
			searchThis = t;
			
			search();
		
		}
		public void search()
		{//binary search
			for (int j = 0; j < qnum; j++) 
			{
				
			   string key = searchThis[j];
				int left=0;
				int right=num-1;
				int mid;
				while (left<=right) 
				{	
					mid=(int )(left+right)/2;
					if (target[mid]==key)
					{
						counter++;
						break;
						
					
					}else if (int.Parse(key)<int.Parse(target[mid]))
					{
						right=mid-1;
					
					}else
					{
						left=mid+1;
					}
			    }
			}
		}
		
		
		
	}
	
}

Measured memory_bytes: 19216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int dp[100005];

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i <= n-1; i++){
        dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0;i<n;i++){
        cin >> p[i];
    }
    int ans = 0;
    for (int i=1;i<n-1;i++){
        if (p[i-1]<p[i] && p[i]<p[i+1]){
            ans++;
        } else if (p[i-1]>p[i] && p[i]>p[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char x[4];
  scanf("%s", x);
  if (x[0] == x[2])
    puts("Yes");
  else
    puts("No");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin>>n;
    vint s(n+1);
    rep(i,n){
        cin>>s[i];
    }
    cin>>q;
    int t,count=0;
    rep(i,q){
        cin>>t;
        s[n]=t;
        int j=0;
        while(s[j]!=t){
            j++;
        }
        if(j!=n){
            count++;
        }
    }
    cout<<count<<'\n';
    return(0);
}
    


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    string S;
    ll K;
    cin >> S >> K;
    ll l = S.size();
    ll ans = 0;
    vector<ll> c(l, 1);
    rep(i, l - 1) {
        if (S[i + 1] == S[i]) {
            c[i + 1] = c[i] + 1;
            continue;
        }
        ans += c[i] / 2;
    }
    ans += c[l - 1] / 2;
    if (c[l - 1] == l) {
        cout << l * K / 2 << endl;
        return 0;
    }
    if (S[0] != S[l - 1]) {
        cout << ans * K << endl;
        return 0;
    }
    int x;
    rep(i, l - 1) {
        if (S[i + 1] != S[i]) {
            x = i + 1;
            break;
        }
    }
    //cout << ans << endl;
    ans -= x / 2 + c[l - 1] / 2;
    ans += (x + c[l - 1]) / 2;
    ans *= K;
    ans -= (x + c[l - 1]) / 2;
    ans += x / 2 + c[l - 1] / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const T = parseInt(arg[0].split(" ")[1]);

    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let answer = 0;
    let now = 0;
    
    for(let i=0; i<N; i++) {
        let abs = A[i + 1] - A[i];
        
        if(abs < T) {
            answer += T - (T - abs);
        } else {
            answer += T;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34188
import Control.Monad
import Data.Bits
import Data.List
import Debug.Trace

inf :: Int
inf = 10^5

listToTuple :: Int -> [Int] -> (Int, Int, Int)
listToTuple x [a,b] = (a, x*100, b)

solve :: [(Int, Int, Int)] -> Int -> Int -> Int
solve pcs g i = minimum $ [l | j <- [0..i], let l = loop pcs g j [], l<inf]
    where
        loop :: [(Int, Int, Int)] -> Int -> Int -> [Int] -> Int
        loop [] g i keep = loop2 (reverse $ sort keep) g
        loop ((a,base,complete):pcs) g i keep
            | g <= 0 = 0
            | i .&. 1 == 1 = a + loop pcs (g-a*base-complete) (shiftR i 1) keep
            | otherwise = loop pcs g (shiftR i 1) ((replicate (a-1) base) ++ keep)
        
        loop2 :: [Int] -> Int -> Int
        loop2 [] g
            | g <= 0 = 0
            | otherwise = inf
        loop2 (x:xs) g
            | g <= 0 = 0
            | otherwise = 1 + loop2 xs (g-x)

main = do
    [d,g] <- map read . words <$> getLine :: IO [Int]
    pcs <- forM [1..d] $ \i -> listToTuple i . map read . words <$> getLine
    print $ solve pcs g (2^d-1)

Measured memory_bytes: 1020
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
	char s[1005], t[1005];
	int i, j, S, T, k, n=0,m=0,l;
	scanf("%s", s);
	scanf("%s", t);
	S = strlen(s);
	T = strlen(t);
	for (i = 0; i <= S-T; i++)
	{
		n = 0;
		for (j = 0; j < T; j++)
		{
			if (s[i+j] == t[j])
			{
				n++;				
			}
		}
		if (n > m)
		{
			m = n;
		}
	}
	printf("%d", T-m);
	return 0;
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
ll mod = 1e9 + 7;

vector<vector<ll>> adj(200001);  
ll s; 

queue<ll> q;
vector<bool> used(200001);
vector<ll> d(200001), p(200001);


void bfs(ll s){
    q.push(s);
    used[s] = true;
    p[s] = -1;
    while (!q.empty()) {
        ll v = q.front();
        q.pop();
        for (ll u : adj[v]) {
            if (!used[u]) {
                used[u] = true;
                q.push(u);
                d[u] = d[v] + 1;
                p[u] = v;
            }
        }
    }
}

int main(){
    ll n, m; cin >> n >> m;
    for(ll i = 0; i < m; ++i){
        ll a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    bfs(1);
    for(ll i = 2; i <= n; ++i){
        if(d[i] == 0){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(ll i = 2; i <= n; ++i){
        cout << p[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 17444
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.size();i++)
  {
    sum+=s[i]-'0';
  }
  if(sum%9==0)
  {
    cout<<"Yes\n";
  }
  else
  {
    cout<<"No\n";
  }
}

Measured memory_bytes: 3724
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		String s = sc.next();		
		sc.close();
		
		int len = s.length();
		int[] a = new int[len-2];
		int c = 0;
		for (int i = 0; i<len-2; i++) {
			a[i] = Integer.parseInt(s.substring(c, c+3));
			c++;
		}
		int[] b = new int[len-2];

		for (int i = 0; i<len-2; i++) {
			b[i] = Math.abs(753 - a[i]);
		}
		
		Arrays.sort(b);

		System.out.println(b[0]);
	}
}


Measured memory_bytes: 35488
'''
A 以上 B 以下の整数、小さい方 K 番目以内、大きい方 K 番目以内、昇順

制約
1 <= A <= B <= 10 の 9 乗
1 <= K <= 100

A と B の 間 を 全探索 したら TLE となる。
A と B の 間 は 最大で 10 の 9 乗 離れている為。

次に素直に A から K 個 取り、B から K 個 取り、集合に格納する。
これも A から K 個 取った時に、Bを超えるとダメで、逆も同様。

そこで、in range の 終了条件に min max を使う。
min(A + K, B + 1) ならば A + K - 1 と B のうち、小さい方までとなる。
max(A - 1, B - K) ならば A と B - K + 1のうち、大きい方までとなる。

in range の 終了条件 の インデックス 自体 は 含まず
一つ前のまでとなるので注意する。
'''


A, B, K = map(int, input().split())

s = set()

for i in range(A, min(A + K, B + 1)):
    s.add(i)

for i in range(B, max(A - 1, B - K), -1):
    s.add(i)

s = sorted(s)

for i in s:
    print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int a, b;
	vector<pair<int, int> > v;
	while(scanf("%d,%d", &a, &b) && (a || b)) {
		v.push_back(make_pair(b, a));
	}
	sort(v.begin(), v.end(), greater<pair<int, int> >());
	int Rank[100];
	Rank[0] = 1;
	rep2(i,1,v.size()) {
		if(v[i].first != v[i-1].first) Rank[i] = Rank[i-1] + 1;
		else Rank[i] = Rank[i-1];
	}
	int c;
	while(cin >> c) {
		rep(i,v.size()) {
			if(v[i].second == c) cout << Rank[i] << endl;
		}
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<double> vec;
  double max = 0;
  for(int i=0; i<n; i++){
    double num;
    cin >> num;
    if(max < num) max = num;
    vec.push_back(num);
  }
  double middlest = 0;
  for(int i=0; i<n; i++){
    if(vec[i] != max){
      if(abs(max/2-middlest)>abs(max/2-vec[i])) middlest = vec[i];
    }
  }
  cout << (int)max << " " << (int)middlest << endl;
  return 0;
}
  

Measured memory_bytes: 1400
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    A, B, C = li_input()

    if A + B >= C + 1:
        print(B + C)
        return

    ans = B * 2
    ans += A + 1
    print(min(ans, B + C))


main()


Measured memory_bytes: 5204
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <utility>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b) { return a == 0 ? b : gcd(b%a, a); }
ll mod(ll a) { return a % MOD < 0 ? (a % MOD) + MOD : a % MOD; }
ll mod_add(ll a, ll b) { return (a%MOD + b%MOD) % MOD; }
ll mod_sub(ll a, ll b) { return (a%MOD - b%MOD) % MOD; }
ll mod_mul(ll a, ll b) { return (a%MOD * b%MOD) % MOD; }
ll mod_pow(ll a, ll b) 
{
    if(b == 0) return 1;
    ll p = mod_pow(a, b/2) % MOD;
    p = mod_mul(p, p);
    return (b%2 == 0) ? p : mod_mul(a, p);
}
ll mod_inv(ll a) { return mod_pow(a, MOD-2); }
ll mod_div(ll a, ll b) { return a%MOD * mod_inv(b) % MOD; }

ll res(ll n)
{
    ll ten = 1, nine = 1, eight = 1;
    while(n > 0)
    {
        ten = mod_mul(ten, 10);
        nine = mod_mul(nine, 9);
        eight = mod_mul(eight, 8);
        n--;
    }
    
    return mod_add(mod(mod_sub(mod(mod_sub(ten, nine)), nine)), eight);
}

int main()
{
    ll N;
    std::cin >> N;

    if(N == 1)
    {
        print(0);
    }

    else
    {
        print(res(N));
    }
    return 0;
}

Measured memory_bytes: 3608
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int64_t Solve(const vector<int64_t>& costs,
           const vector<vector<int64_t>> books,
           const int64_t X,
           vector<int64_t> skills,
           int64_t cost,
           size_t idx) {
  if (costs.size() == idx) {
    return -1;
  }
  int64_t cost_no_use = Solve(costs, books, X, skills, cost, idx+1);
  bool all = true;
  for (size_t i = 0, size = books[idx].size(); i < size; ++i) {
    int64_t skill = skills[i] + books[idx][i];
    if (skill < X) all = false;
    skills[i] = skill;
  }
  cost += costs[idx];
  if (all) {
    if (cost_no_use == -1) {
      return cost;
    } else if (cost == -1) {
      return cost_no_use;
    }
    return min(cost, cost_no_use);
  }
  int64_t cost_use = Solve(costs, books, X, skills, cost, idx+1);
  
  if (cost_no_use == -1) {
    return cost_use;
  } else if (cost == -1) {
    return cost_no_use;
  }
  return min(cost_use, cost_no_use);
}

int main() {
  int64_t N, M, X;
  cin >> N >> M >> X;
  vector<int64_t> costs(N);
  vector<vector<int64_t>> books(N, vector<int64_t>(M));
  for (int64_t n = 0; n < N; ++n) {
    cin >> costs[n];
    for (int64_t m = 0; m < M; ++m) {
      cin >> books[n][m];
    }
  }
  cout << Solve(costs, books, X, vector<int64_t>(M), 0, 0) << endl;

  return 0;
}


Measured memory_bytes: 3628
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  string s,t;cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int main(int argc, char const *argv[]){
	int a,b;
	vector<int> answer;
	while(cin >> a >> b){
		printf("%d\n",(int)log10(a+b) + 1);
	}
}

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

#define MAX 250
#define NIL -2000000001
typedef struct node{
  int key;
  int l;
  int r;
  int p;
}Node;

Node A[MAX];
int H;

void print(int);
int parent(int);
int left(int,int);
int right(int,int);

int main(){
  int i,l,r,p,j,k;
  
  scanf("%d",&H);

  p = NIL;
  l = r = NIL-1;
  for(i = 0; i <= H; i++)A[i].p = A[i].l = A[i].r = A[i].key = NIL;//初期化
  
  for(i = 1; i <= H; i++){
    scanf("%d",&k);
    A[i].key = k;
    p = parent(i);
    if(p != NIL)A[i].p = A[p].key;
  }

  for(i = 1; i <= H; i++){
    if(left(i,H) != NIL)A[i].l = A[left(i,H)].key;
    if(right(i,H) != NIL)A[i].r = A[right(i,H)].key;
  }
  
  print(H);
  
  return 0;
}

void print(int size){
  int i;
  
  for(i = 1; i <= size; i++){
    printf("node %d: key = %d, ",i,A[i].key);
    
    if(A[i].p != NIL)printf("parent key = %d, ",A[i].p);
    if(A[i].l != NIL) printf("left key = %d, ",A[i].l);
    if(A[i].r != NIL)printf("right key = %d, ",A[i].r);
    
    printf("\n");
  }
  
}

int parent(int i){
  
  if(i <= 1)return NIL;
  return i/2;
  
}

int left(int i,int size){
  if(2*i > size)return NIL;
  return 2*i;
  
}

int right(int i,int size){
  if(2*i+1 > size)return NIL;
  return 2*i+1;
  
}


Measured memory_bytes: 2052
<?php
$jud = 0;
$K = trim(fgets(STDIN));  // 入力
list($A, $B) = explode(" ", trim(fgets(STDIN)));
for ($i = $A; $i <= $B; $i++) {
    if ($i % $K == 0) {
        echo 'OK';
        $jud = 1;
        break;
    }
}
if ($jud == 0) {
    echo 'NG';
}


Measured memory_bytes: 16200
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

struct Point 
{ 
	int x, y; 
	bool b; 
};

bool cmp(Point x, Point y)
{
	return (x.x < y.x);
}

vector <Point> R;
vector <Point> B;


main()
{
	IOS
	
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++) 
	{ 
		int x, y; 
		cin >> x >> y; 
		R.push_back({x, y, false}); 
	}
	
	for(int i = 0; i < n; i++) 
	{ 
		int x, y; 
		cin >> x >> y; 
		B.push_back({x, y, false}); 
	}
	
	sort(all(B), cmp);
	
	int count = 0;
	
	for(int i = 0; i < n; i++) 
	{
		int maxY = -1;
		for(int j = 0; j < n; j++) 
		{
			if(!R[j].b && R[j].x < B[i].x && R[j].y < B[i].y) 
			{
				if(maxY == -1 || R[j].y > R[maxY].y) 
					maxY = j;
			}
		}
        
		if(maxY != -1) 
		{
			R[maxY].b = true;
			count++;
		}
	}
	
	cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
int dfs(int n,int k,int valu)
{
    if(n==0) return valu;

    return min(dfs(n-1,k,2*valu),dfs(n-1,k,valu+k));
}
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    cout<<dfs(a,b,1)<<endl;

    return 0;
}


Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc167/tasks/abc167_b
// sorting, greedy
use std::io;

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut k = words[3];

    let mut taken = 0;
    let mut idx = 0;

    while k > 0 {
        if idx == 0 {
            taken += std::cmp::min(words[idx],k);
        }
        if idx == 2 {
            taken -= k;
        }
        k -= words[idx];
        idx += 1;
    }
    println!("{}", taken);
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
string s,t;
int ans;

int main(){
    cin>>s>>t;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]==t[i])
            ans++;
    }
    cout<<ans<<'\n';
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
#1回合成するたびに2で割ることになるので、小さいものから貪欲に合成していく。

n = int(input())
e=[]
s=[int(i) for i in input().split()]
for i in range(n):
    e.append(s[i])
e.sort()
#print(e)
for i in range(1,n):
    e[i]=(e[i]+e[i-1])/2
print(e[n-1])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	string s;
	cin>>s;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]==',')
			cout<<" ";
		else
			cout<<s[i];
	}
	return;
	return;
}
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

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

using namespace std;

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

  int ret = 0;
  for(int i = 0; i < N; i++) {
    int P;
    cin >> P;
    ret += max(0, P - D);
  }

  if(ret == 0) cout << "kusoge" << endl;
  else cout << ret << endl;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

bool is_prime(ll n){
    for(ll i=2;i*i<=n;i++)if(n%i == 0)return false;
    return true;
}
signed main()
{   
    gearup;
    int q; cin >> q;
    int num = 100010;
    vector<int> a(num,0);
    for(int i=3;i<num;i+=2){
        if(is_prime(i) && is_prime((i+1)/2))a[i] = 1;
    }
    vl s(num);
    rep(i,num)s[i+1] = a[i]+s[i];
    rep(i,q){
        int l,r; cin >> l >> r;
        cout << s[r+1] - s[l] << endl;
    }
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int dis[101][101];
main()
{
	int n;
	cin>>n;
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)if(i!=j)dis[i][j]=1e9;
	for(int i=0;i<n;i++)
	{
		int r,k;cin>>r>>k;
		for(;k--;)
		{
			int t;cin>>t;
			dis[r][t]=1;
		}
	}
	for(int k=0;k++<n;)for(int i=0;i++<n;)for(int j=0;j++<n;)
		dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int p;cin>>p;
	for(;p--;)
	{
		int s,t,d;cin>>s>>t>>d;
		if(dis[s][t]<d)cout<<dis[s][t]+1<<endl;
		else cout<<"NA"<<endl;
	}
}



Measured memory_bytes: 3072