akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.1415926535897932;
/******define variable start******/
ll n, k, r, s, p;
string t;
/*******define variable end*******/
ll solve(){
    cin >> n >> k >> r >> s >> p >> t;
    ll dp[n+1];//i回目、いま
    vl what(n);
    dp[0] = 0;
    for(ll i = 0; i < k; i++){
        if(t.substr(i, 1) == "r"){
            dp[i+1] = dp[i] + p;
            what[i] = 2;
        }else if(t.substr(i, 1) == "s"){
            dp[i+1] = dp[i] + r;
            what[i] = 0;
        }else{
            dp[i+1] = dp[i] + s;
            what[i] = 1;
        }
    }
    for(ll i = k; i < n; i++){
        if(t.substr(i, 1) == "r"){
            if(what[i-k] == 2){
                dp[i+1] = dp[i];
                what[i] = 3;
            }else{
                dp[i+1] = dp[i] + p;
                what[i] = 2;
            }
        }else if(t.substr(i, 1) == "s"){
            if(what[i-k] == 0){
                dp[i+1] = dp[i];
                what[i] = 4;
            }else{
                dp[i+1] = dp[i] + r;
                what[i] = 0;
            }
        }else{
            if(what[i-k] == 1){
                dp[i+1] = dp[i];
                what[i] = 5;
            }else{
                dp[i+1] = dp[i] + s;
                what[i] = 1;
            }
        }
    }
    cout <<  dp[n] << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


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

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for (int i = a; i <= b; i++)
using namespace std;
long long maxv = 1e9;

int main()
{
    fast_cin();
    // typedef vector<int> vi;

    int N,M,p;
    cin>>N>>M>>p;
    // vi arr(M);
    if(M*p>=N){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3632
N,X,Y = map(int,input().split())
def dist(i,j):
    return min(j-i,abs(i-X)+1+abs(j-Y),abs(i-Y)+1+abs(j-X))
L = [0 for i in range(N-1)]
for i in range(1,N):
    for j in range(i+1,N+1):
        L[dist(i,j)-1] += 1
for k in range(0,len(L)):
    print(L[k])

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
string cand[4]={"AC","WA","TLE","RE"};

int check(string s)
{
    int N=s.size();
    rep(i,4){
        if(N!=cand[i].size())continue;
        
        bool same=true;
        rep(k,N){
            if(s[k]!=cand[i][k]){
                same=false;
                break;
            }
        }
        if(same)return i;
    }
    return 0;
}

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

    int mp[4]={};
    
    rep(i,4)mp[i]=0;
    rep(i,n){
        string s;
        cin>>s;
        mp[check(s)]++;
    }
    rep(i,4){
        cout<<cand[i]<<" x "<<mp[i]<<endl;
    }

    return 0;

}
/*


*/


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

int main()
{
	char S[100];
	int N=0,MAX=0,count=0;
	
	scanf("%d", &N);
	scanf("%s", S);
	
	int i,j,k;
	
	for(i=0;i<N;i++){
		
		int alp[26]={};
		count = 0;
		
		for(j=0;j<=i;j++){
			for(k=i+1;k<N;k++){
				
				if(S[j]==S[k]&&alp[(int)S[j]-97]==0){
					count++;
					alp[(int)S[j]-97]++;
					
				}
			}
		}
		
		if(MAX<count){
			MAX=count;
		}
		
	}
	
	
	printf("%d", MAX);
	
	
	return 0;
}


Measured memory_bytes: 128
N,K = map(int,input().split())
A = list(map(int,input().split()))

sa = sum(A)
m = 1
divs = set()
while m*m <= sa:
    if sa%m == 0:
        divs.add(m)
        divs.add(sa//m)
    m += 1

for d in sorted(divs,reverse=True):
    mods = []
    for a in A:
        mods.append(a%d)
    mods.sort()
    if all(m==0 for m in mods):
        print(d)
        exit()

    cump = [0]
    for m in mods:
        cump.append(cump[-1] + m)
    cumm = [0]
    for m in reversed(mods):
        cumm.append(cumm[-1] + (d-m))
    for i in range(1,N):
        if cump[i] == cumm[N-i] and cump[i] <= K:
            print(d)
            exit()

Measured memory_bytes: 43228
#include <cstdio>
#include <algorithm>

const int MN = 200005;

int N, K, A[MN], B[18][MN], C[18][MN], D[MN];

void Q(int l, int r, int &x, int &y) {
	int j = 31 - __builtin_clz(r - l + 1);
	x = std::min(B[j][l + (1 << j) - 1], B[j][r]);
	y = std::max(C[j][l + (1 << j) - 1], C[j][r]);
}

int Ans, t2;

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), ++A[i], B[0][i] = C[0][i] = A[i];
	for (int i = 1; i <= N; ++i) D[i] = 1 + (A[i - 1] < A[i] ? D[i - 1] : 0);
	for (int j = 0; 2 << j <= N; ++j)
		for (int i = 2 << j; i <= N; ++i)
			B[j + 1][i] = std::min(B[j][i - (1 << j)], B[j][i]),
			C[j + 1][i] = std::max(C[j][i - (1 << j)], C[j][i]);
	for (int i = K; i <= N; ++i) {
		if (D[i] >= K) t2 = 1;
		else {
			int j = i;
			while (j < N) {
				int x, y;
				Q(j - K + 2, j, x, y);
				if (A[j - K + 1] < x && A[j + 1] > y) ++j;
				else break;
			}
			++Ans;
			i = j;
		}
	}
	printf("%d\n", Ans + t2);
	return 0;
}

Measured memory_bytes: 29824
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL a, b, k;
	cin >> a >> b >> k;
	
	if(a < k){
		//cout << "one" << endl;
		k -= a;
		a = 0;
		//cout << "k one: " << k << endl;
	}
	else if(a >= k){
		//cout << "two" << endl;
		a -= k;
		cout << a << " " << b << endl;
		return 0;
	}
	
	//cout << "half k: " << k << endl;
	
	if(b < k){
		//cout << "three" << endl;
		k -= b;
		b = 0;
	}
	else if(b >= k){
		//cout << "four" << endl;
		b -= k;
		cout << a << " " << b << endl;
		return 0;
	}
	
	cout << a << " " << b << endl;
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

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

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;
	vector<int>a(n);
	int xo=0;

	for(auto &it:a)
	{
		cin>>it;
		xo^=it;
	}

	d(xo);

	vector<int>b(n);

	for(i=0;i<n;i++)
	{
		b[i]=xo^a[i];
	}

	for(auto it:b)
	{
		cout<<it<<" ";
	}

}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int n;
vector<vector<int>> g;
string s[200];


int solve(int st){
    vector<int> dis(n,INF);
    dis[st]=0;
    vector<bool> checked(n,false);
    queue<pair<int,int>> q;
    q.push(make_pair(st,0));
    while(!q.empty()){
        auto now=q.front();q.pop();
        if(checked[now.first]) continue;
        checked[now.first]=true;
        for(auto x:g[now.first]){
            if(checked[x]){
                continue;
            }
            else{
                dis[x]=now.second+1;
                q.push(make_pair(x,now.second+1));
            }
        }

    }

    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(s[i][j]=='1'){
                if(abs(dis[i]-dis[j])!=1)return -1;
            }
        }
    }

    int ret=0;
    rep(i,n){
        ret=max(ret,dis[i]);
    }
    return ret+1;
}


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

    cin>>n;
    g.resize(n);

    rep(i,n){
        cin>>s[i];
    }
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(s[i][j]=='1'){
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
    }

    int ans=-1;
    rep(i,n){
        ans=max(ans,solve(i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 748
#include<bits/stdc++.h>
using namespace std;
int c=0;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	for (int i=0;i<n;i++)
	  if (s[i]=='R') c++;
	if (c*2>n) puts("Yes");
	else puts("No");
	return 0;
}


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

#define f first
#define s second
#define ii pair<int, int>

int n, m, targ[100005];
ii elist[100005];
int dead[100005];
vector<int> G[100005];

int ei = 0;
pair<int, int> E[100005];

inline void add_edge(int u, int v) {
    E[ei++] = { u, v };
    targ[u] ^= 1;
}

int vis[100005];
void dfs(int u) {
    vis[u] = 1;
    for (int e : G[u]) {
        int v = (elist[e].f == u) ? elist[e].s : elist[e].f;
        if (!vis[v]) {
            dfs(v);
        }
    }
    // now process u
    bool flag = true;
    if (targ[u] == 0) flag = false;

    for (int e : G[u]) {
        if (!dead[e]) {
            int v = (elist[e].f == u) ? elist[e].s : elist[e].f;
            if (flag) {
                add_edge(u, v);
                flag = false;
            } else {
                add_edge(v, u);
            }
            dead[e] = 1;
        }
    }
}

int main() {
    // freopen("data.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    if (m & 1) {
        printf("-1\n");
        return 0;
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &elist[i].f, &elist[i].s);
        G[elist[i].f].push_back(i);
        G[elist[i].s].push_back(i);
    }
    dfs(1);
    assert(ei == m);
    for (int i = 0; i < m; ++i) {
        printf("%d %d\n", E[i].first, E[i].second);
    }
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {


       ll N;
       cin>>N;
       unordered_set<string> st;
       forn(i,N){
        string s;
        cin>>s;
        st.insert(s);
       }
       cout<<st.size()<<endl;







    }



    return 0;
}

Measured memory_bytes: 17708
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int score = 0;
    for(int i = 0;i < n-1;i++) {
        if(s[i] == s[i+1])
            score++;
    }
    int ans = min(score+2*k,n-1);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 512
/**
*    author:  yuya1234
*    created: 14.07.2020 10:30:10
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n;
  cin>>n;

  ll a[n],b[n];
  REP(i,n)cin>>a[i]>>b[i];

  ll ans=0;
  REPD(i,n)
  {
    if((a[i]+ans)%b[i]!=0)
    {
      ans+=b[i]-(a[i]+ans)%b[i];
    }
  }

  cout<<ans<<endl;

  return 0;
}

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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int dp[nv];

int a[nv];

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    fill(dp, dp + n, inf);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
6
2 1 6 3 4 5
2 1 3 4 5 6
6 0
1 7 8 2 4 6
 * */

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
    private static int[] calcPrimes(int n) {
        boolean[] table = new boolean[n + 1];
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (!table[i]) {
                for (int j = i + i; j <= n; j += i) {
                    table[j] = true;
                }
            }
        }
        int counter = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                counter++;
            }
        }
        int[] result = new int[counter];
        int index = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                result[index++] = i;
            }
        }
        return result;
    }

    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] primes = calcPrimes(1299709);

        while (true) {
            int k = scanner.nextInt();
            if (k == 0) {
                break;
            }
            int gap = 0;
            for (int i = 0; i < primes.length; i++) {
                if (primes[i] == k) {
                    gap = 0;
                    break;
                } else if (primes[i] > k) {
                    gap = primes[i] - primes[i - 1];
                    break;
                }
            }
            System.out.println(gap);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 14000
package main

import "fmt"

func main() {
	var n, m, l, r int
	fmt.Scan(&n, &m)
	min := 0
	max := 100000

	for i := 0; i < m; i++ {
		fmt.Scan(&l, &r)
		if min < l {
			min = l
		}
		if r < max {
			max = r
		}
	}

	if max < min {
		fmt.Println(0)
	} else {
		fmt.Println(max - min + 1)
	}
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
long long n,m,x[200005],fa[200005],l,r,d;
int find(int now)
{
	if(now == fa[now]) return now;
	int ret=find(fa[now]);
	x[now]+=x[fa[now]];
	return fa[now]=ret;
}
int main()
{
	cin >> n >> m;
	for(int i=1; i<=n; i++) fa[i]=i;
	int l,r,d;
	for(int i=1; i<=m; i++)
	{
		cin >> l >> r >> d;
		if(find(l) != find(r))
		{
			int k=find(r);
			fa[k] = find(l); x[k] = x[l] + d - x[r];
		}
		else
		{
			find(l); find(r);
			if(x[r] != x[l]+d)
			{
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


 int ans1,ans2;



int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

  string s;
  cin >> s;

int ok = 1;

  for(int i = 0; i < s.size(); i++)
   {
      if(ok)
      {
        ans1 += s[i] != '0';
        ans2 += s[i] != '1';
      }
      else
      {
        ans1 += s[i] !='1';
        ans2 += s[i] !='0';
      }

      ok = ok xor 1;
   }

   cout << min(ans1,ans2);








    return 0;   
}


Measured memory_bytes: 3792
/*Bismillahir Rahmanir Rahim*/


#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define ll long long int
#define dd double
using namespace std;

int main()
{
 ll a,b;
 cin>>a>>b;
 if(a==1)
 cout<<b<<endl;
 else
 {
    ll x=a-1;
   
    for(ll i=x;i>=0;i--)
    {
       cout<<b-i<<" ";
    }
    for(ll i=1;i<=x;i++)
    {
       cout<<b+i<<" ";
    }
 }
 
}


Measured memory_bytes: 3600
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;
 
fn main() {
    input! {
        n:usize,
        a:[i64;n]
    }
    let mut map = HashMap::new();
    //map.reserve(200000);
    let mut t = 0;
    // sum[0]==0のため、0の個数を追加。
    map.insert(0, 1);
    for i in 0..n {
        t += a[i];
        *map.entry(t).or_insert(0) += 1;
    }
    let mut ans = 0;
    for (_, &v) in map.iter() {
        ans += combination(v);
    }
    println!("{}", ans);
}
fn combination(v: usize) -> usize {
    if v <= 1 {
        0
    } else {
        v * (v - 1) / 2
    }
}

Measured memory_bytes: 12228
#include <algorithm>
#include <iostream>

	using namespace std;
	int n ,cnt ,ans;
	int a[100000];

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

	sort (a, a+n);

	while(cnt<n){
		int x=a[cnt];
		int f=0;
		while(cnt<n && a[cnt]==x){
			f++;
			cnt++;
		} 
		ans += f%2;
	}

	cout << ans << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N;
    cin >> N;
    vector<P> tasks(N, make_pair(0, 0));
    rep(i,N) cin >> tasks[i].second >> tasks[i].first;
    
    sort(tasks.begin(), tasks.end());
    
    int now = 0;
    rep(i,N) {
        now += tasks[i].second;
        if (now > tasks[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcount(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b)  for(int i=a ; i>=b ; --i)
 
#define PI 3.141592653589793
const ll INF = 1000000000;
const ll MAX_N = 1e5 + 2;
const ll MOD = 1e9 + 7;

void solve(){
    ll a,b; cin >> a >> b;
    
    ll gcd = __gcd(a,b);
    int ans = 1,flag;
    
    for(ll i=2;i*i<=gcd;++i){
        flag = 0;
        while((gcd % i) == 0){
            gcd /= i;
            flag++;
        }
        ans += (flag > 0);
    }
    if(gcd > 1) ans++;
    cout << ans;
}

int main() {
    IOS;
    // int t; cin >> t;
    int t = 1;
    while(t--) solve();
}


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

int main() {
  string a, b;
  cin >> a >> b;
  a = a + b;
  int x = stoi(a);
  int n = pow(x, 0.5);
  if(x == n * n) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int i;
		int z=0;
		
		for(i=a;i<=b;i++){
			if(c%i==0){
				z++;
			}
			
		}
		System.out.println(z);

	}

}



Measured memory_bytes: 26316
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 500009;
const int MOD = 1e9 + 7;
int64_t fac[maxn],inv[maxn];
int64_t pw(int64_t a,int64_t b){
  int64_t c=1;
  while(b){
    if(b&1ll)c=c*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return c;
}
int64_t C(int a,int b){
  return fac[a]*inv[b]%MOD*inv[a-b]%MOD;
}
int64_t A(int a,int b){
  return fac[a]*inv[a-b]%MOD;
}
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,m;cin>>n>>m;
  fac[0]=1;
  for(int i=1;i<maxn;++i)fac[i]=fac[i-1]*i%MOD;
  inv[maxn-1]=pw(fac[maxn-1],MOD-2);
  for(int i=maxn-2;i>=0;--i)inv[i]=inv[i+1]*(i+1)%MOD;
  int64_t res=0;
  for(int i=0;i<=n;++i){
    if(i&1){
      (res+=MOD-C(n,i)*A(m-i,n-i)%MOD)%=MOD;
    }else{
      (res+=C(n,i)*A(m-i,n-i)%MOD)%=MOD;
    }
  }
  res=res*A(m,n)%MOD;
  cout<<res;
  return 0;
}
//2020.06.27 20:41:25


Measured memory_bytes: 11464
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e12
#define MAXN 100005
#define MOD 1000000007
bool dp[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,K; cin>>N>>K;
    
    ll arr[N];
    for(ll i=0;i<N;++i)
    {
        cin>>arr[i];
    }
    
    for(ll i=1;i<=K;++i)
    {
        ll flag = 0;
        for(ll j=0;j<N;++j)
        {
            if(i >= arr[j] && !dp[i - arr[j]])
            {
                flag = 1;
                break;
            }
        }
        
        if(flag)
            dp[i] = 1;
    }
    
    
    if(dp[K])
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
}

Measured memory_bytes: 3748
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

ll n, ans;

int main(){
	scanf("%lld", &n);
	for(ll i = 1; i * i <= n; i++){
		if(!(n % i)){
			ll s = i - 1;
			if(s && n / s == n % s)
				ans += s;
			s = n / i - 1;
			if(s && n / s == n % s && s !=i)
				ans += s;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



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

vector<bool> prime(1300000, true);

int main(){
    prime[0]=prime[1]=false;
    for(int i=2; i*i<1300000; i++){
        if(prime[i]){
            for(int j=2; i*j<1300000; j++){
                prime[i*j] = false;
            }
        }
    }
    
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        int min=n,max=n;
        while(!prime[min]) min--;
        while(!prime[max]) max++;
        cout << max-min << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define endl 			"\n"
#define max_3(x,y,z)   max(x,max(y,z))
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define w(x)            int x; cin>>x; while(x--)
////////////////////
void iPhone() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
//////////////////
//////////////////
int32_t main()
{
	//////////////////////////////////////input/////
	//iPhone();//////////////////////////////fast/////
	//////////////////////////////////////output////
	fast
	/////////////////////////////////////////////////
	int n;
	cin >> n;
	int dp[n + 1][4];
	int a, b, c;
	cin >> a >> b >> c;
	dp[1][1] = a;
	dp[1][2] = b;
	dp[1][3] = c;
	for (int i = 2; i <= n; i++) {
		cin >> a >> b >> c;
		dp[i][1] = a + max(dp[i - 1][3], dp[i - 1][2]);
		dp[i][2] = b + max(dp[i - 1][1], dp[i - 1][3]);
		dp[i][3] = c + max(dp[i - 1][2], dp[i - 1][1]);
	}
	int ans = max_3(dp[n][1], dp[n][2], dp[n][3]);
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int n=1e5+10;
bitset<n> isprime;
vector<int>answer;
void sieve()
{
    isprime[0]=isprime[1]=0;
    for(int p=2; p<=n; ++p)
        if(isprime[p])
            for(int m=2*p; m<n; m+=p)
                isprime[m]=0;

}


int the2017ers[n];
void is2017()
{
    int sum=0;
    for (int p=1; p<=n; p++)
    {
        if (isprime[p]&&isprime[(p+1)/2]){
                sum++;

        }
        the2017ers[p]=sum;

    }

}

int main()
{
    isprime.set();
    sieve();
    is2017();
    int tc,l,r;
    cin>>tc;
    while(tc--)
    {
        cin>>l>>r;
        cout<<the2017ers[r]-the2017ers[l-1]<<endl;
    }


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
double deg(double d){
    return M_PI * d /180;
}
double nijou(double f){
    return f * f;
}
int main(){
   int a,b,h,m;
   cin >> a >> b >> h >> m;
   printf("%.21f\n",sqrt(nijou(a*cos(deg(30.0 * h + m/2.0))-b*cos(deg(6 * m))) 
   + nijou(a*sin(deg(30.0 * h + m/2.0))-b*sin(deg(6 * m)))));
 
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,k,l[50]; cin>>n>>k;
	rep(i,n) cin>>l[i];

	sort(l,l+n);

	cout<<accumulate(l-k+n,l+n,0)<<endl;

	return 0;
}


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

int main(void) {
    int x, y, z;
    std::scanf("%d %d %d", &x, &y, &z);
    std::printf("%d\n", (x - z) / (y + z));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h, w;
string a[1005];
long long dp[1005][1005];
long long MOD = 1e9+7;

long long recur(int i , int j){
    if(i == h-1 && j == w-1) return 1;
    if(dp[i][j] != -1) return dp[i][j];
    if(i < h && j < w){
        if(i == h-1){
            if(a[i][j+1] == '#'){
                return 0;
            }else{
                return dp[i][j] = recur(i,j+1);
            }
        }else if(j == w-1){
            if(a[i+1][j] == '#'){
                return 0;
            }else{
                return dp[i][j] = recur(i+1,j);
            }
        }else if(a[i+1][j] != '#' && a[i][j+1] != '#'){
            return dp[i][j] = (recur(i+1,j) + recur(i,j+1)) % MOD;
        }else if(a[i+1][j] == '#' && a[i][j+1] == '#'){
            return 0;
        }else if(a[i+1][j] == '#'){
            return dp[i][j] = recur(i,j+1);
        }else if(a[i][j+1] == '#'){
            return dp[i][j] = recur(i+1,j);
        }
    }
}


int main(){
    cin>>h>>w;
    memset(dp,-1,sizeof dp);
    for(int i = 0; i < h; i++){
        cin>>a[i];
    }
    cout<<recur(0,0) % MOD;
}


Measured memory_bytes: 9344
from math import log10


def main():
    N = int(input())

    index = int(log10(N))

    count = 0
    for i in range(1, index + 1, 2):
        count += 10**i - 10**(i - 1)

    if index % 2 == 0:
        count += N - 10**index + 1

    print(count)


if __name__ == '__main__':
    main()


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

string s, t;

void insertionSort(string& a, int n) {
  char v;
  int j;
  for (int i = 0; i < n; i++) {
    v = a[i];
    j = i - 1;
    while (j >= 0 && int(a[j])> int(v)) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
  }
}

int main() {

  cin >> s >> t;

  insertionSort(s, s.length());
  insertionSort(t, t.length());
  reverse(t.begin(), t.end());

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int id[1000];
int p[1000];
int q[1000];
int r[1000];
int main() {
  int n;
  while(cin>>n,n) {
    REP(i,n) cin>>id[i]>>p[i]>>q[i]>>r[i];
    int P,Q,R,C;
    cin>>P>>Q>>R>>C;
    bool f = 0;
    REP(i,n) {
      int cal = p[i]*4+q[i]*9+r[i]*4;
      if (p[i] <= P && q[i] <= Q && r[i] <= R && cal <= C){
        f = 1;
        cout << id[i] << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

int a[100001];

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    if(2*n>m) cout << m/2;
    else cout << n+(m-n*2)/4;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
const long long mod=1000*1000*1000+7;
const int nmax=100005;
long long fact[nmax],a[nmax],s[nmax];
long long ans,ad;
int n,i;
long long expo(long long A,int B)
{
    long long ret=1,p2=A;
    for(int p=0;p<=30;p++)
    {
        if(((1<<p)&B))
        ret=(1LL*ret*p2)%mod;
       p2=(1LL*p2*p2)%mod;
    }
    return ret;
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    fact[0]=1;
    for(i=1;i<=n;i++)
        fact[i]=(1LL*fact[i-1]*i)%mod;
    for(i=2;i<=n;i++)
        s[i]=(s[i-1]+1LL*expo(i,mod-2))%mod;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ans=(ans+1LL*s[i]*a[i])%mod;
        ans=(ans+1LL*s[n-i+1]*a[i])%mod;
        ans=(ans+a[i])%mod;
    }
    cout<<(ans*fact[n])%mod;
    return 0;
}


Measured memory_bytes: 2560
S = input()
T = '01'*len(S)
ans = 10**8
ctr = 0
for s , t in zip(S, T):
    if t != s:
        ctr += 1
ans = min(ans, ctr)
T = '10'*len(S)
ctr = 0
for s , t in zip(S, T):
    if t != s:
        ctr += 1
ans = min(ans, ctr)
print(ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=1e5+3;
vector<int>v[N];
string s,p,t,ans[N];
map<pi,int>mp;
int main()
{
    ft
    int i,j,n,k,m,l,r;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>l>>r;
        v[l].pb(r);
        mp[{l,r}]=i+1;
    }
    for(i=1; i<=n; i++)
    {
        sort(v[i].begin(),v[i].end());
        int sz=v[i].size();
        if(sz>0)
        {
            for(int z=0; z<sz; z++)
            {
                s.clear();
                p.clear();
                l=0;
                r=i;
                while(r!=0)
                {
                    s+=((r%10)+48);
                    r/=10;
                    l++;
                }
                for(k=0; k<(6-l); k++)
                {
                    p+='0';
                }
                reverse(s.begin(),s.end());
                t=p+s;
                l=0;
                r=z+1;
                s.clear();
                p.clear();
                while(r!=0)
                {
                    s+=((r%10)+48);
                    r/=10;
                    l++;
                }
                for(k=0; k<(6-l); k++)
                {
                    p+='0';
                }
                reverse(s.begin(),s.end());
                int cc=mp[{i,v[i][z]}];
                ans[cc]=t+p+s;
            }
        }
    }
    for(i=1;i<=m;i++)
    {
        cout<<ans[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

void solve()
{
	ll n,m,k;
	cin>>n>>m>>k;
	vector<ll> a(n+1), b(m+1);
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		a[i] += a[i-1];
	}
	for (int i=1; i<=m; i++) {
		cin>>b[i];
		b[i] += b[i-1];
	}
	ll ans = 0;
	ll j=m;
	for (int i=0; i<=n; i++) {
		if (a[i]>k) {
			break;
		}
		while (b[j]+a[i]>k) {
			j--;
		}
		ans = max(ans, j+i);
	}
	cout << ans << "\n";
}

int main()
{
	fastIO;
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.gir","r",stdin);freopen ("myfile.cik","w",stdout);
#define mod 1000000007
using namespace std;

double n,ar[N],x;


int main()
{
    // fast;
    // cin>>n;
    scanf("%lf %lf",&n,&x);
    printf("%lf",n/x);
}
 

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	vector<char>data(3);
	int ans = 700;
	for (int i = 0; i < 3; i++) {
		cin >> data[i];
		if (data[i] == 'o') {
			ans += 100;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
N, M, C = gets.split().map(&:to_i)
b = gets.split().map(&:to_i)
count = 0

N.times do
    a = gets.split().map(&:to_i)
    count += 1 if (0..M-1).inject(0) {|result, i|result + a[i] * b[i] } + C > 0
end

p count


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>

//#define PI 3.141592653589

using namespace std;

map<string, int> ninzu;

int main()
{
	ninzu["A"] = 0;
	ninzu["B"] = 0;
	ninzu["AB"] = 0;
	ninzu["O"] = 0;
	
	int bangou;
	char kanma;
	string type;
	
	
	//scanf("%d%s", &bangou, &type);
	//cout << bangou << " " << type << endl;
	
	//while (~scanf("%d,%s\n", &bangou, &type))
	while (cin >> bangou >> kanma >> type)
	{
		//cout << type << endl;
		ninzu[type]++;
	}
	
	
	
	cout << ninzu["A"] << endl;
	cout << ninzu["B"] << endl;
	cout << ninzu["AB"] << endl;
	cout << ninzu["O"] << endl;
	
	
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <algorithm>

using namespace std;

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

    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        b[i]=0;
        c[i]=0;
    }

//    cerr << N << endl;
    for (int i = N-1; i >=0 ; i--)
    {
  //      cerr << i << endl;
        c[i]=0;
        if(b[i]!=a[i]){
            c[i]=1;
            vector<int> ret;

            for(int j=1 ; j*j<=i+1 ; ++j)
            {
                if((i+1)%j == 0)
                {
                    ret.push_back(j);
                    if(j!=1 && j*j!=(i+1))
                    {
                        ret.push_back((i+1)/j);
                    }
                }
            }

            // cerr << i+1 << ": ";
            for(auto j:ret){
                if(j<i+1) b[j-1] = 1 - b[j-1];
                // cerr << j << " ";
            }
            // cerr << endl;
            // for (int j = 0; j < sqrt(i+1)-1; j++)
            // {
            //     if( ((i+1)%(j+1)) == 0 ){
            //         b[j] = 1 - b[j];
            //     }
            // }
        }
        // for (int j = 0; j <N ; j++)
        // {
        //     cerr << b[j] << " ";
        // }
        // cerr << endl;
    }

    int cnt =0;
    for (int i = 0; i <N ; i++)
    {
        if(c[i]==1){
            cnt++;
        }
    }
    cout << cnt << endl;
    for (int i = 0; i <N ; i++)
    {
        if(c[i]==1){
            cout << i+1 << " ";
        }
    }
    cout << endl;  
    return 0;
}


Measured memory_bytes: 3200
unittest
{
	assert( [ "5", "3 1 4 1 5", "3", "5 4 3" ].parse.expand.solve == "YES" );
	assert( [ "7", "100 200 500 700 1200 1600 2000", "6", "100 200 500 700 1600 1600" ].parse.expand.solve == "NO" );
	assert( [ "1", "800", "5", "100 100 100 100 100" ].parse.expand.solve == "NO" );
	assert( [ "15", "1 2 2 3 3 3 4 4 4 4 5 5 5 5 5", "9", "5 4 3 2 1 2 3 4 5" ].parse.expand.solve == "YES" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto ds = input.front.split.to!( long[] );
	input.popFront;
	input.popFront;
	auto ts = input.front.split.to!( long[] );
	return tuple( ds, ts );
}

auto solve( long[] ds, long[] ts )
{
	ds.sort();
	ts.sort();
	while( !ds.empty && !ts.empty )
	{
		if( ds.front == ts.front ) ts.popFront;
		ds.popFront;
	}
	return ( ts.empty ) ? "YES" : "NO";
}


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

int main() {
	// your code goes here
	int a,b;
	cin >> a >> b;
	if(a<=8){
		if(b<=8){
			cout << "Yay!";
		}
		else cout << ":("; 
	}
	else
	cout << ":(";
	
	
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}

Measured memory_bytes: 256