akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define M (int)1e9
#define pi 3.1415926536
 
vector <int> SieveOfEratosthenes(int n) 
{ 
    vector<int> ans;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    if (prime[p] == true) 
    for (int i=p*p; i<=n; i += p) 
    prime[i] = false; 
        
  	for (int p=2; p<=n; p++) 
    if (prime[p]) 
    ans.push_back(p);
	return ans;
}
 
vector <int> fib(int n)
{
	vector<int> ans;
	int x=0,y=1,l=1;
	ans.push_back(x);
	ans.push_back(y);
	while(l<n)
	{
		l=x+y;
		x=y;y=l;
		ans.push_back(l);
	}
	return ans;
}
 
bool isPrime(int n) 
{ 
	if (n <= 1) return false; 
	if (n <= 3) return true; 
 
	if (n%2 == 0 || n%3 == 0) return false; 
 
	for (int i=5; i*i<=n; i=i+6) 
		if (n%i == 0 || n%(i+2) == 0) 
		return false; 
 
	return true; 
} 
 
 
long long power(int n,int k)
{
	if(k==0)	return 1;
	else return n*power(n,k-1);
}
 
int sdigit(int x)
{
	int ans=0;
	while(x)
	{
		ans+=x%10;
		x/=10;
	}
	return ans;
}
 
long long lcm(int a,int b)
{
	return ((long long)a*(long long)b)/__gcd(a,b);
}
 
 bool aisekaro(string a,string b)
 {
    //cout<<a<<endl<<b<<endl;
 	int i=0;
 	char x=a[0];
	for(i;i<max(a.size(),b.size());i++)
	{
	    //cout<<a[i]<<" "<<b[i]<<endl;
		if(i<min(a.size(),b.size())){	
			if(a[i]>b[i])	return true;
			if(a[i]<b[i])	return false;
			if(a[i]==b[i])  continue;
			
			//x=a[i];
		}
		if(i>=a.size()){
			if(b[i]==x)	continue;
			else return b[i]<x;
		}
		if(i>=b.size()){
			if(a[i]==x)	continue;
			else  return a[i]>x;
		}

	}
	return true;
 }
 long long subArraySum(int arr[], int n, int sum) 
{ 
    int curr_sum = arr[0], start = 0, i; 
  
    for (i = 1; i <= n; i++) 
    { 
        while (curr_sum > sum && start < i - 1) 
        { 
            curr_sum = curr_sum - arr[start]; 
            start++; 
        } 
  
        
        if (curr_sum == sum) 
        {  
            cout << "Sum found between indexes " 
                 << start << " and " << i - 1; 
            return 1; 
        } 
  
        if (i < n) 
        curr_sum = curr_sum + arr[i]; 
    } 
  
    return -1; 
} 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	if(n%10==3)	cout<<"bon";
	else if(n%10==0||n%10==1||n%10==6||n%10==8)
		cout<<"pon";
	else cout<<"hon";


	return 0;
			
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int h,w,n;

bool simulate(vvi f){
	rep(j,w){
		for(int i=h-1;i>0;i--){
			int k=i;
			while(f[k][j]==0&&k)k--;
			swap(f[i][j],f[k][j]);
		}
	}
	bool isChange=false;
	vvi isVanish(h,vi(w,1));
	rep(j,w){
		rep(i,h-n+1){
			if(f[i][j]==0) continue;
			bool ok=true;
			rep(k,n) ok&=(f[i][j]==f[i+k][j]);
			isChange|=ok;
			if(ok){
				rep(k,n) isVanish[i+k][j]=0;
			}
		}
	}
	rep(i,h){
		rep(j,w-n+1){
			if(f[i][j]==0) continue;
			bool ok=true;
			rep(k,n) ok&=(f[i][j]==f[i][j+k]);
			isChange|=ok;
			if(ok){
				rep(k,n) isVanish[i][j+k]=0;
			}
		}
	}
	if(isChange){
		rep(i,h)rep(j,w) f[i][j]*=isVanish[i][j];
		return simulate(f);
	}else{
		bool ret=true;
		rep(j,w) ret&=!f[h-1][j];
		return ret;
	}
}

int main(){
	cin>>h>>w>>n;
	vvi f(h,vi(w));
	rep(i,h)rep(j,w){
		char c;
		cin>>c;
		if(c=='.') f[i][j]=0;
		else f[i][j]=c-'A'+1;
	}
	rep(i,h)rep(j,w-1){
		if(f[i][j]!=f[i][j+1]){
			swap(f[i][j],f[i][j+1]);
			if(simulate(f)){
				cout<<"YES"<<endl;
				return 0;
			}
			swap(f[i][j],f[i][j+1]);
		}
	}
	cout<<"NO"<<endl;
	return 0;
}



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

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  int c, d, e;
  c = a + b;
  d = a - b;
  e = a * b;
  cout << max(c, max(d, e)) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var Si = Sarray();
            var Q = Sarray()[0];
            var Ti = Sarray();
            var cnt = 0;
            for (var i = 0; i < Q; ++i)
            {
                if (Ti[i] == Si[binaryserch(Si, Ti[i])]) 
                    ++cnt;
            }
            WriteLine(cnt);
        }
        static public int binaryserch(int[] ai, int vl)
        {
            var b = 0;
            var e = ai.Length - 1;
            var mid = 0;
            while (b <= e)
            {
                mid = b + (e - b) / 2;
                if (ai[mid] == vl)
                { break; }
                if (vl < ai[mid])
                {
                    e = mid - 1;
                    continue;
                }
                b = mid + 1;
            }
            return mid;
        }
    }
}



Measured memory_bytes: 31388
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i = x;i < y;i++)
using namespace std;
int main(){
  string S;
  int w;
  cin >> S >> w;
  for(int i = 0;i < S.size();i += w)cout << S[i];
  cout << endl;
}


Measured memory_bytes: 256
/*
	Nishant Singh
	nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

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

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********


// ******** GLOBAL VARIABLES ********

void solve(){
	ll n;
	cin>>n;
	ll a[n];
	ll ans=0;
	REP(i,n)
	{
		cin>>a[i];
		if((a[i]&1) && ((i+1)&1)) 
			ans++;
	}
	cout<<ans;

}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n;
  cin>>n;
  vector<int> num(n+1,0),ans(n+1,0);
  rep(i,n){
    cin>>num[i+1];
    ans[num[i+1]]=i+1;
  }
  rep(i,n-1){
    cout<<ans[i+1]<<' ';
  }
  cout<<ans[n]<<endl;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <tuple>
#include <vector>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::map<int, std::vector<int>> baito;
  // std::vector<std::pair<int, int>> mergin;

  for (int i = 0; i < N; ++i) {
    int a, b;
    std::cin >> a >> b;
    // mergin.push_back(std::make_pair(b, a));
    if (baito.count(a) == 0) {
      std::vector<int> vec;
      vec.push_back(b);
      baito.insert(std::make_pair(a, vec));
    } else {
      baito[a].push_back(b);
    }
  }

  int count = 0;
  std::priority_queue<int> pq;
  for (int i = 1; i <= M; ++i) {
    if (baito.count(i) > 0) {
      for (auto m : baito[i]) {
        pq.push(m);
      }
    }

    if (!pq.empty()) {
      count += pq.top();
      pq.pop();
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 10880
import java.util.Scanner;
 
public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long H = Long.parseLong(scan.next());
		long num = at(H, 1);
		long result = (long) Math.pow(2, num) - 1;
		System.out.println(result);
	}
	
	public static long at(long H, long count) {
		if(H == 1) {
			return count;
		}
		return at(H/2, count + 1);
	}
}

Measured memory_bytes: 20948
#include<cstdio>
#include<cstdlib>
#include<set>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vll=vector<ll>;
using vvll=vector<vll>;
using pii=pair<int,int>;
using vpii=vector<pii>;


int max_u(ll&m, ll v)
{
	if(m<v)
	{
		m=v;
		return 1;
	}
	return 0;
}


ll calc(vpii&dt, vi&f)
{
	int n=dt.size();
	set<int> s;
	ll ret=0;
	int m=0;

	for(int i=0;i<n;i++)
	{
		if(!f[i]) continue;

		ret+=dt[i].first;
		if(s.find(dt[i].second)!=s.end()) continue;
		s.insert(dt[i].second);
		m++;
	}
	return ret+m*m;
}


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		vpii dt(n);
		vi c(n+1);
		vi f(n);
		ll sum=0, tn=0, ans=0;

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &dt[i].second, &dt[i].first);
		}
		sort(dt.rbegin(), dt.rend());

		for(int i=0;i<k;i++)
		{
			int&rc=c[dt[i].second];

			sum+=dt[i].first;
			if(!rc) tn++;
			rc++;
		}

		max_u(ans, sum+tn*tn);
		int t=k;
		for(int i=k-1;i>=0;i--)
		{
			int&rc=c[dt[i].second];
			if(rc<=1) continue;
			rc--;
			for(;t<n;t++)
			{
				if(!c[dt[t].second]) break;
			}
			if(t>=n) break;

			sum+=dt[t].first-dt[i].first;
			c[dt[t].second]++;
			tn++;
			max_u(ans, sum+tn*tn);
		}


		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
def main():
  s = []
  abc = ['A', 'B', 'C']
  s.append(input())
  s.append(input())
  s.append(input())
  c = s[0][0]
  while True:
    c = checkcards(s, c)
    if c in abc:
      print(c)
      break
  
def checkcards(s, c):
  if c == 'a':
    return popcard(0, s)
  elif c == 'b':
    return popcard(1, s)
  return popcard(2, s)

def popcard(i, s):
  abc = ['A', 'B', 'C']
  if len(s[i]) == 0:
    return abc[i]
  else:
    r = s[i][0]
    s[i] = s[i][1:]
    return r

if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a,b,c;

    a=n%10;
    n=n/10;
    b=n%10;
    c=n/10;
    if(a==7||b==7||c==7){
        cout <<"Yes";
    }else{
        cout <<"No";
    }
    return 0;


}

Measured memory_bytes: 3632
from collections import Counter, defaultdict

def main():
    num = int(input())
    data = list(map(int, input().split()))
    ind = 0
    for i in range(num):
        if data[i] != i + 1:
            ind += 1

    if ind == 0 or ind == 2:
        print('YES')
    else:
        print('NO')







if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
a,b = map(int,input().split())

def f(x):
    ret = []
    i = 1
    x += 1
    while 1:
        r,q = divmod(x, 2**i)
        z = (2**(i-1)) * r + min(q, 2**(i-1))
        o = x - z
        if o == 0:
            break
        ret.append([z,o])
        i += 1
    return ret

a -= 1

a_bin = f(a)
b_bin = f(b)

la = len(a_bin)
lb = len(b_bin)

a_bin = a_bin + [[a+1, 0] for i in range(lb-la)]

#print(a_bin)
#print(b_bin)

ans = 0

for i in range(lb):
    one = b_bin[i][1] - a_bin[i][1]
    one = one%2
    ans += (2**i) * one

print(ans)



Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] l1 = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    int[] l2 = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    int[] l3 = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    int n = Integer.parseInt(sc.nextLine());
    for (int i = 0; i < n; i++) {
      int t = Integer.parseInt(sc.nextLine());
      for (int j = 0; j < 3; j++) {
        if (l1[j] == t) {
          l1[j] = 0;
        }
        if (l2[j] == t) {
          l2[j] = 0;
        }
        if (l3[j] == t) {
          l3[j] = 0;
        }
      }
    }
    if (l1[0] == l2[0] && l2[0] == l3[0]) {
      System.out.println("Yes");
    } else if (l1[1] == l2[1] && l2[1] == l3[1]) {
      System.out.println("Yes");
    } else if (l1[2] == l2[2] && l2[2] == l3[2]) {
      System.out.println("Yes");
    } else if (l1[0] == l1[1] && l1[1] == l1[2]) {
      System.out.println("Yes");
    } else if (l2[0] == l2[1] && l2[1] == l2[2]) {
      System.out.println("Yes");
    } else if (l3[0] == l3[1] && l3[1] == l3[2]) {
      System.out.println("Yes");
    } else if (l1[0] == l2[1] && l2[1] == l3[2]) {
      System.out.println("Yes");
    } else if (l1[2] == l2[1] && l2[1] == l3[0]) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
    sc.close();
  }
}


Measured memory_bytes: 36040
program ABC170_C
  integer(8)::X,N,cnta=0,cntb=0
  integer(8),allocatable::P(:)
  read(*,*)X,N
  if(N==0) then
     write(*,*)X
     stop
  end if
  allocate(P(N))
  read(*,*)P
  do i=0,100
     do j=1,N
        if(X-i==P(j)) then
           cnta=0
        else
           cnta=cnta+1
           if(cnta==N) then
              write(*,*)X-i
              stop
           end if
        end if
        if(X+i==P(j)) then
           cntb=0
        else
           cntb=cntb+1
           if(cntb==N) then
              write(*,*)X+i
              stop
           end if
        end if
        if(j==N) then
           cnta=0
           cntb=0
        end if
     end do
    end do
end program ABC170_C

Measured memory_bytes: 2868
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100005
int n,k;
int x[N];
int main(){
	int i,j,ans=1e9;
	in2(n,k);
	for(i=1;i<=n;i++) read(x[i]);
	for(i=1;i<=n;i++){
		j=i+k-1;
		if(j>n) continue;
		if(x[j]<=0) ans=min(ans,abs(0-x[i]));
		else if(x[i]>=0) ans=min(ans,x[j]);
			else{
				int tmp=min(x[j],0-x[i]);
				tmp+=x[j]-x[i];
				ans=min(ans,tmp);
			}
	}
	if(ans==1e9) ans=0;
	printf("%d",ans);
	return 0;
}

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

int main(){
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  int a,b,c,d,e;
  a=A+10-A%10, b=B+10-B%10, c=C+10-C%10, d=D+10-D%10, e=E+10-E%10;
  if(A%10 == 0)
    a-=10;
  if(B%10 == 0)
    b-=10;
  if(C%10 == 0)
    c-=10;
  if(D%10 == 0)
    d-=10;
  if(E%10 == 0)
    e-=10;
  int ans,cnt;
  ans = A+b+c+d+e;
  cnt = a+B+c+d+e;
  ans = min(ans,cnt);
  cnt = a+b+C+d+e;
  ans = min(ans,cnt);
  cnt = a+b+c+D+e;
  ans = min(ans,cnt);
  cnt = a+b+c+d+E;
  ans = min(ans,cnt);
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
 
# 左から順にやるとうまくいかない => [1, 4, 3, 2, 1] みたいな場で失敗
# 右から順に考えよ！
ans = 'Yes'
for i in range(N-1, 0, -1):
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

print(ans)

Measured memory_bytes: 20540
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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 long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];

    if(N==1){
        cout << v[0] << endl;
        return 0;
    }

    rep(i, N){
        if(i!=N-1) cout << v[i] << " ";
        if(i==N-1) cout << v[i] << endl;
    }

    for(int i=1; i<N; i++){
        int c = v[i];
        int j=i-1;
        while(j>=0 && v[j]>c){
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = c;

        rep(i, N){
            if(i!=N-1) cout << v[i] << " ";
            if(i==N-1) cout << v[i] << endl;
        }
    }
}


Measured memory_bytes: 3088
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int abs(int a,int b){
	return (a>b)? a-b:b-a;
}

int min(int a,int b){
	return (a>b)? b:a;
}

int main (){
	long long a,b,c;
	int ans = 10000;
	cin >> a >> b >> c;
	int temp = 0;
	temp = min((abs(a,b)+abs(b,c)),abs(a,c)+abs(c,b));
	ans = min(temp,ans);
	temp =0;
	temp = min((abs(b,a)+abs(a,c)),(abs(b,c)+abs(c,a)));
	ans = min(temp,ans);
	temp = 0;
	temp = min((abs(c,a)+abs(a,b)),(abs(c,b)+abs(b,a)));
	ans = min(temp,ans);
	cout  << ans << endl;
	return 0;
}

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

#define mod                          1000000007
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define pob                          pop_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define rep(i,a,b)                   for(int i=a;i<b;i++)
#define MAX                          1e7+2
using namespace std;

bool isSubSequence(string str1, string str2,int m,int n){int j = 0;for (int i=0; i<n&&j<m; i++){if (str1[j] == str2[i]) j++;}return (j==m);}
int isPrime(ll n) {rep(i, 2, sqrt(n)) if (n%i==0) return 0; return 1;}
int isSquare(ll n) {return (ll) sqrt(n) * (sqrt(n)) == n;}

int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin.tie(NULL);
ll int i,j,n,k,p=0,cnt=0,l=1,ans=0;
cin>>n>>k; ll a[n]; rep(i,0,n) cin>>a[i];
rep(i,0,n)
ans+=2*min(abs(k-a[i]),abs(a[i]));
cout<<ans;


return 0;
}


Measured memory_bytes: 256
/*
a1b1 a1b2 a1b3
a2b1 a2b2 a2b3
a3b1 a3b2 a3b3


*/

#include <iostream>
using namespace std;
 
int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    //cout << A << B << C <<X << Y << endl;
    int min = A*X + B*Y;
    //cout << min << endl;
    for (int c = 0; c <= 2*X+2*Y; ++c) { // c: Aピザ購入枚数
       int a = X - c/2;
       if (a<0) a = 0;
       int b = Y - c/2;
       if (b<0) b = 0;
       int price = a * A + b * B + c * C;
       if (min>price) min = price;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#126_D
import sys
sys.setrecursionlimit(500000)

n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=map(int,input().split())
    edges[u-1].append((v-1,w))
    edges[v-1].append((u-1,w))
visit=[False for _ in range(n)]
d=[0 for i in range(n)]

def dfs(i):
    visit[i]=True
    if all(visit[i] for i in range(n)):
        print(*d,sep='\n')
        exit()
    for v,w in edges[i]:
        if visit[v]==False:
            d[v]=(d[i]+w)%2
            dfs(v)
            
dfs(0)

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

int main(){
  string S;
  cin>>S;
  int Q;
  cin>>Q;
  int hanten = 0;
  rep(i,Q){
    int t;
    cin>>t;
    if(t==1){
      hanten++;
    }else{
      int f;
      string c;
      cin>>f;
      cin>>c;
      if((f==1&&hanten%2==0)||(f==2&&hanten%2==1)){
        S.insert(0, c);
      }else if((f==1&&hanten%2==1)||(f==2&&hanten%2==0)){
        S.push_back(c.at(0));
      }
    }
  }

    if(hanten%2==0){
      cout<<S;
    }else{
      for(int i = S.size()-1;i>=0;i--){
        cout<<S.at(i);
      }
    }


}


Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    vector<int> d1, d2;
    for(int i = 0; i < n / 2; i++) d1.push_back(d[i]);
    for(int i = n / 2; i < n; i++) d2.push_back(d[i]);
    int a = d1.back();
    int b = d2.front();
    cout << b - a << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
const int INF = 1e9;
const int MOD = 1e9+7;


#define lint long long
const lint LINF = 1e18;

using namespace std;
string s;
int k;
map <string,int> mp;

int main(){
  cin >> s >> k;
  int size = s.size();
  FOR(i,5){
    REP(j,size-i+1){
      string s2 = s.substr(j,i);
      mp[s2] ++;
    }
  }
  int num = 0;
  for(map<string,int> :: iterator it = mp.begin(),end = mp.end();it!=mp.end();++it){
    num ++;
    if(num==k){
      cout << it->first << endl;
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
const int maxn = (int)1e5 + 1;

int n, k;
long double ans;
long double get(long double a){
    long double r = a;
    while(a < k){
        a *= 2;
    }
    return (1.0 / ((a / r) * n));
}

int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        ans += get(i * 1.0);
    }
    cout << fixed << setprecision(9) << ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, i, buf;
    int len[3] = {};
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d %d %d", &len[0], &len[1], &len[2]);
        for (int k=0; k<3; k++) {
            for (int m=k+1; m<3; m++) {
                if ( len[k] > len[m] ) {
                    buf = len[k];
                    len[k] = len[m];
                    len[m] = buf;
                }
            }
        }
        if ( len[2] * len[2] == len[0] * len[0] + len[1] * len[1] )
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


ll n, k;
ll cnt[200005];
vector< pll > v;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cin >> n >> k;
        for(ll i=0;i<n;i++) {
                ll x, y;
                cin >> x >> y;
                v.pb(make_pair(y, x));
        }
        sort(v.rbegin(), v.rend());
        ll ans = 0;
        priority_queue<pll, vector<pll>, greater<pll> > pq;
        ll c=0;
        ll sum=0;
        for(ll i=0;i<k;i++) {
                ll d = v[i].first;
                ll t = v[i].second;
                if(cnt[t] == 0) c++;
                cnt[t]++;
                ans += d; sum+=d;
        }
        ans += c*c;
        for(ll i=0;i<k;i++){
                ll d = v[i].first;
                ll t = v[i].second;
                if(cnt[t] > 1) pq.push(v[i]);
        }
        ll ret = ans;
        for(ll i=k;i<n;i++) {
                ll d = v[i].first;
                ll t = v[i].second;
                if(cnt[t] > 0) continue;
                if(pq.empty() == false){
                        pll yo = {-1,-1};
                        while(pq.empty()==false){
                                pll X = pq.top(); pq.pop();
                                if(cnt[X.second] > 1){
                                        yo=X; break;
                                }
                        }
                        if(yo == make_pair(-1LL,-1LL)) continue;
                        cnt[yo.second]--;
                        sum -= yo.first;
                        sum += d;
                        cnt[t]++;
                        c++;
                        pq.push(make_pair(d,t));
                        ret=max(ret, sum+c*c);
                }
        }
        cout << ret << endl;
        return 0;
}


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

using namespace std;

main(){
  int n;
  char data[105][105];
  int dx[] = {0, 1, 0, -1};
  int dy[] = {-1, 0, 1, 0};
  int t;
  cin >> t;
  for(int tc=0;tc<t;tc++){
    cin >> n;
    if(tc != 0) cout << endl;
    if(n == 1){
      cout << "#" << endl;
      continue;
    }
    int y = n-1;
    int x = 0;
    fill(data[0], data[100], ' ');
    data[y][x] = '#';
    int d = 0;
    while(1){
      int ty = y + dy[d];
      int tx = x + dx[d];
      if(ty<0 || ty>=n){ d = (d+1)%4; continue; }
      if(tx<0 || tx>=n){ d = (d+1)%4; continue; }
      if(data[ty][tx] == '#') break;
      int tty = ty + dy[d];
      int ttx = tx + dx[d];
      if((tty>=0 || tty<n) && (ttx>=0 || ttx<n)){
	if(data[tty][ttx] == '#'){
	  d = (d+1)%4; 
	  continue; 
	}
      }
      int cnt = 0;
      for(int i=0;i<4;i++){
	int tty = ty + dy[i];
	int ttx = tx + dx[i];
	if(tty<0 || tty>=n) continue;
	if(ttx<0 || ttx>=n) continue;
	if(data[tty][ttx] == '#') cnt++;
      }
      if(cnt > 1) break;
      data[ty][tx] = '#';
      y = ty;
      x = tx;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cout << data[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.length() == 2){
      System.out.println(s);
    }else{
      System.out.print(s.charAt(2));
      System.out.print(s.charAt(1));
      System.out.println(s.charAt(0));
    }
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int N;
   int a[100];
   int i,count=0;
   scanf("%d\n",&N);
   for(i=1;i<N+1;i++)
   {
       scanf("%d",&a[i]);
   }
   for(i=1;i<N+1;i++)
   {
       if((i%2!=0)&&a[i]%2!=0)
      count++;
   }
   printf("%d",count);
    return 0;
}




Measured memory_bytes: 1728
import sys
from collections import deque
sys.setrecursionlimit(10**6)
k=int(input())
g=[[] for i in range(k)]
for i in range(k):
  g[i].append(((i+1)%k,1))
  if i:
    g[i].append((10*i%k,0))
q=deque([1])
res=[float('inf')]*k
res[1]=1
while q:
  v=q.popleft()
  if v==0:
    break
  for c,d in g[v]:
    if res[c]<=res[v]+d:
      continue
    res[c]=res[v]+d
    if d:
      q.append(c)
    else:
      q.appendleft(c)
print(res[0])

Measured memory_bytes: 35316
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI       3.1415926535897932384626433832795028841971
#define INF 1000000000
#define EPS      1e-10
#define MOD      1000003
#define HOGE 100000
#define HUGA 100000
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
typedef pair<double,P> PQ;

int n;
string str[40];
int x[5] = {5,7,5,7,7};

void solve(){
    rep(i,n) cin >> str[i];
    rep(i,n){
        int cnt = 0;
        int sum = 0;
        for(int j = i; j < n; j++){
            sum += str[j].size();
            if(sum == 5) cnt++;
            if(sum == 12) cnt++;
            if(sum == 17) cnt++;
            if(sum == 24) cnt++;
            if(sum == 31) cnt++;
            if(sum >= 31) break;
        }
        if(cnt == 5){
            cout << i+1 << endl;
            break;
        }
    }
}

int main(){
    while(cin >> n){
        if(n == 0) break;
        solve();
    }
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define ls rt << 1
#define rs rt << 1 | 1
#define sz(x) (int)(x).size()
#define ALL(x) (x).insgin(), (x).end()
#define vi vector<int>
using namespace std;
const int P = 1e9 + 7;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 10;
 
int n, t, l, r, mid, x;
int check(int p)
{
	cout << p << endl;
    char s[N];
	scanf("%s", s);
    if (s[0] == 'M') return 0;
    if (s[0] == 'F') return 1;
    exit(0);
}
 
int main()
{
	n = read();
	t = check(0);
	l = 1; 
	r = n - 1;
	while (l < r)
	{
		mid = (l + r) >> 1;
		x = check(mid);
		if ((mid - l + 1 & 1) ^ x ^ t) r = mid - 1;
		else l = mid + 1, t = x;
	}
	check(l);
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end(), greater<int>());
  if (l.at(0) < accumulate(l.begin() + 1, l.end(), 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main (void){
  long  long int n = 0,k = 0,l = 1,x = 0,m = 1,ans = 0;

  cin >> n;
  cin >> k;

  for(int i = k; i <= n;i++){
    ans = ans + 2 * n + 3 - 2 * i + (i - 2) * (n + 1 - i);
  }

  ans = (ans + 1) % (1000000000 + 7);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
using namespace std;
long long INF = 1000000009;
map<int, int> mp;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		int d = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				d++;
			}
		}
		if (d == 8) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def SumOfDigits(n): #各桁の和を計算する関数
    sum = 0
    while n > 0:
        sum += (n % 10)
        n //= 10
    return sum

n, a, b = map(int, input().split())
sum = 0

for i in range(n+1):
    add = 0
    add = SumOfDigits(i)
    if a <= add and add <= b:
        sum += i

print(sum)

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

A.append(A[0])
B.append(B[0])

AX=[]
BX=[]
for i in range(N):
    AX.append(A[i]^A[i+1])
    BX.append(B[i]^B[i+1])

AX+=AX[:-1]

# KMP法

LEN=len(BX)
MP=[-1]*(LEN+1) #「接頭辞と接尾辞が最大何文字一致しているか」を記録する配列
BX+="0" # 最後に入らない文字をつけ加える

NOW=-1 # 何文字一致しているか.

for i in range(LEN):
    while NOW>=0 and BX[i]!=BX[NOW]: # 一致していなかったら0から数え直すのではなく, MP[NOW]から数える.
        NOW=MP[NOW]
    NOW+=1
    
    if BX[i+1]==BX[NOW]: # ここだけMPと違う
        MP[i+1]=MP[NOW]
    else:
        MP[i+1]=NOW
        
LEN2=len(AX)
AX+="0" # 最後に入らない文字をつけ加える

MP_SEARCH=[0]*(LEN2+1) # その文字までで何個一致しているかを調べる. LEN文字一致したらSが検出できたということ.
NOW=0
for i in range(LEN2):
    while NOW>=0 and AX[i]!=BX[NOW]:
        NOW=MP[NOW]
    NOW+=1

    if AX[i+1]==BX[NOW]: # ここだけMPと違う
        MP_SEARCH[i+1]=MP_SEARCH[NOW]
    else:
        MP_SEARCH[i+1]=NOW
        
    MP_SEARCH[i]=NOW

    if NOW==LEN: # LEN文字一致したら, MP[LEN]から数える.
        NOW=MP[NOW]
        
for i in range(LEN2):
    if MP_SEARCH[i]==LEN:
        print(i-LEN+1,A[i-LEN+1]^B[0])


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

int main(){
    int n, num, S[14] = {}, C[14] = {}, H[14] = {}, D[14] = {};
    char m;
    
    cin >> n;
    
    for(int i = 0;i < n;i++){
        cin >> m >> num;
        if(m == 'S'){
            S[num] = 1;
        }
        else if(m == 'C'){
            C[num] = 1;
        }
        else if(m == 'H'){
            H[num] = 1;
        }
        else if(m == 'D'){
            D[num] = 1;
        }
    }
    for(int i = 1; i < 14;i++){
        if(S[i] == 0){
            cout << "S " << i << endl;
        }
    }
    for(int i = 1; i < 14;i++){
        if(H[i] == 0){
            cout << "H " << i << endl;
        }
    }
    for(int i = 1; i < 14;i++){
        if(C[i] == 0){
            cout << "C " << i << endl;
        }
    }
    for(int i = 1; i < 14;i++){
        if(D[i] == 0){
            cout << "D " << i << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    int inc = 0;
    ll ans = 0;
    rep(i, 0, N-1){
        if(inc == -1){
            if(A[i] < A[i+1]){
                ans++;
                inc = 0;
            }
        }else if(inc == 1){
            if(A[i] > A[i+1]){
                ans++;
                inc = 0;
            }
        }else{
            if(A[i] > A[i+1]) inc = -1;
            else if(A[i] < A[i+1]) inc = 1;
        }
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()

r2l = {'L': 'R', 'R': 'L'}
t = 'L'
ends = {'R': [], 'L': []}
for i, s in enumerate(S):
  if s == t:
    t = r2l[t]
    ends[t].append(i)

ends = []
ans = [0 for _ in range(len(S))]
cnt = 0
for i,s in enumerate(S):
  cnt += 1
  if s == t:
    if t == 'L':
      ans[i] = cnt // 2 + cnt % 2
      ans[i-1] = cnt // 2
      cnt = 0
      m = i
    t = r2l[t]
    cnt = 1
  elif t == 'R':
    if cnt % 2 == 0:
      ans[m-1] += 1
    else:
      ans[m] += 1
print(*ans)
  
#ans = [0 for _ in range(len(S))]
#current = 0
#e = ends['R'][current]
#ends['L'].append(len(S))
#print(ends)

t = 'R'
#m = e

#for i in range(len(S)):
#  if e < i and t == 'R':
#    t = r2l[t]
#    e = ends[t][current]
#  elif e <= i and t == 'L':
#    t = r2l[t]
#    current += 1
#    e = ends[t][current]
#    m = e
#  print(m)
#    
#  if abs(m - i) % 2 == 1:
#    ans[m-1] += 1
#  else:
#    ans[m] += 1

Measured memory_bytes: 12792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string S;
  cin >> S;
  map<char, int> m;
  rep(i, S.size())
  {
    m[S.at(i)]++;
  }
  for (auto a : m)
  {
   // cout << a.first << a.second << endl;
    if (a.second != 1)
    {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

const int MAX = 2000005;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void solve() {
  int n, k;
  cin >> n >> k;
  COMinit();
  rep3(i, 1, k + 1) {
    // k 個のボール
    // i 箇所に 1 個ずつ配る
    // k-i 個のボール, i-1 個の仕切り
    cout << (COM(n - k + 1, i) * COM(k - i + i - 1, i - 1)) % mod << endl;
  }
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = a * a * b;
  if (s >= 2 * x) {
    double y = x / a / b / 0.50;
    double z = sqrt(y * y + b * b);
    double sin = b / 1.0 / z;
    double ac = asin(sin);
    double rad = 180 / M_PI;
    double AC = ac * rad;
    printf("%.08lf", AC);
  }
  else {
    double S = s - x;
    double y = S / a / a *2;
    double z = sqrt(y * y + a * a);
    double cos = a / z;
    double ac = acos(cos);
    double rad = 180 / M_PI;
    printf("%.08lf", ac * rad);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll a,b,n;
  cin >> a >> b >> n;
  ll x = min(b-1, n);
  cout << floor(a*x/b) - a * floor(x/b) << endl;
  return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	string x;
	
	getline(cin,x);
	transform(x.begin(),x.end(),x.begin(),::toupper);
	cout<<x<<endl;
	

}

Measured memory_bytes: 1180
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	String search = scanner.nextLine();	//検索文字
	boolean Judge = true;
  	int count = 0;
  	String end = "END_OF_TEXT";
  	
  	
  	while( Judge ){
		String word = scanner.next();	//文章入力
  		//終わる処理と変換
  		int result = word.lastIndexOf(end);	//検索結果を入れる
  		if( result != -1 ){
  			Judge = false;
  		}else{
  			word = word.toLowerCase(); 		//小文字に
  		}
  		if( word.equals(search) ) {
  			count++;
  		}
  	}
  	//結果出力
	System.out.println(count);
  	
	scanner.close();
  }
}


Measured memory_bytes: 26308
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll a, b, c, d, e, f;
ll ansAB, ansB;

int main() {
	cin >> a >> b >> c >> d >> e >> f;
	for (ll i = 0; i*a * 100 <= f; i++) {
		for (ll j = 0; (i*a * 100 + j*b * 100) <= f; j++) {
			for (ll k = 0; (i*a * 100 + j*b * 100 + k*c) <= f; k++) {
				for (ll l = 0; (i*a * 100 + j*b * 100 + k*c + l*d) <= f; l++) {
					ll A = i*a * 100 + j*b * 100, B = k*c + l*d;
					if ((100 * B <= A*e)) {
						// 100*B / (A+B) > 100*ansB / ansAB
						// ansAB*B > ansB*(A+B)
						if ((ansAB == 0 && ansB == 0) || (ansAB*B >= ansB*(A + B))) ansAB = A + B, ansB = B;
					}
				}
			}
		}
	}
	cout << ansAB << " " << ansB << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  if(a%2==0 || b%2==0 || c%2==0){
    cout << 0 << endl;
  }
  else{
    cout << min(a*b,min(c*a,b*c)) << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main(k, x):
    res = []
    for i in range(-k+1, k):
        res.append(str(x+i))

    return ' '.join(res)


if __name__ == "__main__":
    k, x = map(int, input().split())
    print(main(k, x))


Measured memory_bytes: 2940
def main():
    n,m = map(int,input().split())
    l = 0
    r = float('inf')
    for i in range(m):
        l_,r_ = map(int,input().split())
        if l<l_:
            l = l_
        if r_<r:
            r = r_
    if r-l>=0:
        print(r-l+1)
    else:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> a(N, 0);
  for(auto &i : a) cin >> i;
  vector<int> ans;
  int q; cin >> q;
  REP(i, q){
    int com, b, e; cin >> com >> b >> e;
    if(com == 0){
      int m = 1e9 + 1;
      for(int j = b; j < e; j++){
        m = min(m, a[j]);
      }
      ans.push_back(m);
    }else{
      int M = - 1e9 - 1;
      for(int j = b; j < e; j++){
        M = max(M, a[j]);
      }
      ans.push_back(M);
    }
  }
  for(auto &i : ans) cout << i << endl;
}


Measured memory_bytes: 3196
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int main(void)
{
  int k,t,i=0;
  scanf("%d",&k);
  char str[110],ans[110];
  scanf("%s",str);
  while(str[i]!='\0'){
    ans[i]=str[i];
    i++;
  }
  ans[k]='\0';
  if(i<=k) printf("%s",ans);
  else{
    ans[k]='.';
    ans[k+1]='.';
    ans[k+2]='.';
    ans[k+3]='\0';
    printf("%s",ans);
  }
  
  return 0;
}

Measured memory_bytes: 1728
// https://atcoder.jp/contests/abc172/tasks/abc172_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, M, K;
  cin >> N >> M >> K;

  VL as(N);
  rep(i, N) cin >> as[i];

  VL bs(M);
  rep(i, M) cin >> bs[i];

  ll b_ct = M;
  ll sum = accumulate(all(bs), 0ll);

  ll res = 0;

  rep(a_ct, N + 1) {
    if (a_ct > 0) sum += as[a_ct - 1];

    while (b_ct > 0 && sum > K) {
      b_ct--;
      sum -= bs[b_ct];
    }

    if (sum > K) break;

    chmax(res, a_ct + b_ct);
  }

  cout << res << "\n";
}


Measured memory_bytes: 6352