akhauriyash/Code-Regression huggingface dataset:
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=(0);i<(n);i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if(!e)return 1;
    if(e&1) return qpow(b,e-1)*b;
    int pwur=qpow(b,e>>1);
    return pwur*pwur;
}

/// My Code -------------------------------------------------

bool can(int a){
    string s=to_string(a);
    int n=s.size();
    bool ok=true;
    for(int i=0;i<n/2;i++)if(s[i]!=s[n-1-i])ok=0;
    return ok;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int a,b;
    cin>>a>>b;
    int cnt=0;
    vi v;
    rep2(i,a,b+1){
        if(can(i))cnt++;
    }
    cout<<cnt<<enl;

    return 0;
}


Measured memory_bytes: 3704
N=int(input())
L=list(map(int,input().split()))
m=[]
for i in range(1,N+1):
  m.append(i)
m.sort()
a=0
for j in range(N):
  if L[j]!=m[j]:
    a+=1
if a<=2:
  print('YES')
else:
  print('NO')
  

Measured memory_bytes: 3060
#include<iostream>	// 入出力
#include<stdio.h>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか


using namespace std;

using ll = long long;

int N;

int i;
string s;



int main()
{
	
	cin >> N;

	cout << 0 << endl;

	i = 0;
	cin >> s;

	if (s == "Vacant") { return 0; }

	int lb = -1, ub = N;

	while (true)
	{
		int mid = (lb + ub)/2;

		string s2;

		cout << mid << endl;;

		cin >> s2;

		if (s2 == "Vacant") { return 0; }
		
		if ((mid - i) % 2 == 1 || (mid-i<0&&(mid - i) % 2 == 0))
		{
			if (s == "Male") { s = "Female"; }
			else { s = "Male"; }
		}

		if (s == s2)
		{
			lb = mid;
		}
		else
		{
			ub = mid;
		}

		i = mid;
		s = s2;
	}

	return 0;

}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
int main(){
	string va[200];
	int i=0;
	stack <int> st;
	while(cin >> va[i]){
		if(va[i]!="+" && va[i]!="-" && va[i]!="*" ){
			st.push(atoi(va[i].c_str()));
		}
		else{
			int b=st.top();
			st.pop();
			int a=st.top();
			st.pop();
			int ans;
			if(va[i]=="+")
				ans=a+b;
			else if(va[i]=="-")
				ans=a-b;
			else
				ans=a*b;
			st.push(ans);
		}
		i++;
	}
	cout << st.top() << endl;
	return 0;
}

Measured memory_bytes: 3152
MOD=10**9+7
n,m=map(int,input().split())
a=set([int(input()) for _ in range(m)])
dp=[0]*(n+1)
if n==1:
  print(1)
  exit()
if 1 in a and 2 in a:
  print(0)
  exit()
elif 1 in a:
  dp[1]=0
  dp[2]=1
elif 2 in a:
  dp[1]=1
  dp[2]=0
else:
  dp[1]=1
  dp[2]=2
  
for i in range(3,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%MOD
print(dp[-1]%MOD)

Measured memory_bytes: 18988
#include <bits/stdc++.h>
using namespace std;
int main(){  
  int K,S,A=0;
  cin>>K>>S;
  for(int i=0;i<=min(K,S);i++){
    if(S-i>K){
      if(2*K-S+i+1>0)A+=2*K+1-S+i;
    }
    else A+=S-i+1;
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
### main

n = gets.to_i

n.times do
  text = gets.delete("\r\n")
  #p text

  pos = 0
  tlen = text.length

  nc = gets.to_i

  nc.times do
    cline = gets.strip

    case cline
    when 'forward char'
      pos += 1 if pos < tlen
    when 'forward word'
      pos += 1 while pos < tlen && text[pos] == ' '
      pos += 1 while pos < tlen && text[pos] != ' '
    when 'backward char'
      pos -= 1 if pos > 0
    when 'backward word'
      pos -= 1 while pos > 0 && text[pos - 1] == ' '
      pos -= 1 while pos > 0 && text[pos - 1] != ' '
    when 'delete char'
      if pos < tlen
        text[pos] = ''
        tlen -= 1
      end
    when 'delete word'
      pos0 = pos
      pos0 += 1 while pos0 < tlen && text[pos0] == ' '
      pos1 = pos0
      pos1 += 1 while pos1 < tlen && text[pos1] != ' '
      if pos0 != pos1
        text[pos...pos1] = ''
        tlen -= pos1 - pos
      end
    else
      text0 = cline.split('"').last
      text[pos, 0] = text0
      tlen += text0.length
      pos += text0.length
    end
  end

  text[pos, 0] = '^'
  puts text
end

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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
   #define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n,a;

int main(){
    INIT;
    cin >> n; cin >> a;
    if(n%500 <= a) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
imos=[a for a in A]
for i in range(N-1):
    imos[i+1]+=imos[i]
#print(A)
#print(imos)
for i in range(N-2,-1,-1):
    if 2*imos[i]<A[i+1]:
        print(N-1-i)
        break
else:
    print(N)


Measured memory_bytes: 14276
#include<bits/stdc++.h>
#define N 100005
#define M 65540
using namespace std;
int n,s[N],S,ans,f[M],inf,sum[20];

int dfs(int S)
{
  if(!S)return 0; 
  if(f[S]<inf)return f[S];
  for(int i=0;i<16;i++)if((S>>i)&1)
    for(int j=0;j<16;j++)if(i!=j&&(S>>j)&1)
    {
      int p=i^j,x=S^(1<<i)^(1<<j)^(1<<p);
      if(S>>p&1)f[S]=min(f[S],dfs(x)+2);
      else f[S]=min(f[S],dfs(x)+1);
      //枚举每次异或的两个节点i,j,i异或掉j,j异或掉j,还剩下p=i^j
      //如果p本身存在那两个p直接消掉 
    }
  return f[S];
}

int main()
{
  int a,b,c;
  scanf("%d",&n);
  for(int i=1;i<n;i++)
    scanf("%d%d%d",&a,&b,&c),s[a]^=c,s[b]^=c;
  for(int i=0;i<n;i++)sum[s[i]]++;
  for(int i=1;i<16;i++)
    ans+=(sum[i]>>1),S+=(1<<i)*(sum[i]&1);
  memset(f,127,sizeof(f));inf=f[0];
  printf("%d\n",ans+dfs(S));
  return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint com(lint a,lint b){
    if(b==0) return 1;
    lint res=1;
    rep(i,b){
        res*=(a-i);
        res/=i+1;
    }
    return res;
}

int main(void){
    int N,P;
    cin >> N >> P;
    int A[N];
    rep(i,N) cin >> A[i];
    int even=0,odd=0;
    rep(i,N){
        if(A[i]%2==0) even++;
        else odd++;
    }
    lint base=pow(2,even);
    lint ans=0;
    for(int i=0;i<=odd;i++) if(i%2==P) ans+=base*com(odd,i);
    cout << ans << endl;
}

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


def solve(N: int, M: int, X: int, A: "List[int]"):
    price = [1 if i in A else 0 for i in range(1, N)]
    X -= 1
    left = price[:X]
    right = price[X:]
    print(min(sum(left), sum(right)))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, A)


if __name__ == "__main__":
    main()


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

typedef long long ll;
const ll INF = 1000000000;

int main()
{
	ll t, n;
	while( 1 )
	{
		scanf("%lld", &t);
		if(t == 0) break;

		ll c_max = -INF;
		ll c_min = 0;
		ll c_sum = 0;
		for(int i=0; i<t; i++)
		{
			scanf("%lld", &n);
			c_sum += n;
			if(c_max < c_sum - c_min) c_max = c_sum - c_min;
			if(c_min > c_sum) c_min = c_sum;
			
		}
		printf("%lld\n", c_max);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,i,b,m,n,c;
    cin>>m>>n;
    priority_queue<int>p[m];
    while(n--)
    {
        cin>>a>>b;
        if(a==0)
        {
            cin>>c;
            p[b].push(c);
        }
        else if(a==1)
        {
            if(!p[b].empty())
                cout<<p[b].top()<<endl;
        }
        else
        {
            if(!p[b].empty())
                p[b].pop();
        }
    }
}



Measured memory_bytes: 4028
#include <iostream>

using namespace std;

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;
    for(int i=0; i<k; i++){
        if(i%2 == 0){
            b += a/2;
            a = a/2;
        }else{
            a += b/2;
            b = b/2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, m := nextInt(), nextInt()

	if n >= m {
		fmt.Println(0)
		return
	}

	vv := make([]int, 0, m)
	for i := 0; i < m; i++ {
		vv = append(vv, nextInt())
	}

	sort.Sort(sort.Reverse(sort.IntSlice(vv)))

	nn := make([]int, 0, m)
	for i, item := range vv {
		if i+1 == len(vv) {
			break
		}
		nn = append(nn, item-vv[i+1])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(nn)))

	var sum int
	for _, item := range nn[n-1:] {
		sum += item
	}

	fmt.Printf("%#v\n", sum)
}


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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] a = new String[n];
		Map<String,StringBuilder> map = new HashMap<String,StringBuilder>();

		for (int i=0; i<n; i++) {
			a[i] = br.readLine();
			String num = a[i].substring(2);

			StringBuilder mark = new StringBuilder();
			mark.append(a[i].substring(0,1));

			if (map.containsKey(num)) {
				map.put(num,map.get(num).append(mark));
			}else {
				map.put(num,mark);
			}
		}

		quickSort(a,0,n-1);

		boolean flag = true;
		int index = 0;
		while (index < a.length) {
			StringBuilder marks = new StringBuilder();
			marks.append(map.get(a[index].substring(2)));

			StringBuilder str = new StringBuilder();
			for (int j=index; j < marks.length()+index; j++) {
				str.append(a[j].substring(0,1));
			}

			if (!str.toString().contentEquals(marks)) {
				System.out.println("Not stable");
				flag = false;
				break;
			}
			index += marks.length();
		}
		if(flag){
			System.out.println("Stable");
		}


		for (int i=0; i<n; i++) {
			System.out.println(a[i]);
		}


		br.close();
	}

	static int partition(String[] a,int p,int r) {
		int x = Integer.parseInt(a[r].substring(2));
		int i = p-1;
		for (int j=p; j<r; j++) {
			if (Integer.parseInt(a[j].substring(2)) <= x) {
				i = i+1;
				swap(a,i,j);
			}
		}
		swap(a,i+1,r);
		return i+1;
	}

	static void quickSort(String[] a,int p,int r){
		if (p < r) {
			int q = partition(a,p,r);
			quickSort(a,p,q-1);
			quickSort(a,q+1,r);
		}
	}

    static void swap(String[] a,int idx1,int idx2){
        String temp = a[idx1];
        a[idx1] = a[idx2];
        a[idx2] = temp;
    }

}

Measured memory_bytes: 75200
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

constexpr auto mask = (1ll << 24) - 1;
constexpr auto nask = (1ll << 12) - 1;
long long F[3001][3001];

long long enc(int i, int j) {
  return (F[i][j] & ~mask) | (i << 12) | j;
}

int main() {
  string S, T;
  cin >> S >> T;
  auto N = (int) S.size();
  auto M = (int) T.size();
  for (auto i = 1; i <= N; ++i)
    for (auto j = 1; j <= M; ++j) {
      F[i][j] = max(enc(i - 1, j), enc(i, j - 1));
      if (S[i - 1] == T[j - 1])
        F[i][j] = max(F[i][j], enc(i - 1, j - 1) + (1ll << 24));
    }
  auto i = N, j = M;
  string res;
  while (i || j) {
    auto x = F[i][j] >> 12 & nask;
    auto y = F[i][j] & nask;
    if (x + 1 == i && y + 1 == j) {
      res += S[i - 1];
    }
    i = x;
    j = y;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 100123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define oo 1000000123
#define sz(x) ((int)((x).size()))
#define pi acos(-1)

using namespace std;

int n, m, x, acum;

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    cin >> m >> n;
    for(int i = 0; i < n; ++i){
        cin >> x;
        acum += x;
    }
    if(acum <= m) cout << (m-acum) << '\n';
    else cout << "-1\n";
    return 0;
}


Measured memory_bytes: 3636
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())

    if K % 2 == 0:
        ans = (N // K) ** 3 + (N // (K // 2) - N // K) ** 3
    else:
        ans = (N // K) ** 3

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = s.length() / 2;
		String half = s.substring(0, len);

		StringBuilder lSb = new StringBuilder(half);
		StringBuilder rSb = new StringBuilder(half);

		while (true) {
			rSb.delete(len - 2, len);
			rSb.insert(0, lSb.substring(len - 1));
			lSb.delete(len - 1, len);
			len--;
			if (lSb.toString().equals(rSb.toString())) {
				break;
			}
		}

		System.out.println(len * 2);

		sc.close();
	}
}

Measured memory_bytes: 21844
n = gets.chomp
a_arr = gets.chomp.split(" ").map(&:to_i)

hash = {}
a_arr.each do |a|
  hash[a] ||= 0
  hash[a] += 1
end

sum = 0
hash.each do |k, v|
  sum += v * (v - 1) / 2
end

a_arr.each do |a|
  puts sum - (hash[a] * (hash[a] - 1) / 2) + ((hash[a] - 1) * (hash[a] - 2) / 2)
end


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

using namespace std; 
const int MAX_N = 405; 

long long dp[MAX_N][MAX_N]; 
int n; 
int a[MAX_N]; 
long long sum[MAX_N];

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n; 
	for (int i = 1; i <= n; i++) {
		cin >> a[i]; 
		sum[i] = sum[i - 1] + a[i]; 
	}

	for (int j = 2; j <= n; j++) {
		for (int i = j - 1; i >= 1; i--) {
			dp[i][j] = 1e15; 
			for (int k = i; k < j; k++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum[j] - sum[i - 1]); 	
			}
		}
	}

	cout << dp[1][n];
	return 0; 
}

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

int main(void) {
  int k;
  string s;

  cin >> k >> s;

  if (k >= s.size()) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s.at(i); 
    }
    cout << "..." << endl;
  }

}

Measured memory_bytes: 3604
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $len = strlen($s);
  $count = 0;
  $x = $s[0];
  for ($i=1; $i<$len; $i++) {
    if($x != $s[$i]){
      $x = $s[$i];
      $count++;
    }
  }

  echo $count;

Measured memory_bytes: 16440
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void shortestPath(vector<vector<int> >& dist)
{
    int n = dist.size();
    for(int k=0; k<n; ++k){
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

const int INF = INT_MAX / 4;

int main()
{
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> v(r);
    for(int i=0; i<r; ++i){
        cin >> v[i];
        -- v[i];
    }
    sort(v.begin(), v.end());

    vector<vector<int> > dist(n, vector<int>(n, INF));
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        -- a;
        -- b;
        dist[a][b] = dist[b][a] = c;
    }
    shortestPath(dist);

    int ans = INF;
    do{
        int sum = 0;
        for(int i=1; i<r; ++i)
            sum += dist[v[i-1]][v[i]];
        ans = min(ans, sum);
    }while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	/*
	 * A+B >= B+C
	 * A+B < C -> A+B+B+1
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if(A+B>=C) System.out.println(B+C);
		else System.out.println(A+2*B+1);
	}
}


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

int main(){
  int n,m; cin>>n>>m;
  vector<ll> sum(n+1,0),num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
    num[i]%=m;
  }
  for(int i=0;i<n;i++){
    sum[i+1]=(sum[i]+num[i])%m;
  }ll ans=0;
  map<ll,ll> mp;
  for(int i=0;i<=n;i++){
    ans+=mp[sum[i]];
    mp[sum[i]]++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i = 0; ; i++) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int s = m + f;
            if(m == -1 && f == -1 && r == -1) break;
            if(m == -1 || f == -1) {
                System.out.println("F");
            } else if(s >= 80) {
                System.out.println("A");
            } else if(s >= 65 && s < 80) {
                System.out.println("B");
            } else if(s >= 50 && s < 65) {
                System.out.println("C");
            } else if(s >= 30 && s < 50) {
                if(r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else {
                System.out.println("F");
            }
        }
    }
}


Measured memory_bytes: 26316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data.txt");
    // cin.rdbuf(in.rdbuf());
    int N, D;
    cin >> N >> D;

    int div = D * 2 + 1;
    int ans = N / div;
    if(N % div != 0){
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> H,N;
  invec<ll> A(N);


  return (H <= bst::accumulate(A, 0)) ? "Yes" : "No";
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 1024
import sys
sx,sy = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
ax = 0
ay = 0
# #test
# sx = 8のとき
# 1 1 1 1 1 1 1
# 1 2 2 2 2 2 1
# 1 2 3 3 3 2 1
# 1 2 3 4 3 2 1
# 1 2 3 3 3 2 1
# 1 2 2 2 2 2 1
# 1 1 1 1 1 1 1
# (x[1]-x[0])*sx
# (x[2]-x[1])*sx+sx-2
# (x[3]-x[2])*sx+sx-2+sx-4
# (x[n+1]-x[n])*(sx+sx-2*n)*(n+1)/2
# sxが奇数の時
for n in range(sx-1):
	ax += (x[n+1]-x[n])*(sx-n-1)*(n+1)
for n in range(sy-1):
	ay += (y[n+1]-y[n])*(sy-n-1)*(n+1)
print(ax*ay%(10**9+7))

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int pw(int a,int b,int p){
    if(b==0)return 1;
    int t=pw(a,b/2,p);
    if(b%2)return (((a*t)%p)*t)%p;
    else return ((t*t)%p);
}

int modInverse(int A,int m)
{
    return pw(A,m-2,m);
}

int fact[2000001];
void calc(){
    fact[0]=1;
    for (int i = 1; i <= 2000000; ++i)
    {
        fact[i]=(fact[i-1]*i)%M;
    }
}
int fact1[1000001];
void calc1(){
    fact1[0]=1;
    for (int i = 1; i <= 1000000; ++i)
    {
        fact1[i]=fact1[i-1]*modInverse(i,M)%M;
    }
}
int solve(){
    int x,y; cin>>x>>y;
    if((x+y)%3){
        cout<<0;
        return 0;
    }
    int t=(x+y)/3;
    int b1=x-t,a1=y-t;
    if(a1<0||b1<0){
        cout<<0;
        return 0;
    }
    calc(); calc1();
    cout<<fact[(a1+b1)]*fact1[a1]%M*fact1[b1]%M;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int dp[1001000];  // dp[i]  means
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

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

  for (int i = 0; i < n; i++) {
    for (int j = a[i]; j <= a[n - 1]; j += a[i]) {
      dp[j]++;
    }
  }
  int ans = 0;
  for (int nv : a) {
    if (dp[nv] == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7952
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int interval[100000 - 1];

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;

    int begin, end, left;
    cin >> begin;
    left = end = begin;
    for (int i = 0; i < n - 1; i++) {
      cin >> end;
      interval[i] = end - left;
      left = end;
    }
    sort(interval, interval + n - 1, greater<int>());

    int total = end - begin;
    for (int i = 0; i < k - 1 && i < n - 1; i++) total -= interval[i];
    cout << total << endl;
  }
  return 0;
}

Measured memory_bytes: 1564
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
y = [-1] * n
for i in range(m):
    if s[i][0] == 1 and s[i][1] == 0 and n != 1:
        print(-1)
        break
    elif y[s[i][0]-1] == -1 or y[s[i][0]-1] == s[i][1]:
        y[s[i][0]-1] = s[i][1]
    else:
        print(-1)
        break
else:
    if y[0] == -1 and n != 1:
        y[0] = 1
    z = ''
    for i in y:
        if i == -1:
            i = 0
        z += str(i)
    print(int(z))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

int n,k,x;

int main()
{
	n=read();k=read();
	for(int i=1;i<=k;++i)
		x+=read();
	if(x<n)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int v[100500][3];
ll dp[100500][3];
int n;

ll f(int i, int l){
	if(i == n) return 0;
	if(dp[i][l] != -1) return dp[i][l];
	ll ret = -inf;
	for(int j = 0; j < 3; j++){
		if(j == l) continue;
		ret = max(ret, v[i][j] + f(i + 1, j));
	}
	return dp[i][l] = ret;
}

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

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> v[i][0] >> v[i][1] >> v[i][2];
	}
	ll res = -inf;
	for(int i = 0; i < 3; i++){
		memset(dp, -1, sizeof dp);
		res = max(res, v[0][i] + f(1, i));
	}
	cout << res;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
char a[1000+200][1000+200];
long long int dp[1000+200][1000+200];

int main(int argc, char const *argv[])
{
	int H, W;
	while(cin >> H >> W) {
		memset(a, 0, sizeof(a));
		memset(dp, 0, sizeof(dp));
		for(int i=1; i<=H; i++){
			for(int j=1; j<=W; j++){
				cin >> a[i][j];
			}
		}
		dp[1][1] = 1;
		const unsigned int M = 1000000007;
		for(int i=1; i<=H; i++) {
			for(int j=1; j<=W; j++) {
				if(i == 1 && j == 1) continue;
				if(a[i][j] == '.'){
					dp[i][j] = dp[i-1][j] + dp[i][j-1];
				    dp[i][j] %= M;
				}
			}
		}
		cout << dp[H][W] << endl;
	}
	return 0;
}

Measured memory_bytes: 16264
#include <stdio.h>
#include <string.h>
 
int main(){
  char s[258] = {}, tmp[258] = {};
  int m, h, i, l;
  while(scanf("%s", s) && s[0] != '-'){
    scanf("%d", &m);
    while(m--){
      scanf("%d", &h);
      strcpy(tmp, s + h);
      s[h] = '\0';
      strcat(tmp, s);
      strcpy(s, tmp);
    }
    puts(s);
  }
  return 0;
}


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


int main() {
  int N, M;
  cin >> N >> M;
  int a[M];
  int b[M];
  rep(i, M) cin >> a[i] >> b[i];
  vector<int> count_road(N);
  
  rep(i, M){
    rep(j, N){
      if(a[i] == j + 1 || b[i] == j + 1){
        count_road[j]++;
      }
    }
  }
  rep(i, N) cout << count_road[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;


 
int main() {
  int N,Q;
  cin >> N >> Q ;
  string S;
  cin >> S;
  int l[Q],r[Q];
  for(int i=0; i<Q; i++){
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
  }

  int sum[N];
  int c=0;
  for (int i=0; i<N; i++){    
    if(i==0) sum[i]=0;
    else if(S[i-1]=='A' && S[i] == 'C'){
      sum[i] =sum[i-1] + 1;
    }
    else{
      sum[i] = sum[i-1];
    }
  }
  
  for (int i=0; i<Q; i++){
    //    if(S[l[i]-1] == 'A' && S[l[i]]=='C'){
    cout << sum[r[i]] - sum[l[i]] << endl;
	//    }
  }
  
  return 0;
   

}


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

int main() {
  long long q,h,s,d,n;
  cin >> q >> h >> s >> d >> n;
  h = min(h,2*q);
  s = min(s,2*h);
  d = min(d,2*s);
  cout << n/2*d+(n%2)*s << endl;
}


Measured memory_bytes: 256
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

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

D2=D*D

cnt = 0
for i in range(N):
    X,Y=map(int,input().split())
    if (X*X) + (Y*Y) <= D2:
        cnt = cnt + 1

print(cnt)


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


const long long INF = 1LL << 60;

int main()
{
   int a,b;
   cin >> a >> b;
   cout << ((a*b)%2 == 0 ? "Even": "Odd") << endl;
   return  0;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
typedef long long ll;
ll d[101][4][4][4],n,ans;
int main(void){
    d[0][1][1][1]=1;
    cin>>n;
    for(int l=0;l<n;l++){
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                for(int k=0;k<4;k++){
                    for(int a=0;a<4;a++){
                        if(i==0&&j==2&&a==3)continue;
                        if(i==0&&k==2&&a==3)continue;
                        if(j==0&&k==2&&a==3)continue;
                        if(j==2&&k==0&&a==3)continue;
                        if(j==0&&k==3&&a==2)continue;
                        d[l+1][j][k][a]+=d[l][i][j][k];
                        d[l+1][j][k][a]%=1000000007;
                    }
                }
            }
        }
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                ans+=d[n][i][j][k];
                ans%=1000000007;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from scipy.sparse import*
_,*s=open(0)
*g,=eval('[0]*500,'*500)
i=-1
for t in s:
 i+=1;j=0
 for u in t:k=i*20+j;g[k][k+1]=u>'#'<t[j+1];g[k][k+20]=u>'#'<(s+['#'*20])[i+1][j];j+=1
a=csgraph.johnson(csr_matrix(g),0)
print(int(max(a[a<999])))

Measured memory_bytes: 22252
from itertools import accumulate
from operator import add

def getAccAss(Ass):
    accAss = [[0] * (len(Ass[0])+1)] + [accumulate([0] + As) for As in Ass]
    for x in range(1, len(accAss)):
        accAss[x] = list(map(add, accAss[x], accAss[x-1]))
    return accAss
def getRangeSum2D(accAss, xFr, xTo, yFr, yTo):
    return accAss[xTo+1][yTo+1] - accAss[xTo+1][yFr] - accAss[xFr][yTo+1] + accAss[xFr][yFr]

def rec(x1, x2, y1, y2, no):
    num = getRangeSum2D(accAss, x1, x2, y1, y2)
    if num == 1:
        for x in range(x1, x2+1):
            for y in range(y1, y2+1):
                ansss[x][y] = no
        return no
    else:
        yL = -1
        for y in range(y1, y2+1):
            if getRangeSum2D(accAss, x1, x2, y, y) > 0:
                if yL == -1:
                    yL = y
                else:
                    no = rec(x1, x2, y1, yL, no)
                    no = rec(x1, x2, yL+1, y2, no+1)
                    return no
        xL = -1
        for x in range(x1, x2+1):
            if getRangeSum2D(accAss, x, x, y1, y2) > 0:
                if xL == -1:
                    xL = x
                else:
                    no = rec(x1, xL, y1, y2, no)
                    no = rec(xL+1, x2, y1, y2, no+1)
                    return no


H, W, K = map(int, input().split())
Sss = [input() for _ in range(H)]
Ass = [[int(S == '#') for S in Ss] for Ss in Sss]

accAss = getAccAss(Ass)

ansss = [[0]*(W) for _ in range(H)]
rec(0, H-1, 0, W-1, 1)

print('\n'.join([' '.join(map(str, anss)) for anss in ansss]))


Measured memory_bytes: 13244
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	map<LL, int>mp;
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		LL a; cin >> a;
		mp[a]++;
	}
	vector<LL>tam;
	for (auto& p : mp)
	{
		while (p.second > 1)
		{
			p.second -= 2;
			tam.push_back(p.first);
		}
	}
	sort(tam.rbegin(), tam.rend());
	if (tam.size() < 2)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << tam[0] * tam[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 6528
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.append(0)
b = {}
c = 0
for i in range(n):
    if a[i] not in b:
        for j in range(1, 10**6//a[i]+1):
            b[a[i]*j] = 1
        if a[i] != a[i+1]:
            c += 1
print(c)

Measured memory_bytes: 101576
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a = 0,b = 0,c = 0;
    for(int i = 0;i<s.length();i++){
      if (s.substring(i,i+1).equals("a")) {
        a++;
      }else if (s.substring(i,i+1).equals("b")) {
        b++;
      }else{
        c++;
      }
    }
    int max = Math.max(a,Math.max(b,c));
    int min = Math.min(a,Math.min(b,c));
    if (max-min<=1) {
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
    int N, M;
    COMinit();
    cin >> N >> M;
    auto vec = prime_factorize(M);
    long long res = 1;
    for (auto pa : vec) {
        int k = pa.second;
        long long tmp = COM(N+k-1, k);
        res = (res * tmp) % MOD;
    }
    cout << res << endl;
}          


Measured memory_bytes: 5120
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 4e6 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

ll n,k;
ll fac[maxn],inv[maxn];
ll dp[2005][2005];
ll C(ll n,ll x)
{
	if(n<0||x<0)
	{
		return 0;
	}
	return fac[n]*inv[x]%mod*inv[n-x]%mod;
}

void init()
{
	fac[0]=1;
	inv[0]=1;
	ll up = 4e6;
	for(ll i=1;i <= up;i++)
	{
		fac[i]=fac[i-1]*i%mod;
		inv[i]=po(fac[i],mod-2,mod);
	}
}

ll cal(ll i,ll j)
{
	if(dp[i][j]!=-1)
	{
		return dp[i][j];
	}
	ll res=0;
	if(i==0&&j==0)
	{
		return 1;
	}
	if(j > i)
	{
		//cout<<i<<" "<<j<<endl;
		//cout<<i+j*(k-1)-1<<" "<<k-2<<endl;
		//cout<<C(i+j*(k-1)-1,k-2)<<endl;
		res += C(i+j*(k-1)-1,k-2)*cal(i,j-1)%mod;
	}
	res%=mod;
	if(i)
	{
		//cout<<i-1<<" "<<j<<endl;
		res += cal(i-1,j);
	}
	res%=mod;
	dp[i][j]=res;
	return res;
}

void solve()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	if(k==1)
	{
		cout<<1<<endl;
		return;
	}
	ll res= cal(n,n);
	for(ll i=1;i<=n;i++)
	{
		res=res*i%mod;
	}
	cout<<res<<endl;
}
int main()
{
    init();
    solve();
	return 0;
}

Measured memory_bytes: 94208
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    ll A, B, K;
    cin >> A >> B >> K;

    if (A >= K) {
        A -= K;
    } else {
        K -= A;
        A = 0;
        if (B >= K) {
            B -= K;
        } else {
            B = 0;
        }
    }

    cout << A << " " << B << "\n";

    return 0;
}


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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	ll a[125252], b[125252];
	cin>>n;
	REP(i, n+1){
		cin>>a[i];
	}
	REP(i, n){
		cin>>b[i];
	}
	ll ans=0;
	REP(i, n){
		ll tmp=min(a[i], b[i]);
		ans+=tmp;
		b[i]-=tmp;
		tmp=min(a[i+1], b[i]);
		ans+=tmp;
		a[i+1]-=tmp;
	}
	cout<<ans<<'\n';
	return 0;
}


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

void dfs(int i,vector<vector<int>>& e,vector<bool>& vis){
    if(vis[i]==true)
    return;
    vis[i]=true;
    for(int a:e[i]){
        if(!vis[a])
        dfs(a,e,vis);
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> e(n+1);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int conn=0;
    vector<bool> vis(n+1,false);
    for(int i=1;i<=n;i++){
        if(!vis[i]){
        dfs(i,e,vis);
        conn++;
        }
    }
    cout<<conn-1<<endl;
return 0;
}

Measured memory_bytes: 9592
#include<stdio.h>
int saidaikouyakusuu(int a,int b){
while(a!=b){
if(a>=b){
a=a-b;
}else{
b=b-a;
}
}
return a;
}
 
int main(){
int a,b,yakusuu;
while(scanf("%d %d",&a,&b)!=EOF){
yakusuu=saidaikouyakusuu(a,b);
a=a/yakusuu;
printf("%d %d\n",yakusuu,a*b);
}
return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while (a > 0)
  {
    c -= b;
    a -= d;
    if (c <= 0)
    {
      cout << "Yes";
      break;
    }
    else if (a <= 0)
    {
      cout << "No";
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define __ ios::sync_with_stdio(false),cin.tie(0)
/*
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
*/
using namespace std;
void solve(){
string s,t;
cin>>s>>t;
string er;
for(int i=0;i<s.size();++i){
er=t.erase(t.size()-1,1);
if(s==er) {cout<<"Yes"; return;}
else {cout<<"No";return;}
}

}
int main(){
//freopen("","",stdin);
__;
int T=1;
//cin>>T;
while(T--){
solve();
}
}


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

using namespace std;

const int size = 2e5 + 7;

int weight[size], value[size];
long long int ans[107][size]; 


int main(){
	memset(ans, 0, sizeof(ans));
	int n,w;
	long long int totalA = 0;
	cin>>n>>w;
	for(int x=1;x<=n;x++){
		cin>>weight[x]>>value[x];
	}
	for(int x=1;x<=n;x++){
		for(int i=0;i<=w;i++){
			ans[x][i] = ans[x-1][i];
			if(i - weight[x] >= 0){
				ans[x][i] = max(ans[x][i], ans[x-1][i-weight[x]] + value[x]);
				totalA = max(totalA, ans[x][i]);
			}
		}
		
	}
	cout<<totalA;
	return 0;
}

Measured memory_bytes: 168192
import java.util.Scanner;
public class Main {
   public static void main(String[] args){
	   Scanner scanf = new Scanner(System.in);
	   int a,b;
	   a = scanf.nextInt();
	   b = scanf.nextInt();
	   System.out.print(a/b + " " + a%b + " ");
	   System.out.printf("%.5f\n",(double)a/b);
   }
}

Measured memory_bytes: 17244
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

n, m =map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l, r = l-1, r-1
    g[l].append((d, r))
    g[r].append((-d, l))

s = []
visit = [-1]*n
dist = [False]*n
for i in range(n):
    if visit[i] == -1:
        s.append(i)
        visit[i] = 0
        dist[i] = 0
        while s:
            v = s.pop()
            for d, u in g[v]:
                if dist[u]:
                    if dist[u] != dist[v]+d:
                        print('No')
                        exit()
                if visit[u] == -1:
                    visit[u] = 0
                    dist[u] = dist[v]+d
                    s.append(u)
else:
    print('Yes')


Measured memory_bytes: 76208
# u+++さんの解放
from itertools import accumulate


N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

flg = []
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == 'AC':
        flg.append(1)
    else:
        flg.append(0)

flg2 = [0] + flg
flg2 = list(accumulate(flg2))

for a in A:
    print(flg2[a[1]-1] - flg2[a[0]-1])

Measured memory_bytes: 33116
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

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



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

    vector<ll> w = v;
    sort(ALL(w));

    for(auto u:v){
        if(u == w[N-1]) cout << w[N-2] << "\n";
        else cout << w[N-1] << "\n";
    }
    return 0;
}

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

using namespace std;

int main ()
{
    long long n, k;
    cin >> n >> k;
    if (n <= k) {
        if (n <= abs(n-k)) cout << n << endl;
        else cout << abs(n-k) << endl;
    }
    else {
        n = n%k;
        if (n <= abs(n-k)) cout << n << endl;
        else cout << abs(n-k) << endl;
    }
    return 0;
}

Measured memory_bytes: 256