akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.awt.geom.*;

public class Main{

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int sum1 = 0, sum2 = 0;
			for(int i = 0; i < 4; i++){
				sum1 += sc.nextInt();
			}
			for(int i = 0; i < 4; i++){
				sum2 += sc.nextInt();
			}
			if(sum1 > sum2){
				System.out.println(sum1);
			}
			else{
				System.out.println(sum2);
			}
		}
	}

	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 17168
//https://atcoder.jp/contests/dp/tasks/dp_n
#include <bits/stdc++.h>

using namespace std;
#define ll signed long long int

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin>>n;
	ll *a=new ll[n];
	ll *pre=new ll[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		if(i==0){
			pre[i]=a[i];
		}
		else{
			pre[i]=a[i]+pre[i-1];
		}
	}

	vector<vector<ll>> dp(n, vector<ll>(n, 0));
	for(ll c=1; c<n; c++){
		ll i=0;
		for(ll j=c; j<n; j++){
			dp[i][j]=1e13;
			for(ll k=i; k<j; k++){
				ll part1 = i!=0?pre[k]-pre[i-1]:pre[k];
				ll part2 = pre[j]-pre[k];
				dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j] + part1+part2);
			}
			i++;
		}
	}
	// for(auto x:dp){
	// 	for(auto y:x){
	// 		if(y<10)cout<<" ";
	// 		cout<<y<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[0][n-1];
}

Measured memory_bytes: 1536
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
	fwrite(buf, 1, _bl, stdout);
	_bl = 0;
}
__inline void _putchar(char c) {
	if(_bl == _B) flush();
	buf[_bl++] = c;
}
inline void print(LL x, char c) {
	static char tmp[20];
	int l = 0;
	if(!x) tmp[l++] = '0';
	else {
		while(x) {
			tmp[l++] = x % 10 + '0';
			x /= 10;
		}
	}
	for(int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
	_putchar(c);
}
const int N = 1111;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int a[N];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	cout << accumulate(a + 1, a + 1 + k, 0) << endl;
}






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

typedef struct dice{
	int face[6];
}dice;

void rotate(dice*d,char dir)
{
	int temp;
	switch(dir){
		case 'N':
		temp=d->face[0];
		d->face[0]=d->face[1];
		d->face[1]=d->face[5];
		d->face[5]=d->face[4];
		d->face[4]=temp;
		break;
		case 'E':
		temp=d->face[0];
		d->face[0]=d->face[3];
		d->face[3]=d->face[5];
		d->face[5]=d->face[2];
		d->face[2]=temp;
		break;
		case 'W':
		temp=d->face[0];
		d->face[0]=d->face[2];
		d->face[2]=d->face[5];
		d->face[5]=d->face[3];
		d->face[3]=temp;
		break;
		case 'S':
		temp=d->face[0];
		d->face[0]=d->face[4];
		d->face[4]=d->face[5];
		d->face[5]=d->face[1];
		d->face[1]=temp;
		break;
	}
}
int isSame(dice d1, dice d2)
{
	static const char dir[]= "NNNESSSWNNNESSSWNNNESSSW";
	int i,j;
	for(i=0;i<24;i++){
		for(j=0;j<6&&d1.face[j]==d2.face[j];j++);
		if(j==6) return 1;
		rotate(&d2,dir[i]);
	}
	return 0;
}
int main() 
{
	dice d[100];
	int i,j,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<6;j++){
		scanf("%d",&d[i].face[j]);
		}
		for(j=0;j<i;j++){
			if(isSame(d[i],d[j])){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1836
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, a, b;
    while (cin >> n && n) {
        int apt = 0, bpt = 0;
        rep(i, n) {
            cin >> a >> b;
            if (a > b) {
                apt += a + b;
            }
            else if (a < b) {
                bpt += a + b;
            }
            else {
                apt += a;
                bpt += b;
            }
        }
        cout << apt << " " << bpt << endl;
    }
    return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#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 all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = max(A, C);
    int U = min(B, D);

    cout << max(0, U - L) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int x;
	cin >> x;
	int t = 1;
	while(1){
		int temp = t * (t+1) / 2;
		if(temp >= x){
			cout << t << endl;
			return 0;
		}
		t++;
	}
	return 0;
}

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

#define MAX 1046527
#define NIL (-1)
#define L 14

char H[MAX][L];

int getCharVal(char c) {
    int v = 0;
    switch (c) {
        case 'A': v = 1; break;
        case 'C': v = 2; break;
        case 'G': v = 4; break;
        case 'T': v = 8; break;
        default: break;
    }
    return v;
}

int getStringVal(char s[]) {
    int v = 0;
    int p = 1;
    for (int i = 0; i < strlen(s); i++) {
        v += p*getCharVal(s[i]);
        p *= 3;
    }
    return v;
}

int h1(int key) {
    return key % MAX;
}

int h2(int key) {
    return 1 + (key % (MAX - 1));
}


int insert(char H[][L], char s[]) {
    int key, h, i;
    h = 0;

    key = getStringVal(s);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % MAX;
        if (strcmp(H[h], s) == 0) return 1;
        if (strlen(H[h]) == 0) {
            strcpy(H[h], s);
            return 0;
        }
    }
    return 0;
}

int find(char H[][L], char s[]) {
    int key, h, i;
    h = 0;
    key = getStringVal(s);
    for (i = 0; ;i++) {
        h = (h1(key) + i * h2(key)) % MAX;
        if (strcmp(H[h], s) == 0) return 1;
        if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}



int main() {

    int n, i;
    char com[L], s[L];
    // char H[MAX][L];
    scanf("%d", &n);
    for (i = 0; i < MAX; i++) H[i][0] = '\0';
    for (i = 0; i < n; i++) {
        scanf("%s%s", com, s);
        if (com[0] == 'i') insert(H, s);
        else if (com[0] == 'f') {
            printf(find(H, s) ? "yes\n" : "no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 16160
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    ll x; cin >> x;

    ll t1 = x/11;
    ll t2 = x%11;

    if(t2 > 6) t2 = 2;
    else if(t2 > 0) t2 = 1;
    else t2 = 0;

    cout << 2*t1 + t2;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	char a[10001];
	int b,g=0,s=0;
	while(scanf("%s",a)!=EOF)	{
			for(b=0;a[b+2]!=0;b++){
				if(a[b+1]=='O'&&a[b+2]=='I')
				{
					if(a[b]=='J')g++;
					if(a[b]=='I')s++;
			}
		}
		printf("%d\n%d\n",g,s);
		g=0;
		s=0;
	}
	return 0;
}


Measured memory_bytes: 2028
function Main(input){
    input = input.split("\n");
    var mem = input[0].split(" ").map(Number);
    var arr = input[1].split(" ").map(Number);
    arr = arr.sort(function(a,b){return a-b});
    var sum = 0;
    var max = mem[1];
    var ans = 0;
    for(var i=0;i<arr.length;i++){
      sum += arr[i];
      if(max<sum){
        break;
      }else{
        ans++;
      }
  //    console.log(sum,max,ans)
    }
    if(arrsum(arr)<max) ans--;
    console.log(ans);
  }Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
  function arrsum(arr){
      var sum = 0;
      for(var i=0;i<arr.length;i++){
          sum += arr[i];
      }
      return sum;
  }

Measured memory_bytes: 23092
import itertools

n = int(input())
x = [[0]*2 for _ in range(n)]
for i in range(n):
    x[i][0],x[i][1] = map(int,input().split())
y = []
    
a = [i for i in range(8)]
r = list(itertools.permutations(a,len(a)))

for i in r:
    fl = 1
    for j in range(n):
        if i[x[j][0]] != x[j][1]: 
            fl = 0
    if fl == 1:
        an = 1
        for j in range(8):
            for k in range(8):
                if j == k:
                    continue
                else:
                    if i[j]+j == i[k]+k:
                        an = 0
                    if k-j == i[k] - i[j]:
                        an = 0
        if an == 1:
            y = list(i)
            break
            
ans = [['.']*8 for i in range(8)]
for i in range(8):
    ans[i][y[i]] = 'Q'
    print(''.join(ans[i]))


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

using namespace std;

int gcd(int x, int y) {
    while (y) {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main() {

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

    constexpr int A_MAX = 1000000;

    vector<int> min_factor(A_MAX);
    // q[n] = i where n = i * p^e, p = min_factor[n], p does not divide i. + 1);
    vector<int> q(A_MAX + 1, 1);
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        min_factor[i] = i;
    }
    for (int i = 2; i <= A_MAX; ++i) {
        if (min_factor[i] == i) {
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }

    int N;
    cin >> N;
    vector<int> a(A_MAX + 1);
    int GCD = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        ++a[A];
        GCD = gcd(GCD, A);
    }

    if (GCD > 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        if (a[n] > 1) {
            is_pairwise_coprime = false;
        }
        a[min_factor[n]] += a[n];
        a[q[n]] += a[n];
    }
    if (is_pairwise_coprime) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }

    return 0;
}


Measured memory_bytes: 15524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[111],b[111];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        {cin>>a[i];
  }
    /*for(int i=1;i<=n;i++)
        cout<<a[i]<<endl;*/
    int maxn=0x3f3f3f3f;
    for(int i=1;i<=100;i++)
    {
        int sum=0;
        for(int j=1;j<=n;j++)
    {
        sum+=(a[j]-i)*(a[j]-i);
    }
    //cout<<sum<<endl;
    maxn=min(maxn,sum);
    }
    cout<<maxn<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

for i in range(N) :
    h[i] = int(input())

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while mx != mn :
    if (mx-mn) == 1 :
        tmp_mx = h-B*mx
        tmp_mn = h-B*mn
        T_mx = sum(np.ceil(tmp_mx[tmp_mx>0]/(A-B)))
        T_mn = sum(np.ceil(tmp_mn[tmp_mn>0]/(A-B)))

        if T_mn == mn :
            ans = mn
        else :
            ans = mx

        break

    tmp = h-B*now
    T = sum(np.ceil(tmp[tmp>0]/(A-B)))
    if now >= T :
        ans = now
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(ans))

Measured memory_bytes: 17252
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll N, X, T;
  cin >> N >> X >> T;

  ll n = (N + (X-1)) / X;
  
  cout << n * T << endl;
  
  return 0;
}


Measured memory_bytes: 3636
object Main extends App {
	val N = scala.io.StdIn.readInt
	val a = new Array[(String, Int, Int)](N)

	for(i<-0 until N){
		val Array(ta, tb) = scala.io.StdIn.readLine.split(" ")
		a(i) = (ta, tb.toInt, i+1)
	}

	val b = a.sortBy(x => (x._1, -x._2))
	
	for(x <- b){
		println(x._3)
	}

}

Measured memory_bytes: 25532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	while(1) {
		int N, M, P;
		int x[110];
		scanf("%d %d %d", &N, &M, &P);
		if(N == 0 && M == 0 && P == 0) break;
		reps(i, 1, N + 1) scanf("%d", &x[i]);

		ll sum = 0;
		reps(i, 1, N + 1) sum += 100 * x[i];

		ll ans;
		// printf("sum %d\n", sum);
		if(x[M] != 0) ans = (double)sum * (100 - P) / 100.0 / x[M];
		else ans = 0;
		printf("%lld\n", ans);
	}
	return 0;
}

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

const int mod = 1e9+7;
const int N = 2e5;
int a[N];

int32_t main(){

    int n,m;    cin >> n >> m;
    int want = m;

    while(m--){
        int l , r;  cin >> l >> r;
        a[l]++ , a[r+1]--;
    }

    for(int x=1;x<N;x++)
        a[x] += a[x-1];

    int ans = 0;

    for(int x=1;x<=N;x++)
        ans += (want == a[x]);
    
    cout << ans  << endl;


    return 0;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: i64 = std::i64::MAX / 4;

fn main() {
    input! {
        N: usize,
        A: [i64; N],
    }

    let (mut dp0, mut dp1, mut dp2) = (0, -INF, -INF);

    for (i, a) in A.iter().enumerate() {
        if i % 2 == 0 {
            dp1 = max(dp1, dp0);
            dp0 += a;
            dp2 += a;
        } else {
            dp2 = max(dp2, dp1);
            dp1 += a;
        }
    }

    if N % 2 == 0 {
        println!("{}", max(dp0, dp1));
    } else {
        println!("{}", max(dp1, dp2));
    }
}


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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;

const double PI = acos(-1);



int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        pq.push(x);
    }
    while (m--) {
        int x = pq.top();
        pq.pop();
        pq.push(x / 2);
    }
    long long ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans;
}


Measured memory_bytes: 892
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int N; cin >> N;
    int L[202];
    for(int i = 0; i < 2*N; i++){
        cin >> L[i];
    }
    sort(L,L+2*N);
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += L[i*2];
    }
    cout << ans << endl;
}

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

/*     bool comp(pair<ll,ll> a,pair<ll,ll>b ) {
    if(a.second==b.second) return a.first<b.first;
    else return a.second<b.second;
} */

 /*ll power(ll a,ll b){
     ll res=1;
     while(b>0){
         a%=M;
         if(b&1)
         res=res*a %M;
         a=a*a%M;
         b>>=1;
     }
     return res;
 }
 bool isPrime(ll n){
     for(int i=2;i<=sqrt(n);++i)
     if(n%i==0)
     return 0;
     return 1;
 }
 int cnt=0;
 vector<bool>col(8,false),diag1(8,false),diag2(8,0);

void search(int x,vector<string>s){
if(x==8){
    ++cnt;
    return;
}
for(int i=0;i<8;++i){
    if(col[i]||diag1[x+i]||diag2[7+x-i]||s[x][i]=='*') continue;
    col[i]=diag1[x+i]=diag2[7+x-i]=true;
    search(x+1,s);
    col[i]=diag1[x+i]=diag2[7+x-i]=false;
}
} */
struct pt{
    int x,y,num,val;
    bool operator<(const pt& p) const{
        if(y==p.y) return x<p.x;
        else return y<p.y;
    }
};
bool comp(pt&a,pt&b){
    if(a.x==b.x) return a.y<b.y;
    else return a.x<b.x;
}
int main()
{
       /*  int t;
 cin>>t;
 for(int x1=0;x1<t;++x1){


 }   
 */
 /*  int n;
 cin>>n;
 vector<int>v(n);
 for(int i=0;i<n;++i)
 cin>>v[i];
sort(v.begin(),v.end());
int i=0,j=n-1;
int t=0;
int sum=0;
while(i<n){
    if(sum+v[i]<=v[j])
    {sum+=v[i];
    ++i;


}  */
 int n;
 cin>>n;
 multiset<int>s;long long sum=0;vector<int>mp(100001);
 for(int i=0;i<n;++i)
 {
     int x;
     cin>>x;
     mp[x]+=1;
     sum+=x;
     s.insert(x);
 }
int q;
cin>>q;


for(int i=1;i<=q;++i){
    int a,b;
    cin>>a>>b;
    int cnt=mp[a];
    sum=sum+cnt*(b-a);
    s.erase(a);
   s.insert(b);
   mp[b]=mp[b]+cnt;
   mp[a]=0;
    cout<<sum<<'\n';
}

 

    return 0;
}

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

namespace AOJ.Volume2
{
    public class FizzBuzz
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int m = int.Parse(input[0]);
                int n = int.Parse(input[1]);

                if (m == 0 && n == 0) { break; }

                var q = new Queue<int>();
                for(int i = 1; i <= m; i++) { q.Enqueue(i); }

                int counter = 1;
                for(int i = 0; i < n; i++)
                {
                    var remark = Console.ReadLine();
                    // ???????????????????????£??????????¨??????????
                    if(q.Count == 1) { continue; }

                    // ?????§??????
                    bool success = true;
                    if (counter % 15 == 0)
                    {
                        // FizzBuzz
                        if (remark != "FizzBuzz") { success = false; }
                    }
                    else if (counter % 3 == 0)
                    {
                        // Fizz
                        if (remark != "Fizz") { success = false; }
                    }
                    else if (counter % 5 == 0)
                    {
                        // Buzz
                        if (remark != "Buzz") { success = false; }
                    }
                    else
                    {
                        // ??°???
                        if (remark != counter.ToString()) { success = false; }
                    }

                    int no = q.Dequeue();
                    if (success) { q.Enqueue(no); }

                    counter++;
                }

                // ??????(???????????????????°??????????)
                var player = new List<int>();
                while (q.Count > 0) { player.Add(q.Dequeue()); }
                string output = "";
                foreach(int i in player.OrderBy(x => x)) { output += " " + i; }
                Console.WriteLine(output.Trim());
            }

            return 0;
        }
    }
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    if(n == m)
     cout << "Yes\n";
    else
     cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 256
S=str(input())

if S=='SUN':
    print(int(7-0))
elif S=='MON':
    print(int(7-1))
elif S=='TUE':
    print(int(7-2))
elif S=='WED':
    print(int(7-3))
elif S=='THU':
    print(int(7-4))
elif S=='FRI':
    print(int(7-5))
elif S=='SAT':
    print(int(7-6))

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int C[N], A[N][M];
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    
    int ans = INT32_MAX;
    for (int i = 1; i < (1<<N); i++) {
        int a[M]{};
        int v = 0;
        for (int j = 0; j < N; j++) {
            if (i & (1<<j)) {
                v += C[j];
                for (int k = 0; k < M; k++) {
                    a[k] += A[j][k];
                }
            }
        }
        for (int j = 0; j < M; j++) {
           if (a[j] < X) break;
           if (j == M - 1) {
               ans = min(ans, v);
           }
        }
    }
    if (ans != INT32_MAX) {
        cout << ans << "\n";
    } else {
        cout << "-1\n";
    }
    return 0;
}

Measured memory_bytes: 3588
import java.io.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		String[] numbers = input.split(" ");
		Integer a = Integer.parseInt(numbers[0]);
		Integer b = Integer.parseInt(numbers[1]);
		Integer remain = a % b;
		Integer div_int = (a - remain) / b;
		String div_float = String.format("%.5f", (double)a / b);
		System.out.println(div_int + " " + remain + " " + div_float);
	}
}

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

int main() {
    ll n;
    cin>>n;
    ll max=0;
    ll sum=0;
    rep(i,n){
        ll now;
        cin>>now;
        if(max<=now){
            sum++;
            max=now;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
 
int sqrtN = 320;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketSum;
 
    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N, 0);
        bucketSum.assign(K, 0);
    }
 
    void add(int x, int y){
        data[x] += y;
        bucketSum[x / sqrtN] += y;
    }
 
    long long getSum(int x, int y){
        long long ans = 0;
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                ans += data[i];
            }
            return ans;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            ans += bucketSum[i];
        }
 
        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            ans += data[i];
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            ans += data[i];
        }
        return ans;
    }
 
};
 
int a[100000];
int a_aux[100000];
int a_aux_cumsum[100000];
pair <int, int> a_aux_cumsum_ind[100001];
int main(){
  int N;
  cin >> N;
 
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
 
  vector <int> sorted_a;
  for(int i = 0; i < N; i++){
    sorted_a.push_back(a[i]);
  }
  sort(sorted_a.begin(), sorted_a.end());
  sorted_a.erase(unique(sorted_a.begin(), sorted_a.end()), sorted_a.end());
 
  int left = 0;
  int right = sorted_a.size() - 1;
 
  if(sorted_a[left] == sorted_a[right]){
    cout << sorted_a[left] << endl;
    return 0;
  }
 
  while(left + 1 < right){
    int mid = (left + right) / 2;
    int target_a = sorted_a[mid];
    for(int i = 0; i < N; i++){
      if(a[i] <= target_a){
        a_aux[i] = -1;
      } else {
        a_aux[i] = 1;
      }
    }
    a_aux_cumsum[0] = a_aux[0];
    a_aux_cumsum_ind[0] = make_pair(a_aux_cumsum[0], 1);
    for(int i = 1; i < N; i++){
      a_aux_cumsum[i] = a_aux[i] + a_aux_cumsum[i - 1];
      a_aux_cumsum_ind[i] = make_pair(a_aux_cumsum[i], i + 1);
    }
    a_aux_cumsum_ind[N] = make_pair(0, 0);
    sort(a_aux_cumsum_ind, a_aux_cumsum_ind + N + 1);
    reverse(a_aux_cumsum_ind, a_aux_cumsum_ind + N + 1);
 
    SqrtDecomposition sq(N + 1);
    long long less_no = 0;
    for(int i = 0; i < N + 1; i++){
      int ind = a_aux_cumsum_ind[i].second;
      less_no += sq.getSum(0, ind);
      sq.add(ind, 1);
    }
    //cout << sorted_a[mid] << " " << less_no << endl;
    if(less_no < ((long long) N * (long long) (N + 1) / 2) / 2 + 1){
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << sorted_a[right] << endl;
  return 0;
}

Measured memory_bytes: 3448
package main

import "fmt"

func main() {
        var s, t string
        fmt.Scanln(&s)
        fmt.Scanln(&t)

loop:
        for i := range s {
                for j := 0; j < len(s); j++ {
                        if s[(i+j)%len(s)] != t[j] {
                                continue loop
                        }
                }
                fmt.Println("Yes")
                return
        }
        fmt.Println("No")
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, L = MAP()
aa = []
sum = 0

for i in range(1, N+1):
	sum += L + i - 1  
	aa.append([i, abs(L + i -1)])

aa.sort(key = lambda x:x[1])

remove = L + aa[0][0] - 1

print(sum-remove)

Measured memory_bytes: 5396
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int f(int n);
int main(){
	int t;
	int h, m, s;
	h = m = s = 0;
		scanf("%d", &t);
		h = t / 3600;
		t %= 3600;
		m = t / 60;
		s = t % 60;
		printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    double r; cin >> r;
    
    printf("%.6f %.6f\n", M_PI*r*r, 2*M_PI*r);
    
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin >> s;
	int p = -1;
	for(int i = 0; i < 12; i++) {
		if(s[i] == '?') p = i;
	}
	vector<int> ret;
	for(int i = 0; i < 10; i++) {
		s[p] = i + 48;
		int sum = 0;
		for(int j = 0; j < 11; j++) {
			int x = s[j] - 48;
			if(j <= 4) sum += x * (11 - j - 5);
			else sum += x * (11 - j + 1);
		}
		int z = 11 - sum % 11;
		if(z >= 10) z = 0;
		if(z == s[11] - 48) ret.push_back(i);
	}
	if(ret.size() >= 2) cout << "MULTIPLE" << endl;
	else cout << ret[0] << endl;
	return 0;
}

Measured memory_bytes: 3196
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define INF 0x3f3f3f3f
#define MAXN 100005

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K;

int main(void)
{
#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N >> M;

	cout << N / M + (N % M == 0 ? 0 : 1) << '\n';














#ifdef Sunshine
	freopen("CON", "r", stdin);
	system("pause");
#endif
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    for (int i=0;i<n;i++){
        b[a[i]-1]=i+1;

    }
    for (int i=0;i<n;i++){
        cout << b[i] << endl;
        
    }
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int x,a,b; cin >> x >> a >> b;
	if(b<=a) cout << "delicious" << endl;
	else if(b-a<=x) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long Int;
 
int main() {
    Int n, p;
    cin >> n >> p;
    if (n == 1) {
        cout << p << '\n';
        return 0;
    }
    Int c = 0;
    Int res = 1;
    for (Int i = 2; i*i <= p; i++) {
        c = 0;
        while (p%i == 0) {
            p /= i;
            c++;
            if (c%n == 0) res *= i;
        }
    }
    cout << res << '\n';
    return 0;  
}

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

main(){
  int i,j,n,count,t_count=0;
  cin >> n;
  int h[n];
  for(i=0; i<n; i++) cin >> h[i];
  
  for(i=0; i<n-1; i++){
    count=0;
    j=i;
    while(h[j]>=h[j+1]){
      count++;
      j++;
      if(j==n-1) break;
    }
    
    if(count>t_count){
      t_count = count;
    }
    
    if(t_count>n-j) break;
    
  }
    
  cout << t_count << endl;
}
    


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> svec;
void func(string str, int p, int q, string str2)
{
  
  if(p < 0 || q >= str.size()){
    return ;
  }
  if((str[p] == '(' && str[q] == ')')
     || (str[p] == '[' && str[q] == ']')
     || (str[p] == '{' && str[q] == '}')
     || (str[p] == ')' && str[q] == '(')
     || (str[p] == ']' && str[q] == '[')
     || (str[p] == '}' && str[q] == '{')
     || (str[p] == 'i' && str[q] == 'i')
     || (str[p] == 'w' && str[q] == 'w')){
    str2 = str[p] + str2 + str[q];
    svec.push_back(str2);
    func(str, p-1, q+1, str2);   
  } else {
    func(str, p-1, q, str2);
    func(str, p, q+1, str2);
  }
  
  return ;
}

int main()
{
  int p, q, t;
  string str;
 
  while(cin >> str){
    vector<int> vec;
    for(int i = 0; i < str.size()-2; i++){
      if(str.substr(i, 3) == "iwi"){
        vec.push_back(i+1);
      }
    }
    
    t = 0;
    for(int i = 0; i < vec.size(); i++){
      func(str, vec[i]-1, vec[i]+1, "w");
    }

    for(int i = 0; i < svec.size(); i++){
      int c = 0, l = svec[i].size();
      for(int j = 0; j < l-2; j++){
        if((svec[i]).substr(j, 3) == "iwi"){
          c++; 
        }
      }

      if(c == 1){
        t = max(l, t);
      }
    }

    svec.clear();
    cout << t << endl;
  }

  return 0;
}

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

int main() {
  int N; cin >> N; // 投票枚数
  map<string,int> V;  // 投票数
  int M=0;  // 最大票数

  // 投票用紙を読みつつ、投票数をカウントし、最大値を保管する。
  string tmp_S;
  rep(i,N){
    cin >> tmp_S;
    V[tmp_S]++;           // 投票数をカウント
    M = max(M,V[tmp_S]);  // 最大値を残しとく。
  }

  for(auto v : V){
    if(v.second==M){cout << v.first << endl;}
  }

}


Measured memory_bytes: 25216
n, x = map(int, input().split())
a = list(map(int, input().split()))

n = [abs(x-i) for i in a]

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

ans = n[0]
for c in n[1:]:
  ans = gcd(ans, c)

print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    freopen("A.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n; 
    cin >> n;
    int zero=0, one=0, two=0;
    for0(i,n) {
        int x; read(x);
        if (x%4 == 0)
            two++;
        else if (x%2 == 0)
            one++;
        else 
            zero++;
    }
    
    if (one > 0 && zero <= two) {
        cout<<"Yes"<<endl;
    }
    else if (one == 0 && zero <= two+1) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 200010;
int _w;

int l, n, x[N];
ll pf[N], sf[N];
ll ans;

int main() {
	_w = scanf( "%d%d", &l, &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", x+i );
	ans = max( x[n], l-x[1] );
	for( int i = 1; i <= n; ++i )
		pf[i] = pf[i-1] + x[i];
	for( int i = n; i >= 1; --i )
		sf[i] = sf[i+1] + l - x[i];
	for( int L = 1; L < n; ++L ) {
		int R = n-L;
		if( L < R ) {
			ll now = pf[L] * 2 + (sf[L+1] - sf[L+L+1]) * 2 - min(x[L], l-x[L+1]);
			now = max(now, pf[L] * 2 + (sf[L+2] - sf[L+L+2]) * 2 + (l-x[L+1]));
			ans = max(ans, now);
		} else if( L == R ) {
			ll now = pf[L] * 2 + sf[L+1] * 2 - min(x[L], l-x[L+1]);
			ans = max(ans, now);
		} else {
			ll now = (pf[L] - pf[L-R]) * 2 + sf[L+1] * 2 - min(x[L], l-x[L+1]);
			now = max(now, (pf[L-1] - pf[L-R-1]) * 2 + sf[L+1] * 2 + x[L]);
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}


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

fn main() {
    let (w, h): (usize, usize) = (read(), read());
    let mut graph: Vec<(i64, usize)> = Vec::new();
    for _ in 0..w {
        let p: i64 = read();
        graph.push((p, 0));
    }
    for _ in 0..h {
        let q: i64 = read();
        graph.push((q, 1));
    }
    graph.sort();
    let mut a = (w + 1) as i64;
    let mut b = (h + 1) as i64;
    let mut ans: i64 = 0;
    for i in &graph {
        let (pq, po) = *i;
        if po == 0 {
            ans += pq * b;
            a -= 1;
        } else {
            ans += pq * a;
            b -= 1;
        }
    }
    println!("{}", ans);
}

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")
}


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

int N, X[100009];
string S[100009], T;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S[i] >> X[i];
	}
	cin >> T;

	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		if (S[i] == T) {
			for (int j = i + 1; j <= N; j++) cnt += X[j];
			break;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1152
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    key_lst = []
    for i in range(0,8):
        key_lst.append(["keyence"[:i],"keyence"[i:]])
    ans = False
    for b,f in key_lst:
        st = s[:len(b)]
        go = s[len(s)-len(f):]
        if st == b and go == f:
            ans = True
    

    print("YES" if ans else "NO")
main()                  


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

ll X, Y;

void solve() {
  int ans = 0;
  while (X <= Y) {
    ans += 1;
    X *= 2;
  }
  cout << ans << endl;
}

int main() {
  cin >> X >> Y;

  solve();
  return 0;
}


Measured memory_bytes: 256
#pragma warning(disable: 4996)
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust";
	else cout << "win";
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, M, K;
vector<ll> A, B;

int main() {

	cin >> N >> M >> K;
	A.resize(N);
	B.resize(M + 1);
	rep(i, N) cin >> A[i];
	rep(i, M) cin >> B[i];
	B[M] = 0;

	ll a = 0, b = 0, ac = 0, bc = 0;
	ll ans = 0;
	for (; b + B[bc] <= K && bc < M; b += B[bc], bc++);

	ans = bc;

	rep(i, N) {
		ac = i + 1;
		a += A[i];
		while (a + b > K) {
			if (b == 0) {
				cout << ans << endl;
				return 0;
			}
			b -= B[--bc];
		}
		ans = max(ans, ac + bc);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

//For nCk
const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll n, m; cin >> n >> m;
    map<ll, ll> mp;
    if(m==1){
        cout << 1 << endl;
        return 0;
    }

    ll tmp = m;
    for(ll i=2; i<=tmp; i++){
        if(i==m){
            cout << n << endl;
            return 0;
        }
        while(tmp%i==0){
            tmp /= i;
            mp[i]++;
        }
    }

    COMinit();
    ll ans = 1;
    for(auto a:mp){
        ans *= COM(n-1+a.second, a.second);
        ans %= MOD;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 119808
//ABC 154 F Many Many Paths 
//leaf1415 
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#define llint long long
#define mod 1000000007

using namespace std;

llint sx, sy, tx, ty;
const int FACT_MAX = 3000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> sx >> sy >> tx >> ty;
	
	llint ans = 0;
	for(int i = sx; i <= tx; i++){
		ans += comb(i+ty+1, ty), ans %= mod;
		ans += mod - comb(i+(sy-1)+1, sy-1), ans %= mod;
	}
	
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 47104
#include<stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);

	int ans = 0;
	for(int i=1; i<=n; i+=2) {
		int count = 0;
		for(int j=1; j<=i; j++) {
			if(i % j == 0) {
				count++;
			}
		}
		if(count == 8) {
			ans++;
		}
	}

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

    return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
	vector<int>flag;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		flag.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
			if (i >= N)flag[i] = 1;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v]) {
			parent[u] = v;
			flag[v] |= flag[u];
		}
		else {
			parent[v] = u;
			flag[u] |= flag[v];
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
	bool Flag(int node) {
		return flag[Find(node)];
	}
};

struct Edge {
	int a, b, cost;
	Edge(const int aa, const int bb, const int cc) {
		a = aa, b = bb, cost = cc;
	}
	bool operator<(const Edge&e)const {
		return cost < e.cost;
	}
};

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

	cin >> N >> M >> K;
	vector<int>c(N);
	long long int box = 0;
	for (auto &i : c) {
		cin >> i;
		i--;
		box += i == -1;
	}
	UnionFind uf(N + K);
	vector<Edge>edge;
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> H;
		L--, R--;
		edge.push_back(Edge(L, R, H));
		if (c[L] >= 0) {
			edge.emplace_back(L, N + c[L], 0);
		}
		if (c[R] >= 0) {
			edge.emplace_back(R, N + c[R], 0);
		}
	}
	sort(edge.begin(), edge.end());
	long long int ans = 0;
	int sz = K;
	vector<int>used;
	for (auto i : edge) {
		//cout << sz - box << endl;
		if (uf.Check_Same(i.a, i.b))continue;
		if (uf.Flag(i.a) && uf.Flag(i.b))sz--;
		uf.Unite(i.a, i.b);
		ans += i.cost;
		used.push_back(i.cost);
		//cout << sz << " " << ans << endl;
	}
	vector<int>num(N);
	for (int i = 0; i < N; i++) {
		if (c[i] >= 0)continue;
		int p = uf.Find(i);
		if (uf.Flag(p) || num[p]) {
			sz--;
		}
		num[p]++;
	}
//	cout << sz << endl;
	while (sz < 1&&used.size()) {
		sz++;
		ans -= used.back();
		used.pop_back();
	}
//	cout << sz << endl;
	if (sz > 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10992
# coding: utf-8
# Your code here!

N,M = list(map(int,input().split(" ")))
a = [list(map(int,input().split(" "))) for i in range(N)]
tmp = []
for i in range(N):
    del a[i][0]
    tmp+=a[i]
c=0
for _ in list(set(tmp)):
    if tmp.count(_)==N:
        c+=1
print(c)

Measured memory_bytes: 3060
from collections import defaultdict
d = defaultdict(int)
N = int(input())
MAX = 0
max_keys = []
for i in range(N):
    k = input()
    d[k] += 1
    if d[k] == MAX:
        max_keys.append(k)
    elif d[k] > MAX:
        MAX = d[k]
        max_keys = [k]

for i in sorted(max_keys):
    print(i)
# for i in sorted([i for i, v in d.items() if v == max(d.values())]):
#     print(i)


Measured memory_bytes: 33680
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
t = na()
m = ni()
px = nan(m)

s = sum(t)
for i in range(m):
    p, x = px[i]
    p -= 1
    print(s - t[p] + x)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int a[N][3],dp[N][3],n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];	
		}
	}
	for(int i=1;i<=n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;
	return 0;
}

Measured memory_bytes: 2560