akhauriyash/Code-Regression huggingface dataset:
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main() {
int H,W;
cin>>H>>W;
char A[H][W];
rep(i,H){
  string s;
  cin>>s;
  rep(j,W){
    A[i][j]=s[j];
  }
}

int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
int ans[H][W];
rep(i,H){
  rep(j,W){
    ans[i][j]=0;
    rep(k,8){
      if((A[i][j]=='.')&&(i+dy[k]>=0)&&(i+dy[k]<H)&&(j+dx[k]>=0)&&(j+dx[k]<W)&&(A[i+dy[k]][j+dx[k]]=='#')){
        ans[i][j]++;
      }
    }
  }
}
rep(i,H){
  rep(j,W){
    if(A[i][j]=='#'){
      cout<<'#';
    }
    else{
      cout<<ans[i][j];
    }
    
  }
  cout<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);i++)

int x[1600], y[1600];
int main(){
    int n,m;
    while(cin>>n>>m && n){
        x[0] = y[0] = 0;
        rep(i,n){
            int w; cin>>w;
            x[i+1] = x[i]+w;
        }
        rep(i,m){
            int h; cin>>h;
            y[i+1] = y[i]+h;
        }
        map<int,int> ws;
        rep(i,n+1)rep(j,i){
            ws[x[i]-x[j]]++;
        }
        int ans = 0;
        rep(i,m+1)rep(j,i){
            ans += ws[y[i]-y[j]];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 19052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    if(A / 10 >= 1 || B / 10 >= 1){
        cout << -1 << endl;
    }
    else{
        cout << A * B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const double PI = 3.14159265358979323846;
const int MAX = 1e10;
const int MOD = 1e9+7;

const ll INF = 1e9;


int main(int argc, char *args[]) {
	int n; cin >> n;
	set<int> s;
	rep(i, n) {
		int a; cin >> a;
		s.insert(a);
	}
	if (n == s.size()) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#define SIZE_LINEBUFFER 12 
 
#include <stdio.h> 
#include <stdlib.h> 
 
void battle(int* hand) { 
   if ( hand[0] > hand[1] ) { 
      hand[0] = hand[0] + hand[1]; 
      hand[1] = 0;  
   } else if ( hand[0] < hand[1] ) { 
      hand[1] = hand[0] + hand[1]; 
      hand[0] = 0;  
   }   
} 
 
int main(void) { 
   int i, cardline; 
   int card[2], point[2]; 
   char* line = (char*)malloc(SIZE_LINEBUFFER); 
 
   fgets(line, SIZE_LINEBUFFER - 1, stdin); 
   cardline = atoi(line); 
   while ( cardline > 0 ) { 
      point[0] = 0;  
      point[1] = 0;  
      for (i = 0; i < cardline; i++) { 
         fgets(line, SIZE_LINEBUFFER - 1, stdin); 
         card[0] = line[0] - '0'; 
         card[1] = line[2] - '0'; 
         battle(card); 
         point[0] += card[0]; 
         point[1] += card[1]; 
      }   
      printf("%d %d\n", point[0], point[1]); 
      fgets(line, SIZE_LINEBUFFER - 1, stdin); 
      cardline = atoi(line); 
   }   
 
   return 0;  
} 

Measured memory_bytes: 556
import math

while True:
    T,H,S = [int(i) for i in input().split()]
    if T == -1 and H == -1 and S == -1:
        break

    ans = 2 * 3600 - (T * 3600 + H * 60 + S)
    TT = ans // 3600
    HH = (ans - 3600*TT) // 60
    SS = ans % 60

    print(str(TT).zfill(2) + ":" + str(HH).zfill(2) + ":" + str(SS).zfill(2))

    ans = ans * 3
    TT = ans // 3600
    HH = (ans - 3600*TT) // 60
    SS = ans % 60

    print(str(TT).zfill(2) + ":" + str(HH).zfill(2) + ":" + str(SS).zfill(2))


Measured memory_bytes: 5664
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int n;
int main(void) {
	cin >> n;
	int a1[110];
	int a2[110];
	int sum = 0;
	for (int i = 0; i < n; i++) cin >> a1[i];
	for (int i = 0; i < n; i++) cin >> a2[i];

	int ans = 0;
	for (int i = 0; i < n; i++) //i�Ԗڂ����ɍs��
	{
		sum = 0;
		for (int j = 0; j < n; j++)
		{
			if (j < i) sum += a1[j];
			else if (j == i) sum += a1[i] + a2[i];
			else sum += a2[j];
		}
		if (ans < sum) ans = sum;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i = x; i < (int)(n); i++)
#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    
    int x, n;
    cin >> x >> n;

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

    vector<int> pp(102, 0);
    //pp[0]++;
    rep(i, 0, n) {
        pp[p[i]]++;
    }
    int ans_n=INF;
    int ans=0;
    rep(i, 0, 102){
        if(pp[i]==0){
            if(ans_n>abs(x-i)){
                ans_n=abs(x-i);
                ans=i;
            }
        }
        else continue;
    }
    if(n==0)ans=x;

    cout << ans;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  char ans1; int ans2;
  string s;
  for(int i=0;i<H;i++){
    ans2=1+i;
    for(int j=0;j<W;j++){
      ans1='A'+j;
      cin>>s;
    if(s=="snuke")break;
    }
    if(s=="snuke")break;
  }
  cout<<ans1<<ans2<<endl;
}

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int ans;
  ans = r*100+g*10+b;
  if(ans%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().decode('utf8').rstrip()
print('Yes' if set('abc') == set(S) else 'No')


Measured memory_bytes: 2940
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 105;

LL cache[N][2][10];

int n, req;
int arr[N];


LL dp(int k, int small, int cnt) {
	if (cnt > req) return 0;
	if (k == n) {
		return (cnt == req);
	}

	LL &rv = cache[k][small][cnt];
	if (~rv) return rv;
	rv = 0;

	if (small == 0) {
		for (int i = 0; i <= min(arr[k], 9); i++) {
			rv += dp(k + 1, i < arr[k], cnt + (i > 0));
		}
	}
	else {
		for (int i = 0; i <= 9; i++) {
			rv += dp(k + 1, 1, cnt + (i > 0));
		}
	}
	return rv;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

    string s;
    cin >> s >> req;
    n = s.size();

    for (int i = 0; i < n; i++) arr[i] = s[i] - '0';

    memset(cache, -1, sizeof cache);
    LL result = dp(0, 0, 0);
	cout << result << "\n";
}

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

int main(){

  int N, i;
  cin>>N;
  vector<int> a(N);
  long long Sums=0, Suma=0, mn=10000000000000000;
  for(i=0; i<N; i++){
    cin>>a[i];
    Sums+=a[i];
  }
  
  for(i=0; i<N-1; i++){
    Suma+=a[i];
    Sums-=a[i];
    mn=min(mn, abs(Sums-Suma));
  }
  
  cout<<mn<<endl;
  return 0;
}

Measured memory_bytes: 4020
a,b,c,d = map(int,input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


v = c*d//gcd(c,d)

s = b//c - (a-1)//c
t = b//d - (a-1)//d
u = b//v - (a-1)//v

print((b-a+1) - (s+t-u))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
void read (int&a) {
	a = 0; char k = getchar(); int f = 1;
	for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
	for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
	a *= f;
}

int s[200000 + 5];

int main ()
{
	int n; read (n);
	for (int i = 2; i <= n; ++i) {
		int x; read (x);
		s[x]++;
	}
	for (int i = 1; i <= n; ++i) printf ("%d%c", s[i], "\n\n"[i == n]);
	return 0;
}

Measured memory_bytes: 4472
#include <bits/stdc++.h>
//debug
#define vecprint(v) cout << "  vector: ";rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) cout << "  set: ";for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) cout << "  map: ";for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};



int main() {
  //input
  int n, m;
  cin >> n >> m;
  
  int a[n];
  int sum = 0;
  rep(i,m) {
    cin >> a[i];
    sum += a[i];
  }
  
  if(sum > n) {
    cout << "-1" << endl;
  }
  else {
    cout << n - sum << endl;
  }
}

Measured memory_bytes: 3640
n = gets.to_i
hs = gets.split.map(&:to_i)

ans = 'Yes'
last = hs[0]

hs.each do |h|
  if last <= h
    last = h
    next
  end

  # last > h
  if last == h + 1
    h += 1
  else
    ans = 'No'
    break
  end
  last = h
end

puts ans


Measured memory_bytes: 8580
X=int(input())
S=[0]*10**6
goukei=0
for i in range(10**6):
    goukei+=i
    S[i]=goukei
    
for i in range(10**6):
    if X<=S[i]:
        print(i)
        exit()
    
#print(S[(10**6)-1])
    

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

int main() {
  int n,y;
  cin>>n>>y;
  y/=1000;
  int p=-1;
  int q=-1;
  int r=-1;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(10*i+5*j+n-i-j==y){
        p=i;
        q=j;
        r=n-i-j;
      }
    }
  }
  cout<<p<<" "<<q<<" "<<r<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    string A,B,C;
    while (cin >> A >> B >> C) {
        if (*A.rbegin() == *B.begin() && *B.rbegin() == *C.begin())
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
const ll mod=1000000007;
ll fmod(int n) {
	ll ans=1ll;
	rep(i,1,n) ans=(ans*1ll*i)%mod;
	return ans;
}
int main() {
	int n=readint(), m=readint();
	if (abs(n-m)>1) {
		printint(0);
	} else if (n==m) {
		printll((fmod(n)*fmod(n)<<1)%mod);
	} else {
		if (n>m) swap(n,m);
		printll((fmod(n)*fmod(m))%mod);
	}
	return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
#define mod	2019
ll mul(ll a, ll b){
	return (a%mod * b%mod)%mod;
	}
int main()
{
	ll l,r,x,m=2020;
	cin>>l>>r;
	for(ll i=l ; i<r ; i++){
		for(ll j=i+1 ; j<=r ; j++){
			x = mul(i,j);
			if(x==0){
				cout<<0<<nw;
				return 0;
				}
		m = min(m,x);
			}
		}
	cout<<m<<nw;
	
	return 0;
}

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

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

} // namespace null_null

#include <queue>

namespace null_null {

void main_() {
  usize N,M;
  std::cin>>N>>M;

  std::priority_queue<i32> pq;
  while(N--){
    i32 A;
    std::cin>>A;
    pq.push(A);
  }

  while(M--){
    i32 temp;
    temp=pq.top()/2;
    pq.pop();
    pq.push(temp);
  }

  i64 ans=0;
  while(pq.empty()==false){
    ans+=pq.top();
    pq.pop();
  }

  std::cout<<ans<<std::endl;
}

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

Measured memory_bytes: 1400
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=200005;

int a[SIZE];
long long sum[SIZE];
map<long long,int> p;
long long ans;

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	p[0]=1;
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i-1];
		ans+=p[sum[i]];
		p[sum[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
const double PI = acos(-1.0);
int64 x[MAXN],y[MAXN],id[MAXN];
int64 X1,X2,Y1,Y2,num[MAXN],val[MAXN];
int N,tot,c;
void Solve() {
    read(X1);read(Y1);read(X2);read(Y2);
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(x[i]);read(y[i]);
    }
    if(X1 > X2) {
        swap(X1,X2);swap(Y1,Y2);
    }
    if(Y1 > Y2) {
        swap(Y1,Y2);
        for(int i = 1 ; i <= N ; ++i) {
            y[i] = Y1 + Y2 - y[i];
        }
    }
    for(int i = 1 ; i <= N ; ++i) {
        id[i] = i;
    }
    sort(id + 1,id + N + 1,[](int a,int b){return y[a] < y[b];});
    for(int i = 1 ; i <= N ; ++i) {
        int u = id[i];
        if(y[u] >= Y1 && y[u] <= Y2 && x[u] >= X1 && x[u] <= X2) {
            num[++tot] = x[u];
        }
    }
    c = 0;
    val[c] = -1;
    for(int i = 1 ; i <= tot ; ++i) {
        if(num[i] > val[c]) val[++c] = num[i];
        else {
            int t = upper_bound(val + 1,val + c + 1,num[i]) - val;
            val[t] = num[i];
        }
    }
    if(c < min(X2 - X1,Y2 - Y1) + 1) {
        double ans = 100.0 * (X2 - X1 + Y2 - Y1) - (20 - PI * 5) * c;
        printf("%.12lf\n",ans);
    }
    else {
        double ans = 100.0 * (X2 - X1 + Y2 - Y1) - (20 - PI * 5) * (c - 1) + (10 * PI - 20);
        printf("%.12lf\n",ans);
    }
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

struct edge {
  ll to;
  ll cost;
};
struct graph {
  ll V;
  vector<vector<edge>> G;
  vector<ll> d;

  graph(ll n) {
    V = n;
    G = vector<vector<edge>>(V);
    d = vector<ll>(V, INF);
  }

  void add_edge(ll s, ll t, ll cost) {
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s) {
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, s));
    while (!q.empty()) {
      P p = q.top();
      q.pop();
      ll v = p.second;
      if (d[v] < p.first) continue;
      for (auto e : G[v]) {
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          q.push(P(d[e.to], e.to));
        }
      }
    }
  }
};

int main() {
  ll n, a, b, c, q, k, x, y;
  cin >> n;
  graph g(n);
  rep(i, n - 1) {
    cin >> a >> b >> c;
    a--, b--;
    g.add_edge(a, b, c);
    g.add_edge(b, a, c);
  }

  cin >> q >> k;
  k--;
  g.dijkstra(k);
  rep(i, q) {
    cin >> x >> y;
    x--, y--;
    cout << g.d[x] + g.d[y] << endl;
  }
  return 0;
}


Measured memory_bytes: 14012
N,T=map(int, input().split())
TN=list(map(int, input().split()))
a=[0]
b=[]
if N==1:
    print(N)
    exit()
for i in range(1,N):
    if TN[i]>TN[i-1]+T:
        a.append((TN[i-1]+T)-a[-1])
        b.append(a[-1])
        a=[]
        a.append(TN[i])
    if i==N-1:
        a.append(TN[i]+T-a[-1])
        b.append(a[-1])
print(sum(b))


Measured memory_bytes: 25708
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int main(void) {
	int N, M;
	cin>>N>>M;
	vector<ll> hoge(N, 0);
	REP(i, M) {
		ll a, b;
		cin>>a>>b;
		--a;
		--b;
		++hoge[a];
		++hoge[b];
	}
	bool foo = true;
	REP(i, N) {
		if(hoge[i] % 2 == 1) {
			foo = false;
			break;
		}
	}
	if(foo) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


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

int main()
{
	int n;
    cin>>n;
    
   	vector <pair<string,int> >vc;
    for(int i=0;i<n;i++)
    {
		string a;
        int b;
        cin>>a>>b;
        
        vc.push_back( make_pair(a,b) ); 
    }
    string h;
    cin>>h;
    int res=0;
    for(int i=0;i<n;i++)
    {
        if(h.compare(vc[i].first)==0)
        {
            for(int j=i+1;j<n;j++)
            {
                res+=vc[j].second;
            }
            
            break;
        }
    }
    cout<<res<<endl;
    
	return 0;
}

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

main()
{
    int n; cin>>n;
    map<string,int> mp;
    int ma=0;
    while(n--)
    {
        string s; cin >> s;
        if(ma<++mp[s]) ma=mp[s];
    }
    for(auto &e:mp)
    {
        if(e.second==ma)
        {
            cout << e.first << "\n";
        }
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 3010;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

string s, t;
int dp[MAXN][MAXN], trace[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s >> t;
    int n = SZ(s);
    int m = SZ(t);
    s = " " + s;
    t = " " + t;
    dp[0][0] = 0;
    FOR(i,1,n)
        FOR(j,1,m)
            if (s[i] == t[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                trace[i][j] = 2;
            }
            else {
                if (dp[i-1][j] > dp[i][j-1]) {
                    dp[i][j] = dp[i-1][j];
                    trace[i][j] = 0;
                }
                else {
                    dp[i][j] = dp[i][j-1];
                    trace[i][j] = 1;
                }
            }
    string res = "";
    int u = n, v = m;
    while (u > 0 && v > 0) {
        int g = trace[u][v];
        if (g == 2) {
            res.push_back(s[u]);
            u--;
            v--;
        }
        else if (g == 1) {
            v--;
        }
        else {
            u--;
        }
    }
    reverse(ALL(res));
    cout << res;
    return 0;
}


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

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int X = x2 - x1;
    int Y = y2 - y1;
    int x3 = x2 - Y;
    int y3 = y2 + X;
    int x4 = x3 - X;
    int y4 = y3 - Y;
    cout << x3 << endl;
    cout << y3 << endl;
    cout << x4 << endl;
    cout << y4 << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define sii set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#define INF 1000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
	ll n;
	cin>>n;
	cout<<(n*(n+1))/2;
}


int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
  fastio
  int tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3564
n=int(input())
def prime_factor(n):
  ass=[]
  for i in range(2,int(n**0.5)+1):
    while n%i==0:ass.append(i);n//=i
  if n!=1:ass.append(n)
  return ass
d=prime_factor(n)
from collections import Counter
ans=0
c=Counter(d)
for i in c:
  m=c[i]
  mm=1
  while mm<=m:
    m-=mm
    mm+=1
    ans+=1
print(ans)

Measured memory_bytes: 9712
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}

vector<ll> cnt(1000000,0);
int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	rep(i,0,n) cin>>a[i];
	ll f = 0;
	rep(i,0,n){
		ll lt = sqrt(a[i]);
	
		rep(j,1,lt+1){
			if(a[i]%j==0){
				ll x = j;
				ll y = a[i]/j;
			
				if(x>1 && cnt[x]>=1){
					f = 1;
					break;
				} 
				if(y>1 && cnt[y]>=1){
					f = 1;
					break;
				}
				
				cnt[x]++;
				cnt[y]++;
			}
		
		}
	    if(f==1) break;
	}
	if(f==0) cout<<"pairwise coprime";
	else{
		ll g = a[0];
		rep(i,1,n){
			 g= __gcd(a[i],g);
		}
		if(g==1) cout<<"setwise coprime";
		else cout<<"not coprime";
	}
		
	
}

Measured memory_bytes: 18716
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << '\n'
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 101;
constexpr int INF = 1<<21;
enum Color { WHITE = 0, GRAY, BLACK };
int n;
vv(int, M, MAX, MAX, INF);
inline int prim() {
    vi d(n, INF), t(n, -1), color(n, WHITE);
    d[0] = 0;
    int minv, u;
    while(true) {
        minv = INF;
        u = -1;
        rep(i, 0, n) {
            if(minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        rep(v, 0, n) {
            if(color[v] != BLACK && d[v] > M[u][v]) {
                d[v] = M[u][v];
                t[v] = u;
                color[v] = GRAY;
            }
        }
    }
    return accumulate(all(d), 0);
}
int main() {
    cin >> n;
    int e;
    rep(i, 0, n) {
        rep(j, 0, n) {
            cin >> e;
            if(e != -1) M[i][j] = e;
        }
    }
    P(prim());
    return 0;
}

Measured memory_bytes: 3180
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// }}}

using Table = array<int,128>;

Table countTable(const string &s)
{
    Table cnt {};
    for (char c : s) {
        cnt[c] += 1;
    }
    return cnt;
}

signed main()
{
    int N;
    string s[55];
    Table cnt[55];

    cin >> N;
    rep(i, 0, N) {
        cin >> s[i];
        cnt[i] = countTable(s[i]);
    }

    Table minCnt;
    minCnt.fill(INF);

    rep(i, 0, N) {
        for (char c = 'a'; c <= 'z'; ++c) {
            chmin(minCnt[c], cnt[i][c]);
        }
    }

    for (char c = 'a'; c <= 'z'; ++c) {
        rep(i, 0, minCnt[c]) putchar(c);
    }
    putchar('\n');

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    cin >> n;
    pair<ll,int> a[n];
    rep(i,0,n){
	ll b;
	cin >> b;
	a[i] = make_pair(b,i&1);
    }
    sort(a,a+n);

    ll cnt = 0;
    rep(i,0,n){
	if((a[i].sd&1) !=( i&1))cnt++;
    }
    P(cnt/2);
    
    return  0;
}


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

using namespace std;
using ll = long long;

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

    int N;
    cin >> N;

    vector<ll> a(N), b(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        ll temp = a[i];
        int cnt = 0;
        while (temp % 2 == 0) {
            ++cnt;
            temp /= 2;
        }
        b[i] = cnt;
    }

    int b1=0, b2=0, b4=0;
    for (int i = 0; i < N; ++i) {
        if (b[i]==0) ++b1;
        else if(b[i]==1) ++b2;
        else ++b4;
    }

    if (b2) ++b1;

    cout << ((b1 <= b4+1) ? "Yes":"No") << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	string S, T; cin >> S >> T;
	cout << T+S << endl;
}

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

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    char c;
    cin>>c;
    if(c=='A'){
        cout<<'T';
    }else if(c=='T'){
        cout<<'A';
    }else if(c=='G'){
        cout<<'C';
    }else if(c=='C'){
        cout<<'G';
    }
    cout<<endl;
}


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

int main() {
  int n;
  cin >>n;
  vector<int> a(n+1);
  rep(i,n+1) cin >>a[i];
  vector<int> b(n);
  rep(i,n) cin >>b[i];
  ll cnt = 0;
  rep(i,n+1){
    int tmp1 = min(a[i], b[i]);
    b[i] -= tmp1;
    cnt += tmp1;
    int tmp2 = min(a[i+1], b[i]);
    a[i+1] -= tmp2;
    cnt +=tmp2;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let s: usize = iter.next().unwrap().parse().unwrap();

    let mut cnt = 0;
    for i in 1..s + 1 {
        if i % 2 == 1 {
            cnt += 1;
        }
    }

    let ans = (cnt as f64) / (s as f64);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

bool flag = true;
vector<long long> bellman_ford(vector<vector<pair<ll, ll>>> g, long long start){
    vector<ll> distance(g.size(), INF);
    distance[start] = 0;
    ll count = 0;
    while(true){
        bool update = false;
        for(ll i = 0; i < g.size(); i++){
            for(ll j = 0; j < g[i].size(); j++){
                if(distance[i] != INF && distance[g[i][j].second] > distance[i] + g[i][j].first){
                    distance[g[i][j].second] = distance[i] + g[i][j].first;
                    update = true;
                }
            }
        }
        if(!update) break;
        count++;
        if(count == g.size()){
            flag = false;
            return distance;
        }
    }
    return distance;
} 

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll v, e; cin >> v >> e;
    vector<vector<pair<ll, ll>>> g(v);
    rep(i, e){
        ll s, t, d; cin >> s >> t >> d;
        g[s].emplace_back(d, t);
    }

    rep(i, v){
        vector<ll> dis = bellman_ford(g, i);
        if(flag){
            rep(j, v){
                if(dis[j] == INF){
                    cout << "INF";
                }else{
                    cout << dis[j];
                }
                if(j != v-1){
                    cout << " ";
                }
            }
            cout << endl;
        }else{
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
        
    }


}


Measured memory_bytes: 3304
#include<stdio.h>

int calc_week(int, int, int, int *);
int calc_day(int, int);

int main() {
	int a, b, c, d, x, y;
	scanf("%d%d%d", &a, &b, &c);
	x = calc_week (a, b, c, &d);
	y = calc_day (d, a);
	printf("%d\n",7* x + y);
	return 0;
}
int calc_week(int a, int b, int c, int *d) {
	int x;
	x = c / (7 * a + b);
	*d = c % (7 * a + b);
	return x;
}
int calc_day(int d, int a) {
	int y;
	if (d > 7 * a)y = 7;
	else if (d % a == 0)y = d / a;
	else y = (d / a) + 1;
	return y;
}



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

int n;
string s;

int main() {
	cin >> n >> s;
	if (n % 2 == 1) { cout << "No" << endl; return 0; }
	
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n / 2 + i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
from math import sqrt
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

p = [i for i in range(n)]
c = 0
d = 0.0
dp = [[0.0 for _ in range(n)] for _ in range(n)]
for a in permutations(p):
    c += 1
    for i in range(n - 1):
        if dp[a[i]][a[i + 1]] == 0.0:
            dp[a[i]][a[i + 1]] = sqrt((x[a[i]] - x[a[i + 1]]) ** 2 + (y[a[i]] - y[a[i + 1]]) ** 2)
        d += dp[a[i]][a[i + 1]]
print("{:10f}".format(d / c))


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

using namespace std;
int N, temp, swaps = 0;
int arr[100];
void SelectionSort(int *arr, int n, bool stable = 0)
{
    for (int i = 0; i < n - 1; i++)
    {
        int minIdx = i;
        for (int j = i + 1; j < n; j++)
        {
            if (arr[j] < arr[minIdx])
            {
                minIdx = j;
            }
        }
        if (stable)
        {
            int key = arr[minIdx];
            while (minIdx > i)
            {
                arr[minIdx] = arr[minIdx - 1];
                --minIdx;
            }
            arr[i] = key;
        }
        else

            if (arr[i] > arr[minIdx])
            {
                swaps = swaps + 1;
                temp = arr[i];
                arr[i] = arr[minIdx];
                arr[minIdx] = temp;
            }
        //swap(arr[i],arr[minIdx]);
    }
}
int main()
{
    //freopen("in.txt", "r", stdin);
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> arr[i];
    }
    SelectionSort(arr, N);

    for (int k = 0; k < N - 1; k++)
        cout << arr[k] << char(0x20);
    cout << arr[N - 1] << endl;
    cout << swaps;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while (true) {
        lint n, m;
        cin >> n >> m;
        if (n == 0)
            return 0;
        vector<lint> h(n), w(m);
        for (int i = 0; i < n; ++i) {
            cin >> h[i];
        }
        for (int i = 1; i < n; ++i) {
            h[i] += h[i - 1];
        }
        for (int i = 0; i < m; ++i) {
            cin >> w[i];
        }
        for (int i = 1; i < m; ++i) {
            w[i] += w[i - 1];
        }
        map<lint, lint> cnt;
        for (int i = 0; i < n; ++i) {
            for (int j = i; j < n; ++j) {
                lint he = h[j];
                if (i != 0)
                    he -= h[i - 1];
                cnt[he]++;
            }
        }
        lint ret = 0;
        for (int i = 0; i < m; ++i) {
            for (int j = i; j < m; ++j) {
                lint wi = w[j];
                if (i != 0)
                    wi -= w[i - 1];
                ret += cnt[wi];
            }
        }
        cout << ret << "\n";
    }
    return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		void swap(ref long x, ref long y)
		{
			long temp = y;
			y = x;
			x = temp;
		}

		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			long W = array[0];
			long H = array[1];
			long x = array[2];
			long y = array[3];
			long r = array[4];
			string result = "Yes";
			if (x - r < 0 || x + r > W
				|| y - r < 0 || y + r > H) {
				result = "No";
			}

			Console.WriteLine($"{result}");
			Console.Out.Flush();
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
long gcd(long a, long b){
	if (a % b == 0)
		return b;
	else
		return (gcd(b, a % b));
}
long  lcm(long a, long b){
	return (a * b / gcd(a,b));
}
int  main(){
	long a,b; cin >> a >> b;
	long c,d; cin >> c >> d;
	long total = b - a + 1;
	long c_n = b/c - (a-1)/c;
	long d_n = b/d - (a-1)/d;
	long cd_n = (b / lcm(c,d)) - ((a-1) / lcm(c,d));
	cout << total - (c_n + d_n - cd_n) << endl;
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a;
    cin >> a ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    //Sunny, Cloudy, Rainy
    /*
    if( a < 10 && b < 10 ){
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    //*/
    
    cout << a / 2 + a % 2 << endl;
    
    //printf("%lf\n", ((a / 2 + a % 2) / a));

    return 0; 
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define temT template<typename T>
using namespace std;

int n; int cnt,flag;

int main(){
	scanf("%d",&n);
	for(int i=1,a,b;i<=n;i++){
		scanf("%d%d",&a,&b);
		if(a==b) cnt++;
		else cnt=0;
		if(cnt>=3) flag=1;
	}
	printf("%s",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3824