akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n;
bool solve(vi &a){
	int e = 0, oi, one = 0;
	ll sum = 0;
	rep(i, n){
		if(a[i] % 2 == 0) e++;
		else oi = i;
		
		if(a[i] == 1) one++;
		sum += a[i] - 1;
	}
	
	if(one) return sum % 2;
	if(e % 2) return 1;
	
	if(e == n - 1){
		a[oi]--;
		int g = a[0];
		for(int i : a) g = __gcd(i, g);
		for(int &i : a) i /= g;
		return !solve(a);
	}
	return 0;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	vi a(n); rep(i, n) cin >> a[i];
	cout << (solve(a) ? "First" : "Second") << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
#define setzero(x) memset(x,0,sizeof(x))
  
using namespace std;
 
const int inf = 2e9+500;
const int N = 3e5+100;
const int bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;
const ll bs = 550;


int main(){

    FASTIO;
    PRECISION; 

    int n;
    cin>>n;

    vector<array<ll,2>>arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i][0];
        arr[i][1] = i;
    }

    sort(arr.begin(),arr.end());

    // for(int i=0;i<n;i++){
    //     cout<<arr[i][0]<<" "<<arr[i][1]<<"\n";
    // }

    vector< vector<ll> >dp(n+1,vector<ll>(n+1));

    for(int i=0;i<n;i++){
        dp[i][i] = abs(arr[0][1]-i)*arr[0][0];
    }



    for(int len = 2;len<=n;len++){
        for(int i=0,j=len-1;j<n;i++,j++){
            dp[i][j] = max({dp[i][j],dp[i+1][j]+arr[len-1][0]*abs(arr[len-1][1]-i)});

            // cout<<dp[i+1][j]<<" "<<arr[j][0]*abs(arr[j][1]-i)<<" * ";

            dp[i][j] = max({dp[i][j],dp[i][j-1]+arr[len-1][0]*abs(arr[len-1][1]-j)});

            // cout<<dp[i][j-1]<<" "<<arr[j][0]*abs(arr[j][1]-j)<<" * ";
            // cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
        }
    }

    cout<<dp[0][n-1]<<"\n";
    

}

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

A = list(map(int,input().split()))
F = list(map(int,input().split()))

A.sort()
F.sort(reverse=True)

def check(v):
    ans = 0
    for i in range(N):
        ans += max(A[i] - v//F[i],0)
    return ans<=K

if check(0):
    print(0)
else:
    l = 0
    r = 10**12 + 1
    while r-l>1:
        if check((l+r)//2):
            r = (l+r)//2
        else:
            l = (l+r)//2
    print(r)

Measured memory_bytes: 120652
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		int C = GetInt();
		int K = GetInt();
		List<int> T = new List<int>(N);
		for(int i = 0; i < N; i++)
			T.Add(GetInt());
		T.Sort();

		int ans = 0;
		int limit = -1;
		int num = 0;
		{
			int i = 0;
			while(i < N)
			{
				if(limit == -1)
					limit = T[i] + K;

				if(num < C && T[i] <= limit)
				{
					num++;
					i++;
				}
				else
				{
					num = 0;
					limit = -1;
					ans++;
				}
			}
			if(num != 0)
				ans++;
		}		

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'



// ********** CODE STARTS HERE ****************//

int main()
{
	fastio;
    int N;
    cin >> N;
    vl a(N);
    fi(N)
        cin >> a[i];
    ll xr = 0;
    fi(N)
        xr^=a[i];
    fi(N)
    {
        cout<<(xr^a[i])<<' ';
    }
    cout<<endl;
	return 0;
}

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

const int maxn = 2e5 + 5;
int head[maxn], next[2*maxn], ver[2*maxn];
long long cnt[maxn];
int tot = 1, n, q;
long long ans[maxn];
void add(int a, int b){
	ver[++tot] = b;
	next[tot] = head[a], head[a] = tot;
}

void solve(int u, int f, long long val){
	ans[u] = val + cnt[u];
	val += cnt[u];
	for(int i=head[u];i;i=next[i]){
		int y = ver[i];
		if(y == f) continue;
		else solve(y,u,val);
	}
}

int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;i++){
		int a, b;
		scanf("%d%d",&a,&b);
		add(a,b);
	}
	for(int i=1;i<=q;i++){
		long long a;
		int b;
		scanf("%d%lld",&b,&a);
		cnt[b] += a;
	}
	solve(1,0,0);
	for(int i=1;i<=n;i++) printf("%lld ",ans[i]);
	return 0;
}

Measured memory_bytes: 18432
import math
N = int(input())
hs = list(map(int,input().split()))
c = 0
while True:
    pmi = 101
    start = 0
    flag = True
    for i in range(N):
        if hs[i] == 0:
            if pmi == 101:
                start += 1
                continue
            for j in range(start,i):
                hs[j] -= pmi
            #print(hs)
            c += pmi
            start = i+1
            pmi = 101
        else:
            flag = False
            pmi = min(pmi, hs[i])
    if flag:
        break
    else:
        if pmi != 101:
            for i in range(start,N):
                hs[i] -= pmi
            c += pmi
print(c)

Measured memory_bytes: 65648
#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 rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vvi G(n*3);
    rep(i,m) {
        int v,u;
        cin >> v >> u;
        v--; u--;
        rep(j,3) G[v*3+j].pb(u*3+(j+1)%3);
    }
    int s,t;
    cin >> s >> t;
    s--; t--;
    vi dist(n*3,inf);
    dist[s*3] = 0;
    deque<int> q;
    q.pb(s*3);
    while(q.size()) {
        int v = q.front();
        q.pop_front();
        for(int u : G[v]) {
            if(v%3 == 2) {
                if(chmin(dist[u],dist[v]+1)) q.pb(u);
            } else {
                if(chmin(dist[u],dist[v])) q.push_front(u);
            }
        }
    }
    cout << (dist[t*3] == inf ? -1 : dist[t*3]) << endl;
}


Measured memory_bytes: 17792
#include <iostream>
#include<string>
#include<stdio.h>
#include<sstream>
#include<map>
#include<vector>
#include<queue>
using namespace std;
int main()
{
  string s;
  cin>>s;
  for(auto a:s)
  {
      if(a=='A') cout<<"T";
      else{
        if(a=='T') cout<<"A";
        else
        {
            if(a=='C')  cout<<"G";
            else cout<<"C";
        }
      }
  }
}










Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

typedef pair<int, int> Edge;

int n;
vector<Edge> G[100000];
vector<ll> D(100000, 0);

void dfs(int v, int p = -1, ll dist = 0) {
  D[v] = dist;
  for (auto &&edge: G[v]) {
    if (p == edge.first) continue;
    dfs(edge.first, v, dist + edge.second);
  }
}


int main() {
  cin >> n;
  loop(i,0,n-1) {
    int a, b, c; cin >> a >> b >> c;
    a--;b--;
    G[a].emplace_back(b, c);
    G[b].emplace_back(a, c);
  }
  int q, k; cin >> q >> k; k--;
  dfs(k);
  
  while (q--) {
    int x, y; cin >> x >> y; x--;y--;
    cout << D[x] + D[y] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int n;
	cin >> n;
	vector<long long> a(n + 1);
	for (auto &e : a) cin >> e;
	
	reverse(a.begin(), a.end());
	
	vector<long long> b(n + 2, 0);
	for (int i = 0; i < n + 1; i++) b[i + 1] = b[i] + a[i];
	b.erase(b.begin());

	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	
	long long v = 1LL;
	for (int i = 0; i < n + 1; i++) {
		if (chmin(b[i], v)) {
			v = (v - a[i]) * 2LL;
		} else {
			v = b[i];
		}
	}
	
	bool flag = (b[n] == a[n]);
	long long ans = 0;
	for (auto e : b) {
		flag &= (e > 0);
		ans += e;
	}

	if (not flag) ans = -1;
	
	cout << ans << '\n';
}

Measured memory_bytes: 4840
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *r, *l, *p;
};

Node *root, *NIL;

Node * find (Node *u, int k) {
    while (u != NIL && k != u->key) {
        if (k < u->key) u = u->l;
        else u = u->r;
    }
    return u;
}

void insert (int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->l;
        } else {
            x = x->r;
        }
    }
    z->p = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->l = z;
        } else {
            y->r = z;
        }
    }
}

void inorder (Node *u) {
    if (u == NIL) return;
    inorder(u->l);
    printf(" %d", u->key);
    inorder(u->r);
}

void preorder (Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->l);
    preorder(u->r);
}

int main () {
    int n, i, x;
    string com;

    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            cin >> x;
            Node *t = find(root, x);
            if (t != NIL) cout << "yes\n";
            else cout << "no\n";
        } else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 22016
#include<stdio.h>
int a,b;
int main(){
	scanf("%d %d",&a,&b);
	if(a==1)
		a=14;
	if(b==1)
		b=14;

	if(a==b)
		printf("Draw");
	else if(a>b)
		printf("Alice");
	else
		printf("Bob");
		
	
}

Measured memory_bytes: 128
A,B,M=map(int, input().split())
As=list(map(int, input().split()))
Bs=list(map(int, input().split()))
List=[]
for i in range(M):
  List.append(list(map(int, input().split())))

ans=min(As)+min(Bs)
for l in List:
  candidate=As[l[0]-1]+Bs[l[1]-1]-l[2]
  ans = min(ans, candidate)
print(ans)


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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }

    ll ans = INF;

    for (ll i = -100; i <= 100; i++){
        ll x = 0;
        for (ll j = 0; j < n; j++){
            x += (a[j] - i)*(a[j] - i);
        }
        ans = min(ans,x);
    }

    cout << ans << endl;

}

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

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		Long[] h = new Long[N];
		for(int i =0;i<N;i++) {
			h[i]=scan.nextLong();
		}

		Arrays.sort(h);

		Long result = h[N-1]+1;

		//N=5, K=3のとき比較対象はh[0]とh[2]、比較終了はh[3]とh[5]
		//N=n, K=kのとき比較対象はh[i]とh[i+k-1]、比較終了はh[n-k+1]とh[n]

		for(int i=0;i<N-K+1;i++) {
			if(h[i+K-1]-h[i]<result) {
				result=h[i+K-1]-h[i];
			}
		}
		System.out.println(result);

	}
}

Measured memory_bytes: 62560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ans = 0;
  int N;
  cin >> N;
  vector<int> B(N - 1);
  vector<int> A(N);
  REP(i, N - 1) cin >> B[i];
  A[0] = B[0];
  ans += A[0];
  FOR(i, 1, N - 1) {
    if (B[i - 1] > B[i])
      A[i] = B[i];
    else
      A[i] = B[i - 1];
    ans += A[i];
    // debug(i);
    // debug(B[i]);
    // debug(A[i]);
  }
  ans += B[N - 2];
  cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if (((a * b) % 2) == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }

  }
}

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

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long n = scan.nextLong();
		long a = scan.nextLong();
		long b = scan.nextLong();
		
		long count = n / (a + b);
		long rem = n - count * (a + b);
		
		System.out.println(count * a + Math.min(rem, a));
	}
}

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

/* Point */
class Point
{
private:
  double x;
  double y;

public:
  Point(double a, double b):
    x(a), y(b)
  {}

  Point rotate()
  {
    double temp_x = x;
    double temp_y = y;
    temp_x = (1.0 / 2.0) * x - (sqrt(3.0) / 2.0) * y;
    temp_y = (sqrt(3.0) / 2.0) * x + (1.0 / 2.0) * y;
    return Point(temp_x, temp_y);
  }

  friend Point operator+(const Point& p1, const Point& p2);
  friend Point operator-(const Point& p1, const Point& p2);
  friend Point operator*(const Point& p, const double& n);
  friend ostream& operator<<(ostream& os, const Point& p);
};

Point operator+(const Point& p1, const Point& p2)
{
  return Point(p1.x + p2.x, p1.y + p2.y);
}

Point operator-(const Point& p1, const Point& p2)
{
  return Point(p1.x - p2.x, p1.y - p2.y);
}

Point operator*(const Point& p, const double& n)
{
  return Point(p.x * n, p.y * n);
}

ostream& operator<<(ostream& os, const Point& p)
{
  os << fixed << setprecision(8) << p.x << ' ' << p.y;
  return os;
}

// Generate a triangle in a line
vector<Point> gen_triangle(const Point& p1, const Point& p2)
{
  Point pa = p1 + ((p2 - p1) * (1.0 / 3.0));
  Point pc = p1 + ((p2 - p1) * (2.0 / 3.0));
  Point pb = pa + (pc - pa).rotate();
  return vector<Point>{pa, pb, pc};
}

// Generate triangles along the specified points
vector<Point> iterate_triangle(vector<Point> points)
{
  vector<Point> result;
  for (vector<Point>::const_iterator itr = points.begin(); itr != points.end() - 1; ++itr)
  {
    result.push_back(*itr);
    vector<Point> buffer = gen_triangle(*itr, *(itr + 1));
    for (int i = 0; i < 3; ++i)
    {
      result.push_back(buffer.at(i));
    }
  }
  result.push_back(*(points.end() - 1));

  return result;
}

// Generate Koch Curve
vector<Point> gen_koch(const int& n)
{
  if (n == 0)
  {
    return vector<Point>{Point{0, 0}, Point{100, 0}};
  }
  else
  {
    return iterate_triangle(gen_koch(n - 1));
  }
}

int main()
{
  int n;
  cin >> n;
  vector<Point> v = gen_koch(n);

  for (vector<Point>::const_iterator itr = v.begin(); itr != v.end(); ++itr)
  {
    cout << *itr << endl;
  }

  return 0;
}



Measured memory_bytes: 3328
#!/usr/bin/env python
# coding: utf-8

# In[16]:


S = int(input())


# In[17]:


x1 = 0; y1 = 0
if S <= 10**9:
    x2 = S; y2 = 0
    x3 = 0; y3 = 1
else:
    x2 = 10**9; y2 = 1
    mod = 10**9
    x3 = (mod - S%mod)%mod
    y3 = (S+x3)//mod
print(x1,y1,x2,y2,x3,y3)


# In[ ]:






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

using namespace std;

int main() {
	int64_t L, R;
	cin >> L >> R;

	if (R - L + 1 >= 673) {
		cout << 0 << endl;
	}
	else {
		int64_t ans = 2019;
		for (int64_t i = L; i <= R; i++) {
			for (int64_t j = i + 1; j <= R; j++) {
				int64_t s = (i*j) % 2019;
				ans = min(ans, s);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int i,j;
int main(void)
{
    int a[3],key=0,sum=0;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<3;i++)
    {
        if(a[i]==5||a[i]==7)
        {
            key++;
        }
    }
    sum=a[0]+a[1]+a[2];
    if(key==3&&sum==17)
    {
        printf("YES");
    }else{
        printf("NO");
    }
    
    return 0;
}

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

using namespace std;

const int MAXN=512;
double dp[MAXN][MAXN][MAXN];
int num[8];
int n;

double dfs(int a,int b,int c){
	if(a==n) return 0;
	if(dp[a][b][c]) return dp[a][b][c];
	double res=(double)n/(n-a);
	if(b) res+=dfs(a+1,b-1,c)*b/(n-a);
	if(c) res+=dfs(a,b+1,c-1)*c/(n-a);
	if(n-a-b-c) res+=dfs(a,b,c+1)*(n-a-b-c)/(n-a);
	return dp[a][b][c]=res;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		num[x]++;
	}
	double ans=dfs(num[0],num[1],num[2]);
	printf("%.10lf\n",ans);
	return 0;
}
 

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

int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  
  int ans=min(k,a);
  k-=a;
  if (k<=0)
    cout<<ans;
  else
  {
    k-=b;
    if (k<=0)
      cout<<ans;
    else
    {
      cout<<ans-min(c,k);
    }
  }
}

Measured memory_bytes: 3588
import numpy as np

N, A, B = map(int, input().split())
A -= B
H = np.array([int(input()) for _ in range(N)], dtype=np.int64)


def C(X):
    """
    x回爆発して、全部消滅させれるとTrue
    """
    HP = H - X * B
    HP = HP[HP > 0]
    cnt = (HP + A - 1) // A
    return cnt.sum() <= X


l = -1
r = 10 ** 18
while r - l > 1:
    m = (r + l) // 2
    if C(m):
        r = m
    else:
        l = m

ans = r
print(ans)


Measured memory_bytes: 17856
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const int INF = 1e9;
vector<int>to[200200];
int a[200200];
int dp[200200];
int ans[200200];

void dfs(int v,int pre=-1){
    int idx=lower_bound(dp, dp+200200, a[v])-dp;
    int prenum=dp[idx];
    dp[idx]=a[v];
    ans[v]=lower_bound(dp, dp+200200, INF)-dp-1;
    for(auto u:to[v]){
        if(u==pre) continue;
        dfs(u,v);
    }
    dp[idx]=prenum;
}

signed main(){
    int n; cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        int u,v; cin >> u >> v;
        u--; v--;
        to[u].pb(v); to[v].pb(u);
    }
    rep(i,200200)dp[i]=INF;
    dp[0]=-INF;
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
}


Measured memory_bytes: 31068
import java.util.Scanner
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n,m = sc.nextInt
    val list = List.fill(n)(sc.nextInt) // nextIntがn回呼ばれる
    
    val allPoint = list.sum
    val kijun = (list.sum.toDouble/(4D*m.toDouble)).toInt
    
    def kijunOver(x: Int, m:Int, kijun: Long): Long = {
      x match{
        case x if (x*4.0*m).toLong < kijun => 0
        case x if (x*4.0*m).toLong >= kijun => 1 
      }
    }
    
    val list2 = list.map(kijunOver(_, m, allPoint.toLong))
 	
    
    list2.sum >= m match{
        case true => println("Yes")
        case false => println("No")
    }
  }
}
 

Measured memory_bytes: 25792
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(K,T);
  vi a(T); in(a);
  sort(all(a));
  out(max(0 , (a.back() * 2) - K - 1));
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

map<string, int> mp;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    cout << x / (y + z) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());

		HashMap<Integer, Integer> ty = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> tx = new HashMap<Integer, Integer>();

		for(int i=1;i<=H;i++) {
			for(int j=1;j<=W;j++) {
				int a = Integer.parseInt(sc.next());
				ty.put(a,i);
				tx.put(a,j);
			}
		}
		int[] d = new int [90001];
		for(int i=D+1;i<=H*W;i++) {
			d[i]=d[i-D]+Math.abs(ty.get(i)-ty.get(i-D))+Math.abs(tx.get(i)-tx.get(i-D));
		}
		StringBuilder buf = new StringBuilder();
		int Q = Integer.parseInt(sc.next());
		while(Q>0) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			buf.append(d[R]-d[L]+System.getProperty("line.separator"));
			Q--;
		}
		sc.close();
		System.out.println(buf);
    }
}

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

int main()
{
    int N;
    cin >> N;
    int s = sqrt(N);
    cout << (s * s) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef map<int, int> MI;
typedef set<int> SI;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COUT(x) cout << (x) << endl

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


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

    string s; cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'o') cnt++;
    }
    if((15 - s.size()) + cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

const int INF=100000000;

int N;
vector <int> ab[100100];
int F=0, S=0;
int Fgraph[100100];
int Sgraph[100100];

int main(){
        cin>>N;
        for(int i=0;i<=N;i++){
                Fgraph[i]=INF;
                Sgraph[i]=INF;
        }
        for(int i=0;i<N-1;i++){
                int aa, bb;
                cin>>aa>>bb;
                ab[aa].push_back(bb);
                ab[bb].push_back(aa);
        }
        queue <int> q;
        //Fennec
        Fgraph[1]=0;
        q.push(1);
        while(!q.empty()){
                int qq=q.front();
                q.pop();
                for(int i=0;i<(int)ab[qq].size();i++){
                        if(Fgraph[ab[qq][i]]==INF){
                                Fgraph[ab[qq][i]]=Fgraph[qq]+1;
                                if(ab[qq][i]!=N)
                                        q.push(ab[qq][i]);
                        }
                }
        }

        //Snuke
        Sgraph[N]=0;
        q.push(N);
        while(!q.empty()){
                int qq=q.front();
                q.pop();
                for(int i=0;i<(int)ab[qq].size();i++){
                        if(Sgraph[ab[qq][i]]==INF){
                                Sgraph[ab[qq][i]]=Sgraph[qq]+1;
                                if(ab[qq][i]!=1)
                                        q.push(ab[qq][i]);
                        }
                }
        }
        for(int i=2;i<=N-1;i++){
                //cout<<i<<":"<<Fgraph[i]<<" "<<Sgraph[i]<<endl;
                if(Sgraph[i]>=Fgraph[i]){
                        F++;
                }
                else{
                        S++;
                }
        }
        //cout<<F<<" "<<S<<" "<<SF<<endl;
        if(F>S){
                cout<<"Fennec"<<endl;
        }
        else{
                cout<<"Snuke"<<endl;
        }
        return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    speed;
    ll n;
    cin>>n;
    if(n%2 !=0)
    {cout<<"0"<<"\n";return 0;}
    ll x=10;
    ll sum=0;
    for(ll i=5;n/i>=1 ; i=i*5)
    {
        // if(n%2==0)
        sum+=(n/i)/2;
        
        
    }
    
    cout<<sum<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,T,i,j,count=0;
	int c[102],t[102],a[102];
	cin>>n>>T;
	for(i=0;i<n;i++){
		cin>>c[i]>>t[i];
		if(t[i]<=T){
			a[count++]=c[i];
		}
	}
	if(count==0){
		cout<<"TLE"<<endl;
		return 0;
	}
	for(i=0;i<count-1;i++){
		for(j=0;j<count-1-i;j++){
			if(a[j]>a[j+1]){
				int temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	cout<<a[0]<<endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  char ss = S.at(0);
  if (ss == 'a' || ss == 'i' || ss == 'u' || ss == 'e' || ss == 'o')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <string>
#include <iostream>

using namespace std;

int main()
{
	long long ans=1, i, j, k, l, m, n, N, M, cnt=0;
	string A[50], B[50];

	cin >> N >> M;
	for (i = 0; i < N; i++)
		cin >> A[i];
	for (i = 0; i < M; i++)
		cin >> B[i];

	int al, bl;
	al = A[0].length(); bl = B[0].length();

	for (i = 0; i < N - M + 1; i++) {
		for (j = 0; j < al - bl + 1; j++) {
			if (A[i][j] == B[0][0]) {
				cnt = 0;
				for (k = 0; k < bl; k++) {
					for (l = 0; l < M; l++) {
						if (A[i + l][j + k] == B[l][k])
							cnt++;
					}
				}
				if (cnt == bl*M) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
mod = 998244353


def pow_by_iter(a, x, n):
    acc = a
    for i in range(1, x):
        acc = (acc * a) % n
    return acc


d = Counter(D)
d_key = sorted(d.keys())
if D[0] != 0 or d[0] > 1:
    print(0)
    exit()


answer = 1

for i in range(1, len(d_key)):
    if d_key[i] != d_key[i - 1] + 1:
        print(0)
        exit()
    else:
        answer *= pow_by_iter(d[d_key[i - 1]], d[d_key[i]], mod)
        answer %= mod

print(answer)

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

#define V_MAX 100005

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

	const int INF = W+1;
	int dp[V_MAX];
	for (int j = 1; j < V_MAX; ++j) dp[j] = INF;
	dp[0] = 0;
	int v_idx = 0;
	for (int i = 0; i < N; ++i) {
		int w, v;
		cin >> w >> v;
		int idx = v_idx;
		int tmp[V_MAX];
		for (int j = 0; j <= idx; ++j) tmp[j] = dp[j];
		for (int j = 0; j <= idx; ++j) {
			dp[j+v] = min(dp[j+v], tmp[j] + w);
			if (dp[j+v] < INF) v_idx = max(v_idx, j+v);
		}
	}
	int ans = v_idx;

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

Measured memory_bytes: 1024
from collections import deque

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

edges = []
dfsEdges = [[] for _ in range(N)]
dfsReverseEdges = [[] for _ in range(N)]

for _ in range(M):
    back, to, cost = map(int, input().split())
    back -= 1
    to -= 1
    edges.append((back, to, -cost))

    dfsEdges[back].append(to)
    dfsReverseEdges[to].append(back)

minDist = [float('inf') for _ in range(N)]
minDist[0] = 0

canGo = [False for _ in range(N)]
canBack = [False for _ in range(N)]

canGo[0] = True
canBack[N - 1] = True

def dfs(start, edge, confilm):
    que = deque([])
    que.append(start)

    while que:
        now = que.pop()
        for to in edge[now]:
            if not confilm[to]:
                que.append(to)
                confilm[to] = True

dfs(0, dfsEdges, canGo)
dfs(N - 1, dfsReverseEdges, canBack)

for time in range(N):
    for back, to, cost in edges:
        if minDist[to] > minDist[back] + cost:
            minDist[to] = minDist[back] + cost
            if time == N - 1:
                if canGo[to] and canBack[to]:
                    print('inf')
                    exit(0)

print(-minDist[N - 1])

Measured memory_bytes: 3948
n,k=map(int,input().split( ))
s=list(input())

if s[k-1]=='A':
    s[k-1]='a'
elif s[k-1]=='B':
    s[k-1]='b'
elif s[k-1]=='C':
    s[k-1]='c'

print(''.join(s))

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

using namespace std;
using ll = long long;

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

  string s;
  cin >> s;
  if (s[s.size() - 1] != 's') {
    s += "s";
  } else {
    s += "es";
  }
  cout << s << endl;

  return 0;
}


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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 3e3 + 5;
const int inf = 1e9+7;

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

string a, b, ans;

int main()
{
    cin >> a >> b;
    a = ' ' + a;
    b = ' ' + b;
    n = a.size() - 1;
    m = b.size() - 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i] == b[j])
                dp[i][j] = dp[i - 1][j - 1] + 1, p[i][j] = 2;
            else
            {
                if (dp[i - 1][j] >= dp[i][j - 1])
                    dp[i][j] = dp[i - 1][j], p[i][j] = 0;
                else
                    dp[i][j] = dp[i][j - 1], p[i][j] = 1;
            }
        }
    }
    int x = n, y = m;
    while (x >= 1 && y >= 1)
    {
        if (p[x][y] == 2)
               ans = a[x] + ans, x--, y--;
        else if (p[x][y] == 1)
            y--;
        else
            x--;
    }
    cout << ans << endl;
}




Measured memory_bytes: 70784
#include<iostream>
using namespace std;
int main(void){
    int n,r;
    string s; 
    cin>>n;
    while(n){
        r=n%(-2);
        r=(r?1:0);
        s=(r?"1":"0")+s;
        n=(n-r)/(-2);
    }
    if(s=="")s+="0";
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int a,b,x; cin >> a >> b >> x;
    if (a <= x && x <= a + b) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}

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

const int N = 200000;
int a[N+5];

int main(){
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a+i);
    sort(a+1, a+n+1, greater<int>());
    long long ans = 0;
    queue<int> Q;
    for (int i = 1; i <= n; ++i){
        if (!Q.empty()){
            ans += Q.front();
            Q.pop();
        }
        if (i == 1) Q.push(a[i]);
        else { Q.push(a[i]); Q.push(a[i]); }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5304
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

long long getDigit(long long num){
    long long digit = 0;
    while(num != 0){
        num /= 10;
        ++digit;
    }
    return digit;
}

long long getDigitSum(long long num){
    long long sum = 0;
    while(num > 0){ 
        sum += num % 10; 
        num /= 10;
    }
    return sum;
}

void solve(){

}
int main(){
    ll n;
    cin >> n;
    ll ans = INT_MAX;
    for (int i = 1; i <= n/2; i++){
        int a = i;
        int b = n-i;
        ans = min(ans, getDigitSum(a)+getDigitSum(b));
    }
    cout << ans << endl;



    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<bool> sink(n+2, 0);
    sink[0] = sink[n+1] = true; // centinel
    vector<pair<int,int>> vp;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        vp.push_back({x, i+1});
    }
    vp.push_back({0, 0});  // centinel
    sort(vp.begin(), vp.end());
    int ans = 0, tmp = 1;
    for(int i = 1; i < vp.size(); i++){
        if(vp[i].first != vp[i-1].first)    ans = max(ans, tmp);
        int pos = vp[i].second;
        sink[pos] = true;
        if(sink[pos-1]+sink[pos+1] == 0)        tmp++;
        else if(sink[pos-1]+sink[pos+1] == 2)   tmp--;
    }
    cout << max(ans, tmp) << endl;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    ll ans=0;
    vector<ll>v(n);
    vector<ll>c(n);
    for (int i = 0; i < n; ++i) {
        cin >>v[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >>c[i];
    }
    for (int i = 0; i < n; ++i) {
        ans+=max(0LL,v[i]-c[i]);
    }
    cout <<ans <<endl;
    return 0;
}

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

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

typedef long long ll;

//#define INF 0x3fffFFFF
//#define INF_NEG (INF * -1)

#define MAX_N 100000

signed main()
{
    int n,m; cin >> n >> m;
    vector<int>room[MAX_N + 10];
    rep(i,m){
        int a, b; cin >> a >> b;
        --a; --b;
        room[a].push_back(b);
        room[b].push_back(a);
    }

    vector<int> from(n,-1);
    vector<int> distance(n,-1);
    distance[0] = 0;
    queue<int> q;
    q.push(0);

    while(!q.empty()){
        int v = q.front(); q.pop();
        for (int r: room[v]){
            if(distance[r] != -1) continue;
            distance[r] = distance[v] + 1;
            from[r] = v;
            q.push(r);
        }
    }

    bool OK = true;
    for (int i = 1; i < n; ++i) if(from[i] == -1) OK = false;

    if (OK){
        puts("Yes");
        for (int i = 1; i < n; ++i) cout << from[i] + 1 << endl;
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 10620
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

x = list(map(int , input().split()))
for i in range(len(x)):
	if x[i] == 0:
		print(i+1)
		exit()









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

int main() {
    int A,B;
    cin >> A >> B;
    if (A<=5)
    cout << 0 << endl;
    else if (6<=A&&A<=12)
    cout << B/2 << endl;
    else 
    cout << B << endl;
}

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;


int32_t main(){
    FAST;

    int a, b;
    cin >> a;
    char ch;    cin >> ch;
    cin >> b;

    if(ch == '+')
        cout << a + b;
    else cout << a - b;

    return 0;
}




Measured memory_bytes: 256
from collections import defaultdict
import math
# N, K = map(int, input().split(' '))
N = int(input())
wa = 0
d = defaultdict(set)
d[1].add(1)

for i in range(2, 201):
    for j in range(i, 0, -1):
        if i % j == 0:
            d[i].add(j)

for i in range(1, N+1):
    for j in range(1, N+1):
        for k in range(1, N+1):
            #wa += 1
            wa += max(d[i] & d[j] & d[k])
print(wa)
# wa = 0
# for i in range(1, N+1):
#     if i % 3 == 0 or i % 5 == 0:
#         continue
#     wa += i
# print(wa)


Measured memory_bytes: 69548
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")



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

	int n, i, j, k;
	bool found = false;

	cin >> n;
	vector<int> x(n), y(n);
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];

	for (i = 2; i < n; i++) {
		if ((x[i - 2] == y[i - 2]) && (x[i - 1] == y[i - 1]) && (x[i] == y[i])) found = true;
	}
	if (found) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}




Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  int i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  int count=1,maxi=vec.at(0);
  for(i=1;i<n;i++){
    if(maxi<=vec.at(i)){
      maxi=vec.at(i);
      count++;
    }
  }
  cout << count;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxn = 234567, base = 227;
int pre[26];
int n;
string s[maxn];
int f[maxn][26];
unordered_map<int, int> want; 
int fu;

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	F1 (i, n)
		cin >> s[i];
}

void solve()
{
	F1 (i, n)
	{
		int hsh = 0;
		for (int j = s[i].length() - 1; j >= 1; --j)
		{
			hsh *= base; hsh += s[i][j];
		}
		if (!want.count(hsh)) want[hsh] = ++fu;
		f[want[hsh]][s[i][0] - 'a']++;
	}
	int ans = 0;
	F1 (i, n)
	{
		for (auto x : s[i]) ++pre[x - 'a'];
		int hsh = 0;
		if (want.count(hsh))
		{
			int cur = want[hsh];
			for (int j = 0; j < 26; ++j)
				if (pre[j]) ans += f[cur][j];
		}
		for (int j = s[i].length() - 1; j >= 0; --j)
		{
			--pre[s[i][j] - 'a'];
			hsh *= base; hsh += s[i][j];
			if (want.count(hsh))
			{
				int cur = want[hsh];
				for (int j = 0; j < 26; ++j)
					if (pre[j]) ans += f[cur][j];
			}
		}
	}
	cout << ans - n << '\n';
}

main()
{
	input();
	solve();
}


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

using namespace std;

int main()
{
    int a, b, c, k, count = 0;
    cin >> a >> b >> c >> k;
    while (k > 0 && a--)
    {
        count++;
        k--;
    }
    while (k > 0 && b--)
    {
        k--;
    }
    while (k > 0 && a--)
    {
        count--;
        k--;
    }
    cout << count << endl;
}

Measured memory_bytes: 3600