akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
    int n,ans=0;
    cin>>n;
    if(n%10==0){cout<<10;return;}
    while(n){
    	ans+=n%10;
    	n/=10;
    }
   cout<<ans<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n;
    int y, m, d;
    cin >> n;
    for (; n>0; n--) {
        int day = 0;
        cin >> y >> m >> d;
        if (y%3 == 0 || m%2 != 0) {
            day += 20-d;
        }
        else {
            day += 19-d;
        }
        day++;
        for (m++; m<11; m++) {
            if (y%3 != 0 && m%2 == 0) {
                day += 19;
            }
            else {
                day += 20;
            }
        }
        for (y++; y<1000; y++) {
            if (y%3 == 0) {
                day += 200;
            }
            else {
                day += 195;
            }
        }
        cout << day << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int N;
    string ans;
    cin >> N;
    if(N<=999){
        ans="ABC";
    }else{
        ans="ABD";
    }
    cout << ans << endl;
    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, long long K, std::vector<long long> p){

    SORT(p);

    lli sum = 0;
    REP(i,0,K)sum+=p[i];

    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

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


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <queue>

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

using namespace std;
using Graph = vector<vector<int>>; //グラフ

bool dbg = false;

int main(void){
    int N, M; cin >> N >> M;
    Graph G(N);
    vector<int> next(N);
    bool avail= true;

    rep(i, M){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // Data structure for BFS
    vector<int> dist(N, -1);
    queue<int> que;
    //BFS init
    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int nv:G[v]){
            if(dist[nv] != -1) continue; //already found
            // new unreached node: renew dist, add queue
            dist[nv] = dist[v] + 1;
            que.push(nv);
            next[nv] = v;
        }
    }

    if(dbg){
        
        cout << "dbg: next[i]= ";
        rep(i, N){ if(i==0) continue; cout << next[i] << " "; } 
        cout << endl;
        cout << "dbg: dist[i]= ";
        rep(i, N){ if(i==0) continue; cout << dist[i] << " "; } 
        cout << endl;
    }

    rep(i,N){
        if(dist[i] == -1) avail = false;
    }

    if(avail){
        cout << "Yes" << endl;
        rep(i, N){
            if(i==0) continue;
            if(dbg) cout <<"dbg: "<< i+1 << " dist:" << dist[i] << " ";
            cout << next[i]+1 << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
  int n;
  double t, a;
  cin>>n>>t>>a;
  double h[n];
  cin>>h[0];
  double temp=t-h[0]*0.006-a;
  if (temp<0){
    temp=-temp;
  }
  int c=1;
  for(int i=1; i<n; i++){
    cin>>h[i];
    double b=t-h[i]*0.006-a;
    if(b<0){
      b=-b;
    }
    if(b<temp){
      temp=b;
      c=i+1;
    }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
v=pow(10,18)
inp = list(map(int,input().split()))
prod=1
from collections import Counter
c=Counter(inp)
if c[0]>=1:
  print (0)
else:
  flag=1
  for item in inp:
    prod*=item
    if prod>v:
      flag=0
      print (-1)
      break
  if flag==1:
    print (prod)


Measured memory_bytes: 24056
//created by Whiplash99
import java.io.*;
import java.util.*;
import java.util.function.BiPredicate;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        long count[][]=new long[10][20];
        for(i=0;i<10;i++)
        {
            count[i][1] = 1;
            count[i][2]=3;
        }
        count[0][2]=count[9][2]=2;

        for(i=3;i<=12;i++)
        {
            count[0][i]=count[0][i-1]+count[1][i-1];
            count[9][i]=count[8][i-1]+count[9][i-1];

            for(int j=1;j<=8;j++) count[j][i]=count[j-1][i-1]+count[j][i-1]+count[j+1][i-1];
        }

        long digits[]=new long[20];
        for(i=1;i<=12;i++)
        {
            for(int j=1;j<=9;j++) digits[i]+=count[j][i];
        }

        int K=Integer.parseInt(br.readLine().trim());
        int cur=0;

        for(i=1;i<=12;i++)
        {
            if (digits[i] >= K) break;
            K-=digits[i];
        }
        cur=i;

        int prev=0;
        char str[]=new char[cur];
        for(i=0;i<cur;i++)
        {
            for(int j=0;j<=9;j++)
            {
                if (i == 0 && j == 0) continue;
                if(i!=0&&Math.abs(prev-j)>1) continue;

                if (count[j][cur - i] >= K)
                {
                    str[i]=(char)(48+j);
                    prev=j;
                    break;
                }
                else K-=count[j][cur-i];
            }
        }
        System.out.println(new String(str));
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int a[100002];
int r[100002];
int k[100002];

int main()
{
	int n;
	ll ans=0;
	a[0]=0;
	r[0]=0;
	
	cin>>n;
	for(int i=1;i<n+1;i++)
	{
		int temp;
		cin>>a[i];
		r[i]=r[i-1]+abs(a[i]-a[i-1]);
	}
	a[n+1]=0;
	r[n+1]=r[n]+abs(0-a[n]);

	for(int i=1;i<n+1;i++)
	{
		k[i]=abs(a[i+1]-a[i-1]);
	}

	for(int i=1;i<n+1;i++)
	{
		ans=0;
		ans += r[i-1];
		ans += (r[n+1]-r[i+1]);
		ans += k[i];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2432
import math
a, b, h, m = map(int, input().split())

h2 = (h+(m/60)) * 30
m2 = m * 6
d = abs(h2 - m2)

c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(d)))

print(c)

Measured memory_bytes: 9484
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long int N, A, DW[2] = {}, count = 0, Rac;
	bool check = false;
	map<long long int, long long int> mp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		mp[A]++;
	}
	map<long long int, long long int>::iterator it;
	for (it = mp.begin(); it != mp.end(); it++) {
		if (it->second >= 2) {
			DW[0] = it->first;
		}
	}
	mp[DW[0]] -= 2;
	for (it = mp.begin(); it != mp.end(); it++) {
		if (it->second >= 2) {
			DW[1] = it->first;
		}
	}
	cout << DW[0] * DW[1];
}

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

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

#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let hon = vec!['2', '4', '5', '7', '9'];
    let pon = vec!['0', '1', '6', '8'];
    // let bon = vec!['3'];
    let n: u64 = read::<u64>();
    let n_str = n.to_string();
    let n_chars = n_str.chars();
    for (i, v) in n_chars.enumerate() {
        if i == n_str.len() - 1 {
            if hon.contains(&v) {
                println!("hon");
            } else if pon.contains(&v) {
                println!("pon");
            } else {
                println!("bon");
            }
        }
    }
}


Measured memory_bytes: 2164
N = int(raw_input())

plan = []

for i in range(N):
    num = map(int, raw_input().split())
    plan.append(num)

#print array

pre_time  = 0
pre_cord_x = 0
pre_cord_y = 0

available = True

while len(plan) > 0:
    case = plan.pop(0)
    dif_t = case[0] - pre_time
    dif_x = case[1] - pre_cord_x
    dif_y = case[2] - pre_cord_y

    if ((dif_x + dif_y) <= dif_t) and (((dif_t - (dif_x + dif_y)) % 2) == 0):
        available = True
    else:
        available = False
        break
    # continue
    pre_time   = case[0]
    pre_cord_x = case[1]
    pre_cord_y = case[2]

if available == True:
    print 'Yes'
else:
    print 'No'


Measured memory_bytes: 21508
c = [[int(i) for i in input().split()] for j in range(3)]
f = True
a, b = c[0][0] - c[0][1], c[0][1] - c[0][2]
for i in range(1, 3):
    if not(c[i][0] - c[i][1] == a and c[i][1] - c[i][2] == b):
        f = False
a, b = c[0][0] - c[1][0], c[1][0] - c[2][0]
for i in range(1, 3):
    if not(c[0][i] - c[1][i] == a and c[1][i] - c[2][i] == b):
        f = False
print("Yes" if f else "No")

Measured memory_bytes: 3064
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (new InputStreamReader (System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		System.out.println (c + " " + a + " " + b);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef long long ll;

const int MAX_SIZE = 10000;

struct edge{
	int to;
	int cost;
	int kipKind;
};

// ツノツーツドツづ個暗環置
vector<edge> G[101][11];
int d[101][11];
const int INF = 1000000000;


class Situation{
public:
	Situation(double _cost,int _node,int _used){
		cost = _cost;
		node = _node;
		used = _used;
	}

	Situation();

	double cost;
	int node;
	int used;

	bool operator<(const Situation &sit)const{
		return sit.cost < (this->cost);
	}
};

void dijkstra(int s,int g,int c){
	priority_queue<Situation> que;

	for(int i = 0; i < 101; i++)
		fill(d[i],d[i]+11,INF);
	d[s][c] = 0;

	que.push(Situation(0,s,c));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
		int v = p.node;
		int used = p.used;
		if(d[v][used] < p.cost)
			continue;
		for(int i = 0; i < G[v][used].size(); i++){
			edge e = G[v][used][i];
			if(d[e.to][e.kipKind] > d[v][used]+e.cost){
				d[e.to][e.kipKind] = d[v][used]+e.cost;
				que.push(Situation(d[e.to][e.kipKind],e.to,e.kipKind));
			}
		}

	}
	

	int minCost = INF;

	for(int i = 0; i <= c; i++){
		minCost = min(minCost,d[g][i]);
	}
	if(minCost != INF)
		cout << minCost << endl;
	else
		cout << "Impossible" << endl;
}



int main(){

	int n,m,s,d,c;
	while(cin>>c>>n>>m>>s>>d&&!(c==0&&n==0&&m==0&&s==0&&d==0)){
		s--;
		d--;
		for(int i = 0; i < m; i++){
			int from,to,cost;
			cin>>from>>to>>cost;
			from--;
			to--;
			for(int j = 0; j <= c; j++){
				if(j-1>=0){
					edge e;
					e.cost=cost/2;
					e.to=to;
					e.kipKind=j-1;
					G[from][j].push_back(e);
					e.to=from;
					G[to][j].push_back(e);
				}
				edge e;
				e.cost=cost;
				e.to=to;
				e.kipKind=j;
				G[from][j].push_back(e);
				e.to=from;
				G[to][j].push_back(e);
			}
		}
		dijkstra(s,d,c);
		for(int i = 0; i < 101; i++)
			for(int j = 0; j < 11; j++)
				G[i][j].clear();
		//cout<<endl;
	}


	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int count = 0;
  bool even = true;
  while(even) {
    int i = 0;
    for(i = 0; i < N; i++) {
      if(A.at(i) % 2 != 0) {
        even = false;
        break;
      } else {
        A.at(i) /= 2;
      }
    }
    if(even){
      count++;
    }
  } 
    


  cout << count << endl;  

  return 0;
}

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

int done[100005], parent[100005];
vector<int> X[100005], Y, Z[100005];

void dfs(int i)
{
    done[i] = 1;
    
    for(auto x : X[i])
        if(!done[x])
            dfs(x);
    
    Y.push_back(i);
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N, M;
    cin >> N >> M;
    
    for(int i=1; i<=N-1+M; i++)
    {
        int a, b;
        cin >> a >> b;
        
        X[a].push_back(b);
        Z[b].push_back(a);
    }
    
    int root = -1;
    
    for(int i=1; i<=N; i++)
        if(Z[i].empty())
            root = i;
    
    dfs(root);
    
    memset(done, 0, sizeof(done));
    
    done[root] = 1;
    reverse(Y.begin(), Y.end());
    
    for(int i=1; i<Y.size(); i++)
    {
        int maxx = 0, indx = -1;
        
        for(auto y : Z[ Y[i] ])
        {
            if(done[y] && done[y] > maxx)
            {
                maxx = done[y];
                indx = y;
            }
        }
        
        done[ Y[i] ] = maxx + 1;
        parent[ Y[i] ] = indx;
    }
    
    for(int i=1; i<=N; i++)
        cout << parent[i] << "\n";
    
    return 0;
}


Measured memory_bytes: 17788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	ll s, c;
	cin >> s >> c;

	if (c <= 2 * s) cout << c / 2 << endl;
	else cout << s + (c - 2 * s) / 4 << endl;
}

Measured memory_bytes: 256
import math
import fractions
from collections import Counter

def read():
    return int(input())

def readmap():
    return map(int, input().split())

def readlist():
    return list(map(int, input().split()))

def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def root_cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    
    return True


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if __name__ == "__main__":
    a, b = readmap()
    g = fractions.gcd(a, b)

    c = Counter(prime_factorize(g))

    print(len(c) + 1)

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
int main() {
    int N; cin>>N;
    int neq=0;
    for (int i = 0; i < N; i++){
        int p;cin>>p;
        if(p!=i+1)neq++;
    }
    if(neq<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, n) for(ll i = 0; i < n; i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
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(a > b){ a=b; return 1; } return 0; }

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

  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];

  vector<pll> v;
  for(ll i = 0; i < m; i++){
    ll a, b;
    cin >> a >> b;
    a--, b--;
    v.pb(pair<ll, ll>(a, b));
    v.pb(pair<ll, ll>(b, a));
  }
  sort(all(v));

  vector<bool> ok(n, true);
  for(ll i = 0; i < v.size(); i++){
    if(h[v[i].first] <= h[v[i].second]){
      //cout << h[v[i].first] << ' ' << h[v[i].second] << "a" << endl;
      ok[v[i].first] = false;
    }
  }

  ll ans = 0;
  for(ll i = 0; i < n; i++){
    if(ok[i] == true) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8212
def GCD(a, b):
    if (b == 0):
        return a
    return GCD(b, a%b)

def LCM(a, b):
    return a//GCD(a, b)*b

n = int(input())
res = int(input())
for i in range(1, n):
    x = int(input())
    res = LCM(res, x)
print(res)



Measured memory_bytes: 2940
N = int(input())
dp = [1e10]*(N+1)
dp[0] = 0
for i in range(1,N+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power]+1)
        power *= 6
    power = 1
    while power<=i:
        dp[i] = min(dp[i], dp[i-power]+1)
        power *= 9
print(dp[N])

Measured memory_bytes: 3828
import sys

S = input()
T = input()
m1 = dict()
m2 = dict()
for s, t in zip(S, T):
    if s in m1 and m1[s] != t:
        print('No')
        sys.exit()
    if t in m2 and m2[t] != s:
        print('No')
        sys.exit()

    m1[s] = t
    m2[t] = s

print('Yes')


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

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var rs = new int[h[1]].Select(_ => read()).ToArray();

		var map = new int[n + 1].Select(_ => new List<int[]>()).ToArray();
		foreach (var r in rs)
		{
			map[r[0]].Add(new[] { r[1], r[2] });
			map[r[1]].Add(new[] { r[0], -r[2] });
		}

		var u = Enumerable.Repeat(int.MinValue, n + 1).ToArray();
		var q = new Queue<int>();
		for (int i = 1; i <= n; i++)
		{
			if (u[i] > int.MinValue || !map[i].Any()) continue;

			u[i] = 0;
			q.Enqueue(i);
			while (q.Any())
			{
				var p = q.Dequeue();
				foreach (var np in map[p])
				{
					if (u[np[0]] > int.MinValue)
						if (u[np[0]] == u[p] + np[1]) continue;
						else { Console.WriteLine("No"); return; }

					u[np[0]] = u[p] + np[1];
					q.Enqueue(np[0]);
				}
			}
		}
		Console.WriteLine("Yes");
	}
}


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

int main(){
	int N;
	cin >> N;
	vector<pair<double,double>> p(N);
	rep(i,N){
		double x,y;
		cin >> x >> y;
		p[i] = make_pair(x,y);
	}
	
	vector<int> d(N);
	rep(i,N){
		d[i] = i;
	}
	
	double sum = 0;
	double count = 0;
	
	do{
		rep(i,N-1){
			double dx = p[d[i+1]].first - p[d[i]].first;
			double dy = p[d[i+1]].second - p[d[i]].second;
			sum += sqrt(dx*dx + dy*dy);
		}
		count++;
	}while (next_permutation(d.begin(),d.end()));
	
	double ans = sum / count;
	printf("%.12f", ans);
    return 0;
}



Measured memory_bytes: 768
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		
	    long[][] allData = new long[10][1001];

	    allData[0][0] = 1;

	    for (int iRang = 0; iRang <= 100; iRang++){
	        for (int iSum = 1000; iSum >= 0; iSum--){
	            for (int item = 9; item >= 1; item--){
	                if (iSum - iRang >= 0) allData[item][iSum] += allData[item - 1][iSum - iRang];
	            }
	        }
	    }

	    Scanner input = new Scanner(System.in);
	    while (input.hasNext()){
	    	String[] nAnds = input.nextLine().split(" ");
	    	int valueN = Integer.parseInt(nAnds[0]);
	    	int valueS = Integer.parseInt(nAnds[1]);
	    	if(valueN != 0 || valueS != 0){
	    		System.out.printf("%d\n", allData[valueN][valueS]);
	    	} else {
	    		break;
	    	}
	    }

	    input.close();
	}
}

Measured memory_bytes: 26980
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		String s = next();
		int n = s.length();
		char[] lr = s.toCharArray();
		int[] d = new int[n];
		int[] result = new int[n];
		//distance to last r.
		int tmp = 0;
		for(int i = 0; i < n; i++) {
			if(lr[i] == 'L') {
				tmp++;
				d[i] = tmp; 
			} else {
				tmp = 0;
			}
		}
		//distance to next l
		tmp = 0;
		for(int i = n-1; i >= 0; i--) {
			if(lr[i] == 'R') {
				tmp++;
				d[i] = tmp; 
			} else {
				tmp = 0;
			}
		}
		
		//result children count
		for(int i = 0; i < n; i++) {
			if(lr[i] == 'R') {
				if(d[i] % 2 == 0) {
					result[i + d[i]]++;
				} else {
					result[i + d[i] - 1]++;
				}
			} else {
				if(d[i] % 2 == 0) {
					result[i - d[i]]++;
				} else {
					result[i - d[i] + 1]++;
				}
			}
		}
		Arrays.stream(result).forEach(v -> System.out.print(v + " "));
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 38744
l, r = map(int,input().split())
MOD = 2019
ans = 10**9
lm, rm = l%MOD, r%MOD
if lm ==0 or rm==0 or l//MOD!=r//MOD:
    ans = 0
else:
    for i in range(lm,rm):
        for j in range(i+1,rm+1):
            ans = min(ans,(i*j)%MOD)
print(ans)

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
char s[105];
int x=-1,y=-1,minx=105;
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C')
		{
			if(i<minx)
			{
				x=i;
				minx=i;
			}
		}
		if(s[i]=='F') y=i;
	}
	if(x==-1||y==-1) cout<<"No"<<endl;
	else if(x<y) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int N,W,dp[110][10010];

int main(){
    cin >> N >> W;
    int weight[110];
    int value[110];
    for(int i=0;i<N;i++){
        cin >> value[i] >> weight[i];
    }
    for(int i=0;i<=W;i++){
        dp[0][i]=0;
    }
    for(int n=0;n<N;n++){
        for(int w=0;w<=W;w++){
            if(w>=weight[n]){
                dp[n+1][w]=max(dp[n][w-weight[n]]+value[n],dp[n][w]);
            } else {
                dp[n+1][w]=dp[n][w];
            }
        }
    }

    cout << dp[N][W] << endl;
    return 0;

}


Measured memory_bytes: 7048
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<double,int> Pdi;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
priority_queue<Pdi,vector<Pdi>,greater<Pdi>> que;
vector<Pli> v[18];
P2 xy[MAX_N]={};
ll dp[1<<18]={};
string str[100000];
typedef pair<int,int> O;
typedef pair<O,O> P;
int main() {
	queue<P> que;
	int H,W;
	int a[500][500];
	bool b=false;
	cin>>H>>W;
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			cin>>a[i][j];
		}
	}
	int endh=H-1,endw=W-1;
	if(H%2==0)endw=0;
	int nh=0,nw=0;
	int N=0;
	while(1){
		if(nh==endh&&nw==endw)break;
		if(a[nh][nw]%2==1)b=!b;
		if(nh%2==0){
			if(nw==W-1){
				if(b){
					N++;
					que.push(P(O(nh+1,nw+1),O(nh+2,nw+1)));
				}
				nh++;
			}else{
				if(b){
					N++;
					que.push(P(O(nh+1,nw+1),O(nh+1,nw+2)));
				}
				nw++;
			}

		}else{
			if(nw==0){
				if(b){
					N++;
					que.push(P(O(nh+1,nw+1),O(nh+2,nw+1)));
				}
				nh++;
			}else{
				if(b){
					N++;
					que.push(P(O(nh+1,nw+1),O(nh+1,nw)));
				}
				nw--;
			}
		}
	}
	cout<<N<<endl;
	for(int i=0;i<N;++i){
		P p=que.front();que.pop();
		cout<<p.first.first<<" "<<p.first.second<<" "<<p.second.first<<" "<<p.second.second<<endl;
	}
	return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string st;
    cin >> st;
    int n = 0, s = 0, e = 0, w = 0;
    rep (i, st.size()) {
        if (st[i] == 'N') n++;
        else if (st[i] == 'S') s++;
        else if (st[i] == 'E') e++;
        else w++;
    }
    if ((n > 0 && s == 0) || (n == 0 && s > 0) || (e > 0 && w == 0) || (e == 0 && w > 0)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
}



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

int main()
{
	int h, w;
	string row;
	cin >> h >> w;
	
	char goal[h][w];
	
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> goal[i][j];
		}
	}
	
	for (int i = 0; i < h; i++) //row
	{
		for (int j = 0; j < w; j++) //column
		{
			if (goal[i][j] == '#')
			{
				if(!(goal[i+1][j] == '#' || goal[i-1][j] == '#' || goal[i][j-1] == '#' || goal[i][j+1] == '#'))
				{
					cout << "No" << endl;
					return 0;
				}
				
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
 
#define MOD 1000000007
#define INF 1000000000
 
using ll = long long int;
using namespace std;
 
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int N, L;
    cin >> N >> L;
    vector<string> s(N);
    rep(i,N) cin >> s[i];
    sort(s.begin(), s.end());

    string ans;
    rep(i,N) ans += s[i];

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  int n,k;
  cin >> n >> k;

  vector<int> l(n);
  rep(i,n) cin >> l[i];

  sort(l.begin(),l.end());
  int s=0;
  for (int i=0; i<k; i++) {
    s += l[n-1-i];
  }
  cout << s << endl;

  
}


int main() {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[100][100], b[100];

int main()
{
    int i, j, n, m, ans;
    scanf("%d%d", &n, &m);
    for(i=0; i<n; i++) {
        for(j=0; j<m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(i=0; i<m; i++) {
        scanf("%d", &b[i]);
    }
    for(i=0; i<n; i++) {
        ans=0;
        for(j=0; j<m; j++) {
            ans+=a[i][j]*b[j];
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 640
def rt(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x
N,M,K = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
D = {i:[] for i in range(1,N+1)}
for _ in range(K):
    c,d = map(int,input().split())
    D[c].append(d)
    D[d].append(c)
T = {i:[i,0] for i in range(1,N+1)}
for a in G:
    for b in G[a]:
        r1 = rt(a)
        r2 = rt(b)
        if r1!=r2:
            if T[r1][1]>=T[r2][1]:
                T[r2][0] = r1
                if T[r1][1]==T[r2][1]:
                    T[r1][1] += 1
            else:
                T[r1][0] = r2
C = {}
for i in range(1,N+1):
    rt1 = rt(i)
    if rt1 not in C:
        C[rt1] = 0
    C[rt1] += 1
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    rt1 = rt(i)
    numc = C[rt1]
    numd = len(G[i])
    B[i] = numc-1-numd
    for j in D[i]:
        if rt(j)==rt1:
            B[i] -= 1
print(*B[1:])

Measured memory_bytes: 124644
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d.sort()
t.sort()

a = 0
b = 0
cnt = 0
last = t[-1]
for i in range(a, n):
    for j in range(b, m):
        if d[i] == t[j]:
            cnt += 1
            b = j+1
            break
        elif d[i] < t[j]:
            break

if cnt == m:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 127572
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b,c,x,ans=0;
 	cin >> a>>b>>c>>x;
 	for (int i = 0; i < a+1; i++){
 		for (int j = 0; j < b+1; j++){
 			for (int k = 0; k < c+1; k++){
 				if(i*500+j*100+k*50==x){
 					ans++;
 				}
 			}
 		}
 	}
 	cout << ans << endl;
 }

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

int main(void)
{
    int N, D;
    scanf("%i %i", &N, &D);
    int X[N];
    int Y[N];
    for (int i = 0; i < N; i++)
    {
        scanf("%i %i", &X[i], &Y[i]);
    }
    int counter = 0;
    for (int i = 0; i < N; i++)
    {
        if ((long long)X[i] * X[i] + (long long)Y[i] * Y[i] <= (long long)D * D)
        {
            counter++;
            // printf("+");
        }
    }
    printf("%i\n", counter);
}

Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vector<vector<P>> G;
vl height;
bool ok = true;

void dfs(ll v, ll h) {
    // 行きの処理はこのへんに書く
    if(height[v] == INF) {
        height[v] = h;
    }
    else {
        if(height[v] != h) {
            ok = false;
        }
        return;
    }
    for(auto p : G[v]) { 
        ll u = p.first;
        ll cost = p.second;
        dfs(u, h + cost);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n, m;
    cin >> n >> m;    
    
    G.resize(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a].pb(make_pair(b, c));
        G[b].pb(make_pair(a, -c));
    }

    height.assign(n, INF);
    rep(v, n) {
        if(height[v] == INF) {
            dfs(v, 0);
        }
    }

    if(ok) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 15616
#include <stdio.h>

int A[1000000],t;

int binarySearch(int k){
	int left = 0,right = t;
	int mid;
	for(;left < right;){
		mid = (left+right)/2;
		if(k == A[mid])return 1;
		if(k > A[mid])left = mid +1;
		else if(k < A[mid]) right = mid;
	}
	return 0;
}

int main(void){
	int i,m,k;
	int sum = 0;
	
	scanf("%d",&t);
	for(i = 0;i < t;i++){
		scanf("%d",&A[i]);
	}
	
	scanf("%d", &m);
	for(i = 0;i < m; i++){
		scanf("%d",&k);
		if(binarySearch(k) == 1)sum++;
	}
	printf("%d\n",sum);
	return 0;
	
}


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

typedef long long int lint;
int N;
bool check(int i,lint m,vector<lint> &S)
{
	auto begin=S.begin()+i,end=S.begin()+i+N-1;
	
	auto bmk1=lower_bound(begin,end,m+(i?S[i-1]:0));
	auto bmk2=lower_bound(bmk1,end,m+*bmk1);
	return *end-*bmk2>=m;
}


int main()
{
	cin>>N;
	vector<lint> A(N),S(3*N);
	
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		S[2*N+i]=S[N+i]=S[i]=A[i];
	}
	
	for(int i=0;i<3*N-1;i++)
	{
		S[i+1]+=S[i];
	}
	
	lint ans=-1;
	for(int i=0;i<N;i++)
	{
		lint l=0,r=1e16,m;//left,right,middle
		while(l!=r)
		{
			m=(l+r+1)/2;
			if(check(i,m,S))
			{
				l=m;
			}
			else
			{
				r=m-1;
			}
		}
		ans=max(ans,l);
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 5992
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    vector<double> P(N);
    rep(i, N)cin >> P[i];

    vector<vector<double>> dp(N+1, vector<double>(N+1));
    dp[0][0] = 1;

    rep(i, N) {
        rep(j, i + 1) {
            dp[i + 1][j + 1] += dp[i][j] * P[i];
            dp[i + 1][j] += dp[i][j] * (1 - P[i]);
        }
    }

    double ans = 0;
    for (int i = N; i > N - i; --i)ans += dp[N][i];
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll total = 0;
    rep(i, n) total += a[i];

    float limit = (float)total * (1 / (4 * (float)m));
    int cnt = 0;
    rep(i, n) {
        if ((float)a[i] < limit) {
            ;
        } else {
            cnt++;
        }
    }

    if (cnt >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main(){

    int N,M;
    cin>>N>>M;
    vector<int> X(M),Y(M-1);
    for(int i=0;i<M;i++){
        cin>>X.at(i);
    }
    sort(X.begin(),X.end());
    for(int j=0;j<M-1;j++){
        Y.at(j)=X.at(j+1)-X.at(j);
    }
    sort(Y.begin(),Y.end());
    int ans=0;
        for(int i=0;i<M-N;i++){
        ans+=Y.at(i);
    }
        cout<<ans<<endl;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int p[N], c[N];

int main()
{
	cin >> n >> m;
	m /= 100;
	for (int i = 1; i <= n; i ++ )
	{
		cin >> p[i] >> c[i];
		c[i] /= 100;
	}
	
	int res = 0x3f3f3f3f;
	for (int i = 0; i < 1 << 10; i ++ )
	{
		int sum = 0, tot = m;
		for (int j = 1; j <= 10; j ++ )
			if ((i >> (j - 1)) & 1)
			{
				sum += p[j];
				tot -= p[j] * j + c[j];
			}
		for (int j = n; j; j -- )
			if (tot > 0 && !((i >> (j - 1)) & 1))
			{
				int need = (tot + j - 1) / j;
				if (need <= p[j] - 1)
				{
					sum += need;
					tot = 0;
				}
				else
				{
					sum += p[j] - 1;
					tot -= (p[j] - 1) * j;
				}
			}
		if (tot <= 0) res = min(res, sum);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n, m, k;
	cin >> n >> m >> k;
	Vec a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	Vec sa(n), sb(m);
	rep(i, n){
		if (i == 0) sa[i] = a[i];
		else
			sa[i] = sa[i - 1] + a[i];
	}
	rep(i, m){
		if (i == 0) sb[i] = b[i];
		else
			sb[i] = sb[i - 1] + b[i];
	}

	ll ans = upper_bound(all(sb), k) - sb.begin();
	rep(i, n){
		ll t = k - sa[i];
		if (t < 0) break;
		ll p = upper_bound(all(sb), t) - sb.begin();
		p--;
		chmax(ans, i + p + 2);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int main() {
  int n;
  cin >> n;
  vector<int> h(n+1);
  FOR(i, 1, n+1) {
    cin >> h[i];
  }

  FOR(i, 1, n+1) {
    cout << "node " << i << ": ";
    cout << "key = " << h[i] << ", ";
    if (i != 1) cout << "parent key = " << h[i/2] << ", ";
    if (2*i <= n) cout << "left key = " << h[2*i] << ", ";
    if (2*i+1 <= n) cout << "right key = " << h[2*i+1] << ", ";
    cout << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	lint a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({a*c, a*d, b*c, b*d})<<"\n";	

	return 0;	
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main(){
long N,A,B;
  cin>>N>>A>>B;
  long a=(N/(A+B))*A;
  long b=N % (A+B);
    if(A<=b)
      b=A;
  cout<<a+b<<endl;


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int 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(); }
    x*=f;
}

void solve(){
    int n;
    cin >> n;
    cout << n / 2 - (n % 2 == 0);
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

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

int m;
string s, s1,s2;
vector<string> v;

void add(string s){
  unsigned int i;

  if( v.size()==0 ){
    v.push_back( s );
    return;
  }

  for( i=0;i<v.size();i++ ){
    if( v[i]==s )
      return;
    if( v[i]>s ){
      v.insert( v.begin()+i, s );
      return;
    }
  }
  v.push_back( s );
}

string rev(string s){
  string r="";
  for( unsigned int i=0;i<s.length();i++ ){
    r = s.at(i) + r;
  }
  return r;
}

int main(){
  unsigned int ui,len;

  cin >> m;
  for( int loop=0;loop<m;loop++ ){
    cin >> s;
    //    cout << s << endl;
    
    v.clear();
    len = s.length();
    for( ui=1;ui<len;ui++ ){
      s1 = s.substr( 0,ui );
      s2 = s.substr( ui );
      //      cout << " "<<s1<<" "<<s2<<endl;
      add( s1+s2 );
      add( s1+rev(s2) );
      add( rev(s1)+s2 );
      add( rev(s1)+rev(s2) );
      add( s2+s1 );
      add( s2+rev(s1) );
      add( rev(s2)+s1 );
      add( rev(s2)+s1 );
    }
    cout << v.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 984
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        int A = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
        int B = int.Parse(str[1]);
        int C = 0;
        for (int i=0; i < 2; i++)
        {
            if(A < B)
            {
                C = C + B;
                B--;
            }else
            {
                C = C + A;
                A--;
            }
        }
        Console.WriteLine(C);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const int maxsize = 131072;
int val[262155];
void update(int ptr, int x) {
	ptr += maxsize; val[ptr] = x;
	while(ptr > 1) ptr >>= 1, val[ptr] = min(val[ptr * 2], val[ptr * 2 + 1]);
}
int query(int a, int b, int k, int l, int r) {
	if(a <= l && r <= b) return val[k];
	if(r <= a || b <= l) return inf;
	int lc = query(a, b, k * 2, l, (l + r) >> 1);
	int rc = query(a, b, k * 2 + 1, (l + r) >> 1, r);
	return min(lc, rc);
}
int N, Q, tp, x, y;
int main() {
	scanf("%d%d", &N, &Q);
	fill(val, val + maxsize * 2 + 1, inf);
	while(Q--) {
		scanf("%d%d%d", &tp, &x, &y);
		if(tp == 0) update(x, y);
		else printf("%d\n", query(x, y + 1, 1, 0, maxsize));
	}
	return 0;
}

Measured memory_bytes: 4164
#include <cstdio>
#include <cmath>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
int main( void ){
	int n;
	if (!scanf( "%d", &n )){
		return -1;
	}
	char* string = new char[n];
	if(!scanf("%s", string))
		return -1;
	int sum = 0;
	char c = ' ';
	for(int i = 0; i < n; i++){
		if (c != string[i])
			sum++;
		c = string[i];
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
  int N;
  cin >> N;
  int P[N];
  bool negative = false;
  for (int i = 0; i < N; ++i) {
    cin >> P[i];
    if (P[i] < 0) {
      negative = true;
    }
  }

  if (P[0] != 0 || negative) {
    printf("-1\n");
    return 0;
  }

  long cnt = P[N-1];
  
  for (int i = N-2; i >= 0; --i) {
    if (P[i] == P[i+1] - 1) {
      continue;
    }
    if (P[i] < P[i+1] - 1) {
      printf("-1\n");
      return 0;
    }
    cnt += P[i];
  }

  printf("%ld\n", cnt);
  
  return 0;
}


Measured memory_bytes: 1024
using System;
public class Hello{
    public static void Main(){
        string s = Console.ReadLine();
        //Console.WriteLine(s.Substring(0,s.Length / 2));
        //Console.WriteLine(s.Substring(s.Length / 2,s.Length / 2));
        s = s.Substring(0,s.Length - 1);
        
        while(s.Length > 0){
            if(s.Length % 2 == 0){
                if(s.Substring(0,s.Length / 2) == s.Substring(s.Length / 2,s.Length / 2)){
                    Console.WriteLine(s.Length);
                    return;
                }
            }
            s = s.Substring(0,s.Length - 1);
        }
    }
}


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

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

    int n;
    cin >> n;
    string ans(n, '-');
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;
        s--;
        if (ans[s] == '-') {
            ans[s] = '0' + c;
        } else {
            if (ans[s] != '0' + c) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    if (n == 1 && ans[0] == '-') {
        cout << 0 << endl;
        return 0;
    }
    if (ans[0] == '-') ans[0] = '1';
    for (int i = 1; i < n; i++) {
        if (ans[i] == '-') ans[i] = '0';
    }
    if (n > 1 && ans[0] == '0') {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

c = [[0] * 2001 for _ in range(2001)]
c[0][0] = 1
for i in range(1, 2001):
    ci = c[i]
    ci1 = c[i - 1]
    ci[0] = 1
    for j in range(1, i + 1):
        ci[j] = (ci1[j - 1] + ci1[j]) % 1000000007

for i in range(1, K + 1):
    print(c[K - 1][i - 1] * c[N - K + 1][i] % 1000000007)


Measured memory_bytes: 98292
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a+b+c)>=22)
  {
    cout<<"bust"<<endl;
    return 0;
  }
  else
  {
    cout<<"win"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256