akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int R; cin >> R;
	if(R < 1200) cout << "ABC" << endl;
	else if(R < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod7 1000000007
#define mod5 10005
#define sz 100005
using namespace std;
//0-> for color black
//1-> for white
ll dp[sz][2];
ll recurse(vector<vector<int> > &edges, int vertex, int parent, bool color){
    if(dp[vertex][color] != 0) return dp[vertex][color];
    int ansBlack = 1, ansWhite = 1;
    for(int i = 0; i < edges[vertex].size();++i){
        if(edges[vertex][i] != parent){
            ansBlack = (ansBlack % mod7 * recurse(edges, edges[vertex][i], vertex, 1) % mod7) % mod7;
            ansWhite = (ansWhite % mod7 * (recurse(edges, edges[vertex][i], vertex, 1) % mod7 + recurse(edges, edges[vertex][i], vertex, 0) % mod7) % mod7) % mod7;
            dp[vertex][0] = ansBlack;
            dp[vertex][1] = ansWhite;
        }
        else if(edges[vertex].size() == 1 && edges[vertex][i] == parent){
            dp[vertex][0] = 1;
            dp[vertex][1] = 1;
        }
    }
    return dp[vertex][color];
}
int main() {
    int n;
    cin >> n;
    vector<vector<int> > edges(n + 1);
    int src, dest;
    for(int i = 1;i < n;++i){
        cin >> src >> dest;
        edges[src].push_back(dest);
        edges[dest].push_back(src);
    }
    memset(dp, 0, sizeof(dp));
    int ans = (recurse(edges, 1, -1, 0) % mod7 + recurse(edges, 1, -1, 1) % mod7) % mod7;
    if(n == 1) ans = 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17024
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

    vector<vector<int>> backet(n, vector<int>(26, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < s[i].length(); j++){
            backet[i][s[i][j]-'a']++;
        }
    }

    vector<int> backet2(26, 1000);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 26; j++){
            if(backet2[j] > backet[i][j]) backet2[j] = backet[i][j];
        }
    }

    string ans = "";
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < backet2[i]; j++) ans += (char)(i+'a');
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265

    void solve()
    {
        inp(n);
      cout<<n+pow(n,2)+pow(n,3);
    }


    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin >> q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 4204
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

int main() {
	char s[3];

	scanf("%s", s);

	if (s[0] == s[1] && s[1] == s[2]) {
		printf("No");
	}
	else {
		printf("Yes");
	}
}

Measured memory_bytes: 1712
#include <stdio.h>

#define N 100001
#define MAX 10000

int search(int*, int, int, unsigned int, unsigned int);
int getNumPackage(int*, int, int, unsigned int);

int main () {
  int n, k;
  int array[N];

  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &array[i]);
  }

  int p = search(array, n, k, 0, n*MAX);

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

int search(int* array, int n, int k, unsigned int left, unsigned int right) {
  unsigned int mid;
  while (left < right - 1) {
    mid = (left + right)/2;

    int np = getNumPackage(array, n, k, mid);

    if (np == n) {
      right = mid;
    } else {
      left  = mid;
    }
  }

  return right;
}

int getNumPackage(int* array, int n, int k, unsigned int p) {
  int cnt = 0;
  int weight = 0;
  
  do {
    weight += array[cnt];
    if (weight > p) {
      weight = 0;
      k--;
    } else {
      cnt++;
    }	
  } while (k > 0 && cnt < n);

  return cnt;
}



Measured memory_bytes: 2244
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int n, m;
vvll d;
vvll e;
const ll INF = 100000000;

template <class T>
void warshall_froyd(vector<vector<T>>& v)
{
	int n{ (int)v.size() };

	REP(k, n)
		REP(i, n)
		REP(j, n)
		v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
}

void init()
{
	cin >> n >> m;
	d.resize(n, vll(n, INF));
	e.resize(m, vll(3));

	REP(i, m)
	{
		int a, b; ll c;
		cin >> a >> b >> c;

		--a; --b;
		d[a][b] = d[b][a] = c;

		e[i][0] = a; e[i][1] = b; e[i][2] = c;
	}

	warshall_froyd(d);
}

int main()
{
	init();
	int ans = 0;
	REP(i, m)
	{
		if (e[i][2] > d[e[i][0]][e[i][1]])
			++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	
	char ch;
	cin >> ch;
	if(ch>='A' && ch<='Z'){
		cout<<"A";
	}
	else{
		cout<<"a";
	}


	return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const int nm=301,mod=1e9+7;
int f[nm][nm][nm];
vector<int>lb[nm],kind[nm];
void update(int &a,int b){a=(a+b)%mod;}
int main(){
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	for(int l,r,x;m--;){
		scanf("%d%d%d",&l,&r,&x);
		lb[r].push_back(l),kind[r].push_back(x);
	}f[1][0][0]=1;
	for(int r=1;;r++){
		for(int i=0,Lb,Kind;i<lb[r].size();i++){
			Lb=lb[r][i],Kind=kind[r][i];
			for(int g=0;g<r;g++)
				for(int b=0;b<g||!b;b++){
					if(Kind==1){
						if(Lb<=g)f[r][g][b]=0;
					}else
						if(Kind==2){
							if(Lb<=b||g<Lb)f[r][g][b]=0;
						}else if(b<Lb)f[r][g][b]=0;
				}
		}if(r==n)break;
		for(int g=0;g<r;g++)
			for(int b=0,x;b<g||!b;b++){
				x=f[r][g][b];
				update(f[r+1][g][b],x);
				update(f[r+1][r][b],x);
				update(f[r+1][r][g],x);
			}
	}for(int g=0;g<n;g++)
		for(int b=0;b<g||!b;b++)update(ans,f[n][g][b]);
	return printf("%lld\n",(long long)ans*3%mod),0;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;
	vector<int> arr;
	arr.push_back(0);
	for(int i=1; i<N; i++){
		if(s[i-1] != s[i]) arr.push_back(i);
	}
	if(arr.size() == 1){ cout << N << endl; return 0; }
	int ans = -1;
	for(int i=0; i<arr.size(); i++){
		if(s[arr[i]] == '0'){
			if(i + 2*K > arr.size()-1){
				ans = max(ans, N-arr[i]);
			}else{
				ans = max(ans, arr[i+2*K] - arr[i]);
			}
		}else{
			if(i + 2*K + 1 > arr.size()-1){
				ans = max(ans, N-arr[i]);
			}else{
				ans = max(ans, arr[i+2*K+1] - arr[i]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1020
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll n , a, b , c ;
	cin>> n >> a >> b >> c ;
	string str[n];
	for(ll i=0;i<n ;i++)cin>>str[i];
	string ans;
	for(ll i=0;i<n ;i++){
		if(str[i]=="AB"){
			if(a==0 && b==0){
				cout<<"No"<<endl;return 0;
			}
			if(a==0)ans.pb('A'),a++,b--;
			else if(b==0)ans.pb('B'),b++,a--;
			else if(i<n && a==b && str[i+1]=="AC")ans.pb('A'),a++,b--;
			else if(i<n && a==b && str[i+1]=="BC")ans.pb('B'),b++,a--;
			else if(a<b)ans.pb('A'),a++,b--;
			else ans.pb('B'),a--,b++;
		}
		else if(str[i]=="BC"){
			if(c==0 && b==0){
				cout<<"No"<<endl;return 0;
			}
			if(c==0)ans.pb('C'),c++,b--;
			else if(b==0)ans.pb('B'),b++,c--;
			else if(i<n && c==b && str[i+1]=="AC")ans.pb('C'),c++,b--;
			else if(i<n && c==b && str[i+1]=="AB")ans.pb('B'),c--,b++;
			else if(c<b)ans.pb('C'),c++,b--;
			else ans.pb('B'),c--,b++;
		}
		else{
			if(a==0 && c==0){
				cout<<"No"<<endl;return 0;;
			}
			if(a==0)ans.pb('A'),a++,c--;
			else if(c==0)ans.pb('C'),c++,a--;
			else if(i<n && a==c && str[i+1]=="BC")ans.pb('C'),a--,c++;
			else if(i<n && a==c && str[i+1]=="AB")ans.pb('A'),a++,c--;
			else if(a<c)ans.pb('A'),a++,c--;
			else ans.pb('C'),a--,c++;
		}
	}
	cout<<"Yes"<<endl;
	for(auto x : ans)cout<<x<<endl;

	return 0;
}

Measured memory_bytes: 6824
import copy
N = int(input())
X = list(map(int, input().split()))
Xsort = copy.copy(X)
Xsort.sort()
centerR = Xsort[N//2]
centerL = Xsort[N//2-1]
for i in range(N):
    if X[i] >= centerR:
        print(centerL)
    else:
        print(centerR)


Measured memory_bytes: 32772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int q;
    cin >> q;
    rep (k, 0, q) {
        string s, t;
        cin >> s >> t;
        int sl = s.size(), tl = t.size();
        int dp[sl + 1][tl + 1];
        rep (i, 0, sl + 1) rep (j, 0, tl + 1) dp[i][j] = 0;
        rep (i, 0, sl) {
            rep (j, 0, tl) {
                if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
                else
                    dp[i + 1][j + 1] =
                        max ({dp[i + 1][j], dp[i][j + 1], dp[i][j]});
            }
        }
        cout << dp[sl][tl] << "\n";
    }
}


Measured memory_bytes: 7124
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string s;
    cin >> s;
    if(s.size()<4){
        cout << "No" << endl;
    }else{
        if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] =='I'){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll N,A,B,test,cnt=0,now,cntcnt;
double sum=0;
ll dp[51][51];

void ncr(int n){
    rep(i,51)rep(j,51)dp[i][j]=0;
    for(int i=0;i<n+1;++i){
        for(int j=0;j<=i;++j){
            if(j==0||j==i){
                dp[i][j]=1;
            }
            else{
                dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
            }
        }
    }
}

int main(){
    cin>>N>>A>>B;
    ll v[N];
    rep(i,N){
        cin>>v[i];
    }
    sort(v,v+N,greater<ll>());
    ncr(50);

    rep(i,A){
        sum+=v[i];
    }
    sum/=A;


    if(v[0]==v[A-1]){
        now=v[0];
        cntcnt=0;
        rep(i,N){
            if(now==v[i]){
                cntcnt++;
            }else{
                break;
            }
        }
        for(int i=A;i<=B;i++){
            cnt+=dp[cntcnt][i];
        }
    }
    else{
        now=v[0];
        cntcnt=0;
        rep(i,N){
            if(now==v[i]){
                cntcnt++;
            }
            else{
                if(A<=cntcnt){
                    cnt+=dp[cntcnt][A];
                    break;
                }
                A-=cntcnt;
                now=v[i];
                cntcnt=1;
            }
            if(i==N-1){
                cnt+=dp[cntcnt][A];
            }
        }
    }



    cout.precision(20);
    cout << fixed << sum << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function main() {
	var N = parseInt(readLine());
	var s = readLine().split(" ");
	var T = [0];
	var sum=0;
	for (var i=1; i <= N; i++){
		T.push(parseInt(s[i-1]));
		sum += T[i];
	}
	var M = parseInt(readLine());
	for (var k=0; k < M; k++){
		s = readLine().split(" ");
		var i = parseInt(s[0]);
		var x = parseInt(s[1]);
		console.log(sum - T[i] + x);
	}
}


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

int main() {
  int K, X;
  cin >> K >> X;
  // X-K+1からX+K-1まで
for (int i = X-K+1; i < X+K; i++) {
  cout << i << " ";
  }
  cout <<endl;
}


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

public class Main{
    public static void main (String[] args) throws java.lang.Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        long N = Long.parseLong(line);
        long ans = 1;
        for(long i=1;i<=N;i++){
            ans *= i;
            ans%=(long)Math.pow(10,9)+7;
        }
        System.out.println(Long.toString(ans));
    }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll H, N;
    cin >> H >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll sum = 0;
    REP(i,0,N) sum += A[i];
    _PR(sum>=H?"Yes":"No");

    return 0;
}

/*



*/

Measured memory_bytes: 1024
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	string t;
	cin >> t;
	VecB f(n, true);

	ll ans = 0;
	rep(i, n){
		if(t[i] == 'r'){
			if(i >= k && t[i-k] == 'r' && f[i-k]){
				t[i] = false;
			}else{
				ans += p;
			}
		}else if(t[i] == 's'){
			if(i >= k && t[i-k] == 's' && f[i-k]){
				t[i] = false;
			}else{
				ans += r;
			}
		}else{
			if(i >= k && t[i-k] == 'p' && f[i-k]){
				t[i] = false;
			}else{
				ans += s;
			}
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 512
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int a, b, c;

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

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

using namespace std;

void die() { cout << -1; exit(0); }

int main(){
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	
	long long arr[n];
	for(int i = 0;i < n;i++) cin >> arr[n-1-i];
	
	long long low = 2, high = 4;
	if(arr[0] != 2) die();
	
	for(int i = 1;i < n;i++){
		if(low % arr[i] != 0) low = arr[i] + low - (low % arr[i]);
		else low = low - (low % arr[i]);
		
		if(high % arr[i] != 0) high = high - (high % arr[i]) + arr[i];
		else high = high - (high % arr[i]);
		//cout << low << " " << high << "\n";
		
		if(low >= high) die();
	}
	
	cout << low << " " << high-1 << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%1000==0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        int x=abs((n%1000)-1000);
        cout<<x<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
struct edge{ll to,cost;};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    string b;
    cin>>a>>b;
    int z=0;
    string bz,bs;
    rep(i,b.size()){
        if(b[i]=='.') z=1;
        else if(z==0) bz+=b[i];
        else bs+=b[i];
    }
    cout<<a*(ll)stoi(bz)+a*(ll)stoi(bs)/100;
}

Measured memory_bytes: 3632
import Control.Monad (replicateM)

main = do
    n <- read <$> getLine
    table <- ([0, 0, 0]:) <$> replicateM n (map read . words <$> getLine)
    putStrLn $ if let
        f ([t, x, y], [t', x', y']) = let
            u = abs (t' - t)
            z = abs (x' -x) + abs (y' - y)
            p = u >= z
            q = even u == even z
            in p && q
        in all f $ zip (take n table) (drop 1 table)
        then "Yes"
        else "No"


Measured memory_bytes: 81276
data = input()
#data2 = input().split()
x = int(data)
#a = int(data2[0])
#b = int(data2[1])
yen = 100.0
cnt = 0
while(1):
    cnt = cnt + 1
    yen = int(yen * 1.01)
    if yen >= x:
        print(cnt)
        break

Measured memory_bytes: 9164
N = int(input())
songs = []

for i in range(N):
  s, t = input().split()
  t = int(t)
  songs.append((s, t))
  
X = input()
found = False
ans = 0
for i in range(len(songs)):
  s, t = songs[i]
  if s == X:
    found = True
    continue
  
  if found:
    ans += t
    
print(ans)
  

Measured memory_bytes: 3060
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n){
        cin>>vec[i];
    }
    ll res=1000;
    ll money=1000;
    ll kabu=0;
    bool f=false;
    if(vec[1]>vec[0]){
        f=true;
    }
    rep(i,n){
        if(i==n-1){
            chmax(res,money+kabu*vec[i]);
            continue;
        }
        if(f){
            if(vec[i+1]>vec[i]&&money/vec[i]!=0){
                ll cnt=money/vec[i];
                kabu+=cnt;
                money-=cnt*vec[i];
                f=false;
            }
        }else{
            if(vec[i+1]<=vec[i]){
                money+=kabu*vec[i];
                kabu=0;
                f=true;
            }
        }
      //  cout<<i<<"日目"<<money<<" "<<kabu<<endl;
        chmax(res,money+kabu*vec[i]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  cin >>N>>L;
  int ans=0;
  if(L>=0){
    for(int i=1;i<N;i++){
      ans+=L+i;
  }
  }
  else{
  if(N>((-1)*L)){
    for(int i=0;i<N;i++){
      ans+=L+i;}
                }
    else{ 
       for(int i=0;i<N-1;i++){
      ans+=L+i;}
         }
    
     }
    cout <<ans<<endl;
  }

Measured memory_bytes: 256
n,*a = map(int,open(0).read().split())
ans = a[0]//2
a[0] %= 2
for i in range(n-1):
  if a[i] == 1 and a[i+1] != 0:
    ans += 1
    a[i+1] -= 1
  if a[i+1] >1:
    ans += a[i+1]//2
    a[i+1] %= 2
print(ans)

Measured memory_bytes: 20060
from collections import Counter

def comb(n, r):
    result = 1
    r = min(r, n-r)
    for i in range(n, n-r, -1):
        result *= i
    for i in range(2, r+1):
        result //= i
    return result


n, m = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

b = [0]
for v in a:
    b.append(v + b[-1])

mod_dict = Counter([v % m for v in b])
ans = 0
for v in mod_dict.values():
    if v >= 2:
        ans += comb(v, 2)
print(ans)

Measured memory_bytes: 18772
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    int n,a,b,sum=0,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a==b)
            sum++;
        else{
            if(sum>ans){
                ans=sum;
            }
            sum=0;
        }
    }
    if(sum>ans){
        ans=sum;
    }
    if(ans>=3){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
  return(0);
}

Measured memory_bytes: 3620
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
s1 = Counter(s)
max_s = max(s1.values())
ans = []
for k,v in s1.items(): 
    if v == max_s:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 35476
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e7 * 100;

vector<ll> vec;
vector<bool> graph[2];

int main() {
    fastInp;

    string s;
    cin >> s;

    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2;
            return 0;
        }
    }

    for (int i = 0; i < s.size() - 2; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3;
            return 0;
        }
    }
    cout << "-1 -1";
    return 0;
}



Measured memory_bytes: 512
import collections
import bisect
S = input()
T = input()
N = len(S)

d = collections.defaultdict(list)
for i, s in enumerate(S):
    d[s].append(i + 1)

ans = 0
end = 0
isOK = True
i = 0

for t in T:
    if len(d[t]) == 0:
        isOK = False
        break
    dic = d[t]
    idx = bisect.bisect_right(dic, i)
    if len(dic) == idx:
        i = dic[0]
        end += 1
    else:
        i = dic[idx]

if isOK:
    ans = N * end + i
else:
    ans = -1

print(ans)


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

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

  std::vector<int64_t> an(n);

  for (auto& a : an) {
    std::cin >> a;
  }

  std::vector<int64_t> seq;

  for (auto iter = an.rbegin(); iter != an.rend(); ++iter) {
    auto found = std::upper_bound(seq.begin(), seq.end(), *iter);
    if (found == seq.end()) {
      seq.push_back(*iter);
    } else {
      *found = *iter;
    }
  }

  std::cout << seq.size() << std::endl;
  return 0;
}

Measured memory_bytes: 2168
n,q=map(int,input().split())
s=input()
cum=[0]*n

for i in range(1,n):
    if s[i]=="C" and s[i-1] == "A":
        cum[i]=cum[i-1]+1
    else:
        cum[i]=cum[i-1]

for i in range(q):
    a,b=map(int,input().split())
    print(cum[b-1]-cum[a-1])

Measured memory_bytes: 6060
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0;
  cin >> N;
  vector<ll>A(10000000);
  for(ll i = 1; i <= 10000000;i++){
    for(ll j = 1; i*j<=10000000;j++){
      A[i*j]++;
    }
  }
  ll ans = 0;
  rep(i,N+1){
    ans += i*A[i];
  }
  cout << ans;
}

Measured memory_bytes: 81380
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pii> a(n);
    vector<pii> b(n);
    rep(i,n){
        cin >> a[i].first;
        a[i].second = i;
    }
    rep(i,n){
        cin >> b[i].first;
        b[i].second = i;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    rep(i,n)if(a[i].first > b[i].first){
        cout << "No" << endl;
        return 0;
    }
    rep(i,n-1){
        if(a[i+1].first <= b[i].first){
            cout << "Yes" << endl;
            return 0;
        }
    }
    int cnt = 0;
    int now = 0;
    vector<int> p(n);
    rep(i,n)p[a[i].second] = b[i].second;
    do{
        cnt++;
        now = p[now];
    }while(now != 0);
    show(cnt);
    show(a);
    if(cnt != n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    int[][] edges = new int[M][2];
    int[][] graph = new int[N][N];
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      graph[a][b] = 1;
      graph[b][a] = 1;
      edges[i][0] = a;
      edges[i][1] = b;
    }

    int count = 0;
    for (int i = 0; i < M; i++) {
      int a = edges[i][0];
      int b = edges[i][1];
      graph[a][b] = 0;
      graph[b][a] = 0;

      boolean[] visited = new boolean[N];
      dfs(graph, visited, N, 0);
      boolean bridge = false;
      for (int j = 0; j < N; j++) if (!visited[j]) bridge = true;
      if (bridge) count++;

      graph[a][b] = 1;
      graph[b][a] = 1;
    }
    System.out.println(count);
  }

  private static void dfs(int[][] graph, boolean[] visited, int N, int i) {
    visited[i] = true;
    for (int j = 0; j < N; j++) if (graph[i][j] > 0 && !visited[j]) dfs(graph, visited, N, j);
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll k;
    cin>>k;

    string s;
    cin>>s;
    if(s.size()<=k)cout<<s<<endl;
    else
    {
        for(int i=0;i<k;i++)cout<<s[i];
        cout<<"...";
    }


}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  vector<string> week={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  
  for(int i=0; i<7;i++){
    if(s==week[i]){
      cout << 7-i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1619&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */

ll n,m;

string b[505];

// n <= 20 , 25 <= m <= 500
bool ok[501];

// 25 <= n <= 500, m <= 20
int bit[501];
int dp[2][1<<22];

int solve(){
    int res = 0;
    for(int i = 0; i < n;i++) cin >> b[i];
    if(n <= m){ // n <= 20 , 25 <= m <= 500
        for(int i = 0; i < (1<<n);i++){
            if(res >= __builtin_popcount(i)) continue;
            fill(ok,ok+501,false);
            for(int j = 0; j < n;j++){ // n <= 20
                if(!((i>>j)&1)) continue;
                for(int k = 0; k < m;k++){ // m <= 500
                    if(b[j][k] == '1') ok[k] = !ok[k];
                }
            }
            if(accumulate(ok,ok+m,0)) continue;
            res = max(res,__builtin_popcount(i));
        }
    }else{ // 25 <= n <= 500, m <= 20
        fill(bit,bit+n,0);
        for(int i = 0; i < n;i++){
            for(int j = 0; j < m;j++){
                if(b[i][j] == '1'){
                    bit[i] |= (1<<j);
                }
            }
        }
        for(int i = 0; i < 2;i++) for(int j = 0; j < (1<<m);j++) dp[i][j] = -1;
        dp[0][0] = 0;
        int cur = 0, next = 1;
        for(int i = 0; i < n;i++){
            for(int j = 0; j < (1<<m);j++){
                if(dp[cur][j] == -1) continue;
                dp[next][j] = max(dp[next][j],dp[cur][j]);
                dp[next][j^bit[i]] = max(dp[next][j^bit[i]],dp[cur][j]+1);
                
                dp[cur][j] = -1;
            }
            swap(cur,next);
        }
        res = dp[cur][0];
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> n >> m,n){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 19632
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

struct Warshall_Floyd{
    int V;
    long long int *d;//d[i_v1*V+i_v2]= v1tov2
    vector<  pair<int,int>  > *edges;
    Warshall_Floyd(int N): V(N){
        d = new long long int[V*V];
        edges=new vector<  pair<int,int>  >[V];
        rep(i,V*V){
            d[i]=LLINF;
        }
    }
    void push_edges(int a,int b, int c){
        edges[a].pb( mp(c,b));
        edges[b].pb( mp(c,a));
        if(ite(a,b)>c)d[a*V+b]=c;
        if(ite(b,a)>c)d[b*V+a]=c;
    }
    long long int ite(int i,int j){
        return d[i*V+j];
    }
    void solve() { // nは頂点数
        for (int i = 0; i < V; i++)      // via
        for (int j = 0; j < V; j++)    // start
        for (int k = 0; k < V; k++)  // end
         d[j*V+k] = min(ite(j,k), ite(j,i) + ite(i,k));
    }
    void free_wf(){
        delete[] d;
        delete[] edges;
    }
    
};

int main(void){
    int V,E;
    scanf("%d %d",&V,&E);
    Warshall_Floyd WF(V);
    rep(i,E){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        a--;b--;
        WF.push_edges(a,b,c);
    }
    //dijkstra * N
    int ans=0;
    WF.solve();
    rep(i,V){
        rep(j,WF.edges[i].size()){
            if( (long long int)(WF.edges[i][j].first) > WF.ite(i,WF.edges[i][j].second ))ans++;
        }
    }
    //WF.free_wf();
    printf("%d\n",ans/2);
}


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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
#define N 200093
long long k;
int T,f[N],g[N],u,v,st[N],t,n,a[N],h[N],tt,hh[N];
inline void pr(int u)
{
	while(u<=n){
		if(f[u]>u)u=f[u]; else printf("%d ",a[u]);
		++u;
	}
	exit(0);
} 

int main()
{
	n=read(); cin >> k;
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i) {
		if(!h[a[i]])h[a[i]]=i;
	}
	for(int i=n;i;--i){
		if(!g[a[i]])f[i]=h[a[i]]; else f[i]=g[a[i]];
		g[a[i]]=i;
	}
	
	/*
	u=1;
	while(1){
		v=f[u]+1;if(v>n)v=1;
		if(v<=u+1)++t;
		if(v==1){
			T=t;
			break;
		}
		u=v;
	}
	*/ 
	
	T=1,u=1;
	while(1){
		if(f[u]<=u)++T;
		u=f[u]+1;
		if(u==n+1)break;
	}
	
	u=1; --k; k%=T; if(!k)pr(u);
	while(1){
		v=f[u]+1;if(v>n)v=1;
		if(v<=u+1)--k;
		if(!k)pr(v);
		u=v;
	}
}

Measured memory_bytes: 5376
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        Console.WriteLine(Min(
            F(s, Enumerable.Range(0, s.Length).Select(x => x & 1)),
            F(s, Enumerable.Range(1, s.Length).Select(x => x & 1))));
    }
    static int F(string s, IEnumerable<int> l) => s.Zip(l, (x, y) => x - '0' == y ? 0 : 1).Sum();
}



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

using namespace std;


int main() {
  int n,m;
  long long k;
  cin>>n>>m>>k;
  vector<long long> a(n+1,0),b(m+1,0);
  for(int i=0;i<n;++i){
    cin>>a[i+1];
    a[i+1]+=a[i];
  }
  for(int i=0;i<m;++i){
    cin>>b[i+1];
    b[i+1]+=b[i];
  }
 
  int ans = 0;
  for(int i=0;i<=n;++i){
    long long rest=k-a[i];
    if(rest<0) continue;
    int temp=upper_bound(b.begin(),b.end(),rest)-b.begin()-1+i;
    ans=ans<temp?temp:ans;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a, 0, sizeof(a))
#define sqr(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int mn = 1e5 + 5;

int n,m;

vector<int> g[mn];

int d[mn];
int fa[mn];
int ans[mn];

int main() {
#ifdef LOCAL
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n-1+m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].pb(v);
        d[v]++;
    }
    queue<int> q;
    for(int i=1;i<=n;i++){
        if (!d[i]) {q.push(i);break;}
    }
    while(!q.empty()){
        int u=q.front();q.pop();
        for(auto &i:g[u]) {
            ans[i]=u;
            d[i]--;
            if (!d[i]) q.push(i);
        }
    }
    for(int i=1;i<=n;i++) printf("%d\n",ans[i]);

    return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>

int main(void)
{
	int n;
	int a;
	int v;
	
	int i;
	
	int c;
	int x;
	
	scanf("%d", &n);
	
	c = -1;
	x = 0;
	
	for (i = 1; i <= n; i++) {
		scanf("%d %d", &a, &v);
		if (c == v) {
			if (x > a){
				x = a;
			}
		}
		if (c < v) {
			c = v;
			x = a;
		}
	}
	printf("%d %d\n", x, c);
	
	return (0);
}

Measured memory_bytes: 600
s = gets
k = gets.to_i
if s[0] != "1" then
  puts s[0]
else
  count = 0
  s.chars do |char|
    if char != "1" then
      break
    else
      count += 1
    end
  end
  if count < k then
    puts s[count]
  else
    puts 1
  end
end


Measured memory_bytes: 1788
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;

long long N,arr[5];
int main(){
	cin>>N;
	for(long long i=0;i<5;i++)
		cin>>arr[i];
	long long mini=arr[0];
	for(int i=0;i<5;i++){
		if(arr[i]<mini)
			mini=arr[i];
	}
	if(mini>=N)
		cout<<"5";
	else{
		long long packets=(N/mini);
		if(N%mini==0)
			packets-=1;
		cout<<5+packets;
	}
	return 0;
}


Measured memory_bytes: 256
from itertools import permutations
N, C = map(int, input().split())

d = [[0]*C for i in range(C)]
for i in range(C):
  d[i] = [int(c) for c in input().split()]

grid = [[0]*C for i in range(3)]
for i in range(N):
  inf = [int(c)-1 for c in input().split()]
  for j in range(N):
    x = (j+i+2)%3
    g = inf[j]
    grid[x][g] += 1

record = [[0]*C for i in range(3)]
for i in range(3):
  for j in range(C):
    m = 0
    for h in range(C):
      m += grid[i][h]*d[h][j]
    record[i][j] = m

ans = 10**9
seq = range(C)
for i,j,h in permutations(seq,3):
  m = record[0][i]+record[1][j]+record[2][h]
  if m<ans:
    ans = m
    
print(ans)

Measured memory_bytes: 43228
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                \
  \   
  ios::sync_with_stdio(false); \
  cin.tie(0);
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define debug(...)
#endif
#define trace(c, x) for (auto& x : c)
int64_t p = 1e9 + 7;
int64_t power(int64_t x, int64_t y) {
  int64_t res = 1;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int64_t np2(int64_t n) { return n * (n - 1); }
int main() {
  FAST_IO
  int64_t n;
  cin >> n;
  int64_t ans =
      (((power(10, n) + power(8, n)) % p) + (p - (power(9, n) * 2) % p)) % p;
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<string> items(n);
    rep(i, n) cin >> items.at(i);
    sort(items.begin(), items.end());
    int ans = 1;
    rep(i, n - 1)
    {
        if (items.at(i) == items.at(i + 1))
            continue;
        ans++;
    }
    cout << ans << endl;
}

// TLE

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  priority_queue<int> pq;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    pq.push(x);
  }
  for (int i = 0; i < m; ++i) {
    int x = pq.top();
    pq.pop();
    if (x <= 0) break;
    pq.push(x / 2);
  }
  long long res = 0;
  while (!pq.empty()) {
    res += pq.top();
    pq.pop();
  }
  cout << res << '\n';
  return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    int x, y;
    cin >> s >> x >> y;

    vector<int> v;
    vector<int> h;

    bool b = true;
    int c = 0;
    REP(i, sz(s)) {
        if (s[i] == 'T') {
            if (c != 0) {
                if (b) h.push_back(c);
                else v.push_back(c);
            }
            b = !b;
            c = 0;
        } else {
            c++;
        }
    }
    if (c != 0) {
        if (b) h.push_back(c);
        else v.push_back(c);
    }

    vector<vector<bool>> hdp(sz(h) + 1, vector<bool>(20001, false));
    hdp[0][10000] = true;
    REP(i, sz(h)) {
        REP(j, 20001) {
            if (j - h[i] >= 0) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j - h[i]];
            if ((i != 0 || s[0] == 'T') && j + h[i] < 20001) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j + h[i]];
        }
    }
    if (!hdp[sz(h)][x + 10000]) {
        cout << "No" << EOL;
        return;
    }

    vector<vector<bool>> vdp(sz(v) + 1, vector<bool>(20001, false));
    vdp[0][10000] = true;
    REP(i, sz(v)) {
        REP(j, 20001) {
            if (j - v[i] >= 0) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j - v[i]];
            if (j + v[i] < 20001) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j + v[i]];
        }
    }
    if (!vdp[sz(v)][y + 10000]) {
        cout << "No" << EOL;
        return;
    }

    cout << "Yes" << EOL;
}


Measured memory_bytes: 10240