akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, p;
  while (cin >> n >> p, n) {
    int c = p, t = 0;
    vi v(n);
    for (;;) {
      if (c) {
        v[t]++;
        c--;
        if (!c) {
          bool f = true;
          rep(i, n) f &= !v[i] || i == t;
          if (f) {
            cout << t << endl;
            break;
          }
        }
      } else {
        c    = v[t];
        v[t] = 0;
      }
      t = (t + 1) % n;
    }
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    constexpr ll MOD = 1e9 + 7;

    int n, m;
    cin >> n >> m;

    vector<ll> dp(n + 1);
    dp[0] = 1;

    for (int i = 0, a; i < m; ++i) {
        cin >> a;
        dp[a] = -1;
    }

    for (int i = 0; i < n; ++i) {
        if (dp[i] == -1) continue;
        if (dp[i + 1] != -1) (dp[i + 1] += dp[i]) %= MOD;
        if (i + 2 <= n && dp[i + 2] != -1) (dp[i + 2] += dp[i]) %= MOD;
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    int d,remainder;
    double function;
    
    scanf("%d %d", &a,&b);
    function = (double)a/b;
    d = (int)function;
    remainder = a%b;
    printf("%d %d %f\n",d,remainder,function);
    return 0;
}


Measured memory_bytes: 2080
n = int(input())
l = list(map(int, input().split()))
even = 0
e_sum = 0
odd = 0
o_sum = 0
for i in range(n):
  e_sum += l[i]
  if i % 2 == 0 and e_sum <= 0:
    even += abs(e_sum)+1
    e_sum = 1
  elif not i % 2 == 0 and e_sum >= 0:
    even += abs(e_sum)+1
    e_sum = -1

for i in range(n):
  o_sum += l[i]
  if i % 2 == 0 and o_sum >= 0:
    odd += abs(o_sum)+1
    o_sum = -1
  elif not i % 2 == 0 and o_sum <= 0:
    odd += abs(o_sum)+1
    o_sum = 1

print(min(even, odd))

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

using namespace std;

const int INF=1e9+10;

int main()
{
    int n;
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin>>n)
    {
        vector<int> dp(n);
        fill(dp.begin(),dp.end(),INF);
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            *lower_bound(dp.begin(),dp.end(),a)=a;
        }
        cout<<lower_bound(dp.begin(),dp.end(),INF)-dp.begin()<<endl;
    }

    return 0;
}



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

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    int ans = 0;
    for(auto p : prime_factor(n)){
        ll x = p.second, cnt = 1;
        while(x > 0){
            x -= cnt++;
            ++ans;
        }
        if(x < 0) --ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.rbegin(), a.rend())
using namespace std;

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

    string s; cin>>s;
    loop(3) if(s[i] == '7') return cout<<"Yes\n", 0;
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  vector<int> X(s.size()-2);
  for(int i=0;i<s.size()-2;i++){
    string a=s.substr(i,3);
    int num = stoi(a);
    if(num>753){
      X.at(i)=num-753;
    }
    else{
      X.at(i)=753-num;
    }
  }
  sort(X.begin(),X.end());
  cout<<X.at(0)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char a[3];
	scanf("%s", a);
	if (a[0] == 'A'&&a[1]=='B'&&a[2]=='C') {
		printf("ARC");
	}
	else if (a[0] == 'A' && a[1] == 'R' && a[2] == 'C') {
		printf("ABC");
	}
	return 0;
	}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
using ll = long long;

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

int main() {
    ll x,y;cin>>x>>y;
    int a = -1;if ((2*x-y)%3==0) a = (2*x - y)/3;
    int b = -1;if ((2*y-x)%3==0) b = (2*y - x)/3;
    if (a>=0 and b>=0) {
        COMinit();
        cout << COM(a+b,a) << endl;
    }
    else cout << 0 << endl;

}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;

if((a==5 && b==5 && c==7) || (a==7 && b==5 && c==5) || (a==5 && b==7 && c==5)) cout<<"YES"<<endl;
else cout<<"NO"<<endl;


}


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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
typedef long long ll;
typedef int64_t i6;
//π M_PI
//deg = rad*180/M_PI

int main() {
  ll r;
  cin >> r;
  cout << r*r << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using indexed_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = { 0, 0, -1, 1, -1, 1, -1, 1 };
int _y[] = { -1, 1, 0, 0, 1, -1, -1, 1 };
void solve();
int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.setf(ios::fixed);
	cout.precision(20);
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		//    cout << "Case #: " << i << "\n";
		solve();
	}
	return 0;
}

void solve() {
	int x;
	cin >> x;
	if (x == 0)
		cout << 1 << "\n";
	else
		cout << 0 << "\n";
}


Measured memory_bytes: 3608
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int lo = Integer.MAX_VALUE;
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			int x = input.nextInt();
			if (x<=lo) {
				cnt++;
				lo=x;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 62860
using System;
using System.Linq;

class Program {
    static void Main() {
        int[,,] people = new int[4,3,10];
        int n = int.Parse(Console.ReadLine());
        for(int i = 0; i < n; i++) {
            int[] info = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            people[info[0] - 1, info[1] - 1, info[2] - 1] += info[3];
        }

        for(int i = 0; i < 4; i++) {
            if(i != 0) Console.WriteLine("####################");
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 10; k++) {
                    Console.Write(" {0}", people[i, j, k]);
                }
                Console.WriteLine();
            }
        }
    }
}


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

int vec[100010];
int dp[100010];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  for(int i=1;i<n;i++){
    if(i==1){
      dp[i]=abs(vec[i]-vec[i-1]);
      continue;
    }
    dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

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

int convert(string f)
{
    int k=0,p=1;
  //  cout<<f<<endl;
   // reverse(f.begin(),f.end());
    for(int i=0;i<f.size();i++)
    {
      //  cout<<f[i]<<endl;
        k+=(f[i]-'0');
      if(i<f.size()-1)  k*=10;
    }
    return k;
}

int main()
{
    string s;
    cin>>s;
    int counter=1e8;
    for(int i=0;i<s.size()-2;i++)
    {
        string frr;
        frr+=s[i];
        frr+=s[i+1];
        frr+=s[i+2];
        int k=convert(frr);
        counter=min(counter,abs(k-753));
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int after_tax(int value, int tax) {
  return value * (100 + tax) / 100;
}

int main(int argc, char *argv[])
{
  int tax_1, tax_2, a, b, sum;
 
  int d = 0;
  
  while(!feof(stdin)) {
    fscanf(stdin, "%d", &d);
    tax_1 = d;
    fscanf(stdin, "%d", &d);
    tax_2 = d;
    fscanf(stdin, "%d", &d);
    sum = d;

    if (tax_1 == 0 && tax_2 == 0 && sum == 0) break;
    int current_max = 0;
    int tax1_sum;
    int tax2_sum;
    for (a = 1; a < sum; a++) {
      for (b = 1; b < sum; b++) {
	tax1_sum = after_tax(a, tax_1) + after_tax(b, tax_1);
	if (tax1_sum == sum) {
	  tax2_sum = after_tax(a, tax_2) + after_tax(b, tax_2);
	  if (tax2_sum > current_max) current_max = tax2_sum;
	}
      }
    }
    printf("%d\n", current_max);
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)
          cin >>
      a[i];
  int ans = 0;
  rep(i, n)
  {
    if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
import java.io.*;
  
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = input.readLine()) != null) {
            char[] line_chars = line.toCharArray();
            int line_len = line_chars.length;
            for (int i = 0; i < line_len; i++) {
                char ch = line_chars[i];
                int amount = 0;
                if (Character.isUpperCase(ch))
                    amount = 32;
                else if (Character.isLowerCase(ch))
                    amount = -32;
                line_chars[i] += amount;
            }
            System.out.println(new String(line_chars));
        }
    }
}

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

int main() {
    int x, y, ans = 0;
    cin >> x >> y;
    for(int i = 0; i <= x; i++) {
        if (2*i + 4*(x-i) == y) {
            ans = 1;
            break;
        }
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main()
{
    string a;
    cin>>a;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]==a[i+1])
        {
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    public class ABC
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>>();
            for (int i = 0; i < N; i++) {
                list.Add(new KeyValuePair<int, int>(a[i], i + 1));
            }
            int[] ans = list.OrderBy(p => p.Key).Select(p => p.Value).ToArray();
            Console.WriteLine(string.Join(" ", ans));


            Console.Out.Flush();
        }
    }
}


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

namespace AtCoder
{
    class Abc167C
    {
        public static void Main()
        {
            var nmx = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var n = nmx[0];
            var m = nmx[1];
            var x = nmx[2];

            var ca = new int[n][];
            for (int i = 0; i < n; i++)
                ca[i] = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();

            var minCost = int.MaxValue;
            for (int i = 0; i < 1 << n; i++)
            {
                var xx = new int[m];
                int cost = 0;
                int bit = i;
                int j = 0;
                while (bit > 0)
                {
                    if ((bit & 1) == 1)
                    {
                        cost += ca[j][0];
                        for (int k = 0; k < m; k++)
                        xx[k] += ca[j][k + 1];
                    }
                    j++;
                    bit >>= 1;
                }
                if (xx.All(a => a >= x) && minCost > cost)
                    minCost = cost;
            }

            Console.WriteLine(minCost == int.MaxValue ? -1 : minCost);
        }
    }
}


Measured memory_bytes: 28536
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

A = [list(map(int, (input().split()))) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

chk = [[0]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            chk[i][j] = 1

ans = "No"
for i in range(3):
    if chk[i][0] == chk[i][1] == chk[i][2] == 1:
        ans = "Yes"
        break
    if chk[0][i] == chk[1][i] == chk[2][i] == 1:
        ans = "Yes"
        break
if chk[0][0] == chk[1][1] == chk[2][2] == 1:
    ans = "Yes"
elif chk[0][2] == chk[1][1] == chk[2][0] == 1:
    ans = "Yes"

print(ans)


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int A=0,B=0;
  
  for(int i=0; i<N; i++){
    if(i%2 == 0){
      A += vec.at(i);
    }
    
    else{
      B += vec.at(i);
    }
    
  }
  
  cout << A-B << endl;
  
}


Measured memory_bytes: 3636
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()

for i in range(1, 2000):
    tax8 = i * 8 // 100
    tax10 = i * 10 // 100
    if tax8 == a and tax10 == b:
        print(i)
        exit()
    
print(-1)
exit()
x1 = a / 0.08
y1 = b /0.1
x2 = (a+1) / 0.08
y2 = (b+1) /0.1


# exit()
if ceil(y1) <= ceil(x1) < y2:
    ans = ceil(x1)
    print(ans)
elif ceil(x1) <= ceil(y1) < x2:
    ans = ceil(y1)
    print(ans)
else:
    print(-1)



Measured memory_bytes: 5156
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	ll N,K;
	cin>>N>>K;
	vector<ll> V(N);
	FOR(i,0,N){
		cin>>V[i];
	}
	ll ans=1e15;
	FOR(i,0,N-K+1){
		if(V[i]*V[i+K-1]<0LL){
			ll x=abs(V[i]),y=abs(V[i+K-1]);
			ans=min(ans,(ll)x+y+min(x,y));
		}else{
			ans=min(ans,(ll)max(abs(V[i]),abs(V[i+K-1])));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 100000
bool prime[MAX_N+100];
void eratos(){
    for(int i=0;i<MAX_N;i++)prime[i]=true;
    prime[0]=prime[1]=false;
    for(int i=2;i*i<=MAX_N;i++){
    	if(prime[i]){
    		for(int j=i*2;j<=MAX_N;j+=i)prime[j]=false;
    	}
    }
    return;
}
ll is_sq(ll x){
	ll s = (ll)sqrt((double)x);
	for(ll i=-1ll;i<=1ll;i++){
		if((s+i)*(s+i)==x){
			assert(prime[s+i]);
			return s+i;
		}
	}
	return -1ll;
}
int N;
vector<ll> p;
ll s[100100];
map<ll,int> m;
map<ll,ll> f;
int main(){
	cin >> N;
	for(int i=0;i<N;i++)cin >> s[i];
	eratos();
	for(int i=1;i<=2000;i++){
		if(prime[i])p.pb((ll)i);
	}
	bool flag = false;
	for(int i=0;i<N;i++){
		ll nf = 1ll;
		ll pa = 1ll;
		ll t = s[i];
		for(int j=0;j<p.size();j++){
			int c = 0;
			while(t%p[j]==0){
				t/=p[j];
				c++;
			}
			if((c%3)>0){
				for(int k=0;k<(c%3);k++)nf*=p[j];
				for(int k=0;k<3-(c%3);k++)pa*=p[j];
			}
		}
		if(t!=1ll){
			nf *= t;
			ll rt = is_sq(t);
			if(rt==-1ll)pa *= (t*t);
			else pa *= rt;
		}
		//cout << nf << ' ' << pa << endl;
		if(nf==1ll){
			flag = true;
			continue;
		}
		m[nf]++;
		f[nf]=pa;
	}
	map<ll,int>::iterator it;
	int ans = 0;
	int mi = 0;
	for(it=m.begin();it!=m.end();it++){
		//cout << it->fi << ' ' << it->sec << endl;
		map<ll,int>::iterator it2 = m.find(f[it->fi]);
		if(it2==m.end()){
			ans+=it->sec;
		}else{
			//cout << it2->fi << ' ' << it2->sec << endl;
			mi += max(it->sec,it2->sec);
		}
	}
	ans+=mi/2;
	if(flag)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13568
#include "bits/stdc++.h"
using namespace std;

int main() {
	int A,B;
	cin >> A >> B;
	if ((0 == A%3)||(0 == B%3)||(0==(A+B)%3)) {
		cout << "Possible" << endl;
	}
	else {
		cout <<"Impossible" <<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
function readLines(): Promise<string[]> {
    return new Promise<string[]>((resolve) => {
        let inputBuffer = "";
        process.stdin.resume();
        process.stdin.setEncoding("utf8");
        process.stdin.on("data", (chunk) =>
            inputBuffer += chunk.toString()
        );
        process.stdin.on("end", () =>
            resolve(inputBuffer.split("\n"))
        );
    });
}

async function main() {
    const inputs: string[] = await readLines();
    const n = parseInt(inputs[0]);
    let count = 0;
    for (var i = 1; i <= n; i++) {
        if (eight(i)) count++;
    }
    console.log(count);
}

function eight(input: number): boolean {
    if (input % 2 === 0) return false;

    let count = 0;
    for (var i = 1; i <= input; ++i) {
        if (input % i === 0) count++;
        if (count > 8) return false;
    }

    return count === 8;
}

main();


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
const ll mod=1e9+7;
const int maxn = 3100;

ll dp[maxn][maxn];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	int h,w;
	cin>>h>>w;
	string s[h];
	for (int i = 0; i < h; ++i)
	{
		cin>>s[i];
	}
	dp[0][0]=1;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if(s[i][j]=='.'){
				if(i>0 and s[i-1][j]=='.') dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				if(j>0 and s[i][j-1]=='.') dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
		}
	}
	output(dp[h-1][w-1]);
	return 0;
}

Measured memory_bytes: 24832
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;


int main() {
	
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> s(n + 1, 0);

	rep(i, n) {
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
	}

	ll dif = s[n];
	for(int i = 0; i < n; i++) {
		dif = min(abs(2*s[i] - s[n]), dif);
	}

	cout << dif << endl;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n;
struct Node{
	int id,v;
};
int ans[100010];
vector<Node> q[100010];
void dfs(int id,int fa,int tot)
{
	if(tot%2==0)
		ans[id]=0;
	else
		ans[id]=1;
	for(int i=0;i<q[id].size();i++)
	{
		if(q[id][i].id!=fa)
		dfs(q[id][i].id,id,q[id][i].v+tot);
	}
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y,w;
		Node aa;
		cin>>x>>y>>w;
		aa.id=y,
		aa.v=w;
		q[x].push_back(aa);
		aa.id=x,
		aa.v=w;
		q[y].push_back(aa);
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int n, m, x, y;
    VE X;
    VE Y;
    cin >> n >> m >> x >> y;
    int q, p;
    REP(i, n){
        cin >> q;
        X.push_back(q);
    }
    REP(i, m){
        cin >> p;
        Y.push_back(p);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    
    if(X[n-1] < Y[0] && X[n - 1] < y && Y[0] > x){
        print("No War");
    }else{
        print("War");
    }
}

Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	k := scanInt()

	as := scanInts(n)

	sort.Ints(as)

	if k == 1 {
		fmt.Println(0)
		return
	}

	cum := make([]int, n+1)
	cum[0] = 0

	for i := 0; i < n; i++ {
		cum[i+1] = (as[i]+cum[i])%mod
	}

	facInit(n)
	// fmt.Println(cum)
	ans := 0

	for i := 0; i < n-k+1; i++ {
		// fmt.Println(n-k-i)
		val := ((cum[n]-cum[i+k-1])%mod-cum[n-k+1-i])%mod
		ans = (ans+val*comb(k-2+i,k-2)%mod)%mod
		// fmt.Println((cum[n]-cum[i+k-1]),val)
	}

	fmt.Println(ans)

}

const mod = 1000000007

var (
	fac []int
	ifac []int
)

func facInit(n int) {
	fac = make([]int,n+1)
	ifac = make([]int,n+1)
	
	mpow := func (x,n int) int {
		a := 1
		for {
			if n&1 == 1 {
				a = a*x %mod
			}
			x = x*x %mod
			n = n >> 1
			if n == 0 {
				break
			}
		}
		return a
	}

	fac[0] = 1
	ifac[0] = 1
	for i := 0; i < n; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		ifac[i+1] = ifac[i]*mpow(i+1,mod-2)%mod
	}
}

func comb(a,b int) int {
	if a == 0 && b == 0 {
		return 1
	}
	return (fac[a]*ifac[b]%mod)*ifac[a-b]%mod
}


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

int main(){
	double r;
	double face,circle;

	scanf("%lf",&r);
	
	face = r*r*M_PI;
	circle = r*2*M_PI;

	printf("%f ",face);
	printf("%f\n",circle);

return 0;
}


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

int main(){

	int N=0,L=0;
	cin>>N>>L;
	string S [100];
	for(int i=0;i<N;i++){
		cin>>S[i];
	}
	
	sort(S, S+N); 
	string ans="";
	for(int i=0;i<N;i++){
		ans+=S[i];
	}
	cout<<ans;
}



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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()

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

typedef long long ll;
#define vv(t) vector< t > 

#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))

template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}

#pragma endregion

template<typename T>
void SV(vector<T> v){
    #ifdef LOCAL
        REP(i,v.size()){
                cout << i << " : " << v[i] << endl;
        }
    #endif
}

template<typename T>
void SV(map<int, T> v){
    #ifdef LOCAL
        FOREACH(i, v){
            cout << i.first << " : " << i.second << endl;
        }
    #endif
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

int main(void){
    ll N, cpn;
    cin >> N;
    cpn = N;
    if(N%2){
        cout << 0 << endl;
        return 0;
    }
    ll p=1;
    ll cnt=0;
    ll mul=1;
    N/=10;
    while(N>0){
        int s=N%5;
        cnt+=s*p;
        p=p*5+1;
        N/=5;
    }
    cout << cnt << endl;
    /*
    N=cpn;
    cnt=0;
    mul=1;
    while(N>0){
        mul*=N;
        mul%=10000000000ll;
        while(!(mul%10)&&mul>0){
            cnt++;
            mul/=10;
        }
        //debug(N, mul, cnt);
        if((!(N%10))&&false){
            N-=10;
        }else{
            N-=2;
        }
    }
    cout << cnt << endl;
    //*/
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	cin >> N;
	map<string, uint32_t> m;
	forn(i, N)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
	return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=202000*8;
const int Mod=924844033;
const int inf=2147483647;

int n,N,L,G,Fac[maxN],InvF[maxN];
int edgecnt=0,Head[maxN],Next[maxN],V[maxN],Sz[maxN],Cnt[maxN];
int A[maxN],B[maxN],Rader[maxN];

void Add_Edge(int u,int v);
void dfs(int u,int fa);
int QPow(int x,int cnt,int M);
int GetG(int x);
void NTT(int *P,int opt);

int main(){
	Fac[0]=InvF[0]=1;for (int i=1;i<maxN;i++) Fac[i]=1ll*Fac[i-1]*i%Mod;
	InvF[maxN-1]=QPow(Fac[maxN-1],Mod-2,Mod);for (int i=maxN-2;i>=1;i--) InvF[i]=1ll*InvF[i+1]*(i+1)%Mod;
	G=GetG(Mod);mem(Head,-1);
	scanf("%d",&n);for (N=1;N<=(n+n);N<<=1) ++L;for (int i=0;i<N;i++) Rader[i]=(Rader[i>>1]>>1)|((i&1)<<(L-1));
	for (int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		Add_Edge(u,v);Add_Edge(v,u);
	}
	dfs(1,1);
	for (int i=1;i<=n;i++) A[i]=1ll*Cnt[i]*Fac[i]%Mod;
	for (int i=0;i<=n;i++) B[i]=InvF[i];
    /*
	for (int i=1;i<=n;i++) cout<<Cnt[i]<<" ";cout<<endl;
	for (int i=0;i<N;i++) cout<<A[i]<<" ";cout<<endl;
	for (int i=0;i<N;i++) cout<<B[i]<<" ";cout<<endl;
	//*/
	reverse(&B[0],&B[n+1]);
	NTT(A,1);NTT(B,1);for (int i=0;i<N;i++) A[i]=1ll*A[i]*B[i]%Mod;NTT(A,-1);
	for (int i=1,mul=1;i<=n;i++) printf("%lld\n",(1ll*Fac[n]*InvF[n-i]%Mod*InvF[i]%Mod*n%Mod-1ll*InvF[i]*A[i+n]%Mod+Mod)%Mod);
	return 0;
}

void Add_Edge(int u,int v){
	Next[++edgecnt]=Head[u];Head[u]=edgecnt;V[edgecnt]=v;
	return;
}

void dfs(int u,int fa){
	Sz[u]=1;
	for (int i=Head[u];i!=-1;i=Next[i])
		if (V[i]!=fa){
			dfs(V[i],u);Sz[u]+=Sz[V[i]];++Cnt[Sz[V[i]]];
		}
	if (Sz[u]!=n) ++Cnt[n-Sz[u]];return;
}

int QPow(int x,int cnt,int M){
	int ret=1;
	while (cnt){
		if (cnt&1) ret=1ll*ret*x%M;
		x=1ll*x*x%M;cnt>>=1;
	}
	return ret;
}

int GetG(int x){
	int pcnt=0,P[50],k=x-1;
	for (int i=2;1ll*i*i<=k;i++)
		if (k%i==0){
			P[++pcnt]=i;while (k%i==0) k/=i;
		}
	for (int i=2;i;i++){
		bool flag=1;
		for (int j=1;(j<=pcnt)&&(flag);j++) if (QPow(i,(x-1)/P[j],x)==1) flag=0;
		if (flag) return i;
	}
}

void NTT(int *P,int opt){
	for (int i=0;i<N;i++) if (i<Rader[i]) swap(P[i],P[Rader[i]]);
	for (int i=1;i<N;i<<=1){
		int dw=QPow(G,(Mod-1)/(i<<1),Mod);
		if (opt==-1) dw=QPow(dw,Mod-2,Mod);
		for (int j=0;j<N;j+=(i<<1))
			for (int k=0,w=1;k<i;k++,w=1ll*w*dw%Mod){
				int X=P[j+k],Y=1ll*P[j+k+i]*w%Mod;
				P[j+k]=(X+Y)%Mod;P[j+k+i]=(X-Y+Mod)%Mod;
			}
	}
	if (opt==-1){
		int inv=QPow(N,Mod-2,Mod);
		for (int i=0;i<N;i++) P[i]=1ll*P[i]*inv%Mod;
	}
	return;
}

Measured memory_bytes: 54784
#include<stdio.h>
#include<string.h>

#define MAX 500001

struct node{
  int parent;
  int left;
  int right;
  int key;
};
typedef struct node Node;

void insert(int);
void inorder(int);
void preorder(int);
int find(int,int);

int  root=-1;
Node T[MAX];

int main(){
  int i, n, m;
  char str[10];

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].left=T[i].right=T[i].parent=-1;

  for (i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0){
      scanf("%d",&T[i].key);
      insert(i);
    }
    else if(strcmp(str,"print")==0){
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
    else if(strcmp(str,"find")==0){
      scanf("%d",&m);
      if(find(root,m)==-1) printf("no\n");
      else printf("yes\n");
    }
  }
  return 0;
}

void insert(int z){
  int y = -1;
  int x = root;

  while(x != -1){
    y = x;
    if(T[z].key < T[x].key) x = T[x].left;
    else x = T[x].right;
  }

  T[z].parent = y;

  if(y == -1) root = z;

  else if(T[z].key < T[y].key) T[y].left = z;

  else T[y].right = z;
}

void inorder(int t){
  if(t != -1){
    inorder(T[t].left);
    printf(" %d",T[t].key);
    inorder(T[t].right);
  }
}

void preorder(int t){
  if(t != -1){
    printf(" %d",T[t].key);
    preorder(T[t].left);
    preorder(T[t].right);
  }
}

int find(int x, int k){
  if(x==-1 || k==T[x].key) return x;
  if(k<T[x].key) return find(T[x].left,k);
  else return find(T[x].right,k);
}

Measured memory_bytes: 8428
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) FOR(i,0,n)

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int cash = 0;
	int n = min(x, y);
	int deal = min(a+b, c*2);

	cash = deal * n;

	n = max(x, y) - n;

	if(x >= y){
		deal = min(a, c*2);
	}else{
		deal = min(b, c*2);
	}
	cash += deal * n;
	cout << cash << endl;
	return 0;
}

Measured memory_bytes: 256
S = list(input())
K = int(input())

S1 = list(S)
cnt1 = 0
for i in range(1, len(S1)):
    if S1[i] == S1[i - 1]:
        S1[i] = '*'
        cnt1 += 1

S2 = list(S) * 2
cnt2 = 0
for i in range(1, len(S2)):
    if S2[i] == S2[i - 1]:
        S2[i] = '*'
        cnt2 += 1
        
S3 = list(S) * 3
cnt3 = 0
for i in range(1, len(S3)):
    if S3[i] == S3[i - 1]:
        S3[i] = '*'
        cnt3 += 1

# print("#", S1, S2, S3)
# print("#", cnt1, cnt2, cnt3)
ans = cnt1 + (cnt2 - cnt1) * (K // 2) + (cnt3 - cnt2) * ((K - 1) // 2)
print(ans)


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

#define int long long int 

int32_t main()
{
  int x;
  cin>>x;
  vector<bool> c(x+1,0);
  c[1]=1;
  for(int i=2;i<x;i++)
  {
    int temp=i*i;
    while(temp<=x)
    {
      c[temp]=1;
      temp*=i;
    }
  }
 
  for(int i=x;i>=1;i--)
  if(c[i])
  {
    cout<<i<<endl;
    return 0;
  }
}	

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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;

int main(){    
	int a, b;
	cin >> a >> b;
	if(a <= 0 && 0 <= b)
		cout << "Zero";
	else
	if(0 < a)
		cout << "Positive";
	else
	if((b - a) % 2 == 0)
		cout << "Negative";
	else
		cout << "Positive";				 
	return 0;
}


Measured memory_bytes: 256
function main() {
  var
  i, x, n,
  len = input.length;
  for(i = 0; i < len; i++) {
    n = parseInt(input[i],10);
    if(n === 0) break;
    x = 0;
    while(n = Math.floor(n / 5)) x += n;
    console.log(x);
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7648
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 10
#define MAX_S (1<<13)
 
int N,M[2*MAX_N];
int memo[2*MAX_N][MAX_S+1];
 
int solve(int p,int rem){
    if(rem == 0) return memo[p][rem] = 1;
    if(memo[p][rem] >= 0) return memo[p][rem];
    for(int i = 1 ; i <= M[p] ; i++){
	if(rem-i < 0) continue;
	if(solve((p+1)%N,rem-i) == 0){
	    return memo[p][rem] = 1;
	}
    }
    return memo[p][rem] = 0;
}
 
int main(){
    int S;
    while(cin >> N,N){
	cin >> S;
	N *= 2;
	for(int i = 0 ; i < N ; i++){
	    cin >> M[i];
	}
	memset(memo,-1,sizeof(memo));
	cout << solve(0,S) << endl;
    }
    return 0;
}

Measured memory_bytes: 3872
def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(input())

    used = [True]*(h*w)

    p = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                p.append(i*w+j)
                used[i*w+j] = False


    
    res = 0
    while p:
        tank = []
        for e in p:
            if e>w-1 and used[e-w]:
                tank.append(e-w)
                used[e-w] = False
            if e%w > 0 and used[e-1]:
                tank.append(e-1)
                used[e-1] = False
            if e<(h-1)*w and used[e+w]:
                tank.append(e+w)
                used[e+w] = False
            if e%w<w-1 and used[e+1]:
                tank.append(e+1)
                used[e+1] =  False
        p = tank
        res += 1
    print(res-1)

if __name__ == '__main__':
    main()

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

int ms[15];
int mp[15];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,m;cin>>n>>m;
  int res=0;
  for(int i=0;i<m;i++){
    int k;cin>>k;
    for(int j=0;j<k;j++){
      int s;cin>>s;s--;
      ms[i] = ms[i] | (1<<s);
    }
  }
  for(int i=0;i<m;i++){
    cin>>mp[i];
  }

  for(int i=0;i<(1<<n);i++){
    // switch - i
    bool ok = true;
    for(int j=0;j<m;j++){
      int mod = (__builtin_popcount(ms[j] & i) % 2);
      if(mod != mp[j])ok = false;
    }
    if(ok)res++;
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
int main() {
    init();
    ll N, V;
    cin >> N >> V;
    vl A(N), B(N), C(N), D(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    rep(i, N) cin >> D[i];

    vl ab, cd;
    ab.reserve(N * N), cd.reserve(N * N);
    repa(a, A) repa(b, B) ab.eb(a + b);
    repa(c, C) repa(d, D) cd.eb(c + d);
    sort(all(ab)), sort(all(cd));

    ll ans = 0;
    for (auto p1 = ab.begin(); p1 != ab.end();){
        if (*p1 >= V) break;
        auto pp1 = equal_range(all(ab), *p1), pp2 = equal_range(all(cd), V - *p1);
        ans += (pp1.second - pp1.first) * (pp2.second - pp2.first);

        p1 = pp1.second;
    }

    cout << ans << endl;
}


Measured memory_bytes: 18340
//by The_One_Solver
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
double r,m,d,c;
int n;
int main()
{
    cin>>n;
    if(n%3==0)
    {
        r=n/3;
        m=n/3;
        d=n/3;
    }
    else
    {
        c=n%3;
        n-=c;
        r+=(n/3)+(c/3);
        m+=(n/3)+(c/3);
        d+=(n/3)+(c/3);
    }
  cout<<fixed<<setprecision(12)<<(r*m*d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vc vector<char>
#define vs vector<string>
#define vpi vector<pii>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvb vector<vector<bool>>
#define vvd vector<vector<double>>
#define vvc vector<vector<char>>
#define vvs vector<vector<string>>
#define vvpi vector<vector<pii>>
#define vvpl vector<vector<pll>>

const int INF = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;

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

	string S, T; cin >> S >> T;

	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) ans++;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3884
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn = 55;
const int inf = 1000000007;

ll a[maxn],K;
int n;

int checkHelper(ll x, ll k){
  bool hasNeg = false;
  bool hasLarge = false;
  for(int i=0;i<n;i++){
    ll tmp=-k/n;
    int tt=k%n;
    if(i+1<=tt)tmp+=(tt-1)-n;
    else tmp+=tt;
    if(x+tmp<0)hasNeg=true;
    else if(x+tmp>n)hasLarge=true;
  }
  if(hasNeg)return -1;
  if(hasLarge)return 1;
  return 0;
}
int check(ll x) {
  ll tt = checkHelper(x, K);
  ll tt2 = checkHelper(x, K-1);
  if(tt==0) {
    if(tt2>0)return 0;
    return -1;
  }
  if(tt<0)return -1;
  return 1;
}

int main() {
  //freopen("in.cpp","r",stdin);
  n = 50;
  cin>>K;
  if(K==0) {
    cout<<n<<endl;
    for(int i=0; i<n; i++) {
      cout<<n-1;
      if(i==n-1)cout<<endl;
      else cout<<" ";
    }
    return 0;
  }
  if(K<n) {
    cout<<n<<endl;
    for(int i=0; i<n-1; i++)cout<<0<<" ";
    cout<<K*n<<endl;
    return 0;
  }
  /*
  ll l=n,r=10000000000000000L+1000,ret=r;
  while(l<=r) {
    ll m = (l+r)>>1;
    int tt=check(m);
    cout<<m<<", "<<tt<<endl;
    if(tt==0) {
      ret=m;
      break;
    } else {
      if(tt>0)r=m-1;
      else l=m+1;
    }
  }
  cout<<n<<endl;
  for(int i=0; i<n; i++) {
    cout<<ret;
    if(i==n-1)cout<<endl;
    else cout<<" ";
  }*/
  cout<<n<<endl;
  ll lt = K%n;
  for(int i=0;i<n;i++){
    ll tt=K/n+n-1-i;
    if(i+1<=lt){
      tt++;
    }
    cout<<tt;
    if(i==n-1)cout<<endl;
    else cout<<" ";
  }
  return 0;
}


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

int main() {
    //
    long long num;
    string str;
    char c;
    long long cnt = 0;
    vector<long long> vec(5, 0);

    cin >> num;

    for (long long i = 0; i < num; i++) {
        cin >> str;
        c = str.at(0);

        if (c == 'M') vec.at(0)++;
        if (c == 'A') vec.at(1)++;
        if (c == 'R') vec.at(2)++;
        if (c == 'C') vec.at(3)++;
        if (c == 'H') vec.at(4)++;
    }

    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {  //
                cnt += vec.at(i) * vec.at(j) * vec.at(k);
            }
        }
    }

    cout << cnt;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
	ArrayList<Integer> list = new ArrayList<>();
	for(int i=0; i<num; i++){
		list.add(sc.nextInt());
	}
	List<Integer> listB = new ArrayList<Integer>(new LinkedHashSet<>(list));
	System.out.println(listB.size());
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll h,w,ans;
    cin>>h>>w;
    if (h==1||w==1)ans=1;
    else ans=(h/2+h%2)*(w/2+w%2)+(h/2)*(w/2);
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n,m,k;
	cin >> n >> m >> k;
	string s[n];
	for(int i=0; i<n; i++){
		cin >> s[i];
	}

	int bin[n+m+1] = {};
	int c=0;
	
	while(bin[n+m]<2){
		int arr[n][m];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				if(s[i][j]=='#')
					arr[i][j]=1;
				else
					arr[i][j]=0;
			}
		}

		for(int i=1; i<=n; i++){
			if(bin[i]==1){
				for(int j=0; j<m; j++){
					arr[i-1][j]=-1;
				}
			}
		}
		for(int i=n+1; i<=n+m; i++){
			if(bin[i]==1){
				for(int j=0; j<n; j++){
					arr[j][i-n-1] = -1;
				}
			}
		}

		int x=0;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				if(arr[i][j]==1){
					x++;
				}
			}
		}
		if(x==k){
			c++;
		}

		bin[1]++;
		for(int i=1; i<n+m; i++){
			if(bin[i]==2){
				bin[i]=0;
				bin[i+1]++;
			}
		}
	}

	cout << c;


	
	

	return 0;
}

Measured memory_bytes: 3604
N,Q=map(int,input().split())
S=input()

aclist=[0 for i in range(N+1)]
for i in range(2,N+1):
    aclist[i]=aclist[i-1]+(1 if S[i-2]=='A' and S[i-1]=='C' else 0)

for j in range(Q):
    l,r=map(int,input().split())
    print(aclist[r]-aclist[l])

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

int main() {
  int N,K;
  cin >> N >> K;
  
  vector<int>H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  sort(H.begin(), H.end());
  
  long long sum = 0;
  for (int i = 0; i < N-K; i++) {
    sum += H.at(i);
  }
  cout << sum << endl;
}



Measured memory_bytes: 4052