akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int a2, b2;
		a2 = a + w;
		b2 = b + w;
		if(Math.abs(a-b)> w) {
			if(a>b) {
				System.out.println(a-b2);
			}else if(a<b) {
				System.out.println(b-a2);
			}
		}else {
			System.out.println("0");
		}
	}
}

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

int main()
{
    long long n,k,res=0,maxx,minn;
    cin>>n>>k;
    for(long long i=k;i<=n+1;i++)
    {
      maxx=(n+n-i+1)*i/2;
      minn=i*(i-1)/2;
      res=res+maxx-minn+1;
    }
    if(k==n+1)
        cout<<1<<endl;
    else
        cout<<res%1000000007<<endl;
    return 0;
}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;

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

  int N,K;
  cin >> N >> K;
  vector<int> X(N);
  REP(i,N) cin >> X[i];

  int ans = 0;
  REP(i,N) {
    int diff = min(X[i], K-X[i]);
    ans += 2 * diff;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3656
function main(input) {
	var inputs = [];
	var a = Number(input.charAt(0));
	var b = Number(input.charAt(1));
	var c = Number(input.charAt(2));
	var d = Number(input.charAt(3));

	for(var op = 0; op < 8;op++){
        if(
        	a + b * (1 - (op & 1) * 2) + c * (1 - (op & 2)) + d * (1 - (op & 4) / 2) === 7
        ){
        	return a +  ((op & 1)?'-':'+') + b + ((op & 2)?'-':'+') + c + ((op & 4)?'-':'+') + d + '=7';
        }
	}
}

console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
while True:
    data = input()
    if(data == "-"):break
    m = int(input())
    tmp = []

    for i in range(m):
        num = int(input())
        if(len(tmp) == 0):
            tmp = data[num:] + data[:num]
            data = ""
        else:
            data = tmp[num:] + tmp[:num]
            tmp = ""
    if(data): print(data)
    else: print(tmp)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	
	int plus= c-(a-b);
	
	if(plus>0)
	{
		cout<<plus<<"\n";
	}
	else
	{
		cout<<"0\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   string s;
   cin >> s;
   sort(s.begin(),s.end());
   if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3])
   cout << "Yes" << endl;
   else 
   cout << "No" << endl;
 }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in);) {
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double C = sc.nextDouble();
			
			double S = a * b * Math.sin(C / 180 * Math.PI) / 2;
			double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(C / 180 * Math.PI));
			double h = 2 * S / a;
			
			System.out.format("%.6f %.6f %.6f\n", S, L, h);
		}
	}
}


Measured memory_bytes: 28268
'''
38分あたり
https://www.youtube.com/watch?v=T1zXzsoK268
'''
def input_num_list(): return list(map(int, input().split()))

n = int(input())
t = input_num_list()
T = sum(t)
v = input_num_list()
maxv = [100 for _ in range(2 * T + 1)]
maxv[0] = 0
maxv[2 * T] = 0

t_l, t_r = 0, 0
for i in range(n):
    t_l = t_r
    t_r += t[i]
    vv = v[i]
    for j in range(2 * t_l, 2 * t_r + 1):
        maxv[j] = min(maxv[j], vv)

#print(maxv)
i = 1
while i <= 2 * T:
    maxv[i] = min(maxv[i], maxv[i - 1] + 0.5)
    i += 1
#print(maxv)
i = 2 * T - 1
while i >= 0:
    maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
    i -= 1
#print(maxv)
ans = 0
i = 0
while i <= 2 * T - 1:
    ans += 0.25 * (maxv[i] + maxv[i + 1])
    i += 1
    
print(ans)
#print(maxv)

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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int N; cin >> N;
    vector<int> cnt(N+1);

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        // for (int j = i; j <= N; j += i) {
        //     cnt[j]++;
        // }
        // ans += (ll)cnt[i] * i;
        int cnt = N / i;
        ans += ((ll)i + i+(cnt-1)*i) * cnt /2;

    }

    cout << ans << endl;
}


Measured memory_bytes: 42324
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
red = sorted(LIR(n), key=lambda x:x[1], reverse=True)
blue = sorted(LIR(n))
red_used = [0] * n
for i in range(n):
    blue_x, blue_y = blue[i]
    for j in range(n):
        red_x, red_y = red[j]
        if red_x < blue_x and red_y < blue_y and not red_used[j]:
            red_used[j] = 1
            break


print(sum(red_used))

Measured memory_bytes: 40148
use proconio::input;

/*
for i in range(0, 1000):
    if (i+1)**5 - i**5 > 10**9:
        print(i)
        break
-> 119
*/

fn main() {
    input! {
        x: i128
    };

    'outer: for a in -125..125 {
        let a = a as i128;
        for b in -125..125 {
            let b = b as i128;
            if a.pow(5) - b.pow(5) == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

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

    for(int i=0;i<N-1;i++){
        if(A[i]==A[i+1]){
            cout << "NO" << endl;
            break;
        }

        if(i==N-2){
            cout << "YES" << endl;
            break;
        }
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int N;
char S[110];
int main(){
  cin >> N;
  for (int i=0; i<N; ++i){
    cin >> S[i];
  }
  bool flag =false;
  for(int i=0; i<N; ++i){
    if ( S[i] == 'Y') flag =true;
  }
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
ai = list(map(int,input().split()))
ai.sort()

if sum(ai)<x:
    print(n-1)
elif sum(ai)==x:
    print(n)
else:
    divi = 0
    for k in range(n):
        if divi + ai[k] > x:
            print(k)
            break
        divi += ai[k]

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;
pair<int, int> P[200200];

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> P[i].second >> P[i].first;
    }
    sort(P, P + N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += P[i].second;
        if(sum > P[i].first){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");

    return 0;
}
/*


*/

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>


int main() {
	int n;
	std::cin >> n;

	std::vector<int> S;
	S.resize(n, 0);
	for (int i = 0; i < n; i++) {
		std::cin >> S[i];
	}

	int q;
	std::cin >> q;
	
	std::vector<int> T;
	T.resize(q, 0);
	for (int i = 0; i < q; i++) {
		std::cin >> T[i];
	}

	int cnt = 0;
	for (int i = 0; i < q; i++) {
		if (std::binary_search(S.begin(), S.end(), T[i]))
			cnt++;
	}

	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

const int INF = 100000001;

int main() {
    int n, m; cin >> n >> m;
    vector<P> key;
    vector<vector<int>> c(m);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c; cin >> c; //これでcBit目を1にしている
            c--; 
            s |= 1 << c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1<<n, INF); //2^n
    dp.at(0) = 0;
    rep(s, 1<<n){
        rep(i, m){
            int t = s | key.at(i).first;
            int cost = dp.at(s) + key.at(i).second;
            dp.at(t) = min(dp.at(t), cost);
        }
    }

    int ans = dp.back();
    if(ans == INF) ans = -1;
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];


ll N, a, b, c, d;
map<ll, ll> mem;

ll rec(ll n) {
  if(n==1) return d;
  if(mem[n]!=0) return mem[n];
  
  ll res=INF;
  
  if(n*d>0) res=n*d; //オーバーフローなし
  
  for(ll k=n-1; k<=n+1; k++) {
    if(k<=0) continue;
    if(k%2==0) chmin(res, rec(k/2)+a+abs(k-n)*d);
  }
  for(ll k=n-2; k<=n+2; k++) {
    if(k<=0) continue;
    if(k%3==0) chmin(res, rec(k/3)+b+abs(k-n)*d);
  }
  for(ll k=n-4; k<=n+4; k++) {
    if(k<=0) continue;
    if(k%5==0) chmin(res, rec(k/5)+c+abs(k-n)*d);
  }
  
  
  return mem[n]=res;
  
}


int main(void) {
  ll i, j, k;
  
  ll T;
  cin >> T;
  
  
  for(i=0; i<T; i++) {
    mem.clear();
    cin >> N >> a >> b >> c >> d;
    pt(rec(N));
  }
  
  
  
  
  
}
 
 




Measured memory_bytes: 4308
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define N 100100
using namespace std;
typedef long long ll;

struct edge {
    int u, v, w;
    edge() { }
    edge(int a, int b, int c) : u(a), v(b), w(c) { }
    bool operator<(const edge &b) { return w < b.w;}
};

int n, m, b[N], c[N], fa[N];
ll sum[N], f[N];
edge e[N];
vector<int> G[N];

int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

void dfs(int u, int p = 0) {
    sum[u] = b[u];
    for (int v : G[u])
        if (v != p) dfs(v, u), sum[u] += sum[v];
}

ll dfs2(int u, int p = 0) {
    ll res = max(1ll * c[u], f[u] = max(f[p], c[p] - sum[u]));
    for (int v : G[u])
        if (v != p) res = min(res, dfs2(v, u));
    return res;
}

int main() {
#ifdef isLOCAL
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", c + i, b + i);
        c[i] = max(c[i] - b[i], 0);
    }

    for (int i = 1, u, v; i <= m; ++i) {
        scanf("%d%d", &u, &v);
        if (c[u] < c[v]) swap(u, v);
        e[i] = edge(u, v, c[u]);
    }

    sort(e + 1, e + m + 1);

    for (int i = 1; i <= n; ++i)
        fa[i] = i;

    int rt = 1;
    for (int i = 1; i <= m; ++i) {
        int u = find(e[i].u), v = find(e[i].v);
        if (u != v) fa[v] = rt = u, G[u].push_back(v);
    }

    dfs(rt);

    cout << dfs2(rt) + sum[rt] << endl;

    return 0;
}


Measured memory_bytes: 12928
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n;
void f(string s,char c){
    if(s.length()==n){
        cout<<s<<endl;
        return;
    }
    for(char x='a';x<=c;x++){
        f(s+x,x==c?c+1:c);
    }
}

void run(){
    cin>>n;
    f("",'a');
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
  int x; cin >> x;
  FOR(i,1,1000){
    if(x>=100*i && x<=105*i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;

}

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

int main()
{
    int n;
    cin >> n;

    ll ten = 1;
    for(ll i = 0; i < n; i++)
    {
        ten = ten * 10 % mod;
    }
    ll nine = 1;
    
    for(ll i = 0; i < n; i++)
    {
        nine = nine * 9 % mod;
    }

    ll eight = 1;
    for(ll i = 0; i < n; i++)
    {
        eight = eight * 8 % mod;
    }

    ll res = ten - (nine + nine) + eight;
    res %= mod;
    res = (res % mod + mod) % mod; 
    
    cout << res << "\n";
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 100000
#define MAXL 100
typedef long long int lli;

int main(){
    lli x, y;
    cin >> x >> y;

    lli ans = 1;
    while(x <= y){
        x *= 2;
        if(x <= y){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];

        Console.WriteLine(n % k == 0 ? 0 : 1);
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int main()
{
	int h, n;
	int a;
	scanf("%d%d", &h, &n);
	
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a);
		h = h - a;
	}
	
	if (h > 0) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	
	
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> d(N,false);
    rep(i,K) {
        int di;
        cin >> di;
        rep(j,di) {
            int aki;
            cin >> aki;
            d.at(aki-1) = true;
        }
    }
    int ans = 0;
    rep(i,N) {
        if (d.at(i) == false) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;
#define LL long long

int a, b;

int main(){

	cin >> a >> b;

	if (a <= 8 && b <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	

	return 0;
}

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

main(){
  int a,b,c,count;
  cin >> a >> b >> c;
  for(int i=a ; i < b+1 ; i++){

      int result = c % i;
      if(result == 0){ 
        count++;
      }
  }
  cout <<  count << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#define maxn 200005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
map <int,int> mp;
typedef map <int,int> :: iterator Ite;
int n,a[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		mp[a[i]]++;
	}
	Ite it = mp.end();
	int ans = 0;
	do{
		it--;
		int tar = (1 << (32 - __builtin_clz(it -> first))) - it -> first;
		if(tar == it -> first) ans += it -> second >> 1;
		else{
			int num = min(it -> second,mp[tar]);
			ans += num;
			mp[tar] -= num;
		}
	}while(it != mp.begin());
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 65024
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0
ans_a=0
ans_c=0

for i in b:
    ans_a=bisect.bisect_left(a,i)
    ans_c=n-(bisect.bisect_right(c,i))
    ans+=ans_a*ans_c

print(ans)

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    x--;y--;
    vector<int> dist(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            dist[min(abs(i - j), abs(x - i) + 1 + abs(j - y))]++;
        }
    }
    for (int i = 1; i < n; i++)
    {
        cout << dist[i] << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 
class Dice3{
public:
    Dice3(){
        number = new int[6];
        checkTable = new int[101];
        for(int i = 0; i < 101; i++) checkTable[i] = -1;
    };
    ~Dice3(){
        delete[] number;
        delete[] checkTable;
    };
 
    void setLabel(int index,int num){
        number[index] = num;
        checkTable[num] = index;
    };
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isValidMember(int inputed[]){
        for(int i = 0; i < 6; i++)
        {
            if(checkTable[inputed[i]] == -1)
                return false;
        }
        return true;
    }
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
private:
    int* number;
    int* checkTable;
};
 
int main(){
    Dice3 dice3;
    int tmp,inputed[6];
    for(int i = 0; i < 6; i++){
        scanf("%d",&tmp);
        dice3.setLabel(i,tmp);
    }
    for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);
 
    if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int N;

    cin >> N;
    int a[N + 1], box[N + 1] = {0};

    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    for (int i = N; i >= 1; i--)
    {
        int sum = 0;
        for (int j = 1; j <= N / i; j++)
        {
            if (box[i * j] == 1)
                sum += 1;
        }
        if (sum % 2 != a[i])
            box[i] = 1;
    }
    int M = 0;
    for (int i = 1; i <= N; i++)
    {
        if (box[i] == 1)
            M += 1;
    }

    OP(M)
    for (int i = 1; i <= N; i++)
    {
        if (box[i] == 1)
            OP(i)
    }

    return 0;
}

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

long long int n,k,x,a,j,i;
bool tr[110];

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	for (i=1;i<n+1;i++) tr[i]=false;
	for (i=1;i<k+1;i++)
	{
		cin>>x;
		for (j=1;j<x+1;j++) cin>>a,tr[a]=true;
	}
	x=0;
	for (i=1;i<n+1;i++) if (!tr[i]) x++;
	cout<<x;
}


Measured memory_bytes: 3600
let readInts = readLine()!.split(separator: " ").map { Int($0)! }
let n = readInts[0]
let sum = readInts[1]

func main() {
    for i in 0...n {
        for j in 0...(n - i) {
            let k = n - i - j
            if i * 10_000 + j * 5_000 + k * 1_000 == sum && i + j + k == n {
                print("\(i) \(j) \(k)")
                return
            }
        }
    }
    print("-1 -1 -1")
}

main()

Measured memory_bytes: 8252
#include <iostream>
#include <numeric>
#include <algorithm>

#define REP(i, b) for (int i = 0 ; i < b ; i++ )
typedef long long ll;
using namespace std;

int main() {
    ll H;
    ll ans = 0;
    cin >> H ;
    for(int i =0;(1L<<i) <= H; i++) {
        ans += (1L<<i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
A, B, Q = map(int, input().split())
INF = 10**12
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]


def binary_search(query, arr):
    low = 0
    high = len(arr)
    while high-low>1:
        mid = (low+high)//2
        if query>arr[mid]:
            low = mid
        else:
            high = mid
    return arr[low], arr[high]

def main():
    for x in X:
        s1, s2 = binary_search(x, S)
        t1, t2 = binary_search(x, T)
        ans = [ abs(t-s)+min(abs(t-x), abs(s-x)) \
            for t in [t1, t2] for s in [s1, s2] ]
        print(min(ans))
    return

main()

Measured memory_bytes: 16256
#include <iostream>

#define DIV (1000000007)

using namespace std;

int kai[200020] = {1};
int gkai[200020];

int euclid(int x, int y)
{
  int r1, r2, x1=1, x2=0, y1=0, y2=1;
  r1 = x;
  r2 = y;
  int a = r1;
  int b = r2;

  int r3, x3, y3, q;
  while (r2) {
    r3 = r1 % r2;
    q = r1 / r2;
    x3 = x1 - q*x2;
    y3 = y1 - q*y2;
    r1 = r2;
    r2 = r3;
    x1 = x2;
    x2 = x3;
    y1 = y2;
    y2 = y3;
  }
  if (x1 < 0) x1 += y;
  return x1;
}
int64_t combination(int n, int r)
{
  //  cout << "kai[n]"<<kai[n] << endl;
  //  cout << "gkai[r]" << gkai[r] << endl;
  //  cout << "gkai[n-r]" << gkai[n-r] << endl;
  //  cout << gkai[r] * gkai[n-r] << endl;
  int64_t tt = (int64_t)gkai[r] * (int64_t)gkai[n-r];
  //  cout << tt <<" tt" << endl;
  //  cout << "(kai[n] * gkai[r])%DIV" << (kai[n] * gkai[r])%DIV << endl;
  if (gkai[n-r] < 0) cout << "mismis" << endl;
  int64_t t = ((((int64_t)kai[n] * (int64_t)gkai[r])%DIV) * (int64_t)gkai[n-r]) % DIV;
  //  if (t < 0) t += DIV;
  return t;
}
int main()
{
  int H,W,A,B;
  long ans = 1;
  cin >> H >> W >> A >> B;

  // start making table for combination
  for (int i = 1; i <= H+W-2; i++) {
    ans = ans * i;
    ans = ans % DIV;
    kai[i] = ans;
  }
  for (int i = 0; i <= H+W-2; i++) {
    gkai[i] = euclid(kai[i], DIV);
    if (gkai[i] < 0) gkai[i] += DIV;
  }
  // end making table for combination

  long a = 0;
  for (int i = B; i <= W-1; i++) {
    //    if (combination(H-A-1+i,H-A-1) < 0) { cout << "err" << i << endl; exit(1); }
    //    if (combination(W+A-2-i,A-1) < 0) { cout << "er2r" << i << endl; exit(1); }
    //    cout << "=" << combination(H-A-1+i, H-A-1) << endl;
    //    cout << "=" << combination(W+A-i-2,A-1) << endl;
    a = (a + combination(H-A-1+i,H-A-1) * combination(W+A-i-2,A-1))%DIV;
    //    if (a < 0) a += DIV;
  }

  for  (int i = 0; i <= H+W-2; i++) {
    //    if (gkai[i] < 0 || kai[i] < 0)
      //      cout << kai[i] << ", " << gkai[i] << endl;
  }

    cout << a << endl;

    //  cout << " === " << combination(5,2) << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=3,count=0,temp=0;
    char s[3];
    for(int i=0;i<3;i++)
    cin>>s[i];
    for(int i=0;i<n;i++)
    {
        
        if(s[i]=='R'){
        count++;
        temp=count;}
        else
        count=0;
    }
    cout<<temp;
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_H 100
#define MAX_W 100
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int h, w;
char a[MAX_H][MAX_W];
bool b[MAX_H + MAX_W];
signed main(){
	cin >> h >> w;
	REP(i, h) REP(j, w) cin >> a[i][j];
	REP(i, h){
		bool eliminate = true;
		REP(j, w){
			if(a[i][j] == '#') eliminate = false;
		} 
		b[i] = eliminate;
	}
	REP(j, w){
		bool eliminate = true;
		REP(i, h){
			if(a[i][j] == '#') eliminate = false;
		} 
		b[h + j] = eliminate;
	}

	REP(i, h){
		REP(j, w){
			if(b[i] || b[h + j]) continue;
			else  cout << a[i][j];
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
ul N[3],cnt;

inline void solve2(){
  IN3(N[0],N[1],N[2]);
  sort(N,N+3);
  cnt+=N[2]-N[1];
  N[0]+=N[2]-N[1];
  N[1]=N[2];
  cnt+=(ul)ceil((N[1]-N[0])/2.0);
  if((N[1]-N[0])%2)cnt+=1;
  OUT(cnt);
}

inline void solve(){
  IN3(N[0],N[1],N[2]);
  sort(N,N+3);
  while(N[1]!=N[2]){
    N[0]++;
    N[1]++;
    cnt++;
  }
  while(N[0]<N[1]){
    N[0]+=2;
    cnt++;
  }
  cnt+=N[0]-N[1];
  OUT(cnt);
}

int main(int argc,char**argv){
  BEGIN;
  solve2();
  END;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
vw = [[0, 0]]+[list(map(int, input().split())) for _ in range(N)]
'''
ナップザック問題
i番目までの品物で作れる価値の最大値を求めていく
'''
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(W+1):
        v = dp[i-1][j]
        if j >= vw[i][1]:
            t = dp[i-1][j-vw[i][1]] + vw[i][0]
            if t > v:
                v = t
        dp[i][j] = v
print(dp[N][W])



Measured memory_bytes: 25952
# -*- coding: utf-8 -*-
import sys

def main():
	tmp = input().split(" ")
	nums = [int(s) for s in tmp]
	counts = int(input())
	
	max_num = max(nums)
	for _ in range(counts):
		for i, val in enumerate(nums):
			if val == max_num:
				nums[i] = val * 2
				max_num = nums[i]
			
	print(nums[0] + nums[1] + nums[2])
		
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<int> A(n);
    vector<int> D(n);
    rep(i, n) {
        cin >> A[i];
        A[i]--;
    }
    int ans = 0;
    while(k) {
        if (k & 1) ans = A[ans];
        rep(i, n) {
            D[i] = A[A[i]];
        }
        A = D;
        k /= 2;
    }
    cout << ans + 1 << endl;
}

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

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

int count_upper(uint64_t v, vector<uint64_t>& as, vector<uint64_t>& bs, vector<uint64_t>& cs, int x, int y, int z, int k)
{
	int count = 0;

	multiset<uint64_t> vals;
	FOR_LT(a, 0, x) {
		if (v <= as[a]) {
			count += y * z;
			continue;
		}

		FOR_LT(b, 0, y) {
			if (v <= as[a] + bs[b]) {
				count += z;
				continue;
			}

			FOR_LT(c, 0, z) {
				if (as[a] + bs[b] + cs[c] < v) break;

				count++;
				if (k < count) return count;
			}
		}
	}

	return count;
}

int main()
{
	int x, y, z, k; cin >> x >> y >> z >> k;

	vector<uint64_t> as(x);
	vector<uint64_t> bs(y);
	vector<uint64_t> cs(z);
	for (auto &a : as) {
		cin >> a;
	}
	for (auto &b : bs) {
		cin >> b;
	}
	for (auto &c : cs) {
		cin >> c;
	}

	sort(as.begin(), as.end(), greater<uint64_t>());
	sort(bs.begin(), bs.end(), greater<uint64_t>());
	sort(cs.begin(), cs.end(), greater<uint64_t>());

	uint64_t h = as.front() + bs.front() + cs.front();
	uint64_t l = as.back() + bs.back() + cs.back();
	uint64_t h_n = 1;
	uint64_t l_n = x * y * z;

	while (true) {
		if (l == h) break;
		uint64_t m = (h + l) / 2;

		int count = count_upper(m, as, bs, cs, x, y, z, k);
		if (count == k) {
			h = l = m;
		}
		else if (count < k) {
			h = max(m - 1, l);
		}
		else {
			l = m;
			if (h - l == 1) {
				h = l;
				break;
			}
		}
	}

	vector<uint64_t> vals;
	FOR_LT(a, 0, x) {
		FOR_LT(b, 0, y) {
			FOR_LT(c, 0, z) {
				if (as[a] + bs[b] + cs[c] < l + 1) break;

				vals.push_back(as[a] + bs[b] + cs[c]);
			}
		}
	}

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

	int count = 0;
	for (auto it = vals.rbegin(); it != vals.rend(); it++) {
		cout << *it << endl;
		count++;
		if (count == k) break;
	}

	if (count < k) {
		for (int i = 0; i < k - count; i++) {
			cout << l << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 133344
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = stdIn.nextInt();
		}
		
		int count = 0;
		for(int i = 0; i < N; i++) {
			if(i == N-1)count++;
			else if(A[i] == A[i+1]);
			else if(A[i] < A[i+1]) {
				while(A[i] <= A[i+1]) {
					i++;
					if(i == N-1) break;
				}
				count++;
			}
			else {
				while(A[i] >= A[i+1]) {
					i++;
					if(i == N-1) break;
				}
				count++;
			}
		}
		System.out.println(count);

	}

}

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

using namespace std;

int is_smaller(const string& x, const string& y)
{
    int m = min(x.size(), y.size());
    for (int i = 0; i < m; i++) {
        if (x[i] < y[i])
            return -1;
        else if (x[i] > y[i])
            return 1;
    }

    if (x.size() < y.size())
        return -1;
    else if (x.size() > y.size())
        return 1;
    return 0;
}

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

    string x, y;
    cin >> x >> y;

    sort(begin(x), end(x), [](auto c, auto d) { return c < d; });
    sort(begin(y), end(y), [](auto c, auto d) { return d < c; });

    is_smaller(x, y) == -1 ? cout << "Yes\n" : cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)

int main(){
    int N;
    sd(N);
    int ang = (N-2)*180;
    pd(ang);
    return 0;
}

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

int main()
{
    ll N;
    cin >> N;

    if(N == 1 || N == 2)
    {
        cout << 1 << endl;
        return 0;
    }
    
    vector<ll> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    int cnt = 1;
    bool upFlag = false;
    bool downFlag = false;
    bool equalFlag = true;

    for(int i = 0; i < N-1; i++)
    {
        if(equalFlag == true)
        {
            if(A.at(i) < A.at(i+1))
            {
                upFlag = true;
                equalFlag = false;
            }
            else if(A.at(i) > A.at(i+1))
            {
                downFlag = true;
                equalFlag = false;
            }
        }

        if(A.at(i) > A.at(i+1) && upFlag == true)
        {
            cnt++;
            equalFlag = true;
            upFlag = false;
        }
        else if(A.at(i) < A.at(i+1) && downFlag == true)
        {
            cnt++;
            equalFlag = true;
            downFlag = false;
        }

    }

    cout << cnt << endl;
}

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

int main(){
  int x;
  cin >> x;
  int tmp = x;
  int sum = 0;
  while(tmp){
    sum += tmp % 10;
    tmp /= 10;
  }
  if(x % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main(){
    ll n;
    string s;
    cin >> n >> s;
    ll b = 0, w = 0;
    REP(i, n){
        if(s[i] == '.') w++;
        else b++;
    }
    ll ans = INF;
    ll bb = 0, ww = 0;
    REP(i, n + 1){
        ans = min(ans, bb + w);
        if(i == n) break;
        if(s[i] == '.'){
            w--;
            ww++;
        }
        else{
            b--;
            bb++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(){
  double x1,x2,y1,y2,z;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  x2=x2-x1;
  y2=y2-y1;
  z=pow(x2,2.0)+pow(y2,2.0);
  printf("%lf\n", sqrt(z));
  return 0; 
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  if(n%2) {
    pr(0);
    return;
  }
  ll ans=0;
  while(n) {
    ans+=n/10;
    n/=5;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z=[]
for i in range(X+1,Y+1):
    if max(x)<i and min(y)>=i:
        z.append(i)
if len(z)>=1:
    print('No War')
else:
    print('War')

Measured memory_bytes: 63908
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int M;
		if(N >= K){
			M = K * X + (N - K) * Y;
			System.out.println(M);
		}
		else{
			M = N * X;
			System.out.println(M);
		}
		

	}

}


Measured memory_bytes: 21716
#include <stdio.h>
#define INF (int)2e9
#define MAX 100

int A[MAX][MAX];

void dijkstra(int n)
{
    int u,minv;
    int mV[MAX],Type[MAX];

    for ( int i = 0; i < n; ++i) {
        mV[i] = INF;
        Type[i] = 0;
    }

    mV[0] = 0;
    Type[0] = 1;
    while(1) {
        minv = INF;
        u = -1;
        for (int i = 0; i < n; ++i) {
            if (Type[i] != 2 && minv > mV[i]) {
                u = i;
                minv = mV[i];
            }
        }
        if ( u == -1 ) {
            break;
        }
        Type[u] = 2;
        for (int i = 0; i < n; ++i) {
            if (Type[i] != 2 && A[u][i] != INF) {
                if (mV[i] > mV[u]+A[u][i] ) {
                    mV[i] = mV[u] + A[u][i];
                    Type[i] = 1;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        printf("%d %d\n", i, mV[i]);
    }
}
int main() {
    int n;
    int i,j;
    int v;
    int u,k,c;
    scanf("%d",&n);

    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            A[i][j] = INF;
        }
    }

    for (i = 0; i < n; ++i) {
        scanf("%d %d",&u,&k);
        for (j = 0; j < k; ++j) {
            scanf("%d %d", &v, &c);
            A[u][v] = c;
        }
    }
    dijkstra(n);
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mid ((l+r)>>1)
const int M=3e5+20,P=1e9+7;
struct Task{
	LL n,m,v,p,a[M];
	LL sum[M];
	void init(){
		scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
		for(int i=1;i<=n;++i)
			scanf("%lld",&a[i]);
	}
	void run(){
		init();
		sort(a+1,a+n+1);
		for(int i=1;i<=n;++i)
			sum[i]=sum[i-1]+a[i];
		LL ans=n-p;
		while(ans>=1){
			if(a[ans]+m<a[n-p+1])
				break;
			if(1LL*(ans+p-1)*m+1LL*(n-p+1-(ans+1)+1)*(a[ans]+m)-(sum[n-p+1]-sum[ans])>=1LL*v*m)
				--ans;
			else
				break;
		}
		printf("%lld\n",n-ans);
	}
}t;
int main(){
	t.run();
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k;
    cin >> k;
    if (k % 2 == 0){
        cout << (k / 2) * (k / 2) << endl;
    } else {
        cout << (k / 2 + 1) * (k / 2) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int main() {
	string S;
	cin >> S;
	vector<int> ans(2, 0);
	for (int i = 0; i < S.size(); i++)
	{
		ans[S[i] - '0']+=1;
	}
	cout << min(ans[0], ans[1])*2 << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))
numofnum = [0 for i in range(N)]
for i in range(N):
    numofnum[a[i]-1] += 1
k =0
for i in range(N):
    k += numofnum[i]*(numofnum[i]-1)//2

for i in range(N):
    num = numofnum[a[i]-1]
    x =num*(num-1)//2
    y = (num-1)*(num-2)//2
    print(k-x+y)

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

const long long mod=1000000007;
long long n, k, ans;

long long arith(long long a){
	return (a*(a+1)/2)%mod; //(a/2)*(3*a-1)+(a%2 ? (3*a/2) : 0);
}

int main(){
	ans=0;
	cin >> n >> k;
	vector<long long>a(n);
	for (int i=0;i<n;i++) cin >> a[i];
	for (int i=0;i<n;i++){
		for (int j=1;j<=n;j++){
			if (a[i]>a[(i+j)%n]){
//				cout << i << " " << j << "\n";
				if (i+j<n) ans+=arith(k);
				else ans+=arith(k-1);
				ans%=mod;
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=2000000;
const int inf=1e9;
const ll mod=1000000007;

int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    FasterIO;

    int k;
    cin>>k;
    cout<<a[k-1]<<endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let _n: usize = input();
    let k: usize = input();
    let mut s: Vec<char> = input::<String>().chars().collect();

    let k = k - 1;
    if s[k] == 'A' {
        s[k] = 'a';
    } else if s[k] == 'B' {
        s[k] = 'b';
    } else {
        s[k] = 'c';
    }
    println!("{}", s.iter().cloned().collect::<String>());
}


Measured memory_bytes: 4352
let h, w, d = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let ps = Array.make (h * w) (0, 0)
let q = for i = 0 to h - 1 do for j = 0 to w - 1 do ps.(Scanf.scanf " %d" pred) <- i, j done done; Scanf.scanf " %d" (+) 0
let lrs = Array.init q @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b - 1
let tss = Array.make d [||]
let f a b = let (i, j), (k, l) = ps.(a), ps.(b) in abs (i - k) + abs (j - l)
let _ = for i = 0 to d - 1 do let s, m = (h * w - 1 - i) / d + 1, ref i in tss.(i) <- Array.make s 0; for j = 1 to s - 1 do tss.(i).(j) <- tss.(i).(j - 1) + f !m (!m + d); m := !m + d done done; Array.iter (fun (l, r) -> let m = l mod d in Printf.printf "%d\n" @@ tss.(m).((r - m) / d) - tss.(m).((l - m) / d)) lrs

Measured memory_bytes: 12032
#include<stdio.h>
long cmp(const void *a,const void *b){
  return *(long*)a -*(long*)b;
}
long rcmp(const void *a,const void *b){
  return *(long*)b -*(long*)a;
}
int main(){
  int n = 0;
  int m = 0;
  int a[100000] = {};
  int diff[100000] = {};
  int hani = 0;
  int remove = 0;
  int i = 0;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,m,sizeof(int),cmp);
  /*for(i=0;i<m;i++){
    printf("%d\n",a[i]);
  }*/
  hani = a[m-1] - a[0];
  for(i=0;i<m-1;i++){
    diff[i] = a[i+1] - a[i];
  }
  qsort(diff,m-1,sizeof(int),rcmp);
  if(n >= m){
    remove = hani;
  }else{
    for(i=0;i<n-1;i++){
      remove += diff[i];
    }
  }
  printf("%d",hani-remove);
  return 0;
}
  
  

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

struct DSU {
	vector<int> v;
	int n;
	
	DSU( int n ) : n(n){
		v.resize(n);
		iota(v.begin(), v.end(), 0);
	}
	
	// xのグループを求める
	int find(int x){
		if ( x == v[x] )
			return x;
		v[x] = find(v[x]);
		return v[x];
	}
	
	// xとyが同じグループか?
	bool same( int x, int y ){
		return find(x) == find(y);
	}
	
	// xとyを同じグループにする
	void unify( int x, int y ){
		x = find(x);
		y = find(y);
		if ( x != y ){
			v[y] = x;
		}
	}
};



ll N;
struct pt{
	ll x, y;
	int i;
};

int main(){
	cin >> N;
	
	DSU dsu(N);
	vector<pt> v(N);
	for ( int i = 0; i < N; i++ ){
		cin >> v[i].x >> v[i].y;
		v[i].i = i;
	}
	
	
	// xかyが同じなら、同じグループにする
	sort(v.begin(), v.end(), [](const pt &l, const pt &r){return l.x < r.x;});
	for ( int i = 1; i < N; i++ )
		if ( v[i-1].x == v[i].x )
			dsu.unify( v[i-1].i, v[i].i );
	
	sort(v.begin(), v.end(), [](const pt &l, const pt &r){return l.y < r.y;});
	for ( int i = 1; i < N; i++ )
		if ( v[i-1].y == v[i].y )
			dsu.unify( v[i-1].i, v[i].i );
	
	
	
	// それぞれのグループに、操作後の点がいくつあるか調べる
	map<int,pair<set<int>,set<int>>> m;
	
	for ( int i = 0; i < N; i++ ){
		int group = dsu.find(v[i].i);
		auto &p = m[group];
		p.first.insert(v[i].x);
		p.second.insert(v[i].y);
	}
	
	ll count = 0;
	for ( auto it : m ){
		auto &p = it.second;
		
		count += (ll)p.first.size() * (ll)p.second.size();
	}
	
	cout << (count-N) << endl;
	
	return 0;
}



Measured memory_bytes: 12416