akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    s[3] = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;

fn main() {
    solve_d();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n = n.trim().parse::<usize>().unwrap();

    let mut min = i64::max_value();
    let mut diff = i64::min_value();
    for i in 0..n {
        let mut v = String::new();
        io::stdin().read_line(&mut v).unwrap();
        let v = v.trim().parse::<i64>().unwrap();
        if i == 0 {
            min = v;
        }

        if 0 < i {
            let tmp = v - min;
            if diff < tmp {
                diff = tmp
            }
            if v < min {
                min = v;
            }
        }
    }
    println!("{}", diff);
}



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

int main(){
    string s; cin >> s;
    int len = s.length();
    for(int i = 0; i < len-1; i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

template<int mod> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % mod) {
        if (val < 0) val += mod;
    }
    constexpr int getmod() { return mod; }
    constexpr Fp operator - () const noexcept {
        return val ? mod - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= mod) val -= mod;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % mod;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % mod;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<mod>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<mod> modpow(const Fp<mod> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<mod>;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

mint d[100100];

int main() {
    int n, k; cin >> n >> k;
    mint ans = 0;
    for (int i = k; i>0; --i) {
        int num = k/i;
        mint cnt = modpow(num, n, mod);
        int j = 2;
        while (i*j <= k) {
            cnt -= d[i*j];
            ++j;
        }
        d[i] = cnt;
    }
    for (int i = 1; i<=k; ++i) ans += d[i]*i;
    cout << ans << endl;
    return 0;
}






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

int main()
{
    int a , b;
    cin>>a>>b;
    
    for(int i=1;i<=1e4;i++)
    {
        int a1 = i*8/100 , a2 = i*10/100;
        
        if(a1==a && a2==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    
    cout<<-1;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> P;

Int D;
vector<Int> C(26);
vector<vector<Int>> S(365, vector<Int>(26));


// 各日における満足度の配列を返す関数
vector<Int> score(vector<int> schedule){
    vector<int> last_day(26, 0); // 各コンテストを最後に行った日

    vector<Int> res(D, 0);

    rep(d,D){
        int type = schedule[d]-1; // その日に行われるコンテスト

        res[d] += S[d][type];
        rep(i,26){
            if(i == type) continue;
            res[d] -= C[i] * (d+1 - last_day[i]);
        }
        last_day[type] = d+1;

        if(d != D-1) res[d+1] += res[d];
    }

    return res;
}

int main(){
    cin >> D;
    rep(i,26) cin >> C[i];
    rep(i,D) rep(j,26) cin >> S[i][j];

    rep(i,D) cout << i % 26 + 1 << endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m,x,y;
  cin >> n >> m >> x >> y;
  ll a[n],b[m];
  rep(i,n) R a[i];
  rep(i,m) R b[i];
  sort(a,a+n,greater<ll>());
  sort(b,b+m);
  REP(i,a[0]+1,b[0]+1) {
    if(x<i&&i<=y) {
      pr("No War");
      return;
    }
  }
  pr("War");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
int main()
{
    char ch;
    
    while (1) {
        scanf("%c", &ch);
        if (ch == '\n') {
            break;
        }
        
        if (islower(ch)) {
            ch = toupper(ch);
        }
        else if (isupper(ch)) {
            ch = tolower(ch);
        }
        printf("%c", ch);
    }
    printf("\n");
}

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    int a[3];
    for(auto&& i : a) {
      in >> i;
    }
    sort(begin(a), end(a));
    if (a[0] == a[1]) {
      out << a[2] << "\n";
    } else {
      out << a[0] << "\n";
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for(auto& i : v) cin >> i;
    sort(all(v));
    for(auto i : v) cout << i;
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
int LIS(vector<int>x) {
	vector<int>a(x.size() + 10, 1 << 30);
	for (int i = 0; i < x.size(); i++) {
		int p = x[i];
		*lower_bound(a.begin(), a.end(), p) = p;
	}
	return lower_bound(a.begin(), a.end(), 1 << 30) - a.begin();
}
int a, b, c, d, n, x[200009], y[200009]; long double PI = 3.14159265358979323846264L;
int main() {
	cin >> a >> b >> c >> d >> n;
	for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; }
	if (a > c) { swap(b, d); swap(a, c); }
	if (b > d) { b *= -1; d *= -1; for (int i = 0; i < n; i++)y[i] *= -1; }
	long double F = 100.0L*(abs(a - c) + abs(b - d));
	long double ret = 0;
	if (a == c) {
		int cnt = 0;
		for (int i = 0; i < n; i++) { if (a <= x[i] && x[i] <= c && b <= y[i] && y[i] <= d)cnt++; }
		ret = F + (10.0L*PI - 20.0L)*cnt;
	}
	else if (b == d) {
		int cnt = 0;
		for (int i = 0; i < n; i++) { if (a <= x[i] && x[i] <= c && b <= y[i] && y[i] <= d)cnt++; }
		ret = F + (10.0L*PI - 20.0L)*cnt;
	}
	else {
		vector<pair<int, int>>Z;
		for (int i = 0; i < n; i++) {
			if (a <= x[i] && x[i] <= c && b <= y[i] && y[i] <= d)Z.push_back(make_pair(x[i], y[i]));
		}
		sort(Z.begin(), Z.end()); vector<int>A;
		for (int i = 0; i < Z.size(); i++)A.push_back(Z[i].second);
		long long V = LIS(A); if (V == min(c - a, d - b) + 1) { F += (10.0L*PI - 20.0L); V--; }
		ret = F - (20.0L - 5.0L*PI)*V;
	}
	printf("%.20Lf\n", ret);
	return 0;
}

Measured memory_bytes: 6000
#include <stdio.h>

int main(){

  int a, b, c, d, res = 0;

  scanf("%d%d%d%d",&a,&b,&c,&d);

  if( a <= b )
    res += a;
  else
    res += b;

  if( c <= d )
    res += c;
  else
    res += d;

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

  return 0;


}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int s;
	cin>>s;
	for(int i=1;i<=3;i++)
	{
		if(s%10==s/10%10)
		{
			cout<<"Bad";
			return 0;
		}
		s=s/10;
	}
	cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <set>
#define ll long long
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
#define inf 1152921504606846976LL

using namespace std;
long long fastpow(int a, int b, int MOD)
{
    long long x=1,y=a; 
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y) % MOD;
        }
        y = (y*y) % MOD;
        b /= 2;
    }
    return x;
}

long long InverseEuler(int n, int MOD)
{
    return fastpow(n,MOD-2,MOD);
}
 
long long f[300000];
bool init;

int a[55];
int b[55];

long long C(int n, int r, int MOD)
{
    if (!init){
        init=1;
        f[0]=1;
        for (int i=1; i<300000;i++)
            f[i]= (f[i-1]*i) % MOD;
        
    }
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int N;

long long path[55][55];

set<long long> opsi[55][55];
void coba(int from, int x, long long cost){
    opsi[from][x].insert(cost);
    for (long long i=1;i<=x;i++){
        coba(from, x % i, cost | (1LL<<i));
    }
}

int main(){
   std::ios::sync_with_stdio(false); 
    for (int i=0;i<=50;i++){
      for (int j=0;j<=50;j++){
        path[i][j] = inf;
      }
    }

    for (int i=0;i<=50;i++){
      for (int j=1;j<=50;j++){
        path[i][i % j] = min(path[i][i % j], (1LL<<j));
      }
    }

    for (int k=0;k<=50;k++)
        for (int i=0;i<=50;i++)
            for (int j=0;j<=50;j++){
                path[i][j] = min(path[i][j] , path[i][k] | path[k][j]);
            }
   for (int i=1;i<=50;i++){  
        coba(i, i,0);
    }
    opsi[0][0].insert(0);
    cin>>N;
    readN(N,a);
    readN(N,b);
    long long ans = 0;
    int BZ=N;
    while (BZ--){
        long long worst = ans;
        for (int i=0;i<N;i++){
            long long locbest = inf;
            if (opsi[a[i]][b[i]].size() == 0) {
                cout<<-1<<endl;
                return 0;
            }
            for (long long o: opsi[a[i]][b[i]]){
                locbest = min(locbest, o | ans);
            }
            worst = max(worst, locbest);
        }
        ans = worst;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1664
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),f[]=new int[n],dp[]=new int[n];
		Arrays.setAll(f,i->s.nextInt());
		dp[1]=Math.abs(f[1]-f[0]);
		for(int i=2;i<n;++i)
			dp[i]=Math.min(
					dp[i-1]+Math.abs(f[i]-f[i-1]),
					dp[i-2]+Math.abs(f[i]-f[i-2]));
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 61148
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    rep(i, n) if (s[i] == 'R') cnt++;
    cout << (2 * cnt > n ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,tokuten;
	scanf("%d %d %d %d %d %d %d %d %d %d",&s1,&s2,&s3,&s4,&s5,&s6,&s7,&s8,&s9,&s10);
	tokuten=s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;
	printf("%d\n",tokuten);
	return 0;
}


Measured memory_bytes: 2036
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
        if(n == 1 & m == 1){
            cout << 1 << endl;
        }else if(n == 1 & m != 1){
            cout << m-2 << endl;
        }else if(m == 1 & n != 1){
            cout << n-2 << endl;
        }else{
            cout <<1ll*(n-2)*(m-2) << endl;
        }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int DX4[4]= {-1,0,0,1};
const int DY4[4]= {0,-1,1,0};
 
int main(){
	int ta[2],tb[2];
	int r,g;
	int n,m;
	int i,j,p;
	char temp;
 
	SCAN(&r);SCAN(&g);

 
	printf("%d\n",g*2-r);
 
	return 0;
}

Measured memory_bytes: 256
# python3
# -*- coding: utf-8 -*-
import sys
import math
from fractions import gcd
from itertools import count, permutations, combinations, combinations_with_replacement, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
lmtx = lambda h: [list(map(int, lmis())) for _ in range(h)]
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
k = ii()
d = deque()

for i in range(1, 10):
    d.append(i)

x = 1

for _ in range(k):
    x = int(d.popleft())

    if x % 10 != 0:
        d.append(10 * x + x % 10 - 1)

    d.append(10 * x + x % 10)

    if x % 10 != 9:
        d.append(10 * x + x % 10 + 1)

print(x)


Measured memory_bytes: 13668
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

const int gmax_n = 40005;

int par[gmax_n]; //???
int depth[gmax_n];//??¨?????±???

void init(int n){
	rep(i,n){
		par[i] = i;
		depth[i] = 0;
	}
}

int find(int x){
	if(par[x] == x){
		return x;
	}else {
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(depth[x] < depth[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(depth[x] == depth[y]) depth[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
	int n, h, w;
	cin >> n >> w >> h;

	vector<pair<int, int>> in(n);
	//vector<P> x(n), y(n);
	rep(i,n){
		int a, b;
		cin >> a >> b;
		in[i] = make_pair(a,b);
		//x[i] = make_pair(make_pair(a,b),i);
		//y[i] = make_pair(make_pair(b,a),i);
	}
	//sort(all(x));
	//sort(all(y));

	init(n);
	rep(i,n){
		//auto xs = lower_bound(all(x), make_pair(make_pair(in[i].first, - 1),-1));
		//for(; xs != x.end() && xs->first.first == in[i].first; xs++){
		//	unite(i, xs->second);
		//}
		//auto ys = lower_bound(all(y), make_pair(make_pair(in[i].second, - 1),-1));
		//for(; ys != y.end() && ys->first.second == in[i].second; ys++){
		//	unite(i, ys->second);
		//}
		rep(j,n){
			if(in[i].first == in[j].first || in[i].second == in[j].second){
				unite(i,j);
			}
		}
	}

	int ans = 0;
	map<int,int> m;
	vector<bool> isEdge(n,0);
	rep(i,n){
		if(in[i].first == 1 || in[i].first == w || in[i].second == 1 || in[i].second == h){
			isEdge[find(i)] = true;
		}
		m[find(i)]++;
	}
	auto f = [&](){
		if(m.size() == 1) return 0;
		rep(i,n){
			if(isEdge[find(i)]) return 0;
		}
		return 1;
	};

	for(auto i : m){
		ans += i.second - 1;
	}
	ans += (m.size() - 1) * 2;
	cout << ans + f() << endl;
}

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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int sum=0;
		int i=1;
		while(sum<x){
			sum+=i;
			i++;
		}
		i--;
		System.out.println(i);
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	ll n;
	cin >> n;
	deque<char> ans;
	while (n > 0)
	{
		n--;
		ans.push_front(n % 26 + 97);
		n /= 26;
	}
	while (!ans.empty())
	{
		cout << ans.front();
		ans.pop_front();
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

long long dp[2005][2005];
int n, a[2005];

void p(){
  REP(i,0,n){
    REP(j,0,n){
        cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
}

long long dfs(int sta, int end, int left){
  if(dp[sta][end] != -1) return dp[sta][end];

  if(left == 1){
    if(left%2 != n%2) {  /*not JOI turn*/
      return dp[sta][end] = 0;
    }else{
      return dp[sta][end] = a[sta];
    }
  }

  if(left%2 != n%2){  /*not JOI turn*/
    if(a[sta] < a[end]){
      return dp[sta][end] = dfs(sta, (end+1)%n, left-1);
    }else{
      return dp[sta][end] = dfs((sta-1+n)%n, end, left-1);
    }
  }else{
    return dp[sta][end] = max(dfs((sta-1+n)%n, end, left-1) + a[sta], dfs(sta, (end+1)%n, left-1) + a[end]);
  }

}

int main() {
  cin>>n;
  REP(i,0,n) cin>>a[i];

  REP(i,0,n)REP(j,0,n) dp[i][j] = -1;

  vector<long long> v;
  REP(i,0,n) v.push_back( dfs(i,(i+1)%n,n) );

  cout<<*max_element(v.begin(), v.end())<<endl;

  //p();

  return 0;
}

Measured memory_bytes: 34600
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll n,k,a[100010],dp[100010];
inline int read(){
     int x=0,f=1;
     char ch=getchar();
     while(ch<'0'||ch>'9'){
         if(ch=='-')
             f=-1;
         ch=getchar();
     }
     while(ch>='0'&&ch<='9'){
         x=(x<<1)+(x<<3)+(ch^48);
         ch=getchar();
     }
     return x*f;
 }
int main ( )
{
	n=read();k=read();
	for(int i=1;i<=n;i++) a[i]=read();
	memset(dp,0x7f,sizeof(dp));
	dp[1]=0;
	for(ll i=2;i<=n;i++)
		for(ll j=1;j<=k&&i-j>=1;j++)
		   dp[i]=std::min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){

  int N,M,C;
  int A[20][20];
  int B[20];
  int i,j,lengh_sum,result = 0;
  
  scanf("%d %d %d",&N,&M,&C);
  
  for(i = 0;i < M;i++){
    scanf("%d",&B[i]);
  }
  
  for(i = 0;i < N;i++){
    for(j = 0;j < M;j++){
      scanf("%d",&A[i][j]);
    }
  }
  
  for(i = 0;i < N;i++){
    lengh_sum = 0;
    for(j = 0;j < M;j++){
      lengh_sum += A[i][j]*B[j];
    }
    if(lengh_sum + C > 0){
     result++; 
    }
  }
  
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int arr[100][100];
int main()
{
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0; i<h; i++)
    {
        cin>>s[i];
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(s[i][j]=='#')
                arr[i][j]=0;
            else
            {
                if(i&&j&&s[i-1][j-1]=='#')
                    arr[i][j]++;
                if(i&&s[i-1][j]=='#')
                    arr[i][j]++;
                if((j+1)<w&&i&&s[i-1][j+1]=='#')
                    arr[i][j]++;
                if(j&&s[i][j-1]=='#')
                    arr[i][j]++;
                if((j+1)<w&&s[i][j+1]=='#')
                    arr[i][j]++;
                if((i+1)<h&&j&&s[i+1][j-1]=='#')
                    arr[i][j]++;
                if((i+1)<h&&s[i+1][j]=='#')
                    arr[i][j]++;
                if((i+1)<h&&(j+1)<w&&s[i+1][j+1]=='#')
                    arr[i][j]++;
            }
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(s[i][j]=='#')
                cout<<s[i][j];
            else
                cout<<arr[i][j];
        }
        cout<<endl;
    }
    return 0;
}



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

int main(){
    string s;
    cin>>s;

    int len = s.size();
    ll ans = 0;
    for(int i=0; i<len; i++){
        ans += s[i]-'0';
    }

    if(ans%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	int n; cin >> n;
	ll x = 1, y = 1;
	Loop(i, n) {
		ll t, a; cin >> t >> a;
		if (t >= x&&a >= y) {
			x = t;
			y = a;
		}
		else {
			ll p, q;
			if (x%t == 0) p = x / t;
			else p = x / t + 1;
			if (y%a == 0) q = y / a;
			else q = y / a + 1;
			if (p >= q) {
				x = t*p;
				y = a*p;
			}
			else {
				x = t*q;
				y = a*q;
			}
		}
	}
	cout << x + y << endl;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
H = list(map(int,input().split()))
michi = [[] for i in range(N)]
 
for i in range(M):
    a,b = map(int,input().split())
    michi[a-1].append(b-1)
    michi[b-1].append(a-1)

 
ans = 0
for i in range(N): #i番目の展望台に注目
    if michi[i] == []:
        ans +=1
    else:
        counter = 0
        # カウンターを追加
        for j in michi[i]:
            counter += 1
            # インクリメント
        # print(i,j,H[i],H[j]) 
        # このprintを消した
            if H[i] <= H[j]:
            #   不等号を直した
                break
            if counter == len(michi[i]):
                # 最後までいったらの判定の変更
                ans += 1
 
print(ans)

Measured memory_bytes: 29436
#include <stdio.h>
#include <string.h>

typedef long long ll;

ll dp[100005][4];
char S[100005];

ll mod =1000000007ll;

int main(){

	scanf("%s",S);

	int len=strlen(S);

	int i,j;

	dp[0][0]=1ll;

	for(i=0;i<len;i++){
		if(S[i]=='A' || S[i]=='?'){
			for(j=0;j<4;j++){
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=mod;
			}
			dp[i+1][1]+=dp[i][0];
			dp[i+1][1]%=mod;
		}
		if(S[i]=='B' || S[i]=='?'){
			for(j=0;j<4;j++){
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=mod;
			}
			dp[i+1][2]+=dp[i][1];
			dp[i+1][2]%=mod;
		}
		if(S[i]=='C' || S[i]=='?'){
			for(j=0;j<4;j++){
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=mod;
			}
			dp[i+1][3]+=dp[i][2];
			dp[i+1][3]%=mod;
		}
	}

	printf("%lld\n",dp[len][3]);

	return 0;
}

Measured memory_bytes: 3328
void main(){
	int[] atox;
	int cnt;
	foreach(i; 0..4)atox ~= _scan();
	for(int an; an<=atox[0]; an++){
		for(int bn; bn<=atox[1]; bn++){
			for(int cn; cn<=atox[2]; cn++){
				if(500*an+100*bn+50*cn==atox[3])cnt++;
			}
		}
	}
	cnt.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2636
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
int main(void){
  long A,B;
  cin>>A>>B;
  long len=B-A+1;
  long ans=0;
  if(A==B){cout<<A;}
  else{
  if(A%2==0&&B%2==1){
      if(len%4==0){cout<<0;}
      else cout<<1;
  }
  if(A%2==1&&B%2==1){
      if(len%4==1){cout<<A;}
      else {ans=A^1; cout<<ans;}
  }
  if(A%2==0&&B%2==0){
      if(len%4==1){cout<<B;}
      else {ans=B^1; cout<<ans;}
  }
  if(A%2==1&&B%2==0){
      if(len%4==2){ans=A^B; cout<<ans;}
      else {ans=A^B; ans=ans^1; cout<<ans;}
  }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=1e3+10;

int main()//所有的循环已改正 
{
	int n;
	cin>>n;
	char s1[MAXN],s2[MAXN];
	int vis[MAXN]={0};
	ll ans=0;
	cin>>s1>>s2;
	for(int i=0;i<n;i++){
		if(i==0){
			if(s1[i]==s2[i]){
				ans=3;
				vis[i]=1;
			}
			else {
				ans=6;
				vis[i+1]=2;
				i++;
			}
		}
		else {
			if(s1[i]==s2[i]){
				if(vis[i-1]==1){//情况2 
					ans*=2;
				}
				else if(vis[i-1]==2){//情况3 
					ans*=1;
				}
				vis[i]=1;
			}
			else{
				if(vis[i-1]==1){
					ans*=2;
				}
				else if(vis[i-1]==2){
					ans*=3;
				}
				vis[i+1]=2;
				i++;
			} 
		}
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}	 


Measured memory_bytes: 256
def main():
    N = int(input())

    dp = [999999999999 for _ in range(N + 1)]
    dp[0] = 0

    for n in range(1, N + 1):
        # 1 yen
        dp[n] = min(dp[n], dp[n - 1] + 1)

        # 6 yen
        i = 6
        while i <= n:
            dp[n] = min(dp[n], dp[n - i] + 1)
            i *= 6

        # 9 yen
        i = 9
        while i <= n:
            dp[n] = min(dp[n], dp[n - i] + 1)
            i *= 9

    print(dp[N])


main()


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

int main(){
  int N; cin >> N;
  int stdin;
  int count = 0;

  for(int i = 0; i < N; ++i){
    cin >> stdin;
    if((i+1) != stdin) count++;
  }

  if(count == 0 || count == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
using static System.Console;

namespace For_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = ReadLine();
            long K = long.Parse(ReadLine());
            int ans = 0;

            for (int i = 0;i< S.Length; i++)
            {
                int a = int.Parse(S.Substring(i, 1));
                if (a == 1)
                {
                    K--;
                    if (K == 0)
                    {
                        ans = 1;
                        goto Ken;
                    }
                }else
                {
                    ans = a;
                    goto Ken;
                }
            }
            Ken:

            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n);
  deque<i64> b;
  bool f = n % 2 == 0;
  for (i64 x : a) {
    if (f) b.push_back(x);
    else b.push_front(x);
    f = !f;
  }
  for (i64 x : b) cout << x << ' ';
  cout << '\n';
  return 0;
}



Measured memory_bytes: 5376
#include<stdio.h>
#include<string.h>

int main(){
	int i,n;
	char str[25];
	char strc[25];
	for(i=0;i<25;i++)strc[i]='\0';
	scanf("%s",str);
	n=strlen(str);
	for(i=0;i<n;i++)strc[i]=str[n-1-i];
	printf("%s\n",strc);
	return 0;}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iterator>
// #include <iomanip>
// #include <cmath>
// #include <vector>
// #include <numeric>
// #include <cstdio>
// #include <bitset>
// #include <map>
// #include <string>
// #include <valarray>
// #include <queue>
// #include <utility>
#include <list>
#include <functional>


using namespace std;



struct Event
{
    unsigned int start;
    unsigned int finish;

    bool operator<(const Event & e)
    {
        return finish < e.finish;
    }

    Event(unsigned int s, unsigned int f)
    {
        start = s;
        finish = f;
    }

    Event(unsigned int f)
    {
        finish = f;
    }

    Event() {};

    bool operator()(const Event & e)
    {
        return e.start < finish;
    }

    bool operator==(const Event & e)
    {
        return start == e.start && finish == e.finish;
    }

};


bool start_before( const Event & e, unsigned int time)
{
    return e.start < time;
}


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

    list<Event> events;

    Event temp;
    for (int i= 0; i < n; i++)
    {
        cin >> temp.start >> temp.finish;
        events.push_back(temp);
    }

    events.sort();


    //method 1
    // int count = 0;    
    // while (!events.empty())
    // {
    //     ++count;
    //     temp = *min_element(events.begin(), events.end());

    //     // remove_if(events.begin(), events.end(), bind2nd(start_before, min->finish));

    //     list<Event>::iterator it = events.begin();
    //     while (it != events.end())
    //     {
    //         if (it->start < temp.finish)
    //             it = events.erase(it);
    //         else
    //             it++;
    //     }
    // }



    //method 2
    int count = 1;
    list<Event>::iterator it = events.begin();
    unsigned int fin = it->finish;
    while (it != events.end())
    {
        if (it->start > fin)
        {
            count++;
            fin = it->finish;
        }
        it++;
    }

    
    cout << count << endl;



}


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

main()
{
    int n;
    cin>>n;
    int s=0;
    int ss=0;
    for(int i=0;i<n;++i)
    {
        int x; cin>>x;
        s+=x;
        ss+=x*x;
    }
    int p1=s/(n),p2=p1+1;
    cerr<<p1<<" "<<p2<<endl;
    int ans1=p1*p1*n+ss-2*p1*s;
    int ans2=p2*p2*n+ss-2*p2*s;
    cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll L,R;
  cin >> L >>R;
  if(R - L > 2019) {
    cout << 0 << endl;
    return 0;
  }
  v(ll) modN(R-L+1);
  srep(i,L,R+1) {
    modN[i-L] = (ll)i % 2019;
  }
  v(ll) modN2;
  rep(i,R-L+1){
    rep(j,R-L+1){
      if(i == j) continue;
      modN2.push_back((modN[i] * modN[j]) % 2019);
    }
  }
  sort(rng(modN2));
  cout << modN2[0] <<endl; 
  return 0;
}

Measured memory_bytes: 33512
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
    
    static int[][] mainTable, dp;
    static int n;
    
    static int solve(int day, int activity)
    {
        //base case:
        if(day==n-1)
            return mainTable[day][activity];
            
        
        if(activity==0)
        {
            if(dp[day][activity]==0)
            {
                int temp1 = Math.max(solve(day + 1, 1) + mainTable[day][0], solve(day + 1, 2) + mainTable[day][0]);
                dp[day][activity] = temp1;
                return temp1;
            }
            else
                return dp[day][activity];
        }
            
        else if(activity==1)
        {
            if(dp[day][activity]==0)
            {
                int temp2 = Math.max(solve(day + 1, 0) + mainTable[day][1], solve(day + 1, 2) + mainTable[day][1]);
                dp[day][activity] = temp2;
                return temp2;
        
            }
            else
                return dp[day][activity];
        }
            
        else
        {
            if(dp[day][activity]==0)
            {
                int temp3 = Math.max(solve(day + 1, 0) + mainTable[day][2], solve(day + 1, 1) + mainTable[day][2]);
                dp[day][activity] = temp3;
                return temp3;
            }
            else
                return dp[day][activity];
        }
            
    }
    
	public static void main (String[] args) {
	    
	    Scanner scn = new Scanner(System.in);
		
		n = scn.nextInt();
	    
	    mainTable = new int[n][3];
	    dp = new int[n][3];
	    
	    for(int i = 0; i<n; i++)
	    {
	        mainTable[i][0] = scn.nextInt();
	        mainTable[i][1] = scn.nextInt();
	        mainTable[i][2] = scn.nextInt();
	    }
	    
	    int temp = Math.max(solve(0,0), Math.max(solve(0,1), solve(0, 2)));
		System.out.println(temp);
	}
}

Measured memory_bytes: 115460
class Tree:
    def __init__(self, ary):
        self.nodes = [
            Node(node, self) for node in sorted(ary, key=lambda x: x[0])
        ]
        [node.set() for node in self.nodes]
        for node in self.nodes:
            if node.parent == -1:
                node.set_depth(0)
                node.set_height()
                break

    def output(self):
        [node.output() for node in self.nodes]


class Node:
    def __init__(self, node, tree):
        self.tree = tree
        self.no = node[0]
        self.left = node[1]
        self.right = node[2]
        self.parent = -1
        self.sibling = -1
        self.degree = 0

    def set(self):
        if self.left > -1:
            self.tree.nodes[self.left].parent = self.no
            if self.right > -1:
                self.tree.nodes[self.right].sibling = self.left
            self.degree += 1

        if self.right > -1:
            self.tree.nodes[self.right].parent = self.no
            if self.left > -1:
                self.tree.nodes[self.left].sibling = self.right
            self.degree += 1

    def set_depth(self, d):
        self.depth = d
        if self.left > -1:
            self.tree.nodes[self.left].set_depth(d + 1)
        if self.right > -1:
            self.tree.nodes[self.right].set_depth(d + 1)

    def set_height(self):
        if self.degree == 0:
            self.height = 0
        else:
            self.tree.nodes[self.right].set_height()
            self.tree.nodes[self.left].set_height()
            self.height = 1 + max(self.tree.nodes[self.right].height,
                                  self.tree.nodes[self.left].height)

    def output(self):
        if self.parent == -1:
            kind = 'root'
        elif self.degree == 0:
            kind = 'leaf'
        else:
            kind = 'internal node'

        print(
            'node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.
            format(self.no, self.parent, self.sibling, self.degree, self.depth,
                   self.height, kind))


if __name__ == '__main__':
    # import sys
    n = int(input())
    ary = [[int(_) for _ in input().split()] for i in range(n)]
    tree = Tree(ary)
    tree.output()



Measured memory_bytes: 5620
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    ll a[n],b[m];

    inrep(n,a);
    inrep(m,b);

    ll ans = 0;
    if(k >= a[0] || k >= b[0]) ans = 1;
    
    rep(i,1,n){
	a[i] += a[i-1];
	if(k >= a[i])ans = i+1;
    }
    
    rep(i,1,m){
	b[i] += b[i-1];
	if(k >= b[i])ans = max(ans,(ll)i+1);
    }
    
    rep(i,0,n){
	ll t = k-a[i];
	if(t > 0){
	    int p = lb(b,m,t+1);

	    ans = max(ans,(ll)i+1+p);
	}
    }
  
    P(ans);
    return  0;
}


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

ll power(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

ll c(ll a, ll b) {
	ll res = 1;
	for (ll i = 1; i <= b; i++)res = res * (a + 1 - i) % mod * power(i, mod - 2) % mod;
	return res;
}

void solve() {
	int n; cin >> n;
	vector<pair<int, int> > v(n);
	for (auto &u : v)cin >> u.first >> u.second;
	sort(v.begin(), v.end(), [&](pair<int, int> &a, pair<int, int> &b) {
		return a.first + a.second < b.second + b.first;
	});
	int ans = 0;
	for (int i = 1; i < n; i++)ans = max(ans, abs(v[0].first - v[i].first) + abs(v[0].second - v[i].second));
	sort(v.begin(), v.end(), [&](pair<int, int> &a, pair<int, int> &b) {
		return a.first - a.second < b.first - b.second;
	});
	for (int i = 1; i < n; i++)ans = max(ans, abs(v[0].first - v[i].first) + abs(v[0].second - v[i].second));
	cout << ans;
}

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;
	// while (t--)
	solve();

}



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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
int N;
int dp[200001];
string S;
pair<int, int> pat[200001];


// solve
int main(){

    cin >> S;
    N = S.size();

    int xor_all = 0;
    rep(i, N){
        S[i] -= 'a';
        xor_all ^= (1 << S[i]);
        pat[i] = make_pair(xor_all, i + 1);
        dp[i + 1] = 1 << 30;
    }

    if(xor_all == 0){
        cout << "1\n";
        return 0;
    }

    pat[N] = make_pair(1 << 30, N);
    sort(pat, pat + N + 1);
    int xor_now = 0;

    rep(i, N){
        if(xor_now == xor_all)chmin(dp[N], dp[i]);
        rep(j, 26){
            xor_now ^= (1 << j);
            auto it = upper_bound(pat, pat + N + 1, make_pair(xor_now, i));
            if(it->first == xor_now)chmin(dp[it->second], dp[i] + 1);
            xor_now ^= (1 << j);
        }
        xor_now ^= (1 << S[i]);
    }

    cout << dp[N] << '\n';
    return 0;

}


Measured memory_bytes: 2964
def main(n, m, c, b, a):
    ans = 0

    for _a in a:
        t = 0
        for __a, _b in zip(_a, b):
            t += __a * _b

        t += c

        if t > 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    a = [list(map(int, input().split())) for _ in range(n)]

    main(n, m, c, b, a)


Measured memory_bytes: 3064