akhauriyash/Code-Regression huggingface dataset:
//pasta
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)
#define repd(i,a) for(int i=(a);i>=0;--i)

int N, K;
int dp[101][3][2];//day,pastaの種類,前の日と同じかどうか
int P[101];
const int MOD = 10000;

int main(){
	scanf("%d%d", &N, &K);
	std::fill(P,P + N , -1);
	
	rep(i, K){
		int A, B;
		scanf("%d%d", &A, &B);
		P[A - 1] = B - 1;
	}
	if (~P[0])
		dp[0][P[0]][0] = 1;
	else rep(j, 3)
		dp[0][j][0] = 1;
	rep(i, N-1){
		if (P[i + 1] == -1)rep(j, 3){
			rep(k, 3) if (j != k)
				dp[i + 1][j][0] = (dp[i + 1][j][0] + dp[i][k][0] + dp[i][k][1]) % MOD;
			dp[i + 1][j][1] = (dp[i + 1][j][1] + dp[i][j][0]) % MOD;
		}
		else {
			rep(j, 3)if (j != P[i + 1])
				dp[i + 1][P[i + 1]][0] = (dp[i + 1][P[i + 1]][0] + dp[i][j][0] + dp[i][j][1]) % MOD;
			dp[i + 1][P[i + 1]][1] = (dp[i + 1][P[i + 1]][1] + dp[i][P[i + 1]][0]) % MOD;
		}
	}
	int ans = 0;
	rep(j, 3) rep(k, 2)
		ans = (ans + dp[N - 1][j][k]) % MOD;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC171A
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            line = Console.ReadLine();
            char c = line[0];
            Console.WriteLine(c >= 'a' ? "a": "A");


#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 25876
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// using cd = complex<double>;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll N = 2*1e5+9;
// const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod =1e9+7;
const double PI = acos(-1);
// #define x first
// #define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr); 
    #endif
    ll t = 1;
    // cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll a[n];
        ll ma = 0;
        for(int i = 0;i<n;i++){
            cin>>a[i];
            ma = max(a[i],ma);
        }
        // cout<<ma<<'\n';
        ll l = 1,r = ma;
        while(l<r){
            // cout<<l<<" "<<r<<'\n';
            ll mi = (l+r)>>1;
            ll op = 0;
            for(int i = 0;i<n;i++){
                op+=a[i]/mi;
                if(a[i]%mi==0){
                    op--;
                }
            }
            // cout<<op<<'\n';
            if(op<=k){
                r= mi;
            }
            else{
                l = mi+1;
            }

        }
        cout<<l<<'\n';
        

    }

        
}

Measured memory_bytes: 5188
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>

using namespace std;
//for (int i = 0; i < N; i++){}


int main() {
    long long N;
	cin >> N;
    long long b, larger;
    long long res = 10000000001;
    for(long long a=1;a<=sqrt(N)+1;a++){
        if(N%a == 0){
            b = N/a;
            string a_keta = to_string(a);
            string b_keta = to_string(b);
            larger = max(a_keta.size(), b_keta.size());
            res = min(res, larger);
        }else{
            continue;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
x = list(map(int, input().split()))
d = list(input())
for i in d:
    if i == 'S':
        t=x[1]
        x[1]=x[0]
        x[0]=x[4]
        x[4]=x[5]
        x[5]=t
    elif i == 'N':
        t=x[1]
        x[1]=x[5]
        x[5]=x[4]
        x[4]=x[0]
        x[0]=t
    elif i == 'E':
        t=x[2]
        x[2]=x[0]
        x[0]=x[3]
        x[3]=x[5]
        x[5]=t
    elif i == 'W':
        t=x[2]
        x[2]=x[5]
        x[5]=x[3]
        x[3]=x[0]
        x[0]=t
print(x[0])

Measured memory_bytes: 7752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();
		if(x>t){
		System.out.println(x-t);
		} else
			System.out.println(0);
	}
}


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

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    ll ans = 0;
    ans += min(a, k);
    k = max((ll)0, k-a);
    if(k >= 0){
        k = max((ll)0, k-b);
    }
    if(k >= 0){
        ans -= min(c, k);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	int n,a,b,kizi,tpi[1000],karo,x,i,j,temp,max;
	scanf("%d %d %d %d",&n,&a,&b,&kizi);
	for(i=0;i<n;i++) scanf("%d",&tpi[i]);
	for(i=0;i<n-1;i++){
		for(j=i;j<n;j++){
			if(tpi[i]<tpi[j]){
				temp=tpi[i];
				tpi[i]=tpi[j];
				tpi[j]=temp;
			}
		}
	}
//	for(i=0;i<n;i++) printf("%d\n",tpi[i]);
	max=-1;
	for(i=0;i<n;i++){
		karo=kizi;
		for(j=0;j<i;j++){
			karo+=tpi[j];
		}
		x=karo/(a+b*i);
		if(max<x) max=x;
	}
	printf("%d\n",max);
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;

int N;
vector<pii> G[20];

int is_ho(int s,int n){
    return 1 & (s>>(n-1));
}

int judge(int s){
    int OK = 1;
    _rep(i,1,N){
        if(is_ho(s,i)){
            for(pii b : G[i]){
                int jj = b.first;
                int yy = b.second;
                if(yy){
                    if(!is_ho(s,jj)) OK = 0;

                }else{
                    if(is_ho(s,jj)) OK = 0;
                }

            }
        }
    }

    return OK;
}

int ct(int s){
    int ret = 0;
    _for(i,0,N){
        if((s>>i)&1) ret++;
    }

    return ret;

}

int main()
{
    cin >> N;
    _rep(i,1,N){
        int A;
        cin >> A;
        _for(j,0,A){
            int x,y;
            cin >> x >> y;
            G[i].PB(MP(x,y));
        }
    }



    int full = (1<<N)-1;
    int ans = 0;
    _rep(i,0,full){
        if(judge(i))
            ans = max(ans,ct(i));
    }
    cout << ans << endl;



    return 0;
}


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

// {{{ Point
constexpr double eps = 1e-9;
struct Point {
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}
    static double f(double a, double b) { // 浮點數誤差
        return ( abs(a+b)<eps*(abs(a)+abs(b)) )? 0 : a+b;
    }
    Point operator+(const Point& p) const { return Point(f(x, p.x), f(y, p.y)); }
    Point operator-(const Point& p) const { return Point(f(x, -p.x), f(y, -p.y)); }
    Point operator*(double a) const { return Point(x*a, y*a); } // 向量伸縮
    Point operator/(double a) const { return Point(x/a, y/a); } // 向量伸縮
    Point inv() const { return conj()/norm2(); }

    bool operator<(const Point &p) const { return x!=p.x ? x<p.x : y<p.y; }
    bool operator==(const Point &p) const { return f(x, -p.x)==0 && f(y, -p.y)==0; }

    double dot(Point p) const { return f(x * p.x, y * p.y); }
    double det(Point p) const { return f(x * p.y, -y * p.x); }
    double norm2() const { return x*x+y*y; }
    double norm() const { return sqrt(norm2()); }
    double arg() const { return atan2(y,x); }

    // rotate by rad
    Point rotate(double rad) {
        return Point(f(x*cos(rad), -y*sin(rad)), f(x*sin(rad), y*cos(rad)));
    }
    Point rot90() const { return Point(y,-x); }
    Point conj() const { return Point(x,-y); }

    friend istream &operator>>(istream &is, Point &p) { double x, y; is >> x >> y; p = Point(x, y); return is; }
    friend ostream &operator<<(ostream &os, const Point &p) { os << '(' << p.x << ',' << p.y << ')'; return os; }
};

// 計算交點
vector<Point> compute(Point a, Point b, double ra, double rb) {
    Point v=b-a;
    double d=v.norm();
    if ( d==0 ) return {}; // 共圓心
    if ( d+ra+rb==max({d,ra,rb})*2 ) return { a+v*(ra/d) }; // 內切 外切
    if ( d+ra+rb<max({d,ra,rb})*2 ) return {};  // 包含
    double rx=( d*d + ra*ra - rb*rb )/(2*d);
    double rh=sqrt( ra*ra - rx*rx ); 
    Point x=a + v*(rx/d); // 交點連線跟圓心連線的點
    Point y=v.rot90()*(rh/d);
    return { x+y, x-y };
}
// }}}

double dist( Point &a, Point &b ) { return (a-b).norm2(); }
int main() {
    int n;
    scanf("%d", &n);
    vector<Point> points(n);
    for ( int i=0; i<n; i++ ) {
        int x,y;
        scanf("%d %d", &x, &y);
        points[i].x=x; points[i].y=y;        
    }

    double lb=0, ub=3000;
    for ( int q=0; q<100; q++ ) {
        double r=(lb+ub)/2;
        vector<Point> ps;
        for ( int i=0; i<n; i++ ) ps.push_back(points[i]);
        for ( int i=0; i<n; i++ ) {
            for ( int j=0; j<i; j++ ) {
                auto vp=compute(points[i], points[j], r, r);
                ps.insert(ps.end(), vp.begin(), vp.end());
            }
        }
        bool ok=false;
        for ( Point p:ps ) {
            int cnt=0;
            for ( int k=0; k<n; k++ ) {
                if ( (points[k]-p).norm()<=r+eps ) {
                    cnt++;
                }
            }
            if ( cnt==n ) {
                ok=true;
                break;
            }
        }
        if ( ok ) {
            ub=r;
        }
        else {
            lb=r;
        }
    }
 
    printf("%.12f\n", lb);
    return 0;
}


Measured memory_bytes: 3948
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int N, W;
ll w[110], v[110];

ll dp[110][100100];

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

  cin >> N >> W;
  REP(i, N) cin >> w[i] >> v[i];

  // dp[i][j] := i番目までの重さW以下となる最大価値
  dp[0][0] = 0;
  REP(i, N+1){
    REP(j, W+1){
      if(j+w[i] <= W) dp[i+1][j+w[i]] = max(dp[i][j]+v[i], dp[i+1][j+w[i]]);
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      /*
      if(j-w[i] >= 0){
	dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
      }
      else{
	dp[i+1][j] = dp[i][j];
      } 
      */   
    }
  }

  cout << dp[N][W] << endl;
  /*
  REP(i, N+1) {
      REP(j, W+10) cerr << dp[i][j] << " ";
      cerr << endl;
  }
  */
  return 0;
}

/*
3 8
3 30
4 50
5 60
90
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 30 30 30 30 30 30 0 0 0 0 0 0 0 0 0 
0 0 0 30 50 50 50 80 80 0 0 0 0 0 0 0 0 0 
0 0 0 30 50 60 60 80 90 0 0 0 0 0 0 0 0 0 
*/

Measured memory_bytes: 79360
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    long long int N, K, a, f, start = 1, n = 0;
    vector<long long int> A;
    map<long long int, long long int> mp;
    cin >> N >> K;
    n = K;
    for (int i = 0; i < N; i++) {
        cin >> a;
        A.push_back(a);
    }
    int next = A[0];
    int prev = 1;
    for (long long int i = 1; i <= K; i++) {
        if (next != 1 && mp[next] == 0) {
            mp[next] = i;
            prev = next;
        } else {
            f = i - mp[next];
            // cout << f << endl;
            // cout << mp[next] << endl;
            n = (K - mp[next]) % f;
            // cout << K - mp[next] << endl;
            if (n == 0) {
                start = next;
            } else {
                start = next;
            }
            // cout << n << endl;
            break;
        }
        next = A[next-1];
    }
    // cout << start << " " << f << endl;
    for (int i = 0; i < n; i++) {
        start = A[start-1];
    }
    cout << start << endl;
    return 0;
}


Measured memory_bytes: 14608
import java.util.*;

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

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();
        int[] l = new int[Q];
        int[] r = new int[Q];

        for(int i=0; i<Q; i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        int[] ac = new int[N];
        ac[0] = 0;

        for(int i=1; i<N; i++){
            if(S.charAt(i)=='C' && S.charAt(i-1)=='A'){
                ac[i] = ac[i - 1] + 1;
            }
            else{
                ac[i] = ac[i - 1];
            }
        }

        for(int i=0; i<Q; i++){
            System.out.println(ac[r[i] - 1] - ac[l[i] - 1]);
        }
    }
}

Measured memory_bytes: 83008
#include<bits/stdc++.h>
#define ll long long
#define mod 838627288460106
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll n,x,i,j;
    set<ll>st;
    cin>>n;
    while(n--){
        cin>>x;
        st.insert(x);
    }
    cout<<st.size()<<endl;

    return 0;
}





Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    string S;
    cin >> S;
    bool flag = true;
    for(int i=0; i<S.length(); ++i){
        if(i%2==0){
            if(S[i]!='R'&&S[i]!='U'&&S[i]!='D') flag = false;
        }
        else{
            if(S[i]!='L'&&S[i]!='U'&&S[i]!='D') flag = false;
        }
    }

    cout << (flag==true ? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <cstring>
#include <algorithm>
#include <cstdio>

using std::sort;
typedef long long ll;
const int N = 1000010;
int _w;

int n, a[N];
ll ans;

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n+n+n; ++i )
		_w = scanf( "%d", a+i );
	sort(a+1, a+n+n+n+1);
	for( int i = n+1; i <= n+n+n; i += 2 )
		ans += a[i];
	printf( "%lld\n", ans );
	return 0;
}


Measured memory_bytes: 1280
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    int n,m;
    cin >> n >> m;
    if(n==m)cout << "Yes" << endl;
    else cout << "No" << endl;
  
   return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
    
fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();

    let d: i64 = c - a - b;
    
    if 4 * a * b < d * d && d > 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
/*********************************************************************************************/
/**                                                                                          //
//                            _ooOoo_                                                        //
//                           o8888888o                                                       //
//                           88" . "88                                                       //
//                           (| -_- |)                                                       //
//                            O\ = /O                                                        //
//                        ____/`---'\____                                                    //
//                      .   ' \\| |// `.                                                     //
//                       / \\||| : |||// \                                                   //
//                     / _||||| -:- |||||- \                                                 //
//                       | | \\\ - /// | |                                                   //
//                     | \_| ''\---/'' | |                                                   //
//                      \ .-\__ `-` ___/-. /                                                 //
//                   ___`. .' /--.--\ `. . __                                                //
//                ."" '< `.___\_<|>_/___.' >'"".                                             //
//               | | : `- \`.;`\ _ /`;.`/ - ` : | |                                          //
//                 \ \ `-. \_ __\ /__ _/ .-` / /                                             //
//         ======`-.____`-.___\_____/___.-`____.-'======                                     //
//                            `=---='                                                        //
//                                                       //                                  //
//         .............................................                                     //
//                  佛祖保佑             永无BUG                                            //
********************************************************************************************/
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1000000009;
int vis[10000];
int main()
{
    string s[100];
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n);
    for(int i=0;i<n;i++)
        cout<<s[i];
}


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

int main()
{
	long long arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	long long n;
	cin>>n;
	cout<<arr[n-1]<<endl;
}

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

ll solve() {
    ll X;
    cin >> X;
    int k = 1;
    while ( k * X % 360 != 0) k++;
    return k;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3564
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;


int main(){

    int A, B;
    cin >> A >> B;

    if(abs(A-B)>=1){
        cout << max(A,B)*2-1 << endl;
    }
    else {
        cout << max(A,B)*2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI w(N);
		REP(i, N) cin>>w[i];
		ll ans = 0;
		REP(i, N) {
			if(i+1==w[i]) {
				if(i+1<N) {
					swap(w[i], w[i+1]);
				} else {
					swap(w[i], w[i-1]);
				}
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
typedef long long ll;
constexpr ll  MOD = (1e9+7);

using namespace std;

typedef long long ll;

struct fenwick_tree {
    typedef ll T;
    T n;
    vector<T> bit;

    // 各要素の初期値は 0 
    fenwick_tree(T num) : bit(num+1, 0) { n = num; }

    // a_i += w
    void add(T i, T w) {
        for (T x = i; x <= n; x += x & -x) {
            bit[x] += w;
        }
    }
    // [1, i] の和を計算.
    T sum(T i) {
        T ret = 0;
        for (T x = i; x > 0; x -= x & -x) {
            ret += bit[x];
        }
        return ret;
    }
    // [left+1, right] の和を計算.
    T sum(T left, T right) {
        return sum(right) - sum(left);
    }
};

int main() {
    ll n, k; cin >> n >> k;

    vector<ll> a(n);
    vector<ll> b(n);

    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(b.begin(), b.end());
    map<ll, ll> mp;

    for(ll i = 0; i < n; i++) {
        mp[b[i]] = i+1;
    }

    fenwick_tree ft(n+1);
    ll tmp1 = 0;

    for (ll j = 0; j < n; j++) {
        tmp1 += j - ft.sum(mp[a[j]]);
        tmp1 %= MOD;
        ft.add(mp[a[j]], 1);
    }

    vector<ll> a2(n*2);
    vector<ll> b2(n*2);
    for (ll i=0; i<n*2; ++i) {
        a2[i] = a[i%n];
        b2[i] = a2[i];
    }
    sort(b2.begin(), b2.end());
    map<ll, ll> mp2;
    for (ll i=0; i<n*2; ++i) {
        mp2[b2[i]] = i+1;
    }
    fenwick_tree ft2(n*2+1);
    ll tmp2 = 0;

    for (ll j = 0; j < n*2; j++) {
        tmp2 += j - ft2.sum(mp2[a2[j]]);
        tmp2 %= MOD;
        ft2.add(mp2[a2[j]], 1);
    }
    tmp2 -= 2*tmp1;

    cout << (tmp1*k+(k*(k-1)/2)%MOD*tmp2)%MOD << endl;
    return 0;
}

Measured memory_bytes: 512
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 305;

double f[3 * N][2 * N][N];
bool v[3 * N][2 * N][N];
int n;

double go(int a1, int a2, int a3) {
    double& res = f[a1][a2][a3];
    if(!v[a1][a2][a3]) {
        v[a1][a2][a3] = 1;
        res = 0;
        double tot = a1 + a2 + a3;
        if(a1) {
            res += a1 / tot * (n / tot + go(a1 - 1, a2, a3));
        }
        if(a2) {
            res += a2 / tot * (n / tot + go(a1 + 1, a2 - 1, a3));
        }
        if(a3) {
            res += a3 / tot * (n / tot + go(a1, a2 + 1, a3 - 1));
        }
    }
    return res;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
    std::cin >> n;
    int a1 = 0, a2 = 0, a3 = 0;
    rep(i, 1, n + 1) {
        int x;
        std::cin >> x;
        if(x == 1) {
            a1++;
        } else if(x == 2) {
            a2++;
        } else {
            a3++;
        }
    }
    std::cout << std::
    fixed << std::setprecision(10) << go(a1, a2, a3) << std::endl;
}

Measured memory_bytes: 492928
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	L = II()
	x = L/3
	y = L/3
	print(y*x*(L-x-y))




if __name__ == '__main__':
	main()

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    sort(all(a));
    reverse(all(a));
    ll ans=0;
    priority_queue<ll> pq;
    pq.push(a[0]);
    for (int i = 1; i < n; i++)
    {
        ans+=pq.top();
        pq.pop();
        for (int j = 0; j < 2; j++)
        {
            pq.push(a[i]);
        }
        
    }
    
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < ( n ); ++i )
using namespace std;
using ll = long long;
using ull = unsigned long long;
using p  = pair<int, int>;
using vec_int = vector<int>;
using vec_str = vector<string>;
#define INF (1<<29)

void debug_input(vec_str& argv)
{
    // デバッグ用引数読み込み
    ifstream file("./input.txt");
    string str;
    while( getline(file, str) ) {
        argv.push_back(str);
    }
}

void debug_split_string(const string& str, vec_str& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
}

void debug_split_int(const string& str, vec_int& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        istringstream ss(buf);
        int temp;
        ss >> temp;
        v.push_back(temp);
    }
}

int main()
{
    int N = 0;
    string S;
#if 1
	cin >> N;
#endif
#if 0
	cin >> S;
#endif
#if 0
    vec_str v(N);
    //vec_int v(N);
    rep(i, N) cin >> v[i];
#endif

#if 0
    p pp = make_pair(1, 2);
    //cout << pp.first << endl;
    //cout << pp.second << endl;
#endif

#if 0 // for debug
    vec_str argv;
    debug_input(argv);

    // 文字列行の読み込み
    //vec_str v;
    //debug_split_string(argv[1], v);

    // 数値行の読み込み
    vec_int v;
    debug_split_int(argv[0], v);
    
    
    N = v[0];
#endif
    N++;
    ll ans = 0;
    
    rep(i, N) {
    
        if( i % 3 != 0 && i % 5 != 0 ) {
            ans += i;
        }
    }
        

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

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

int gcd(int a, int b){
  if(a == 0) return b;
  if(b == 0) return a;
  if(a % b == 0) return b;
  
  a %= b;
  gcd(b, a);
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a.at(i);
  
  vector<int> left(n);
  vector<int> right(n);
  for(int i = 1; i < n; ++i){
    left.at(i) = gcd(left.at(i-1), a.at(i-1));
  }
  reverse(a.begin(), a.end());
  for(int i = 1; i < n; ++i){
    right.at(i) = gcd(right.at(i-1), a.at(i-1));
  }
  reverse(right.begin(), right.end());
  
  int ans = 0;
  for(int i = 0; i < n; ++i){
    int k = gcd(left.at(i), right.at(i));
    ans = max(ans, k);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	string s0, sn;
	cout << 0 << endl;
	cin >> s0;
	if(s0 == "Vacant") return 0;
	cout << N-1 << endl;
	cin >> sn;
	if(sn == "Vacant") return 0;
	int l =0, r =N-1;
	while(true) {
		int m =(l+r)/2;
		cout << m << endl;
		string s;
		cin >> s;
		if(s == "Vacant") return 0;
		if((r-l)%2 == 0) {
			if((m-r)%2 == 0) {
				if(s == s0) l =m, s0 =s;
				else r =m, sn =s;
			}
			else {
				if(s == s0) r =m, sn =s;
				else l =m, s0 =s;
			}
		}
		else {
			if((m-r)%2 == 0 && sn != s) l =m, s0 =s;
			if((m-r)%2 != 0 && sn != s) r =m, sn =s;
			if((m-r)%2 == 0 && sn == s) r =m, sn =s;
			if((m-r)%2 != 0 && sn == s) l =m, s0 =s;
		}
	}
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 852
import sys

def make_burger(n):
    patty = [None] * (n + 1)
    bun = [None] * (n + 1)
    patty[0] = 1
    bun[0] = 0
    burger = [None] * (n + 1)
    burger[0] = 1
    for i in range(n):
        patty[i+1] = patty[i] * 2 + 1
        bun[i+1] = bun[i] * 2 + 2
        burger[i+1] = patty[i+1] + bun[i+1]
    return burger, patty

burger, patty = make_burger(50)

def patty_cnt(l, r, res):
    if l == 0:
        return res + 1
    half_burger = burger[l] // 2 + 1
    half_patty = patty[l] // 2 + 1
    if r == 1:
        return res
    elif r < half_burger:
        return patty_cnt(l-1, r-1, res)
    elif r == half_burger:
        return res + half_patty
    elif r < burger[l]:
        return patty_cnt(l-1, r-half_burger, res+half_patty)
    elif r == burger[l]:
        return res + patty[l]
    
n, x = map(int, sys.stdin.readline().split())

def main():
    return patty_cnt(n, x, 0)
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
l,r = input().split()
l = int(l)
r = int(r)
 

 
if r - l >= 2019:
    print(0)
else:
    l_mod = l % 2019
    r_mod = r % 2019
    min_val = 2020
    for i in range(r_mod - l_mod + 1):
        for j in range(r_mod - l_mod + 1):
            if i >= j:
                continue
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
            
    print(min_val)

Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}
module Main where
import qualified Data.Vector.Unboxed as U
import Data.Foldable (foldl')
main = do
  _ <- getLine
  xs <- U.fromList . map (pred . read) . words <$> getLine
  ys <- U.fromList . map read . words <$> getLine
  zs <- U.fromList . map read . words <$> getLine
  let go (!acc, !prev) i
        | i == prev + 1, Just b <- zs U.!? prev = (ys U.! i + b + acc, i)
        | otherwise = (ys U.! i + acc, i)

  print $ fst $ U.foldl' go (0 :: Int, -1 :: Int) xs


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;
    int T=-1, S=0;
    for(int w=0; 100*w<=f; w+=a)
    for(int x=0; 100*(w+x)<=f; x+=b)
    for(int y=0; 100*(w+x)+y<=f; y+=c)
    for(int z=0; 100*(w+x)+y+z<=f; z+=d) {
        int s=y+z;
        int t=100*(w+x)+s;
        if (s<=(w+x)*e && t>0 && (T<0 || S*t<s*T)) S=s, T=t;
    }
    cout<<T<<' '<<S<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer[] A = new Integer[N];
        Integer[] B = new Integer[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
            B[i] = A[i];
        }
        Arrays.sort(A, Comparator.reverseOrder());
        int max = A[0];
        int second = A[1];

    //処理
        for (int i=0;i<N;i++){
            System.out.println((B[i]==max)?second:max);
        }
        sc.close();

    }
}


Measured memory_bytes: 102940
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	long N =Long.parseLong(stdIn.next());
	int K = stdIn.nextInt();
	int count=0;
	while(N!=0){
	    N/=K;
	    count++;
	}
	System.out.println(count);
    }
}
	    


Measured memory_bytes: 22996
n = gets.to_i

red = n.times.map {gets.split.map(&:to_i)}.sort_by {|e| e[0]}
blue = n.times.map {gets.split.map(&:to_i)}.sort_by {|e| e[0]}

h = [[0, 1000]]
blue.each do |c, d|
    h << red.shift while !red.empty? && red[0][0] < c
    h.sort_by!{|e| e[1]}
    (x = h.bsearch_index{|e| e[1] >= d}) != 0 and h.delete_at(x-1)
end

p n - h.size + 1 - red.size

Measured memory_bytes: 14220
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int cnt[70],len;
string c;

int query(string s) {
	cout<<"? "<<s<<endl;
	int x;cin>>x;
    if(!x) cout<<"! "<<s<<endl,exit(0);
    return x;
}

string solve(int l,int r) {
	if(l==r) {
		string ret;
		for(int i=0;i<cnt[l];i++) ret+=c[l];
		return ret;
	}
	int mid=(l+r)>>1;
	string ls=solve(l,mid),rs=solve(mid+1,r);
	int p1=0,p2=0;
	string ret;
	while(p1<sz(ls)&&p2<sz(rs)) {
		string s=ret+ls[p1]+string(rs.begin()+p2,rs.end());
		if(query(s)==len-sz(s)) ret+=ls[p1++];
		else ret+=rs[p2++];
	}
	while(p1<sz(ls)) ret+=ls[p1++];
	while(p2<sz(rs)) ret+=rs[p2++];
	return ret;
}

int main() {
	for(char i='a';i<='z';i++) c+=i;
	for(char i='A';i<='Z';i++) c+=i;
	for(char i='0';i<='9';i++) c+=i;
	for(int i=0;i<62;i++) {
		string s;
		for(int j=0;j<128;j++) s+=c[i];
		cnt[i]=128-query(s);
		len+=cnt[i];
	}
  	string ans=solve(0,61);
	cout<<"! "<<ans<<endl;
	return 0;
}


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

const int mod=998244353;
int f[2][410][410],n,a[410],b[410],S,C[410][410],ans,x,y;

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int main()
{
	for (int i=0; i<=400; i++)
	{
		C[i][0]=1;
		for (int j=1; j<=i; j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	scanf("%d",&n),S=0;
	for (int i=1; i<=n; i++) scanf("%d%d",&a[i],&b[i]),S+=a[i];
	f[0][0][0]=mod-1,x=1,y=0;
	for (int i=1,nw; i<=n; i++)
	{
		x^=1,y^=1;
		memcpy(f[y],f[x],sizeof(f[x]));
		for (int j=0; j<=S-a[i]; j++)
		{
			nw=1;
			for (int k=0; k<b[i]; k++,nw=1ll*nw*a[i]%mod)
				for (int l=0; l<=400-k; l++)
					f[y][j+a[i]][k+l]=(f[y][j+a[i]][k+l]-1ll*f[x][j][l]*C[k+l][l]%mod*nw)%mod;
		}
	}
	ans=0;
	for (int nw,i=1,s; i<=S; i++) 
	{
		nw=quickmi(i,mod-2),s=nw;
		for (int j=0; j<=400; j++,s=1ll*s*nw%mod) ans=(ans+1ll*f[y][i][j]*s)%mod;
	}
	ans=1ll*ans*S%mod;
	return printf("%d\n",(ans+mod)%mod),0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  ll n, m, k; cin >> n >> m >> k;
  vector<ll> a(n), b(m); REP(i,n) cin >> a[i]; REP(i,m) cin >> b[i];
  vector<ll> sum_a(n + 1), sum_b(m + 1);
  
  FOR(i, 1, n) 
    sum_a[i] += sum_a[i-1] + a[i-1];
  
  FOR(i, 1, m)
    sum_b[i] += sum_b[i-1] + b[i-1];


  ll ans = 0, j = m;
  REP(i,n + 1) { 
    if (sum_a[i] > k) break;

    while (sum_b[j] > k - sum_a[i]) {
      j--;
    }
    ans = max(ans, i + j);
  }

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


Measured memory_bytes: 9552
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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;
}

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}

string stcut[4][4]={
	{"AA","AB","AX","AY"},
	{"BA","BB","BX","BY"},
	{"XA","XB","XX","XY"},
	{"YA","YB","YX","YY"}
};

int main() {
	int N; cin>>N;
	ll result=0LL;
	result+=N/500*1000;
	N%=500;
	result+=N/5*5;
	cout<<result<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int i, sum=0;
    int arr[100];
    for(i=0; i<100; i++) arr[i]=0;
    
    while(cin >> i)arr[i-1]++;
    for(i=0;i<100;i++)if(arr[i]) sum++;
    cout << sum <<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
	    }
	sort(a,a+5);
	reverse(a,a+5);
	cout<<a[0];
	for(int j=1;j<5;j++){
		cout<<" "<<a[j];
	    }
	cout<<endl;
	return 0;
	}


Measured memory_bytes: 3112
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: [i64; 5],
        k: i64,
    }
    let ans = if a[4] - a[0] > k { ":(" } else { "Yay!" };
    println!("{}", ans);
}

Measured memory_bytes: 4352
H,W = map(int,input().split())
listA =[]
while True:
    try:
        listA.append(list(map(str,input().split())))
    except:
        break;
for i in range(0,2*H):
    for j in range(0,W):
        if j == W-1:
            print(listA[i//2][0][j])
        else:
            print(listA[i//2][0][j],end="")

Measured memory_bytes: 4480
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
SUM = 0
before = -1
for i in A:
    SUM += B[i-1]
    if before + 1 == i:
        SUM += C[before-1]
    before = i
print(SUM)


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

using ll = long long;

int main() {
    int n, p[20];
    cin >> n;
    rep(i, n) cin >> p[i];
    int ans = 0;
    rep(i, n - 2) if ((p[i] - p[i+1]) * (p[i+1] - p[i+2]) > 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int n;
    int length[5] = {5, 7, 5, 7, 7};
    while(cin >> n, n) {
        vector<int> v(n);
        REP (i, 0, n) {
            string str;
            cin >> str;
            v[i] = str.size();
        }
        int ans = -1;
        REP (i, 0, n) {
            int pos = 0;
            int total = 0;
            REP (j, i, n) {
                total += v[j];
                if (length[pos] == total) {
                    pos++;
                    total = 0;
                } else if (length[pos] < total) {
                    break;
                }
                if (pos == 5) {
                    ans = i + 1;
                    break;
                }
            }
            if (ans != -1) break;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3144