akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int main(){
  int N = rd_int() % 10;
  if(N==3){
    wt_L("bon");
    wt_L('\n');
    return 0;
  }
  if(N==0 || N==1 || N==6 || N==8){
    wt_L("pon");
    wt_L('\n');
    return 0;
  }
  wt_L("hon");
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// {
//   int N = rd_int() % 10;
//   if(N==3) wt("bon"), return 0;
//   if(N==0 || N==1 || N==6 || N==8) wt("pon"), return 0;
//   wt("hon");
// }


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static bool IsSosu(int num)
    {
        var max = Math.Sqrt(num);
        for(int i = 2; i <= max; ++i)
        {
            if (num % i == 0) return false;
        }
        return true;
    }

    static void Main(string[] args)
    {
        label:
        int count = Parse(ReadLine());
        var list = new List<string>();
        for(int num=2; ; num += 5)
        {
            if (IsSosu(num))
            {
                list.Add(num.ToString());
                if (list.Count == count) break;
            }
        }
        WriteLine(string.Join(" ", list));
    }
}


Measured memory_bytes: 13140
package main

import "fmt"

func reverse(s string) string {
	r := make([]byte, len(s))
	i, j := len(s)-1, 0
	for i >= 0 {
		r[j] = s[i]
		j++
		i--
	}
	return string(r)
}

func main() {
	var rev = []string{"dream", "dreamer", "erase", "eraser"}
	revs := make([]string, len(rev))
	for i, v := range rev {
		revs[i] = reverse(v)
	}
	// fmt.Println("revs", revs)
	var S string
	fmt.Scan(&S)
	RS := reverse(S)
	var i int
	var ok bool
	for i < len(RS) {
		ok = false
		for j := 0; j < len(revs); j++ {
			if i+len(revs[j])-1 < len(RS) && RS[i:i+len(revs[j])] == revs[j] {
				ok = true
				i += len(revs[j])
				break
			}
		}
		if !ok {
			break
		}
	}
	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isodd(int n)
{
        int dig = 0;
        while(n)
        {
                n = n/10;
                dig+=1;
        }
        return dig%2==1;
}
int main()
{       
        int n;
        cin>>n;
        vector<int> arr(n);
        for(int i = 0 ; i < n ; i++)
        {
                cin>>arr[i];
        }
        for(int i = 0 ; i < n-1 ; i++)
        {       
                if(i == 0 && (arr[i] == arr[i+1]))
                {
                        arr[i]--;
                        arr[i+1]--;
                }
                else if(arr[i] == arr[i+1])
                {
                        continue;
                }
                else if(arr[i]<arr[i+1]) 
                {
                        arr[i]--;
                        arr[i+1]--;
                }
                else 
                {
                        cout<<"No"<<endl;
                        exit(0);
                }
        }
        cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
D = int(input())
c = list(map(int, input().split()))
last = [0] * 26
ans = []
S = []
prev_score = 0
for d in range(1, D+1):
    s = list(map(int, input().split()))
    S += [s]
    maxs = float('-inf')
    maxi = -1
    cumsump = 0
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        cumsump += tmp
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        tmp2 = s[i] + cumsump - tmp
        if tmp2 > maxs:
            maxs = tmp2
            maxi = i
    ans += [maxi+1]
    last[maxi] = d
    prev_score += maxs

for tt in range(13):
    for dd in range(D):
        last = [0] * 26
        score = 0
        for d in range(1, D+1):
            if dd == (d-1):
                maxc = 0
                maxci = -1
                for i in range(26):
                    cost = c[i] * (d - last[i])
                    if maxc < cost:
                        maxc = cost
                        maxci = i+1
                prev_a = ans[dd]
                ans[dd] = maxci
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        if score <= prev_score:
            ans[dd] = prev_a
        else:
            prev_score = score
    
for a in ans:
    print(a)

Measured memory_bytes: 77352
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int h, w;
    cin >> h >> w;
    string a;
    
    for(int i = 0; i < w+1; ++i){
        cout << "#";
    }
    cout << "#" << endl;
    
    vector<string> x(h);
    for(int i = 0; i < h; ++i){
        cin >> x.at(i);
    }
    
    for(int i = 0; i < h; ++i){
        cout << "#" << x.at(i) << "#" << endl;
    }
    
    for(int i = 0; i < w+1; ++i){
        cout << "#";
    }
    cout << "#" << endl;
}


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

using ll = long long;
typedef pair < int , int > ii;
typedef vector < ii > vii;
const int N = 1e5 + 5;

ll n , m;
int p[N];
ll sz[N];
vii edges;
ll ans[N];

int get(int x){
    if(x == p[x])return x;
    return  p[x] = get(p[x]);
}

void join(int x , int y){
    if(sz[x] > sz[y])swap(x , y);
    sz[y] += sz[x];
    p[x] = y;
}

main(){
    for(int i = 0 ; i < N ; i ++){
            p[i] = i ;
            sz[i] = 1;
    }

    scanf("%lld %lld" , &n , &m);

    int u , v;
    for(int i = 0 ; i < m ; i ++){
        scanf("%d %d" , &u , &v);

        edges.push_back({u , v});
    }

    ll sum = n*(n - 1ll) / 2ll;
    for(int i = m-1 ; i >= 0 ; i --){
        ans[i] = sum;
         u = edges[i].first;
         v = edges[i].second;

         u = get(u);
         v = get(v);

         if(u != v){
            sum -= sz[u] * sz[v];
            join(u , v);
         }
    }

    for(int i = 0 ; i < m ; i ++){
        printf("%lld\n" , ans[i]);
    }
}


Measured memory_bytes: 4212
package main
import(
  "fmt"
)
func main(){
  var n, m, i int 
  ans:=0
  fmt.Scan(&m, &n)
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
    ans+=a[i]
  }
  if m-ans<0{
    fmt.Println(-1)
  }else{
    fmt.Println(m-ans)
  }
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define pii pair<int, pair<int, int>>
#define ss second
#define ff first
#define all(x) ((x).begin(), (x).end())

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const ll oo = 1e14;
const double PI = 3.14159265;

int main(){
    ios_base::sync_with_stdio(false);
    ll n, k, l = -1, r = 0;
    cin >> n >> k;

    vector<ll> a(n), f(n);

    for (auto& x : a) cin >> x;
    for (auto& x : f) cin >> x;

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

    for (int i=0; i<n; i++) {
        r = max(r, f[i]*a[i]);
        //cout << a[i] << " " << f[i] << endl;
    }
    r++;

    while (l < r- 1){
        ll mid = (l+r)/2, tot = 0;
        

        for (int i=0; i<n; i++){
            if (a[i]*f[i] > mid) tot+= a[i] - mid/f[i];
        }

        if (tot <= k){
            r = mid;
        }
        else {
            l = mid;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

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

  bool negative = false;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) {
      a[i] *= -1;
      negative ^= true;
    }
  }

  ll ans = accumulate(all(a), 0LL);
  if (negative) {
    ans -= *min_element(all(a)) * 2;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int N;
string s1, s2;
const int M = 1e9 + 7;

ll calc(int i, ll sum) {
    if (i == N) return sum;
    if (s1[i - 1] == s2[i - 1]) {
        sum = sum * 2 % M;
        if (s1[i] == s2[i]) {
            return calc(i + 1, sum);
        } else {
            return calc(i + 2, sum);
        }
    } else {
        if (s1[i] == s2[i]) {
            return calc(i + 1, sum);
        } else {
            sum = sum * 3 % M;
            return calc(i + 2, sum);
        }
    }
}

int main() {
    cin >> N;
    cin >> s1;
    cin >> s2;

    ll ans;
    if (s1[0] == s2[0]) {
        ans = calc(1, 3);
    } else {
        ans = calc(2, 6);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int a[25];
  int b[25];
  int c[25];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<n-1;i++)cin>>c[i];
  int res=0;
  for(int i=0;i<n;i++){
    res += b[a[i]-1];
    if(a[i]+1==a[i+1])res+=c[a[i]-1];
  }
  cout << res;
}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int n, m;
	cin >> n >> m;
	vector<int> heights(n);
	for(int i = 0; i < n; i++) {
		cin >> heights[i];
	}
	vector<vector<int>> adj(n);
	int x, y;
	for(int i = 0; i < m; i++) {
		cin >> x >> y;
		x--;
		y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(adj[i].size() == 0) {
			cnt++;
			continue;
		}
		bool ok = 1;
		for(int j = 0; j < adj[i].size(); j++) {
			if(heights[adj[i][j]] >= heights[i]) {
				ok = 0;
				break;
			}
		}
		if(ok) {
			cnt++;
		}
	}
	cout << cnt << "\n";


	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 8728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

struct CumulativeSum {
  vector<long long> csum;
  template<typename T>
  CumulativeSum(vector<T> const &input) : csum(input.size() + 1, 0) {
    for(int i = 0; i < (int)input.size(); i++) csum[i+1] = csum[i] + input[i];
  }
  long long query(int l, int r) { /* 0-indexed, inclusive */ return csum[r+1] - csum[l]; }
};


int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  CumulativeSum cs(a);
  vector<ll> s;
  rep(l,n) rep(r,l,n) s.push_back(cs.query(l,r));

  ll mask = 0;
  for(int i=62; i>=0; --i) {
    ll bit = (1LL<<i);
    int count = 0;
    ll mb = mask + bit;
    for(auto x : s) if((mb & x) == mb) ++count;
    if(count >= k) mask += bit;
  }
  cout << mask << endl;
}


Measured memory_bytes: 7412
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <climits>
#include <queue>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

struct graph {
	struct node {
		int n, w;
		bool operator < (const node a) const {return w > a.w;}
	};
	using V = vector<node>;
	vector<V> nodes;
	V w;

	graph(int v) : nodes(v), w(v, {0, INT_MAX}) {}
	void dks(int r) {
		w[r].w = 0;
		priority_queue<node> q;
		q.push({r, 0});
		while (!q.empty()) {
			node n = q.top();
			q.pop();
			for (node &x: nodes[n.n]) {
				if (!w[n.n].n && w[x.n].w > n.w + x.w)
					q.push({x.n, w[x.n].w = n.w + x.w});
			}
			w[n.n].n |= 1;
		}
	}
};

int main() {
	graph g(in());
	int E = in(), r = in();
	for (int i = E; i; i--) {
		int s = in();
		g.nodes[s].push_back({in(), in()});
	}
	g.dks(r);
	for (auto &n: g.w)
		if (n.w == INT_MAX)
			outl("INF");
		else
			outl(n.w);
}


Measured memory_bytes: 12892
N = int(input())
xyh = [tuple(int(i) for i in input().split()) for i in range(N)]


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def g(l, cx, cy):
    H_max_l = set(H(cx, cy, x, y, h) for x, y, h in l if h == 0)
    h_max = min(H_max_l) if any(H_max_l) else -1
    
    TH = set(H(cx, cy, x, y, h) for x, y, h in l if h > 0)
    if len(TH) == 1:
        high = TH.pop()
        if h_max == -1 or high <= h_max:
            return high
    return -1


def f(l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            h = g(l, cx, cy)
            if h > 0:
                return cx, cy, h

cx, cy, h = f(xyh)
print(cx, cy, h)


Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a < b){
         System.out.println("a < b");
      }else if(a > b){
         System.out.println("a > b");
      }else{
         System.out.println("a == b");
      }
   }
}



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

string S, T;
string res;

bool Restore(int pos, string &tmp)
{
    tmp = S;
    for (int i = 0; i < T.length(); i++) {
        if (S[pos+i] != '?' && S[pos+i] != T[i]) return false;///shudhu T er shathe S er index millei true;
        else tmp[pos+i] = T[i]; /// mille tmp er ei indx e T er ei indx rakhsi
    }

    for (int i = 0; i < tmp.length(); i++) if (tmp[i] == '?') tmp[i] = 'a';
    return true;
}

int main()
{
    cin >> S >> T;
    string tmp;

    for (int i = 0; i + T.length() <= S.length(); i++) {
        if (Restore(i, tmp)) {
            if (res == "" || tmp < res) res = tmp;
        }
        //cout << tmp << endl;
    }

    if (res == "") printf("UNRESTORABLE\n");
    else printf("%s\n", res.c_str());
}
///dhfe??fehue????????hfe???uihfeu?


Measured memory_bytes: 256
N = int(input())
N_len = len(str(N))
ans = 0

if N_len % 2 != 0:
    ans += N - 10**(N_len-1)+1

for i in range(N_len):
    if (i % 2) != 0:
        ans += 10**i - 10**(i-1)

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;

string strip(string s)
{
    int i = 0;
    while (i < s.length() && s[i] == 0) i++;
    return i == s.length() ? "" : s.substr(i);
}

int less_than(string a, string b)
{
    int d = a.length() - b.length();
    if (d) return d < 0;
    return strip(a).compare(strip(b)) < 0;
}

int main()
{
    while (1) {
        int w, h; cin >> w >> h;
        if (!w) break;
        vector<string> rows(h+1);
        loop (h, i) cin >> rows[i];

        string len[80][80], amt[80][80];
        fill(len[0], len[79]+80, "");
        fill(amt[0], amt[79]+80, "");

        for (int i = h-1; i >= 0; i--) {
            for (int j = w-1; j >= 0; j--) {
                if (rows[i][j] >= 'A') continue;
                if (rows[i][j] == '0') {
                    auto ls = { len[i+1][j], len[i][j+1] };
                    len[i][j] = "0" + *max_element(all(ls), less_than);

                    auto as = { amt[i+1][j], amt[i][j+1] };
                    amt[i][j] = *max_element(all(as), less_than);
                } else {
                    auto ls = { len[i+1][j], len[i][j+1] };
                    amt[i][j] = len[i][j] = rows[i][j] + *max_element(all(ls), less_than);
                }
            }
        }

        string ans = "";
        loop (h, i) loop (w, j) {
            if (less_than(ans, amt[i][j])) ans = amt[i][j];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1432
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<string> a(n), b(n);
	int taro = 0;
	int hana = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == b[i]) {
			taro++;
			hana++;
		}
		else if (a[i] < b[i]) hana += 3;
		else taro += 3;
	}
	cout << taro << " " << hana << endl;
	return 0;
}


Measured memory_bytes: 3212
def main():
    n = int(input())
    a = map(int, input().split())

    ans = 0
    is_even = True

    while is_even:
        list_tmp = []
        for an in a:
            if an % 2 == 0:
                list_tmp.append(an / 2)
            else:
                is_even = False
                break
        if is_even:
            a = list_tmp
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a , b;
    for (int i = 1 ; i <= n ; i++){
        int x , y ; cin >> x >> y;
        a.push_back(x - y);
        b.push_back(x + y);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    ll ans = max (a[0] - a.back() , b[0] - b.back());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cout.tie(0);

	ll a,b,n,x;
	cin>>a>>b>>n;
	if(b-1<=n)
		x=b-1;
	else
		x=n;
	cout<<floor(a*x/b)-a*floor(x/b);
	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
vector<pair<ll, ll>> prime_factorize(ll N) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= N; a++) {
    if (N % a != 0) continue;
    ll ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}
 
int main() {
  ll N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  auto vec = prime_factorize(N);
  int ans = 0;
  for (auto p : vec) {
    // cout << p.first << ' ' << p.second << endl;
    int n = 0;
    while (true) {
      if (p.second < ((n + 1) * (n + 2))/2) {
        break;
      }
      n++;
    }
    ans += n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;




vector<vector<ll>> v(100005);
vector<ll> dist(100005,0);
vector<ll> check(100005,0);

ll dfs(ll u, ll p){
  if (check[u]==1)return dist[u];
  check[u]=1;
  for(ll to:v[u]){
    if (to==p)continue;
  //  if (dist[to]>=0)return dist[u];
    dist[u]=max(dist[u],dfs(to,u)+1);
  //  cout<<to<<'t'<<dfs(to,u)<<'d'<<endl;

  }
//  cout<<u<<'u'<<dist[u]<<'d'<<endl;
  return dist[u];
}

int main() {
  ll n,m;
  cin>>n>>m;
//  cout<<n<<endl;

  rep(i,m){
    ll x1,y1;
    cin>>x1>>y1;
    x1--;y1--;
    v[x1].push_back(y1);
  }

  rep(i,n){
    dfs(i,-1);
  }

ll ans=0;
rep(i,n)ans=max(ans,dist[i]);
cout<<ans;

return 0;
}


Measured memory_bytes: 12036
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli a, b;

lli sumxor(lli n){
    if(n%4 == 0) return n;
    else if(n%4 == 1) return 1;
    else if(n%4 == 2) return n+1;
    else return 0;
}

int main(void){
    cin >> a >> b;
    lli u, v;
    u = sumxor(a-1);
    v = sumxor(b);
    cout << (u^v) << endl;
    return 0;
}


Measured memory_bytes: 3640
import math

a, b, h, m = map(int, input().split())
# print(a, b, h, m)

# print(math.cos(math.radians(60)))

angle = 0
l_angle = m * 6
s_angle = h * 30 + m * 0.5

if l_angle > s_angle:
  angle = l_angle - s_angle
else:
  angle = s_angle - l_angle

ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(angle)))
print(ans)


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

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

  int mx = 0;
  for (int i = x; i >= 0; i--) {
    for (int j = 2; j <= 10; j++) {
      int tmp = pow(i, j);
      if (tmp > x) break;
      mx = max(mx, tmp);
    }
  }
  cout << mx << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	ll A,B,C,D,r;
	cin>>A>>B>>C>>D;
	printf("%lld\n",max(A*B,C*D));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int A,B,C,D,E,F;
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	
	int water,sugar;
	double noudo,maxnoudo=0;
	int ans[2]={A*100,0};
	int a,b,c,d,e;
	for(a=0;a*A*100<=F;a++){
		for(b=0;a*A*100+b*B*100<=F;b++){
			if(a==0&&b==0)continue;
			water = (a*A + b*B)*100;
			for(c=0;water+c*C<=F;c++){
				for(d=0;water+c*C+d*D<=F;d++){
					sugar = c*C+d*D;
					if( (water/100)*E < sugar)continue;
					noudo = 100.0 * sugar/(water+sugar);
					if(maxnoudo<noudo){
						maxnoudo = noudo;
						ans[0] = water + sugar;
						ans[1] = sugar;
					}
				}
			}
		}
	}
	printf("%d %d",ans[0],ans[1]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int d[101010];
struct Edge{
	int to,next;
}e[202020];
int cnt=0,head[101010];
void add(int u,int v)
{
	cnt++;
	e[cnt].to=v;
	e[cnt].next=head[u];
	head[u]=cnt;
}
int f[101010],g[101010];
int dis[101010];
void cal(int x,int fa)
{
	for(int i=head[x];i!=0;i=e[i].next)
	{
		int to=e[i].to;
		if(to!=fa)
		{
			dis[to]=dis[x]+1;
			cal(to,x);
		}
	}
}
void dfs(int x,int fa)
{
	int dd=0;
	for(int i=head[x];i!=0;i=e[i].next)
	{
		int to=e[i].to;
		if(to!=fa)
		{
			dfs(to,x);
			f[x]+=f[to];
			if(f[to]==0)
				dd++;
		}
	}
	if(dd>0)
		f[x]+=dd-1;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		u++;
		v++;
		d[u]++;
		d[v]++;
		add(u,v);
		add(v,u);
	}
	cal(1,1);
	int mx=1;
	for(int i=2;i<=n;i++)
	if(dis[i]>dis[mx])
		mx=i;
	dfs(mx,mx);
	printf("%d\n",f[mx]+1);
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) {
		cin >> a[i];
		a[i]--;
	}
	vector<bool> b(n);
	rep(i,n) b[i] = false;
	int c=0;
	b[0] = true;
	int count=0;
	while(1) {
		c = a[c];
		count++;
		if(c == 1) {
			cout << count << endl;
			return 0;
		} 
		else if(b[c] == true) {
			cout << -1 << endl;
			return 0;
		}
		b[c] = true;
	}

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		if(a % 2 == 1 && b % 2 == 1)
			System.out.println("Odd");
		else
			System.out.println("Even");
	}
}


Measured memory_bytes: 21716
def slove():
    import sys
    input = sys.stdin.readline
    a = [int(input().rstrip('\n')) for _ in range(5)]
    k = int(input().rstrip('\n'))
    a.sort()
    print("Yay!" if abs(a[0] - a[-1]) <= k else ":(")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
n = int(input())
count = 0
max_count = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
        max_count = max(max_count, count)
    else:
        count = 0
if max_count >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62260
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,ans="No";
    cin >>s;
    if(s[2]==s[3]&&s[4]==s[5])ans="Yes";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

solver :: Int -> Int -> Int -> Int
solver a b c =
  let ab = [a..b]
      cand = [x | x <- ab, c `mod` x == 0]
  in
      length cand

main :: IO()
main = do
  (a:b:c:_) <- map (read :: String -> Int) . words <$> getLine
  print $ solver a b c

Measured memory_bytes: 4112
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int l,r,d,ans=0;
cin>>l>>r>>d;
for(int i=l;i<=r;i++)
{
if(i%d==0)
{
ans++;
}
}
cout<<ans;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	string s; cin >> s;
	int l = 0, r = s.size() - 1;
	if(s.size() % 2 == 1) {
		printf("No\n"); return 0;
	}

	bool f = true;
	while(r - l > 0) {
		if(!((s[l] == 'p' && s[r] == 'q') ||
			(s[l] == 'q' && s[r] == 'p') ||
			(s[l] == 'b' && s[r] == 'd') ||
			(s[l] == 'd' && s[r] == 'b')
		)) {
			f = false; break;
		}
		l++, r--;
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 512
x,y = list(map(int, input().split()))
tmp = y%2
count = 0
"""
while tmp == 0:
    y /= 2
    tmp = y%2
#    print(y)
    count += 1
print(count)
if y ==1 and count >= x:
    print("Yes")
else:
    print("No")
"""

for i in range(x+1):
    for j in range(x+1-i):
        a = i*2 + j*4
        if a == y and i+j == x:
            print("Yes")
#            print(i,j)
            exit()

print("No")

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

int main(void) {
	int L, M, N;

	while(cin >> L, L) {
		int sum = 0;
		bool flag = true;

		for(int i = 0; i < 12; i++) {
			cin >> M >> N;
			sum += M - N;

			if(sum >= L && flag) {
				cout << i + 1 << endl;
				flag = false;
			}
		}

		if(flag)
			cout << "NA" << endl;
	}
}

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

bool is_prime[50000000];
int main(){

    for(int i=0;i<50000000;i++){
        is_prime[i]=true;
    }

    is_prime[0]=false;
    for(int i=1;i*i+i<25000000;i++){
        if(is_prime[i]){
            for(int j=i*3+1;j<50000000;j+=2*i+1){
                is_prime[j]=false;
            }
        }
    }

    int n,tag;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin>>tag;
        if(tag%2==0){
            if(tag==2){
                cnt++;
            }
        }else{
            if(is_prime[tag/2]){
                cnt++;
            }
        }
    }
    
    cout<<cnt<<endl;
    int xxx;cin>>xxx;
    return 0; 
}

Measured memory_bytes: 51884
n = int(input())
ns = list(map(int, input().split()))
ns = sorted(ns, reverse=True)
if n % 2 == 1:
    a = n //2 + 1
    print(sum(ns[:a]) * 2 - ns[0] - ns[a-1])
    
else:
    a = n // 2
    print(sum(ns[:a]) * 2 - ns[0])

Measured memory_bytes: 94212
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE
//#define int long long
const int MAXN = 2e5 + 10;
const int MAXM = 1e6 + 10;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,a[MAXN],ans;
bool vis[MAXM];

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifndef ONLINE_JUDGE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(n);
	for(register int i = 1;i <= n; ++i)
		read(a[i]);
	sort(a + 1,a + n + 1);
	for(register int i = 1;i <= n; ++i) {
		if(a[i] == a[i - 1]) continue;
		if(!vis[a[i]] && a[i] != a[i + 1]) ans++;
		for(register int p = 2;a[i] * p <= (int)(1e6); ++p) 
			vis[p * a[i]] = true;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5352
(let ((a (make-array 3))
      (ans 0)
      k)
     (dotimes (x 3)
           (setf (aref a x) (read)))
     (sort a #'<)
     (setf k (read))
     (format t "~A~%" (+ (aref a 0) (aref a 1) (* (aref a 2) (expt 2 k)))))


Measured memory_bytes: 4832
//@truneo
//The purpose of computation is insight, not numbers...
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int t;
	t=1;
	while(t--)
	{
		ll n;
		cin>>n;
		ll hghts[n];
		ll dp[n];
		memset(dp,0,sizeof(dp));
		for(ll i=0;i<n;i++)
		{
			cin>>hghts[i];
		}
		dp[0]=0;
		dp[1]=llabs(hghts[1]-hghts[0]);
		for(int i=2;i<n;i++)
		{
			dp[i]=min(dp[i-2]+llabs(hghts[i-2]-hghts[i]), dp[i-1]+llabs(hghts[i-1]-hghts[i]));
		}
		cout<<dp[n-1]<<"\n";
	}


	return 0;
}

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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1) a += 13;
  if (b == 1) b += 13;
  if (a > b) cout << "Alice\n";
  else if (a == b) cout << "Draw\n";
  else if (a < b) cout << "Bob\n";
}


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

int main()
{
	int rows, columns;
	cin >> rows >> columns;
	int **HW;
	HW = new int * [rows];
	for (int i = 0; i < rows; i++) {
		HW[i] = new int[columns];
	}
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			HW[i][j] = 0;
		}
	}
	//填格子开始

	int Num;
	cin >> Num;
	int *a;
	a = new int[Num];
	for (int i = 0; i < Num; i++) {
		cin >> a[i];
	}
	int var = 0; int x = -1, y = 0;
	for (int i = 0; i < Num; i++) {
		for (int j = 0; j < a[i]; j++) {
			if (var == 0) {
				x++;
				if (x < columns && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x--; j--; var++;
				}
			}else if (var == 1) {
				y++;
				if (y < rows && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y--; j--; var++;
				}
			}else if (var == 2) {
				x--;
				if (x >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x++; j--; var++;
				}
			}else if(var == 3) {
				y--;
				if (y >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y++; j--; var = 0;
				}
			}
		}
	}
	//填格子结束
	for (int i = 0; i < rows; i++) {
		cout << HW[i][0];
		for (int j = 1; j < columns; j++) {
			cout << " " << HW[i][j];
		}
		cout << endl;
	}
	
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

void solve(){
	int n,k;
	cin>>n>>k;
	int max=(n-2)*(n-1)/2,tv=0;
	if(max<k)cout<<"-1"<<endl;
	else if(max>=k){
		tv=n-1+max-k;
		cout<<tv<<endl;
		rep(i,2,n+1){
			cout<<"1 "<<i<<endl;
		}
		int j=3,q=2;
		while((max-k)>0){
			cout<<q<<" "<<j<<endl;
			j++;
			k++;
			if(j==n+1){
				q++;
				j=q+1;
			}
		}
	}
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(long long i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
ll f(ll h) {
	if(h==1) return 1;
	else return 2*f(h/2)+1;
}
int main() {
	ll ans,h;
	cin>>h;
	cout<<f(h);
	return 0;
}


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

int selectionSort(int *a, int size) {
    int count = 0;
    for (int i = 0; i < size; i++) {
        int minj = i;
        for (int j = i; j < size; j++) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }
        if (a[i] > a[minj]) {
            swap(a[i], a[minj]);
            count++;
        }
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    int a[100];
    for (int i = 0; i < n; i++) cin >> a[i];

    int c = selectionSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3068
import java.io.*;
import java.util.*;
import java.util.function.*;

class Cost<T> {
	int cost;
	T thing;

	Cost(int cost, T thing) {
		this.cost = cost;
		this.thing = thing;
	}
}

class Pair {
	int x, y;

	Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int H = Integer.parseInt(sc.get());
		int W = Integer.parseInt(sc.get());

		BitSet[] black = new BitSet[H];
		Arrays.setAll(black, $ -> new BitSet(W+1));
		Queue<Cost<Pair>> queue = new ArrayDeque<>(H * W);
		for (int i = 0; i < H; i++) {
			char[] data = sc.get().toCharArray();
			for (int j = 0; j < W; j++) {
				if (data[j] == '#') {
					Pair pair = new Pair(j, i);
					black[i].set(j);
					queue.add(new Cost<>(0, pair));
				}
			}
		}

		int max = 0;

		while (!queue.isEmpty()) {
			Cost<Pair> next = queue.remove();
			max = Math.max(max, next.cost);
			int x = next.thing.x;
			int y = next.thing.y;
			int cost = next.cost + 1;
			if (x < W - 1) enqueue(x + 1, y, cost, black, queue);
			if (0 < x) enqueue(x - 1, y, cost, black, queue);
			if (y < H - 1) enqueue(x, y + 1, cost, black, queue);
			if (0 < y) enqueue(x, y - 1, cost, black, queue);
		}

		System.out.println(max);
	}

	void enqueue(int x, int y, int cost, BitSet[] black, Queue<Cost<Pair>> queue) {
		Pair pair = new Pair(x, y);
		if (black[y].get(x)) return;
		queue.add(new Cost<>(cost, pair));
		black[y].set(x);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 125784
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  const len = +readLine();
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  const sum = arr.reduce((sum, n) => add(sum, n), 0);
  let ans = mul(sum, sum);

  for (let i = 0; i < len; i++) {
    ans -= mul(arr[i], arr[i]);
  }

  console.log(mul(mod(ans), inv(2)));
}


Measured memory_bytes: 51988
def f():
    s = input()
    if s[0] != 'A':
        print('WA')
        return
    found_C = False
    for i in range(1, len(s)):
        if s[i] == 'C':
            if found_C:
                print('WA')
                return
            if i == 1 or i == len(s) - 1:
                print('WA')
                return
            found_C = True
        elif not('a' <= s[i] <= 'z'):
            print('WA')
            return
    if found_C:
        print('AC')
    else:
        print('WA')


f()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,k;cin >> n >>k;
    if(k/2>n){
        cout << 0 <<endl;
        return 0;
    }
    ll ans=(n/k)*(n/k)*(n/k);
    if(k%2==1){
        cout << ans <<endl;
        return 0;
    }
    ll count=1;
    n-=k/2;
    count+=n/k;
    ans+=(ll)pow(count,3);
    cout << ans <<endl;
}

Measured memory_bytes: 384
N,M,X,Y = (int(T) for T in input().split())
ACityMax = sorted(int(T) for T in input().split())[-1]
BCityMin = sorted(int(T) for T in input().split())[0]
if ACityMax<BCityMin and ACityMax<Y and X<BCityMin:
    print('No War')
else:
    print('War')

Measured memory_bytes: 9100
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

array = [a, b, c, d, e]

tmp = array.map do |t|
  if t % 10 == 0
    0
  else
    10 - t % 10
  end
end

max = tmp.max

sum = 0
tmp.each_with_index do |t, i|
  sum += array[i] + t
end

puts sum - max


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n, t;
	cin >> n >> t;
	
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}

	int minv=v[0], maxv=-2000000000;
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, v[i]-minv);
		minv = min(minv, v[i]);
	}
	int cnt = 0;
	int minv2=v[0], maxv2 = -2000000000;
	bool f = false;
	int past;
	for (int i = 1; i < n; i++) {
		if (v[i]-minv2==maxv) {
			cnt++;
		}
		maxv2 = max(maxv2, v[i] - minv2);
		minv2 = min(minv2, v[i]);
	}
	//if (cnt > t / 2)cnt = t / 2;
	cout << cnt << endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	if(N%2==1) {
		cout<<0<<endl;
	}
	else {
		ll ret=0;
		ll cur=10;
		while(cur<=N) {
			ret+=N/cur;
			cur*=5;
		}
		cout<<ret<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	ll n; cin >> n;
	ll ans = 0;
	for (ll i = 1; i*i <= n; i++) {
		ll a = (n - i) / i;
		if (a != 0 && n / a != n%a) continue;
		ans += a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// D - Knight


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

class Comb {
private:
    int MOD;
    long long* fac;
    long long* finv;
    long long* inv;
public:
    // 事前にテーブルを作成
    Comb(int MAX, int MOD) {
        this->MOD = MOD;

        fac = new long long[MAX + 1];
        finv = new long long[MAX + 1];
        inv = new long long[MAX + 1];

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

    ~Comb() {
        delete[] fac, finv, inv;
    }

    // 二項係数計算
    long long calc(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

int main()
{
    int X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    // move_1: X方向に1, Y方向に2
    // move_2: X方向に2, Y方向に1
    // 1 * move_1 + 2 * move_2 = X
    // 2 * move_1 + 1 * move_2 = Y
    int move_1 = (2 * Y - X) / 3;
    int move_2 = (2 * X - Y) / 3;
    int move_total = move_1 + move_2;

    if (move_1 < 0 || move_2 < 0 || move_total != (X + Y) / 3) {
        cout << 0 << endl;
        return 0;
    }

    Comb comb = Comb(move_total, 1000000007);

    ll ans = comb.calc(move_total, move_1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;
int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	int ans = 1;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.rbegin(), a.rend());
	for (int i = 1; i < n; ++i) {
		sum -= a[i - 1];
		if (2 * sum < a[i - 1])	break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
#define N_MAX 10000
int main()
{
  
  int n, fact[N_MAX + 1];
  bool prime[N_MAX + 1] = {};
  set< int > digit;

  int mul[N_MAX * 1];

  for(int i = 1; i <= N_MAX; i++){
    fact[i] = i * i;
  }

  while(cin >> n, n){
    fill_n( mul, n + 1, 0);

    for(int i = 1; i< n; i++){
      digit.insert(fact[i] % n);
    }
    for(__typeof digit.begin() it = digit.begin(); it != digit.end(); it++){
      for(__typeof digit.begin() iitt = digit.begin(); iitt != digit.end(); iitt++){
        if(it == iitt) continue;

        int calc = *it - *iitt;
        if(calc < 0) calc += n;
        if((n - 1) / 2 < calc) calc = n - calc;
        mul[calc]++;
      }
    }

    for(int i = 1; i <= (n - 1) / 2; i++){
      printf("%d\n", mul[i]);
    }
    digit.clear();
  }
}

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

int main() {
	bitset<8368800> flgs;

	while(1){
		flgs.reset();
		int m,n;
		// ?????????????????£????????°
		int loop = 0;
		cin >> m >> n;
		if(m == 0 && n == 0) break;

		if(m > n){
				cout << m + n << "\n";
		}else{
			int i;
	  	for(i = m ; loop <= n ; i++){
				if(flgs.test(i)){
				}else{
					loop++;
					int lim = 7368792 / i + 1;
					for(int j = 1 ; j < lim ; j++){
						flgs.set(i * j);
					}
		//			cout << "i = " << i << " loop = " << loop << "\n";
				}
			}

			cout << i - 1 << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 4072