akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[55][55][1305];

int main() {
  int n, score;
  cin >> n >> score;
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(j,i+1)rep(k,score+1) {
      {
        int nj = j;
        dp[i+1][nj][k+nj] += dp[i][j][k];
      }
      {
        int nj = j+1;
        dp[i+1][nj][k+nj] += dp[i][j][k];
      }
      {
        int nj = j;
        mint x = j*2;
        dp[i+1][nj][k+nj] += dp[i][j][k]*x;
      }
      if (j >= 1) {
        int nj = j-1;
        mint x = j*j;
        dp[i+1][nj][k+nj] += dp[i][j][k]*x;
      }
    }
  }
  mint ans = dp[n][0][score/2];
  if (score&1) ans = 0;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 31104
using System;

namespace AOJ
{
    class Program1b
    {
        static void Main(string[] args)
        {
            string str = null;
            char ch = '\0';

            while (ch != ' ') 
            {
                int a = Console.Read();
                ch = (char)a;
                if( ch != ' ')
                {
                    str += ch;
                }
                
            } 

            int b = int.Parse(str);         //???????????§?????´??°??????b???????´???????

            

            str = null;
            while (ch != '\n')
            {
                int a = Console.Read();
                ch = (char)a;
                if (ch != '\n')
                {
                    str += ch;
                }

            }

             int c = int.Parse(str);

            Console.WriteLine(b*c + " " + (b*2 + c*2) );
        }
    }
}

Measured memory_bytes: 9084
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    long long int a,b;
    cin>>a>>b;
    if(b/2019-a/2019>=1) cout<<0;
    else{
        long long int m=1000000000;
        for(long long int i=a;i<=b-1;i++){
            for(long long int j=a+1;j<=b;j++)
            if((j*i)%2019<m) m=(j*i)%2019;
        }
    cout<<m<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans = 700;
  if (S[0] == 'o')
    ans += 100;
  if (S[1] == 'o')
    ans += 100;
  if (S[2] == 'o')
    ans += 100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3

def string_two_numbers_spliter():
    x, y = [int(i) for i in input().split()]
    return x, y


def swap_two_numbers_asc(x, y):
    x, y = y, x
    return x, y


def main():
    while True:
        x, y = string_two_numbers_spliter()
        if x == 0 and y == 0:
            break
        if x > y:
            x, y = swap_two_numbers_asc(x, y)
        print('%d %d' % (x, y))


if __name__ == '__main__':
    main()

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

int main()
{
	int N,ans;
	ans = 0;
	cin >> N;

	int i = 1;
	while(i <= N){
		if (i >= 1 && i <= 9) ans++;
		else if(i >= 100 && i <= 999) ans++;
		else if (i >= 10000 && i <= 99999) ans++;
		i++;
	}
	cout << ans << endl;
}

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

typedef long long ll;

void solve(long long N, long long K, std::vector<long long> A) {
  ll tmp = N - K;
  tmp = 1 + tmp / (K - 1) + ((tmp % (K - 1) == 0) ? 0 : 1);
  cout << tmp << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll waru2(ll i)
{
    if(i%2 == 0) return waru2(i/2) + 1;
    else return 0;
}

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

    vector<ll> a(N);
    ll ans = 0;
    rep(i,N)
    {
        cin >> a[i];
        if(a[i]%2==0) ans += waru2(a[i]);
    }
    cout << ans << endl;
}


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

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int h[n],dp[n];
    for (int i=0;i<n;i++) scanf("%d",&h[i]);
    for (int i=1;i<n;i++) dp[i]=-1;
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for (int i=2;i<n;i++) for (int j=1;j<=k;j++) {
        if (i-j<0) break;
        if (dp[i]==-1) dp[i]=abs(h[i]-h[i-j])+dp[i-j];
        else dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
    }
    printf("%d\n",dp[n-1]);
    return 0;
}


Measured memory_bytes: 1024
#include "stdio.h"

int main(void)
{
    char inp[101];
    unsigned char flag = 1; 
    unsigned char i = 0;
	
	scanf("%s", inp);
	
	while (inp[i] != '\0') {
	    if (i % 2 == 1) {
	        if ((inp[i] == 'L') || (inp[i] == 'U') || (inp[i] == 'D')  ) {
	            ;
	        } else {
	            flag = 0;
	            break;
	        }
	    } else {
	        if ((inp[i] == 'R') || (inp[i] == 'U') || (inp[i] == 'D')  ) {
	            ;
	        } else {
	            flag = 0;
	            break;
	        }
	    }
      
      i++;
	}
	
	if ( flag == 1) {
	    printf("Yes\n");
	} else {
	    printf("No");
	}
 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define all(x) (x).begin(),(x).end()     // 昇順ソート
#define rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    FastIO;
    int A[9];
    bool A_m[9];
    rep(i, 9){
        cin >> A[i];
        A_m[i] = false;
    }
    int N, b;
    cin >> N;
    rep(i, N){
        cin >> b;
        rep(j, 9){
            if (A[j] == b) {
                A_m[j] = true;
                break;
            }
        }
    }
    bool ok = false;
    rep(i, 3){
        if (A_m[i*3] && A_m[i*3+1] && A_m[i*3+2]){
            ok = true;
            break;
        }
        if (A_m[i] && A_m[i+3] && A_m[i+6]){
            ok = true;
            break;
        }
    }
    if (A_m[0] && A_m[4] && A_m[8]) ok = true;
    if (A_m[2] && A_m[4] && A_m[6]) ok = true;

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = [int(input()) for i in range(n)]

max_value = max(*p)
taken_max = False
sum = 0

for v in p:
    if v == max_value and not taken_max:
        taken_max = True
        sum += v / 2
    else:
        sum += v

print(int(sum))


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

int main(){
 double a,b,sum;
  string c;
  cin>>a;
 sum=0;
  for(int i=0;i<a;i++){
    cin>>b>>c;
    if(c=="BTC"){
     b*=380000;
    }
    sum+=b;
  }
       cout<<sum<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#入力
n = int(input())

#処理
if n%10 == 1:
    a = 9
else:
    a = 1

n = n//10

if n%10 == 1:
    b = 9
else:
    b = 1

n = n//10

if n == 1:
    c = 9
else:
    c = 1

ans = 100*c + 10*b + a

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 1e5+5;
int n;
vector<int> a;
int dp[N];

bool win(int v) {
  if (dp[v] == 0) {
    dp[v] = -1;
    //goes to a losing state
    for (int x : a) {
      int to = v-x;
      if (to >= 0) {
        if (!win(to)) {
          dp[v] = 1;
          break;
        }
      }
    }
  }
  return dp[v] == 1;
}

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  int k;
  cin >> n >> k;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (win(k)) {
    cout << "First\n";
  } else {
    cout << "Second\n";
  }

  return 0;
}



Measured memory_bytes: 5376
// NK
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
	ll n,k; cin>>n>>k;

	const ll INF = 1e18;
	ll dp[n];
	for (int i=0; i<n; i++)
		dp[i]=INF;
	
	ll a[n];
	for (int i=0; i<n; i++)
		cin>>a[i];

	dp[0]=false;
	dp[1]=abs(a[0] - a[1]);

	for (ll i=2; i<n; i++){
		for (ll j=i-1; ~j && j>=i-k; j--){
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	cout<<dp[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define __m int mid=(l+r)/2;
template<class T>
inline bool read(T &num)  
{
       char in;bool IsN=false;
       while(in=getchar(),in!='-'&&(in<'0'||in>'9'))if(in==EOF)return false;
       in=='-'?(IsN=true,num=0):num=in-'0';
       while(in=getchar(),in>='0'&&in<='9')num=num*10+in-'0';
       return IsN?num=-num:num,true;
}

const int maxn =2e5+7;
const int inf  =2e9+7;
const int mod  =1e9+7;

int need[maxn];
map<int,int>have;
set<int>num;
int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        have[temp]++;
        num.insert(temp);
    }
    if(num.size()<=k)
        cout<<0<<endl;
    else 
    {
        map<int,int>::iterator p;
        int pos=0;
        for(p=have.begin();p!=have.end();p++)
            need[pos++]=p->second;
        sort(need,need+pos);
        int ans=0;
        for(int i=0;i<num.size()-k;i++)
            ans+=need[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
const int N = 200001;
const i64 B = 10;
int n;
i64 p, r;
string s;
i64 e[N];
i64 a[N];
int c[N];

int main() {
  cin >> n >> p >> s;
  reverse(ALL(s));
  e[0] = 1;
  for (int i = 1; i <= n; ++i) {
    e[i] = (e[i - 1] * B) % p;
  }
  for (int i = 0; i < n; ++i) {
    a[i + 1] = (a[i] + (s[i] - '0') * e[i]) % p;
  }
  for (int i = n - 1; i >= 0; --i) {
    ++c[a[i + 1]];
    if (p == 2) {
      if ((s[i] - '0') % 2 == 0) {
        r += n - i;
      }
    } else if (p == 5) {
      if ((s[i] - '0') % 5 == 0) {
        r += n - i;
      }
    } else {
      r += c[a[i]];
    }
  }
  cout << r << '\n';
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t{},n{};
    string p;
    cin>>t>>n;
    std::vector<string> v(t) ;
    for(int i=0;i<t;i++){
        cin>>v[i];
    }
    //cout<<p<<endl;
    sort(v.begin(),v.end());
    for(int i=0;i<t;i++){
        cout<<v[i];
    }
    cout<<p<<endl;
    return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
struct T {
	int to, nxt, v;
} way[maxn << 1];
int h[maxn], num;
inline void link(int x,int y,int v) {
	way[++num] = {y, h[x], v}, h[x] = num;
	way[++num] = {x, h[y], v}, h[y] = num;
}
int n;
int size[maxn], max_son[maxn];
inline void dfs0(int x,int fa = 0) {
	size[x] = 1;
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != fa) {
		dfs0(way[i].to, x);
		size[x] += size[way[i].to];
		if(size[way[i].to] > max_son[x])
			max_son[x] = size[way[i].to];
	}
	max_son[x] = std::max(max_son[x], n - size[x]);
}
ll ans;
inline void dfs1(int x,int fa = 0) {
	size[x] = 1;
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != fa) {
		dfs1(way[i].to, x);
		size[x] += size[way[i].to];
		ans += (ll) size[way[i].to] * way[i].v << 1;
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		link(a, b, c);
	}
	dfs0(1);
	int root = std::min_element(max_son + 1, max_son + n + 1) - max_son;
	dfs1(root);
	if(std::count(max_son + 1, max_son + n + 1, max_son[root]) > 1) {
		for(int i = h[root];i;i = way[i].nxt) {
			if(max_son[way[i].to] == max_son[root]) {
				ans -= way[i].v;
			}
		}
	} else {
		int min_cost = 1e9;
		for(int i = h[root];i;i = way[i].nxt) {
			min_cost = std::min(min_cost, way[i].v);
		}
		ans -= min_cost;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;

int main(){
	int N, L, R;
	cin >> N;
	vector<pair<int, int>> sg(N + 1);
	for (int i = 0;i < N;i++) {
		cin >> L >> R;
		sg[i] = { L + 100001,R + 100001 };
	}
	sg[N] = { 100001,100001 };
	vector<int> AC(200010, 0), WA = AC;
	for (int i = 0;i <= N;i++) {
		AC[sg[i].second]++;
		WA[sg[i].first - 1]++;
	}
	for (int i = 0;i < 200009;i++) {
		AC[i + 1] += AC[i];
		WA[200008 - i] += WA[200009 - i];
	}
	ll ans = 0;
	for (int i = 0;i < 200009;i++) {
		ans += (ll)min(AC[i], WA[i]);
	}
	cout << ans * 2 << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n, k;
    string s;
    cin >> n;
    cin >> s;
    cin >> k;

    char save = s[k-1];
    for(int i = 0; i < n; i++){
        if(s[i] == save){
            cout << save;
        }else{
            cout << "*";
        }
        
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n;
cin>>n;
int v[n][3];
int dp[n][3]={0};
for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
        cin>>v[i][j];
    }
}
//cout<<v[0][0]<<endl;
dp[0][0]=v[0][0];
dp[0][1]=v[0][1];
dp[0][2]=v[0][2];
for(int i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+v[i][2];
}
//cout<<dp[0][2]<<endl;
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

return 0;
}

Measured memory_bytes: 2560
'use strict'

function main(input) {
  input = input.split('\n');
  const NK = input[0].split(' ').map(n => parseInt(n));
  const A = input[1].split(' ').map(n => parseInt(n));
  const countBucket = [...Array(NK[0]+1)].fill(0);

  for (const num of A) {
    countBucket[num] += 1;
  }
  console.log(countBucket.sort((a, b) => b - a).slice(NK[1]).reduce((a, b) => a + b));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 42252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,-1,sizeof(i));
#define pb push_back
const ll mod=998244353;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	while(cin >> n){
		vector<ll>v1,v2;
		f(3){
			ll add;
			cin >> add;
			v1.pb(add);
		}
		f(3){
			ll add;
			cin >> add;
			v2.pb(add);
		}
		vector<pair<ll,ll> >t1,t2;
		f(3){
			if(v1[i]>v2[i]){
				t2.pb({v2[i],v1[i]});
			}
			else if(v1[i]<v2[i]){
				t1.pb({v1[i],v2[i]});
			}
		}
		if(!t1.size()&&!t2.size()){
			cout<<n<<endl;
			exit(0);
		}
		if(!t1.size()){
			for(auto i:t2){
				t1.pb(i);
			}
			t2.clear();
		}
		if(t1.size()==3){
			ll mx = n;
			for(int i=0 ; i*t1[0].first<=n;i++){
				for(int j=0;j*t1[1].first+i*t1[0].first<=n;j++){
					ll left = n-i*t1[0].first-j*t1[1].first;
					ll now = i*t1[0].second+j*t1[1].second+left/t1[2].first*t1[2].second+left%t1[2].first;
					mx = max(mx,now);
				}
			}
			cout<<mx<<endl;
			exit(0);
		}
		if(t1.size()==2){
			ll mx = n;
			for(int i=0 ; i*t1[0].first<=n;i++){
				ll left = n-i*t1[0].first;
				ll now = i*t1[0].second+left/t1[1].first*t1[1].second+left%t1[1].first;
				if(t2.size()){
					ll nxt = now/t2[0].first;
					now += nxt * (t2[0].second-t2[0].first);
				}
				mx = max(mx,now);
			}
			cout<<mx<<endl;
			exit(0);
		}
		if(t1.size()==1){
			ll nxt = n/t1[0].first;
			n += nxt * (t1[0].second-t1[0].first);
			ll mx = n;
			if(t2.size()==2){
				for(int i=0 ; i*t2[0].first<=n;i++){
					ll left = n-i*t2[0].first;
					ll now = i*t2[0].second+left/t2[1].first*t2[1].second+left%t2[1].first;
					mx = max(mx,now);
				}
			}
			else if(t2.size()){
				nxt = n/t2[0].first;
				n += nxt *(t2[0].second-t2[0].first);
				mx = n;
			}
			cout << mx << endl;
			exit(0);
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    if (K % 2 == 0) {
        int e = K/2;
        int o = K/2;
        cout << e * o << endl;
    } else if (K % 2 == 1) {
        int e = K/2;
        int o = (K+1)/2;
        cout << e * o << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a;i<=b;++i)
#define UF(i,a,b) for(register int i=a;i>=b;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
typedef long long LL;
typedef long long ll;
typedef unsigned long long ULL;
typedef unsigned long long ull;
inline int r(int &x)
{
    int f=1;x=0;
    char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
    return x*=f;
}
inline ll r(ll &x)
{
    ll f=1ll;x=0ll;
    char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1ll;
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(ll)(c-'0');
    return x*=f;
}
inline ull r(ull &x)
{
    x=0ull;
    char c=getchar();
    for(;!isdigit(c);c=getchar());
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(ull)(c-'0');
    return x;
}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define mp(a,b) make_pair(a,b)
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int m,n;
int main()
{
	r(n),r(m);
	UF(i,m/n,1) if(m%i==0) {printf("%d\n",i);return 0;}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	string S;
	cin >> S;
	S.at(3) = '8';
	cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[200005],B[200005],C[200005],ans,le,ri,mid;
map <long long,long long> mp;
int main() {
           cin>>n>>m;
           for(long long i=1;i<=m;i++) {
                      cin>>a;
                      b+=a;
           }
           if(b>n) cout<<-1;
           else cout<<n-b;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>

using namespace std;

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

	string s;
	cin >> s;

	for (int i = 1; i <= s.size(); i++)
		if (i & 1)
			cout << s[i - 1];
}

Measured memory_bytes: 592
N, K = map(int, input().split())
S = input()
lens = []

l = 1
for i in range(1, N):
  if S[i] != S[i-1]:
    lens.append(l)
    l = 1
  else:
    l += 1
lens.append(l)

ans = 0
ans += N - len(lens) - 1
ans += min(K*2+1, len(lens))

print(ans)


Measured memory_bytes: 3956
var s;
var x = [['m', 0]];

function main(){
	s = scan_string().split('');
	var ans = true;
	rep(s.length, function(i){
		if(x.length === 0){
			ans = false;
			return false;
		}
		if(s[i] === 'm'){
			if(x[x.length - 1][1] > 0){
				ans = false;
				return false;
			}
			++x[x.length - 1][1];
			x.push(['m', 0]);
		}
		else if(s[i] === 'e'){
			if(x[x.length - 1][0] !== 'm'){
				ans = false;
				return false;
			}
			x[x.length - 1] = ['e', 0];
		}
		else{
			if(x[x.length - 1][0] !== 'e'){
				ans = false;
				return false;
			}
			x.pop();	
		}
	});
	if(x.length !== 1 || x[0][0] !== 'm'){
		ans = false;
	}
	print(ans ? 'Cat' : 'Rabbit');
}

function rep(a, b, c, u){
	if(c === u){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}

var input = '';

function scan(){
	return +input.pop();
}
function scan_string(){
	return input.pop();
} 
function print(val){
	console.log(val);
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/).reverse();
	main();
});

Measured memory_bytes: 16064
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000



int main(){
    
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	vector<int> Y(0);
	
    for(int i=1;i<=N;i++){
		if(N%i==0&&(N/i)%2==1){
			Y.push_back(i);
		}
	}
	map<int,int> mp;
	for(int i=0;i<Y.size();i++){
		string T = S.substr(0,Y[i]);
		int a = 0;
		for(int j=0;j<T.size();j++){
			a = mod(a*2);
			if(T[j]=='1')a = mod(a+1);
		}
		string t = "";
		for(int j=0;j<T.size();j++){
			if(T[j]=='0')t+='1';
			else t+='0';
		}
		bool f = true;
		for(int j=0;j<S.size()/Y[i];j++){
			string tt = S.substr(j*Y[i],Y[i]);
			if(j%2==0){
				if(T>tt){
					f=false;
					break;
				}
				if(T<tt)break;
			}
			else{
				if(t>tt){
					f=false;
					break;
				}
				if(t<tt)break;
			}
		}
		if(f)a = mod(a+1);
		
		for(auto x:mp){
			if(Y[i]%x.first==0){
				a = mod(a - x.second);
			}
		}
		mp[Y[i]] = a;
	}
	
	int ans = 0;
	for(auto a:mp){
		int b = mod(a.first*a.second);
		ans = mod(ans+b);
	}
	
	ans=mod(ans*2);
	
	cout<<ans<<endl;
	
    
    return 0;
}



Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		int n1 = n % 10;
		int n10 = (n - n1) % 100/10;
		int n100 = (n - n1 - n10 * 10) % 1000/100;
		int n1000 = n / 1000;

		if ((n1 == n10 && n1 == n100)
				|| (n10 == n100 && n10 == n1000)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
typedef long long ll;

#define MXN 200005
int N, Q;
int A[MXN];
vector<pii> VQ;

int fall(int qu, int po)
{
    if(qu==Q)return 0;
    if(VQ[qu].f!=A[po])return fall(qu+1, po);
    if(VQ[qu].s==0)
    {
        if(po==1)return -1;
        else return fall(qu+1,po-1);
    }
    else
    {
        if(po==N)return 1;
        else return fall(qu+1,po+1);
    }
}

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

    cin>>N>>Q;
    string str;
    cin>>str;
    FOR(i,1,N)A[i]=str[i-1]-'A';
    int ch, di;
    FOR(i,1,Q)
    {
        cin>>str;
        ch = str[0]-'A';
        cin>>str;
        di = (str[0]=='L') ? 0 : 1;
        VQ.pb( mkp(ch, di) );
    }
    int rm, lm;
    int lo, hi;
    lo=0,hi=N+1;
    while(lo+1<hi)
    {
        int md = (lo+hi)/2;
        if( fall(0,md)==-1 )lo=md;
        else hi = md;
    }
    rm = lo;

    lo=0,hi=N+1;
    while(lo+1<hi)
    {
        int md = (lo+hi)/2;
        if( fall(0,md)==1 )hi=md;
        else lo = md;
    }
    lm = hi;

    cout<<N-rm-(N+1-lm)<<'\n';

    return 0;
}



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

typedef pair<int, int> P;
int ans[200005];
int par[400005];    // Union-Find(2倍用意しておく)

void init(int n){
    for(int i = 0; i < 2 * n; ++i){
        par[i] = i;
    }
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)      return;
    
    par[y] = x;
    return;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k, l;
    cin >> n >> k >> l;
    map<P, int> m;
    init(n);
    for(int i = 0; i < k; ++i){     // road
        int p, q;
        cin >> p >> q;
        --p;
        --q;
        unite(p, q);
    }
    for(int i = 0; i < l; ++i){     // rail
        int r, s;
        cin >> r >> s;
        --r;
        --s;
        unite(r + n, s + n);
    }
    
    for(int i = 0; i < n; ++i){
        ++m[P(find(i), find(i + n))];
    }
    
    for(int i = 0; i < 2 * n; ++i){
        cerr << par[i] << " ";
    }
    cerr << endl;
    for(auto it : m){
        cerr << it.first.first << " " << it.first.second << " " << it.second << "\n";
    }
    
    for(int i = 0; i < n; ++i){
        ans[i] = m[P(find(i), find(i + n))];
    }
    
    for(int i = 0; i < n; ++i){
        cout << ans[i] << ((i == n - 1) ? "\n" : " ");
    }
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;
ll arr[10000001] = {0};

/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}

void findDivisors(ll n, ll div[]) 
{ 
  
   
    for (ll i = 1; i <= n; i++) { 
  
       
        for (ll j = 1; j * i <= n; j++) 
            div[i*j]++; 
    } 
  
  
   
} 
int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j,n;
	cin>>n;

	findDivisors(n,arr);
	ll sum =0;
	for(i=1;i<=n;i++)
	{
		sum += i*arr[i];
	}
	cout<<sum<<endl;
	
	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 81744
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

typedef long long lli;

static const lli M = 1000000007;

main(){
  lli n, t, d[100000];
  cin >> n >> t;
  for(int i=0;i<n;i++) cin >> d[i];
  sort(d, d+n);
  lli ans = 1;
  queue<lli> q;
  for(int i=0;i<n;i++){
    while(!q.empty() && q.front() < d[i] - t) q.pop();
    ans = ans * (q.size() + 1) % M;
    q.push(d[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2588
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int k, n;
    cin>>k>>n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    int ans = INT_MIN;
    for(int i = 0; i < n ; i++){
        if(i == n-1){
            ans = max(ans, k - a[i] + a[0]);
        }else
        {
            ans = max(ans, abs(a[i] - a[i+1]));
        }
        // cout<<i<<" "<<ans<<" "<<a[i]<<endl;
    }
    cout<<k-ans;
    return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    int n;
    cin >> n;

    ll power = 1;
    for ( int i = 1; i <= n; i++ ) {
        power = (power * i) % MOD;
    }

    cout << power << endl;

    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) cin >> v[i].second >> v[i].first;
  sort(v.rbegin(), v.rend());

  bool can = true;
  ll now = v[0].first;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first < now) {
      now = v[i].first;  // 待つ
    }
    now = now - v[i].second;  // さっと仕事を終わらせる
  }
  if (now < 0) can = false;

  cout << ((can) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1792
a =int(input())
list = []
b = 1
for i in range(2,44):
    list.append(b)
    b = b + i
n = 0
e = 0
k = 0
for i in range(2,1000000):
    if (a % i == 0):
        warikaisi = True
        while(warikaisi):
            if a % i == 0:
                list.append(i)
                a = a / i
                e = e + 1
                if (e == list[k]):
                    n = n + 1
                    k = k + 1
            else:
                e = 0
                k = 0
                warikaisi = False
if (a >= 1000000):
    n = n + 1
print(n)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int gcd(int a, int b){if (b == 0) return a; return gcd(b, a % b);}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;
    int ans = gcd(a,b);
    cout << ans << endl;
    return 0;
}


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

int main(){
    ll L, R;
    cin >> L >> R;
    
    ll ans = LLONG_MAX;
    if(R - L > 700){
        ans = 0;
    }else{
        for(ll i=L;i<R;i++){
            for(ll j=i+1;j<=R;j++){
                if( (i*j) % 2019 < ans)
                    ans = (i*j) % 2019;
            }
        }
    }

    cout << ans << endl;

}

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

using namespace std;
typedef long long ll;
static const int MAX = 10001;
void bfs(int s);

int N;
int anstree[MAX];

vector< vector<int> > adjlist;
vector<int> c;

int main() {

    cin >> N;
    vector<int> row;
    for (int i = 0; i < MAX; i++) {
        adjlist.push_back(row);
    }

    int a, b;
    for (int i = 0; i < N-1; i++) {
        scanf("%d %d", &a, &b);
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    for (int i = 0; i < N; i++) {
        int c_;
        scanf("%d", &c_);
        c.push_back(c_);
    }

    sort(c.begin(), c.end(), greater<int>());
    cout << accumulate(c.begin(), c.end(), 0) - c[0] << '\n';

    bfs(1);
    for (int i = 1; i <= N; i++) {
        if (i != 1)
            cout << ' ';
        cout << anstree[i];
    }
    cout << '\n';

}

void bfs(int s) {
    queue<int> q;
    q.push(s);
    int c_ind = 0;
    anstree[s] = c[c_ind++];
    int u;

    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int v = 0; v < adjlist[u].size(); v++) {
            if (anstree[adjlist[u][v]] != 0) continue;
            anstree[adjlist[u][v]] = c[c_ind++];
            q.push(adjlist[u][v]);
        }
    }
}


Measured memory_bytes: 1020
#include <iostream>
#include <cstdio>
using namespace std;
#define NIL -1
const int maxn = 100010;
struct Node{int p,l,r;};
Node T[maxn];
int n,D[maxn];
int depth(int u,int d){
    D[u] = d;
	if(T[u].l!=NIL) depth(T[u].l,d+1);
	if(T[u].r!=NIL) depth(T[u].r,d);
}
int main() {
	int id,k,m,c,i,left,start=0;
	scanf("%d",&n);
    m = n;
	for(i=0;i<n;i++)
		T[i].p=T[i].l=T[i].r=NIL;
	while(n--){
		scanf("%d %d",&id,&k);
		for(i=0;i<k;i++){
			scanf("%d",&c); 
			if(i==0) T[id].l = c;
			else T[left].r = c;
			left = c;  
			T[c].p = id;
		}
	}
	for(i=0;i<m;i++)
        if(T[i].p==NIL) start = i;
	depth(start,0);
    for(i=0;i<m;i++){
        printf("node %d: parent = %d, depth = %d, ",i,T[i].p,D[i]);
        if(T[i].p==NIL) printf("root");
        else if(T[i].l==NIL) printf("leaf");
        else printf("internal node");
        printf(", [");
        int help = T[i].l,j=0;
        while(help!=NIL){
            if(j) printf(", ");
            printf("%d",help);
            help = T[help].r;
            j++;
        }
        printf("]\n");
    }
	return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++)
    cin>>h.at(i);
  sort(h.begin(),h.end());
  vector<int>dh(N-1);
  for(int i=0;i<N-1;i++)
    dh.at(i)=h.at(i+1)-h.at(i);
  vector<int>sum(N);
  sum.at(0)=0;
  for(int i=1;i<N;i++)
    sum.at(i)=sum.at(i-1)+dh.at(i-1);
  vector<int>ans(N-K+1);
  for(int i=0;i<N-K+1;i++)
    ans.at(i)=sum.at(i+K-1)-sum.at(i);
  sort(ans.begin(),ans.end());
  cout<<ans.at(0);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int n;
  int a[10000];
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  int ans = 0;
  rep(i, n) {
    int temp = a[i];
    int x = temp;
    bool f = false;
    for(int i = 2; i * i <= x; i++) {
      if(temp % i == 0) {
        f = true;
      }
    }
    if(f) continue;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i];
  }

  sort(B.begin(), B.end());
  int max0 = B[N-1];
  int max1 = B[N-2];

  for (int i = 0; i < N; i++) {
    if (max0 == A[i]) {
      cout << max1 << endl;
    } else {
      cout << max0 << endl;
    }
  }
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    string s;
    if(n == 25)s = "Christmas";
    if(n == 24)s = "Christmas Eve";
    if(n == 23)s = "Christmas Eve Eve";
    if(n == 22)s = "Christmas Eve Eve Eve";
    cout << s << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 3e5 + 5;
const long long MOD  = 1e9 + 7;

long long N, M, C, res, a[SIZE], b[SIZE];


void calc (int n, int m, long long arr[], long long brr[]) {

	for (int i = 1; i <= n; i++) {
		if (arr[i] <= C) 
			res = max (res, (long long)i);
		
		int l = 1, r = m;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (arr[i] + brr[mid] > C) r = mid - 1;
			else {
				res = max (res, (long long)(i + mid));
				l = mid + 1;
			}
		}
	}

}



int main() { speedhack()

	cin >> N >> M >> C;


	forn (i, N) {
		cin >> a[i];
		a[i] = a[i] + a[i - 1];
	}
	
	forn (i, M) {
		cin >> b[i];
		b[i] = b[i] + b[i - 1];
	}

	calc (N, M, a, b);
	calc (M, N, b, a);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6768
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    
    for i in range(1, len(a)):
        humidai = max(0, a[i-1] - a[i])
        ans +=  humidai
        a[i] += humidai
    print(ans)
        
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 32204
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ll dfs(){

}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<"square1001"<<endl;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,x,temp;
	cin>>n>>x;
	x=min(x,n-1);
	long long int res=n;
	n=n-x;
	while(n!=x){
		if(x<n){
			temp=n/x;
			if(n%x==0){
				res+=(2*x*(temp-1)+x);
				cout<<res;return 0;
			}
			res+=2*x*temp;
			n-=temp*x;
		}else{
			temp=x/n;
			if(x%n==0){
				res+=(2*n*(temp-1)+n);
				cout<<res;return 0;
			}
			res+=2*n*temp;
			x-=n*temp;
		}
	}
	cout<<res+n;return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);

  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  int chepaest = INT_MAX;
  for (int i = 0; i < n; ++i) {
    cin >> m[i];
    x -= m[i];
    chepaest = min(chepaest, m[i]);
  }
  cout << n + x / chepaest << "\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#include<functional>
#pragma comment(linker, "/STACK:8809999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<ld, ld> pld;
typedef pair<ll, pll> pllp;
typedef pair<pll, ll> ppll;
typedef pair<pll, pll> ppp;
typedef vector<vector<vector<ll>>> vvv;
const ll mod = 1e9 + 7;
const ll atcmod = 998244353;
const ld eps = 1e-9;
const ll settled = 400007;

ll l, r, u, d;
ll h, w, n;
ll x, y;
string f, s;

void tak(char c)
{
	if (c == 'L')
		l++;
	
	if (c == 'R')
		r++;

	if (c == 'U')
		u++;

	if (c == 'D')
		d++;
}

void aok(char c)
{
	if (c == 'L')
		r = max(r - 1, (ll)0);

	if (c == 'R')
		l = max(l - 1, (ll)0);

	if (c == 'U')
		d = max(d - 1, (ll)0);

	if (c == 'D')
		u = max(u - 1, (ll)0);
}

int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	/*freopen("capitals.in", "r", stdin);
	freopen("capitals.out", "w", stdout);*/
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> h >> w >> n >> x >> y;
	cin >> f >> s;
	tak(f.back());

	for (ll ind = n - 2; ind >= 0; ind--)
	{
		aok(s[ind]);
		tak(f[ind]);
		if (l + r == w || u + d == h)
			break;
	}

	if (u >= x || d >= (h - x + 1))
	{
		cout << "NO";
		return 0;
	}

	if (l >= y || r >= (w - y + 1))
	{
		cout << "NO";
		return 0;
	}

	cout << "YES";
	return 0;
}

Measured memory_bytes: 920
from itertools import permutations

N,M = map(int,input().split(' '))

nodes = list(range(N))
paths = [[0] * N for i in range(N)]

for i in range(M):
	a,b = map(int,input().split(' '))
	paths[a-1][b-1] = 1
	paths[b-1][a-1] = 1

ans = 0

for p in permutations(nodes[1:],len(nodes)-1):
	cnt = 0
	for j in range(len(p)):
		if(j == 0):
			nb = 0
			nn = p[j]
		else:
			nb = p[j-1]
			nn = p[j]
		if(paths[nb][nn] == 1):
			cnt = cnt + 1
		else:
			break
		if(cnt == len(p)):
			ans = ans + 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5e5+4;
const long long A = 91382323;
const long long B = 1e9+9;
const int mod = 1e9+7;
bool ckpre[N], cksuf[N];
long long pw[N];
int h[N];

int mul(int x, int y)
{
	return (x * y) % B;
}
	

int gethash(int l, int r)
{
	return (h[r] - mul(h[l-1], pw[r-l+1]) + B*1000) % B;
}

signed main()
{
	pw[0] = 1;
	for(int i=1;i<N;i++)
	{
		pw[i] = ( pw[i-1] * A ) % B;
	}

	string s;
	cin>>s;
	int n = s.length();
	s = "1" + s;
	for(int i=1;i<=n;i++)
	{
		h[i] = ( h[i-1]*A + (int)(s[i]) ) % B;
	}

	bool kt = true;
	for(int i=1;i<=n;i++)
	{
		if(s[i] != s[1])
		{
			kt = false;
			break;
		}

	}

	if(kt == true) return cout<<n<<"\n1",0;

	
	for(int len=1;len<=n;len++)
	{
		int j = len*2;
		while(j <= n)
		{
			if(gethash(1,len) == gethash(j-len+1, j))
				ckpre[j] = true;
			else
				break;
			j += len;
		}
	}

	for(int len=1;len<=n;len++)
	{
		for(int i=n-len*2+1;i>=1;i-=len)
		{
			if(gethash(n-len+1,n) == gethash(i,i+len-1))
				cksuf[i] = true;
			else
				break;
		}
	}

	int ans = 0;
	for(int i=1;i<n;i++)
	{
		if(ckpre[i] == false && cksuf[i+1] == false)
			ans++;
		
	}
	if(ckpre[n] == false && cksuf[1] == false) return cout<<"1\n1", 0;

	cout<<2<<'\n';
	cout<<ans<<'\n';

}

Measured memory_bytes: 9624
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int o=0;
	for(int i=0;i<3;i++){
		if(s[i]==s[i+1]){
			o++;
			break;
		}
	}
	if(o==1){
		cout<<"Bad"<<endl;
	}
	else cout<<"Good"<<endl;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  bool ans = false;
  for(int i = 0; !ans && n-i*4 >= 0; i++){
    if((n - i*4)%7 == 0) ans = true;
  }

  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	cin >> N >> M;

	vector<int> ret(N, -1);
	REP(_, M){
		int s, c;
		cin >> s >> c;
		s--;
		if(ret[s] < 0) ret[s] = c;
		else if(ret[s] != c){
			cout << -1 << endl;
			return 0;
		}
	}

	REP(i, N) if(ret[i] < 0) ret[i] = i == 0 && 1 < N ? 1 : 0;

	if(1 < N && ret[0] == 0){
		cout << -1 << endl;
	}
	else{
		REP(i, N) cout << ret[i];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384