akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define ll long long
int main(){
  ll N,i;
  cin >> N;
  ll mx=0;
  ll h[N];
  for(i=0;i<N;i++){
    cin >> h[i];
  }
  ll ans=0;
  for(i=0;i<N;i++){
    if(mx<=h[i]){
      mx=h[i];
      ans++;
    }
  }
  cout << ans;
  return 0;
}

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

using namespace std;
const long long mod = 1e9 + 7;

long long modpow(long long num, long long n){
    long long res = 1;
    
    while (n > 0){
        if (n & 1) res = res * num % mod;
        num = num * num % mod;
        n >>= 1;
    
    }
    
    return res;
}

int main(){
    long long n, k;
    cin >> n >> k;
    
    long long ans = 0;
    
    // GCDの結果がXになるときの数列の数を保持する配列である
    vector<long long> count(k+5,0);
    
    // GCDが大きい方(k)から確定させていく
    for (long long i = k; i > 0; i--){
        
        // 1~kまでにiの倍数がいくつあるかを求める
        long long num = k / i; 
        
        // GCDの結果がiになるときの数列の数を求める
        // ただし重複を許している
        long long tempCount = modpow(num, n);
        count[i] = tempCount;
        
        // GCDが,2*i, 3*i,,,の場合を除く
        long long subtraction = 2 * i;
        
        while (subtraction <= k){
            count[i] -= count[subtraction];
            subtraction += i;
        }
    }
    
    for (long long i = 1; i <= k; i++){
        ans += i * count[i] % mod;
        ans %= mod;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3972
package main
 
import(
  "fmt"
)
 
func main(){
	var A,B int
	fmt.Scan(&A)
	fmt.Scan(&B)
	if A == 1{
		A = 14
	}
	if B == 1{
		B = 14
	}
	if A > B{
		fmt.Println("Alice")
	}else if B > A{
		fmt.Println("Bob")
	}else{
		fmt.Println("Draw")
	}
}

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

const int N = 1e5 + 10;
int a[N], b[N];

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

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MAX_K = 9;
int N, K, D[MAX_K];

bool hasD(int n) {
    while (n > 0) {
        REP(i, K) {
            if (n % 10 == D[i]) {
                return true;
            }
        }
        n /= 10;
    }
    return false;
}

// main
int main() {
    cin >> N >> K;
    REP(i, K) {
        cin >> D[i];
    }
    int res = N;
    while (1) {
        if (!hasD(res)) {
            cout << res << endl;
            break;
        }
        res++;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll c[200010];
ll F[2100010];

ll Mul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}

ll square(ll x) {
	return (x * x) % mod;
}

ll power(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

ll Div(ll a, ll b) {
	return Mul(a, power(b, mod - 2));
}
ll P(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

ll C(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	ll ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int main()
{
	ll N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}
	sort(c, c + N, greater<int>());
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += Div((power(2, N * 2) * c[i]) % mod * (i + 2), 4);
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a + b + c == 17){
    if((a == 5||a == 7)&&(b == 5 || b == 7)&&(c == 5||c == 7))printf("YES");
    else printf("NO");
  }else printf("NO");
  return 0;
}

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

int main(){
  int n;
  string s[300];
  while(cin>>n&&n){
    for(int i=0;i<n;i++) cin>>s[i];
    int m;
    cin>>m;
    bool p=0,np=0;
    while(m--){
      string str;
      cin>>str;
      for(int i=0;i<n;i++)
	if(str==s[i]){
	  np=!np;
	  break;
	}
      if(p==np) cout<<"Unknown "<<str<<endl;
      else if(np) {cout<<"Opened by "<<str<<endl;p=np;}
      else {cout<<"Closed by "<<str<<endl;p=np;}
    }
  }
  return 0;
}

Measured memory_bytes: 1220
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int ketawa(ll n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
		
	}
	return sum;
}
int main() {
	ll n;
	cin >> n;
	if (n%ketawa(n) == 0)cout << "Yes";
	else cout << "No";

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(ll, N);
	int sn = 0;
	auto s = to_string(N);
	for (auto c : s)
		sn += c - '0';
	YesNo(N % sn == 0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k,l,m,n;
  int a[6];
  for(int p=0; p<5; p++){
    cin>>a[p];
    if(a[p]==0) n=p+1;
  }
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
		{
			int x = int.Parse(Console.ReadLine());

			if ((x == 3) || (x == 5) || (x == 7))
				Console.WriteLine("YES");
			else Console.WriteLine("NO");

			Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s;
    cin >> s;
    ll n = s.size();

    ll now = 0;
    REP(i, n) {
        if(s[i]=='(') now++;
        else if(s[i]== ')') now--;
        else {
            cout << now << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3228
#include<stdio.h>

// ITP1_2_A
// 整数値a,bの大小関係を出力
int main()
{
	int iInputA, iInputB;

	scanf("%d %d", &iInputA, &iInputB);

	if (iInputA < iInputB)
	{
		printf("a < b\n");
	}
	else if (iInputA == iInputB)
	{
		printf("a == b\n");
	}
	else
	{
		printf("a > b\n");
	}

	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <math.h>

int main(void){
  int N, n;
  scanf("%d", &N);
  n = N;

  int dig[10];
  int s = 0;

  for(int i=0; i<10; i++){
    dig[i] = n/pow(10, 9-i);
    n -= dig[i]*pow(10, 9-i);
    s += dig[i];
  }

  if(N%s == 0)
    puts("Yes");
  else
    puts("No");
  
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int a[] = {1,6,1,4,5,2,6};//0
	int b[] = {2,3,6,5,2,1,6};//1
	char str[128]={0};
	while(scanf("%s",str) , str[0] != '#'){
		int len = strlen(str);
		int x=0,y=0;
		for(int i = 0; i < len; i++){
			if(str[i] == 48)x = a[y];
			else x = b[y];
			y = x;
		}
		if(x == 5)puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 944
#include<iostream>
#include<string>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

string a[12], b[12];
int pairs[12];
int h, w;

int count_lines[12][26], count_columns[12][26];

void count();
bool check_columns();
bool check_lines();
bool make_even();
bool make_pair_of_lines(int);

void count(){
    fill(count_lines[0], count_lines[12], 0);
    fill(count_columns[0], count_columns[12], 0);
    rep(h){
        repp(j, w){
            count_lines[i][a[i][j]-'a']++;
            count_columns[j][a[i][j]-'a']++;
        }
    }
}

bool check_columns(){
    rep(h){
        if(b[pairs[i]] == ""){
            b[pairs[i]] = a[i];
        }else{
            b[h-1-pairs[i]] = a[i];
        }
    }

    bool center = (w % 2 == 0);
    bool used[w];
    fill(used, used+w, false);

    repp(j, w){
        if(used[j]) continue;
        used[j] = true;
        bool same = false;

        repp(jj, w){
            if(used[jj]) continue;

            same = true;
            rep(h){
                if(b[i][j] != b[h-1-i][jj]){
                    same = false;
                    break;
                }
            }
            if(same){
                used[jj] = true;
                break;
            }
        }

        if(!same){
            if(center) return false;
            else center = true;
        }
    }

    return true;
}

bool check_lines(){
    int pair_first[6];
    fill(pair_first, pair_first+6, -1);
    rep(h){
        if(pair_first[pairs[i]] == -1){
            pair_first[pairs[i]] = i;
        }else{
            repp(k, 26){
                if(count_lines[pair_first[pairs[i]]][k] != count_lines[i][k]) return false;
            }
        }
    }
    return check_columns();
}

bool make_even(){
    h++;
    rep(h-1){
        a[h-1] = a[i];
        pairs[h-1] = -1;
        count();
        if(make_pair_of_lines(0)) return true;
    }
    return false;
}

bool make_pair_of_lines(int paired_line){
    if(h % 2) return make_even();

    if(paired_line == h) return check_lines();

    int pair_line_first = -1;
    rep(h){
        if(pairs[i] == -1){
            if(pair_line_first == -1){
                pair_line_first = i;
                pairs[pair_line_first] = paired_line/2;
                break;
            }
        }
    }

    repp(j, h){
        if(pairs[j] == -1){
            pairs[j] = paired_line/2;
            if(make_pair_of_lines(paired_line+2)) return true;
            pairs[j] = -1;
        }
    }

    pairs[pair_line_first] = -1;

    return false;
}

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

    cin >> h >> w;
    rep(h) cin >> a[i];

    count();

    fill(pairs, pairs+h, -1);
    cout << (make_pair_of_lines(0)?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = gets.split().map(&:to_i)
a = gets.split().map(&:to_i)

len = n - 1
target = k - 1
cost = 10000000000000

[0, 1].repeated_permutation(len) do |bits|
  next unless bits.count(1) == target
  baseH = a[0]
  sum = 0
  bits.each_with_index do |bit, index|
    next if bit == 0
    baseH = [a[0..index].max, baseH].max
    if baseH < a[index+1]
      baseH = a[index+1]
    else
      sum += baseH - a[index+1] + 1
      baseH += 1
    end
  end
  cost = [cost, sum].min
end

puts cost




Measured memory_bytes: 2300
a, b, c, x, y = map(int, input().split())

if x < y:
    a, b = b, a
    x, y = y, x

case1 = a * x + b * y
case2 = c * 2 * y + (x - y) * a
case3 = c * 2 * x

print(min(case1, case2, case3))


Measured memory_bytes: 38384
#dpテーブルのみでの解法(順方向)
n,w=map(int,input().split())
a=[]
dp=[]
for i in range(n):
   a.append(list(map(int,input().split())))
for k in range(n+1):
  dp.append([])
  for l in range(w+1):
      dp[k].append(0)
for i in range(n):
   for j in range(w+1):
       if j<a[i][0]:
           dp[i+1][j]=dp[i][j]
       else:
           dp[i+1][j]=max(dp[i][j],dp[i][j-a[i][0]]+a[i][1])
print(dp[n][w])

Measured memory_bytes: 142668
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Global Variables begin ======

// ====== Global Variables end ======
void speed_solve(){
    ll d,s, t;
    cin >> d >> s >> t;
    cout << (d <= s * t ? "Yes" : "No");
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3644
// Problem : C - Many Requirements
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int n,m,q;
int a[55],b[55],c[55],d[55];
int ans[11],sum;

void dfs(int pos,int cur)
{
	if(pos == n + 1){
		int t = 0;
		rep(i,0,q){
			if(ans[b[i]] - ans[a[i]] == c[i]) t += d[i];
		}
		sum = max(sum,t);
		return;
	}
	rep(i,cur,m + 1) {
		ans[pos] = i;
		dfs(pos + 1,i);
	}
}

int main()
{
	fastIO;
	cin >> n >> m >> q;
	rep(i,0,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(0,1);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve())
}

func resolve() int {
	str := scanString(sc)
	lastPos := map[byte]int{}
	maxSectionLen := map[byte]int{}
	for i := range str {
		b := str[i]
		var l int
		if _, ok := lastPos[b]; ok {
			l = i - lastPos[b] - 1
		} else {
			l = i
		}
		updateWithMax(maxSectionLen, b, l)
		lastPos[b] = i
	}
	for b, p := range lastPos {
		l := len(str) - p - 1
		updateWithMax(maxSectionLen, b, l)
	}
	return selectMin(maxSectionLen)
}

func updateWithMax(m map[byte]int, i byte, v int) bool {
	update := m[i] <= v
	if update {
		m[i] = v
	}
	return update
}

func selectMin(m map[byte]int) int {
	min := math.MaxInt32
	for _, secLen := range m {
		if min > secLen {
			min = secLen
		}
	}
	return min
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

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

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

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

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

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

ll getScore(vector<bool> givingList) {
    ll ans = 0;
    for (bool b : givingList) {
        if (b) {
            ans++;
        }
    }
    return ans;
}

ll calcPath(vector<ll> holdingTrashes, ll X) {
    ll score = 0;
    ll cost = 1;
    score += holdingTrashes[0];
    holdingTrashes.push_back(0);
    FOR(i, 1, holdingTrashes.size()) {
        cost++;
        score += (holdingTrashes[i - 1] - holdingTrashes[i]) * cost * cost;
    }
    score += X * holdingTrashes.size();
    return score;
}

int main() {
    string S, T;
    cin >> S >> T;
    vector<vector<int>> charMatrix;
    charMatrix = vector<vector<int>>(26, vector<int>(26, 0));
    REP(i, S.size()) {
        charMatrix[S[i] - 97][T[i] - 97] = 1;
    }
    for (vector<int> charArray : charMatrix) {
        int count = 0;
        for (int i : charArray) {
            count += i;
        }
        if (count > 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    REP(i, 26) {
        int count = 0;
        REP(j, 26) {
            count += charMatrix[j][i];
        }
        if (count > 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#getting input
statements = []
while True:
    try:
        line = str(input())
    except EOFError:
        break
    statements.append(line)

pair = statements.pop(0).split()
amount = int(pair[0])
quantum = int(pair[1])

#process input
queue = []
for state in statements:
    pair = state.split()
    name = pair[0]
    time = int(pair[1])
    queue.append([name,time])

#processing queue

done_list = list()
time_spend = 0
while True:
    if not len(queue) > 0:
        break
    task = queue[0]


    if task[1] >= quantum: #time left
        time_spend += quantum
        task[1] = task[1] - quantum
    else:
        time_spend += task[1]
        task[1] = 0

    if task[1] <= 0: #finished
        task.append(time_spend)   #name,left_time, finished time
        done_list.append((task[0],task[2])) #name and finished time
        queue.remove(task)
    else:
        temp = task
        queue.remove(task)
        queue.append(temp)

for result in done_list:
    print(result[0],end=' ')
    print(result[1])


Measured memory_bytes: 17900
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
x = 100 * n // 108
y1 = int(x * 1.08)
y2 = int((x + 1) * 1.08)
if n == y1:
    print(x)
elif n == y2:
    print(x + 1)
else:
    print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;



int main()
{
    ll X,Y;

    cin >> X >> Y;

    ll tmp = X;
    ll cnt = 0;

    while(tmp <= Y)
    {
        tmp *= 2;
        cnt++;
    }

    cout << cnt << endl;

}



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

using namespace std;

int main()
{
    int N;
    string ans;
    int i;
    vector<int> a(3);
    cin >> N ;
    for(i=0; i<3; i++)
    {
        a[i] = N%10;
        N /= 10;
    }
    if(a[0] == 3)ans = "bon" ;
    else if(a[0] == 0)ans = "pon";
    else if(a[0] == 1)ans = "pon";
    else if(a[0] == 6)ans = "pon";
    else if(a[0] == 8)ans = "pon";
    else ans = "hon";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
int M = 1e9 + 7;
const int N = 1e6 + 10;
const int IM = 1e16;
const int PI = 3.14159265;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PTN(int n = 1, int a = 0, int b = 0, int c = 0) { if (n--)cout << a << " "; if (n--)cout << b << " "; if (n--)cout << c << " "; cout << endl; }
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <-------------------------------------------------------------------------------------------------------------------------------------------------------------------------> Ignore This--> memset substr pop_back  insert tuple first second push_back string continue make_pair break deque stack queue sort reverse accumulate  count lower_bound upper_bound next_permutation copy_n __builtin_popcount make_tuple
// <========================================================================================================================================================================
vi v[N];
int a[N];
int b[N];
deque<int> vv;
void dfs(int x) {
    a[x]++;
    while (vv.size()) {
        int y = vv[0];
        x = y;
        vv.pop_front();
        for (int i = 0; i < v[y].size(); i++) {
            if (a[v[x][i]] == 0)
                vv.push_back(v[x][i]);
            a[v[x][i]]++;
            if (b[v[x][i]] == 0)
                b[v[x][i]] = y;
        }
    }

}

signed  main() {
    SPD_emergency
  
    int i, j, x, y, u, l;
    int tt = 1;
    // int t; cin >> t; while (t--)
    {   i = j = x = y = u = l = 0;
        int n, m;
        cin >> n >> m;
        for (i = 0; i < m; i++) {
            cin >> x >> y;
            v[x].push_back(y);
            v[y].push_back(x);
        }
        vv.push_back(1);
        dfs(1);
        bool ck = 0;
        for (i = 1; i <= n; i++) {
            if (a[i] == 0) {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes" << endl;
        for (i = 2; i <= n; i++) {
            PT(b[i]);
        }

        /**/
    }


    return 0;
}

Measured memory_bytes: 34836
tax_8,tax_10=gets.chomp.split(" ").map(&:to_i);
x = 1
result = nil
while x < 1010 do
  a = (x * 0.08).floor
  b = (x * 0.1).floor
  if a == tax_8 && b == tax_10
    result = x
    break
  end
  x += 1
end
if result == nil
  print "-1"
else
  print result.to_s
end


Measured memory_bytes: 3836
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1<<32 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

N = int(input())
A = [int(a) for a in input().split()]
g = 0
for a in A:
    g = gcd(g, a)

if g > 1:
    print("not coprime")
    exit()

X = [0] * 1001001
for a in A:
    for p in primeFactor(a):
        if X[p]:
            print("setwise coprime")
            exit()
        X[p] = 1

print("pairwise coprime")

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int x = 0, ans = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'I') x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
int n;
bool visit[1010];
char strs[1010][1010];
bool seen[1010][1010];
 
void dfs(int from, int &node, int &edge) {
  visit[from] = true;
  node++;
  REP(to, n) {
    if (strs[from][to] == 'N') { continue; }
    if (!seen[from][to]) {
      edge++;
      seen[from][to]  = seen[to][from] = true;
    }
    if (visit[to]) { continue; }
    dfs(to, node, edge);
  }
}
 
int memo[1010][1010][2];
int calc(int odd, int even, int e) {
  if (odd + even == 1) { return 1; }
  if (memo[odd][even][e] != -1) { return memo[odd][even][e]; }
  int ret = 0;
  if (e == 1) { ret |= 1 ^ calc(odd, even, 0); }
  if (odd >= 2) {
    ret |= 1 ^ calc(odd - 2, even + 1, e);
  }
  if (even >= 2) {
    ret |= 1 ^ calc(odd, even - 1, e ^ 1);
  }
  if (odd >= 1 && even >= 1) {
    ret |= 1 ^ calc(odd, even - 1, e ^ 1);
  }
  return memo[odd][even][e] = ret;
}
 
int main() {
  while (scanf("%d", &n) > 0) {
    MEMSET(memo, -1);
    MEMSET(visit, false);
    MEMSET(seen, false);
    REP(y, n) {
      scanf("%s", strs[y]);
    }
    int odd = 0;
    int even = 0;
    int e = 0;
    REP(i, n) {
      if (visit[i]) { continue; }
      int node = 0;
      int edge = 0;
      dfs(i, node, edge);
      if (node % 2 == 0) { even++; }
      else { odd++; }
      int rest = node * (node - 1) / 2 - edge;
      if (rest % 2 == 1) { e ^= 1; }
    }
    if (calc(odd, even, e)) {
      puts("Taro");
    } else {
      puts("Hanako");
    }
  }
}

Measured memory_bytes: 10000
# input
listB = []
while True:
    try:
        listB.append(int(raw_input()))
    except:
        break;

A = listB[0]
B = listB[1]
C = listB[2]
D = listB[3]
E = listB[4]

totalCookingTime = A+B+C+D+E

A_lossTime = 10 - (A % 10 if A % 10 != 0 else 10)
B_lossTime = 10 - (B % 10 if B % 10 != 0 else 10)
C_lossTime = 10 - (C % 10 if C % 10 != 0 else 10)
D_lossTime = 10 - (D % 10 if D % 10 != 0 else 10)
E_lossTime = 10 - (E % 10 if E % 10 != 0 else 10)

maxLossTime = max(A_lossTime,B_lossTime,C_lossTime,D_lossTime,E_lossTime)

print(totalCookingTime + A_lossTime + B_lossTime + C_lossTime + D_lossTime +
      E_lossTime - maxLossTime)


Measured memory_bytes: 2692
require 'prime'

h = {}
primes = Prime.each(50000).to_a
primes.each {|pr| h[pr] = true}
until (n = $<.gets.to_i).zero?
  co = 0
  if n.odd?
    co = 1 if h[n - 2]
  else
    primes.each do |pr|
      break if pr > n / 2
      co += 1 if h[n - pr]
    end 
  end
  puts co
end


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<bool> flag(N+1,false);
  vector<int> wa(N+1,0);
  int asum=0;
  int wsum=0;
  for(int i=0;i<M;i++){
    int p;
    string s;
    cin >> p >> s;
    if(!flag.at(p)){
      if(s=="WA"){
        wa.at(p)++;
      }else{
        flag.at(p)=true;
        asum++;
        wsum+=wa.at(p);
      }
    }
  }
  cout << asum << " " << wsum << endl;
  return 0;
}


Measured memory_bytes: 640
//#if !defined(YCM) && 1
//#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx")
////#pragma GCC optimize ("O3")
////#pragma GCC target ("sse4")
//#include <stdio.h>
//#endif
#include <unistd.h>
//#pragma GCC diagnostic ignored "-Wunused-result"
//#pragma GCC diagnostic ignored "-Wunused-function"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>
#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF (ll)1e18
#define m_p make_pair
#define all(v) v.begin(),v.end()
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
ll lcm(ll a,ll b){return (a/__gcd(a,b))*b;}
ll bigmod(ll a,ll p,ll mod){ll ans=1;while(p){if(p&1)ans=ans*a%mod;a=a*a%mod;p>>=1;}return ans;}
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0){ll y=power(x,n/2);return y*y;}else return x*power(x,n-1);}

#ifdef shaft
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
const int N=(int)1e6+5;
const int mod=(int)1e9+7;

int main()
{
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(100); cout.tie(nullptr); cin.tie(nullptr);
    #ifdef shaft
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif ///shaft
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    cout << x % b << endl;
    return 0;
}





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

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

fn main(){
    let m1: u32 = read();
    let d1: u32 = read();
    let m2: u32 = read();
    let d2: u32 = read();

    println!("{}", if m1 != m2 {"1"} else {"0"});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
int main()
{
	bs;
	int n;
	cin >> n;
	int a[n], MX = 0;
	ll tot = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(a[i] < MX)
			tot += (MX - a[i]);
		MX = max(MX, a[i]);
	}
	cout << tot;
}

Measured memory_bytes: 4332
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

int L;

vi x, y, w;

int main(){
	scan(L);
	int B=0;
	while((1<<B) <= L) B++;
	B--;
	assert(B+1<=20);
	for(int i=0; i<B; i++){
		x.pb(i); y.pb(i+1); w.pb(0);
		x.pb(i); y.pb(i+1); w.pb(1<<i);
		if(L & (1<<i)){
			int ww = (L>>(i+1)) << (i+1);
			x.pb(i); y.pb(B); w.pb(ww);
		}
	}
	printf("%d %d\n", B+1, (int)x.size());
	for(int i=0; i<(int)x.size(); i++){
		printf("%d %d %d\n", x[i]+1, y[i]+1, w[i]);
	}
}


Measured memory_bytes: 256
#define Cpp
typedef int readtype;

/* Header {{{ */
#ifdef C
#include <stdio.h>
#include <math.h>
#include <string.h>
#define isdigit(a) ((a) >= '0' && (a) <= '9' ? true : false)
template<typename type> type abs(type a) { return a < 0 ? -a : a; }
template<typename type> type min(type a, type b) { return a < b ? a : b; }
template<typename type> type beMin(type &a, type b) { return a = (a < b ? a : b); }
template<typename type> type max(type a, type b) { return a > b ? a : b; }
template<typename type> type beMax(type &a, type b) { return a = (a > b ? a : b); }
template<typename type> void swap(type &a, type &b) { type c; c = a; a = b; b = c; }
#endif

#ifdef Cpp
#include <bits/stdc++.h>
using namespace std;
#endif

typedef long long var;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}
/* }}} */

const int N = 2100005;
const long double Pi = acos(-1.0);

struct Node {
  int x, y;
};

int n, cnt;
int num[N << 1];
Node cir[N];
Node bnode, enode;

namespace TreeArray {
  int tree[N];
  void modify(int t, int v);
  int query(int t);
};

using namespace TreeArray;

int main() {
  /*
#ifndef ONLINE_JUDGE
  freopen("source.in", "r", stdin);
  freopen("source.out", "w", stdout);
#enodeif
  */
  bnode = (Node) {read(), read()}, enode = (Node) {read(), read()};
  if (bnode.y > enode.y) swap(bnode, enode);
  n = read();
  for (int i = 1; i <= n; ++i) {
    Node t = (Node) {read(), read()};
    if ((t.x < bnode.x && t.x < enode.x) ||
        (t.x > bnode.x && t.x > enode.x) || 
        (t.y < bnode.y && t.y < enode.y) || 
        (t.y > bnode.y && t.y > enode.y)) continue;
    cir[++cnt] = t;
  }
  n = cnt, cnt = 0;
  sort(cir + 1, cir + n + 1, [=] (Node a, Node b) { 
      return (bnode.x < enode.x) ^ (a.x > b.x);
      });
  for (int i = 1; i <= n; ++i) num[++cnt] = cir[i].y;
  sort(num + 1, num + cnt + 1);
  cnt = unique(num + 1, num + cnt + 1) - num - 1;

  /*
  for (int i = 1; i <= n; ++i) printf("%d %d\n", cir[i].x, cir[i].y);
  puts("");
  */

  /*
  for (int i = 1; i <= cnt; ++i) printf("%d ", num[i]);
  puts("");
  */

  int res = 0;
  for (int i = 1; i <= n; ++i) {
    int k = upper_bound(num + 1, num + cnt + 1, cir[i].y) - num - 1, t = query(k) + 1;
    modify(k, t);
    res = max(res, t);
  }

  // printf("%d %d\n", res, n);

  var xdist = abs(enode.x - bnode.x), ydist = abs(enode.y - bnode.y);
  long double dist = 100 * (xdist + ydist);
  // printf("%.13Lf\n", dist);
  dist += (var) res * (5 * Pi - 20);
  dist += (res > xdist || res > ydist) * 5 * Pi;
  printf("%.13Lf\n", dist);
  return 0;
}

namespace TreeArray {
  void modify(int t, int v) {
    for (int i = t; i <= cnt; i += i & -i) 
      tree[i] = max(tree[i], v);
  }
  int query(int t) {
    int res = 0;
    for (int i = t; i; i -= i & -i) 
      res = max(res, tree[i]);
    return res;
  }
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (max < temp) max = temp;
            if (min > temp) min = temp;
        }
        System.out.println(max - min);
    }
}


Measured memory_bytes: 21972
#include <numeric>
#include <iostream>
#include <vector>
#include <cmath>

int mygcd(int a, int b)
{
	return b == 0 ? a : mygcd(b, a%b);
}

int main()
{
	using namespace std;

	int n, x;
	cin >> n >> x;

	vector<int> xs(n);
	for (auto& y : xs) cin >> y;
	for (auto& y : xs) y -= x;

	cout << abs(accumulate(begin(xs), end(xs), 0, mygcd)) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;


struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};

bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}

int main(){
    Dice d[2];
    for(int i=0; i < 2; i++){
        for(int j=0; j < 6; j++){
            cin >> d[i].s[j];
        }
    }
    bool f = false;

    for(int i=0; i < 4; i++){
        d[0].roll('R');
        for(int j=0; j < 4; j++){
            d[0].roll('N');
            if(same(d[0], d[1]))f = true;
        }
    }
    d[0].roll('W');
    for(int i=0; i < 4; i++){
        d[0].roll('N');
        if(same(d[0], d[1]))f = true;
    }
    d[0].roll('E');
    d[0].roll('E');
    for(int i=0; i < 4; i++){
        d[0].roll('N');
        if(same(d[0], d[1]))f = true;
    }
    cout << (f ? "Yes":"No") << endl;
    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int ans = 0;
  int last = 6;
  int div = 10;
  vector<int> n;
  vector<int> amari;
  REP(i, 5){
      int t;
      cin >> t;
      n.pb(t);
    }
    REP(i, 5) ans +=n[i];
    REP(i, 5){
      int t = n[i] % 10;
      if(t != 0) t = 10 - t;
      amari.pb(t);
      }
      sort(amari.begin(), amari.end());
      REP(i, 4) ans += amari[i];
        cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto kab = readln.split.to!(long[]);
    auto K = kab[0];
    auto A = kab[1];
    auto B = kab[2];
    if (K <= A) {
        writeln(1);
    } else if (A - B <= 0) {
        writeln(-1);
    } else {
        writeln((K-B-1)/(A-B)*2 + 1);
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back

ll bucket[1<<16];

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

	ull x = x0;
	rep(i,n){
		bucket[uint16_t((x>>(64-16)) + (1<<15))]++;
		x ^= x<<13;
		x ^= x>>7;
		x ^= x<<17;
	}

	ll key;
	for(key=0;k-bucket[key]>=0;key++){
		k-=bucket[key];
	}

	vector<ll> v;
	x = x0;
	rep(i,n){
		if(uint16_t((x>>(64-16)) + (1<<15))==key){
			v.pb(x);
		}
		x ^= x<<13;
		x ^= x>>7;
		x ^= x<<17;
	}

	sort(all(v));
	cout<<v[k]<<endl;
}

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

int main(){
  string s;
  int l,n=0;
  cin>>s;
  l=s.length();
  rep(i,l/2){
    if(s.at(i)!=s.at(l-i-1)) n++;
  }
  cout<<n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long H;
  cin >> H;
  long long ans=0,cnt=1;
  for(long long i=0;i<1e18;i++){
    if(H==1){
      ans+=cnt;
      break;
    }
    if(H>1){
      H/=2;
      ans+=cnt;
      cnt*=2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
n = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
p1 = 0
p2 = 0
p3 = 0
pinf = 0
for i in range(n):
    tmp = abs(X[i] - Y[i])
    p1 += tmp
    p2 += tmp ** 2
    p3 += tmp ** 3
    pinf = max(pinf, abs(X[i] - Y[i]))
p2 = p2 ** (1/2)
p3 = p3 ** (1/3)
print(p1)
print(p2)
print(p3)
print(pinf)


Measured memory_bytes: 5692