akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
string calc(string s){
  //cout<<s<<endl;
  string res;
  Int n=s.size();
  if(s[0]=='a'){
    vector<Int> a(n*2);
    for(Int i=0,j=0;i<n;i++){
      if(s[i]=='b') continue;
      while(s[j]=='a') j++;
      a[i]=j++;
    }
    for(Int i=0;i<n;i++){
      if(s[i]=='x') continue;
      assert(s[i]=='a');
      res+="ab";
      for(Int j=i;j<a[i];j++)
	if(s[j]=='a') s[j]=s[a[j]]='x';
    }
  }else{
    for(Int k=0;k<n;k++){
      Int a=0,b=0;
      string tmp;
      for(Int i=0;i<n;i++){
	if(s[i]=='a'){
	  if(a>=k) tmp+=s[i];
	  a++;
	}else{
	  if(b>=k) tmp+=s[i];
	  b++;
	}
      }
      chmax(res,tmp);
    }
  }
  //cout<<res<<endl;
  return res;
}

signed main(){
  Int n;
  string s;
  cin>>n>>s;
  n*=2;
  vector<string> v;
  Int x[2]={1,-1};
  for(Int i=0;i<n;){
    Int j=i,k=x[s[j++]-'a'];
    while(j<n&&k!=0) k+=x[s[j++]-'a'];
    assert(k==0);
    v.emplace_back(calc(s.substr(i,j-i)));
    //cout<<i<<" "<<j<<endl;
    i=j;
  }
  reverse(v.begin(),v.end());
  string ans;
  for(string t:v)
    chmax(ans,t+ans);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
    if (a % b == 0) return b;
    else return gcd(b, a%b);
}
int main() {
    int n, k; cin >> n >> k;
    vector<int> v(n);
    int ggcd = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        ggcd = gcd(ggcd, v[i]);
    }
    for (int i = 0; i < n; i++) {
        if (k <= v[i] && (v[i]-k) % ggcd == 0) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 640
val = input()
q = "dream"
w = "dreamer"
e = "erase"
r = "eraser"

while True:
    if val.count(q+r) != 0:
        val = val.replace(q+r, "")
    elif val.count(q+e) != 0:
        val = val.replace(q+e, "")
    elif val.count(w) != 0:
        val = val.replace(w, "")
    elif val.count(q) != 0:
        val = val.replace(q, "")
    elif val.count(r) != 0:
        val = val.replace(r, "")
    elif val.count(e) != 0:
        val = val.replace(e, "")
    else:
        break
print("YES" if len(val) == 0 else "NO")


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


int main() {

    long long N;
    cin>>N;

    long long cop=(N-1);
    long long a = 0,ans = 0;
    for(long long i=1;i*i<=N;i++){
        if(N%i==0){
             a = N/i;
             ans = (a-1)+(i-1);
            if(cop >= ans){
                cop = ans;
            }
        }
    }
    cout<<cop<<endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main()
    {
        var a = ReadLine().Split().Select(int.Parse).ToArray();
        var b = ReadLine().Split().Select(int.Parse).ToArray();

        WriteLine((a[0] - b[0]) * (a[1] - b[1]));
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define clock_start       clock_t begin = clock();
#define clock_end         clock_t end = clock(); double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; cout << time_spent << endl;
#define PI 3.14159265358979323846264338327950288419716939937510
using namespace std;
ll n;
ll ans = 0;
int main(){
    cin >> n;
    for(ll i = 1; i <= n; i ++){
        ll x; cin >> x;
        while(x % 2 == 0){
            ans ++;
            x /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main () {
  vector<char> line(3) ;
  
  for (int i = 0 ; i < 3 ; i++ ) {
    cin >> line.at(i) ;
  }
  
  sort (line.begin(), line.end()) ;
  
  if (line.at(0) == 'a' && line.at(1)  == 'b' && line.at(2) == 'c' ){
    cout << "Yes" << endl ;
  } else {
    cout << "No" << endl ;
  }
  
}

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

namespace C___Rally
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var x = new int[n];
            var input = Console.ReadLine ().Split (' ');
            for (var i = 0; i < n; i++)
            {
                x[i] = int.Parse (input[i]);
            }
            var min = double.MaxValue;
            for (var i = x.Min(); i <= x.Max(); i++)
            {
                var a = 0.0;
                for (var j = 0; j < n; j++)
                {
                    a += Math.Pow (x[j] - i , 2);
                }
                min = Math.Min (min, a);
            }
            Console.WriteLine (min);
        }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <stack>
using namespace std;
#define MAX 1000006

stack <int> S;

void get_e(){
	char op[11];
	int a,b;
	while(~scanf("%s",op)){
		 
		if(isdigit(op[strlen(op)>1 ? 1 : 0])){
			
			S.push(atoi(op));
			
		}else{
			b = S.top();S.pop();
			a = S.top();S.pop();
			
			switch(op[0]){
				
				case '*':{
					S.push(a*b);
					break;}
				case '+':{
					S.push(a+b);
					break;}
				case '-':{
					S.push(a-b);
					break;}
			}
		}
	}
}

int main(){
   // freopen("in","r",stdin);
    get_e();
    printf("%d\n",S.top());
}

Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

string S;

int main(void) {
  cin >> S;
  
  int B=stoi(S)%100;  
  int A=(stoi(S)-B)/100;

  bool a=false, b=false;
  if(1<=A && A<=12) a=true;
  if(1<=B && B<=12) b=true;
  
  if(a==true && b==true) {cout << "AMBIGUOUS" << endl;}
  if(a==true && b==false) {cout << "MMYY" << endl;}
  if(a==false && b==true) {cout << "YYMM" << endl;}
  if(a==false && b==false) {cout << "NA" << endl;}
  return 0;
}


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

const int M = 2e5 + 100;
vector<int> e[M];
int a[M], ans[M];
multiset<int> st;

void dfs(int u, int pre) {
	st.insert(a[u]);
	int era = -1;
	auto it = st.lower_bound(a[u]);
	if (++it != st.end()) {
		era = *it;
		st.erase(it);
	}
	ans[u] = st.size();
	for (auto v : e[u]) {
		if (v != pre) {
			dfs(v, u);
		}
	}
	if (era != -1) st.insert(era);
	st.erase(st.find(a[u]));
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v;
		--u, --v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++) cout << ans[i] << "\n";
}

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

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

	sort(a,a+N,greater<int>());
	int alice=0,bob=0;
	for (int i = 0; i < N; i+=2){
		alice+=a[i];
	}
	for (int i = 1; i < N; i+=2){
		bob+=a[i];

	}
	cout<<alice-bob<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    string a, b, ans;
    cin >> a >> b;
    a = ' ' + a;
    b = ' ' + b;
    unordered_map<int, map<int, int>> dp;
    //map<int, map<int, ii>> tr;
    rep(i, 1, sz(a)) {
        rep(j, 1, sz(b)) {
            if (a[i] == b[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                //tr[i][j] = {i-1,j-1};
            }
            else {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
                //if (dp[i][j-1] > dp[i-1][j]) tr[i][j] = {i,j-1};
                //else tr[i][j] = {i-1,j};
            }
        }
    }
    int x = sz(a) - 1, y = sz(b) - 1;
    while (x >= 1 && y >= 1) {
        if (a[x] == b[y]) {
            ans.pb(a[x]);
            --x;--y;
            continue;
        }
        if (dp[x-1][y] > dp[x][y-1]) {
            --x;
        }
        else --y;
    }
    reverse(all(ans));
    cout << ans << "\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<>());
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += a[i/2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4788
/// wa ^3^

#pragma GCC optimize("O3")

#include<iostream>
#include<vector>
                           
using namespace std;

const int MOD = 1e9 + 7;

const int N = 2e5+10;

int cnt[N];

int main() {
    int n;
    cin >> n;
    int dp = -1;
    vector<int> a;
    for (int x; n--;) {
        scanf("%d", &x);
        if (x != dp)
            a.push_back(x);
        dp = x;            
    }
    dp = 1;
    for (int x : a) {
        cnt[x] += dp;
        if (cnt[x] >= MOD)
            cnt[x] -= MOD;
        dp = cnt[x];    
    }
    printf("%d", dp);
    return 0;
}



Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N,K;
    cin >> N >> K;
    int answer = log(N)/log(K);
    cout <<answer+1<< "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll H, W;
  cin >> H >> W;

  if(H==1 || W==1){
    cout << 1 << endl;
    return 0;
  }
  
  if((H*W)%2 == 0){
    cout << (H*W)/2 << endl;
  }else{
    cout << (H*W)/2+1 << endl;
  }
  
  return 0;
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int s;
	cin >> s;
	VI z={s};
	set<ll> st;
	st.insert(s);
	rep2(i,1,500){
		ll w=0;
		if(z[i-1]%2==0) w=z[i-1] /2;
		else w = z[i-1] * 3 +1;
		z.push_back(w);
		if(st.count(w)){
			cout << i+1 <<"\n";
			return 0;
		}
		st.insert(w);
	}
	
	for(auto x :z) printf("%d, ",x); puts("");
	//cout << a*b /2<< endl;
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int selection_sort(int *A, int N)
{
	int i, j, minj;
	int cnt = 0;
	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			int tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
			cnt++;
		}
	}
	return  cnt;
}

int main(int argc, char** argv)
{
	int i, num, arr[100];

	scanf("%d", &num);
	for (i = 0; i < num; i++) {
		scanf("%d", &arr[i]);
	}

	int cnt = selection_sort(arr, num);

	for (i = 0; i < num; i++) {
		if (i == num - 1) {
			printf("%d\n", arr[i]);
		}
		else {
			printf("%d ", arr[i]);
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
	string s, t;
 	int a = 0;
  	cin >> s;
  	cin >> t;
  	s = s + s;
  	for (int i = 0; i < s.size() - t.size() + 1; i++ ){
    	if (s.substr(i,t.size()) == t) a = 1;
    }
  	if (a == 1) cout << "Yes" << endl;
  	else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

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

ll arr1[100010];
ll segtree[400040];

void build(ll idx,ll left,ll right)
{
    if(left==right)
    {
        segtree[idx]=arr1[left];
        return;
    }
    ll mid=(left+right)/2;
    build(2*idx,left,mid);
    build(2*idx+1,mid+1,right);
    segtree[idx]=gcd(segtree[2*idx],segtree[2*idx+1]);
    return ;
}

ll query(ll idx,ll left,ll right,ll low,ll high)
{
    if(left>right || left>high || right<low)
    {
        return 0;
    }
    if(low<=left && right<=high)
    {
        return segtree[idx];
    }
    ll mid=(left+right)/2;
    ll val1,val2;
    val1=query(2*idx,left,mid,low,high);
    val2=query(2*idx+1,mid+1,right,low,high);
    return gcd(val1,val2);
}

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>arr1[i];
    }
    build(1,0,n-1);
    ll ans=NEGINF;
    ll val1,val2,store;
    for(ll i=0;i<n;i++)
    {
        val1=query(1,0,n-1,0,i-1);
        val2=query(1,0,n-1,i+1,n-1);
        store=gcd(val2,val1);
        ans=max(ans,store);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3072
import heapq

def dijkstra_heap(s):
    d = [float('inf')] * n
    used = [True] * n
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist, e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist, [e[0]+d[v], e[1]])
    return d

n,e,r = map(int, input().split())
std = [[int(x) for x in input().split()] for _ in range(e)]
edge = [[] for _ in range(n)]
for s, t, d in std:
    edge[s].append([d, t])
ans = dijkstra_heap(r)
for x in ans:
    if x==float('inf'): print('INF')
    else: print(x)



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

using namespace std;

using ll = long long;

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

    ll a = 100;
    ll cnt = 0;
    while (a < x) {
        a += a / 100;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int m;
  cin >> m;
  cout << 48-m << endl;
  return 0;
}


Measured memory_bytes: 256
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
L,M,N = [-1]*27,5,5
def calc(d,n)
  s,x = S[d],0
  n = D-d  if n > D-d
  t = (0..25).map { C[_1]*(d-L[_1])*n+s[_1] }
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    c = t[i]
    1 == n and next c
    l,L[i] = L[i],d
    c += calc(d+1,n-1) >> 5
    L[i] = l
    x < c ? x=c : c
  }
  ((x>0 ? x : t[i]) << 5) + i
end
D.times { p 1 + i=calc(_1,N)&31; L[i]=_1 }

Measured memory_bytes: 15264
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
mod = 10**9 + 7

# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

ls = makePrimeChecker(n)
# print(ls)

# def make_divisors(n):
#     divisors = []
#     for i in range(1, int(n**0.5)+1):
#         if n % i == 0:
#             divisors.append(i)
#             if i != n // i:
#                 divisors.append(n//i)

#     # divisors.sort()
#     return divisors

ans = 1
for p in range(2,len(ls)):
    if ls[p]:
        i = 0
        count = 0
        while n>=(p**i):
            i += 1
            count += n//(p**i)
        ans *= count + 1
    else:
        pass

# ans2 = make_divisors(factorial(n))
# print(ans2)

print(ans%mod)

Measured memory_bytes: 38640
#include <stdio.h>

#define LL long long

int main(){

	LL a,b,n,r;

	scanf("%lld%lld%lld",&a,&b,&n);

	if(n<b)r=n;

	else r=b-1;

	printf("%lld\n",r*a/b);

	return 0;

}


Measured memory_bytes: 1724
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if(err != nil) {
		panic(err)
	}
	return num
}

// 読み込みをfloat型へキャスト
func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	a := nextFloat()
	b := nextFloat()
	h := nextFloat()
	m := nextFloat()

	a_angle := h / 12 + (m / 60.0) / 12.0
	b_angle := m / 60
	angle := a_angle - b_angle
	// if angle < 0 {
	// 	angle *= -1
	// }
	// if angle > 180 {
	// 	angle -= 180
	// }
	c_pow := a * a + b * b - 2 * a * b * math.Cos(angle * 2 * math.Pi)
	fmt.Println(math.Sqrt(c_pow))
}

Measured memory_bytes: 1776
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    int N, n;
    cin >> N;
    string S;
    cin >> S;
    if(N % 2 == 1)cout << "No" << endl;
    else
    {
        n = N / 2;
        for(int i = 0; i < n; ++i)
        {
            if(S.at(i) != S.at(n + i))
            {
                cout << "No" << endl;
                return 0;
            }
            else continue;
        }
        cout << "Yes" << endl;
    }
    return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<cstdio>
using namespace std;
int main()
{
  set<string> s;
  string my="a";
  //  printf("?%s\n",my.c_str()); fflush(stdout);
  cout<<"?"<<my<<endl;
  char last=my[my.size()-1];
  s.insert(my);
  for(;;)
    {
      string em;
      cin>>em;
      if(em[0]!=last)
	break;
      if(s.find(em)!=s.end())
	break;
      s.insert(em);
      //      cout<<"em "<<em[em.size()-1]<<endl;
      my=em[em.size()-1];
      my+="a";
      int ii=0;
      while(s.find(my)!=s.end())
	{
	  if(my.size()<=2|| my[ii]>='z')
	    {
	      //	      cout<<"substr "<<my.substr(0,my.size()-2)<<endl;
	      my=my.substr(0,my.size()-1)+"aa";
	      // cout<<"my "<<my<<endl;
	      ii++;
	    }
	  else
	    my[ii]++;
	}
      s.insert(my);
      cout<<"?"<<my<<endl;
    }
  cout<<"!OUT"<<endl;
}

Measured memory_bytes: 1256
import sys
l = [0] * 3
n = int(input())
a = [int(i) for i in input().split()]
m = 1000000007
ans = 1
for i in a:
    if(l.count(i) == 3):
        ans = ans * 3 % m
        l[0] += 1
    elif(l.count(i) == 2):
        ans = ans * 2 % m
        l = [i+1, i, sum(l)-2*i]
    elif(l.count(i) == 1):
        l[l.index(i)] += 1
    else:
        print(0)
        sys.exit()

print(ans)

Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    int a[3][3],b[10],N;
    bool c[3][3];
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }

    cin >> N;
    
    rep(i,3){
        rep(j,3){
            c[i][j]=false;
        }
    }

    rep(i,N){
        int x;
        cin >> x;
        rep(j,3){
            rep(k,3){
            if(x==a[j][k]){
                c[j][k]=true;
                }
            }

        }
    }

    string  ans = "No";

    rep(i,3){
        if(c[i][0] and c[i][1] and c[i][2] ){
            ans ="Yes";
        }
    }

    rep(i,3){
        if(c[0][i] and c[1][i] and c[2][i] ){
            ans ="Yes";
        }
    }

    if(c[0][0] and c[1][1] and c[2][2]){
        ans = "Yes";
    }

    if(c[0][2] and c[1][1] and c[2][0]){
        ans = "Yes";
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fun(int *dp,int *arr,int n)
{
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    return dp[n-1];
}


int main()
{
    int arr[100005];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int dp[100005];
    for(int i=0;i<n+2;i++)
    dp[i]=-1;
    cout<<fun(dp,arr,n)<<endl;
    return 0;
}

Measured memory_bytes: 4420
import java.util.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long minMovePeople = sc.nextLong();
		for (int i = 1; i < 5; i++) {
		    long current = sc.nextLong();
		    if (current < minMovePeople) { 
		        minMovePeople = current;
		    }
		}
		BigDecimal result = new BigDecimal(N).divide(new BigDecimal(minMovePeople), 0, java.math.RoundingMode.UP);
		System.out.println(result.add(new BigDecimal("4")));
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int A,B;
  cin>>A>>B;
  if(B%A==0){cout<<A+B<<endl;}
  else{cout<<B-A<<endl;}
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }

  int ans = numeric_limits<int>::max();
  for (int i = 0; i < (1 << n); ++i) {
    vector<int> v;
    for (int j = 0; j < n; ++j) {
      if ((i >> j) & 1) v.push_back(j);
    }

    vector<int> p(m);
    int temp = 0;
    for (auto itr : v) {
      temp += c[itr];
      for (int k = 0; k < m; ++k) {
        p[k] += a[itr][k];
      }
    }

    bool flag = true;
    for (int k = 0; k < m; ++k) {
      if (p[k] < x) flag = false;
    }

    if (flag) {
      chmin(ans, temp);
    }
  }

  if (ans == numeric_limits<int>::max()) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int q[100] = {};
    for (int i = 2; i * i < n; i++) {
        if (q[i]) continue;
        for (int j = i * i; j < n; j += i) {
            q[j] = 1;
        }
    }
    
    int a[100] = {};
    for (int i = 1; i <= n; i++) {
        int t = i;
        for (int p = 2; p < n; p++) {
            if (q[p]) continue;
            while (t % p == 0) t /= p, a[p]++;
        }
    }

    int b[75 + 1] = {};
    for (int p = 2; p < n; p++) {
        for (int h = 0; h <= min(a[p] + 1, 75); h++) {
            b[h]++;
        }
    }

    int r = 0;
    r += b[5] * (b[5] - 1) / 2 * (b[3] - 2);
    r += b[3 * 5] * (b[5] - 1);
    r += b[5 * 5] * (b[3] - 1);
    r += b[3 * 5 * 5];

    cout << r << endl;

    return 0;
}

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

using namespace std;

//dp[i][j]: The maximum happiness that Taro gains 
//	in the first i days if he choses activity Aj on i-th day

//Initialization
//dp[1][0] = a1, dp[1][1]=a2, dp[1][2]=a3

//Transitions: Two choices Choices: (Choose Ai, Aj different from the last choice)
//dp[i] = dp[i-1]

//Order of Evaluation
//Row wise: Outer Loop should be the i loop or days loop

//Answer
//max(dp[N][0], dp[N][1], dp[N][2])

//Time Complexity
// O(N)

int dp[100005][3] = {0};
int A[100005];
int B[100005];
int C[100005];

const int INF = 1e9+5;

int main(){
	int N;
	cin >> N;
	for(int i=1; i<=N; i++){
		cin >> A[i] >> B[i] >> C[i];
	}

	for(int j=0; j<=2; j++){
		dp[1][0] = A[1];
		dp[1][1] = B[1];
		dp[1][2] = C[1];
	}

	for(int i=2; i<=N; i++){
		for(int j=0; j<=2; j++){
			for(int k=0; k<=2; k++){
				if(j!=k){
					if(j==0) dp[i][j] = max(dp[i][j], dp[i-1][k]+A[i]);
					if(j==1) dp[i][j] = max(dp[i][j], dp[i-1][k]+B[i]);
					if(j==2) dp[i][j] = max(dp[i][j], dp[i-1][k]+C[i]);
				}
			}
		}
	}

	int result =0;
	for(int j=0; j<=2; j++){
		result = max(result, dp[N][j]);
	}
	cout << result << endl;
}

Measured memory_bytes: 5972
<?php
solve1();

// 左子右兄弟表現の実装


// 自力解
function solve1(){
	$n = (int)trim(fgets(STDIN));

	$list = [];
	for ($i=0; $i < $n; $i++) { 
		$node = new TreeNode($i);
		$list[$node->getId()] = $node;
	}
	for ($i=0; $i < $n; $i++) { 
		$input = explode(' ', trim(fgets(STDIN)));
		$id = (int)$input[0];
		$k = (int)$input[1];
		for ($j=0; $j < $k; $j++) { 
			$list[$id]->addChild((int)$input[$j+2]);
			$list[(int)$input[$j+2]]->setParentId($id);
		}
	}
	for ($i=0; $i < $n; $i++) { 
		if ($list[$i]->getParentId() === -1) {
			// root
			$curId = $i;
			break;
		}
	}
	dfs($list, $curId, 0);
	$list[$curId]->setType('root');

	foreach ($list as $v) {
		echo 'node ' . $v->getId() . ': parent = ' . $v->getParentId() . ', depth = ' . $v->getDepth() . ', '  . $v->getType() . ', [' . implode(', ', $v->getChildren()) . ']' . PHP_EOL;
	}
}

function dfs($list, $id, $depth){
	$list[$id]->setDepth($depth);
	++$depth;
	if($list[$id]->hasChild()){
		$list[$id]->setType('internal node');
		$children = $list[$id]->getChildren();
		foreach ($children as $c) {
			dfs($list, $c, $depth);
		}
	}
}

/**
 * 
 */
class TreeNode
{
	private $id;
	private $parent_id = -1;
	private $children = [];
	private $depth = 0;
	private $type = 'leaf';

	function __construct($id)
	{
		$this->id = $id;
	}

	function setParentId($p_id){
		$this->parent_id = $p_id;
	}
	function addChild($c_id){
		$this->children[] = $c_id;
	}
	function hasChild(){
		return count($this->children) > 0;
	}
	function getId(){
		return $this->id;
	}
	function getParentId(){
		return $this->parent_id;
	}
	function getChildren(){
		return $this->children;
	}
	function setDepth($d){
		$this->depth = $d;
	}
	function addDepth(){
		$this->depth += 1;
	}
	function getDepth(){
		return $this->depth;
	}
	function setType($t){
		$this->type = $t;
	}
	function getType(){
		return $this->type;
	}
}


Measured memory_bytes: 77688
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int h,w;
  cin>>h>>w;
  int c[10][10]={};
  REP(i,10)REP(j,10)cin>>c[i][j];
  int a[300][300]={};
  REP(i,h)REP(j,w)cin>>a[i][j];

  REP(k,10)REP(i,10)REP(j,10)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);

  int ans=0;
  REP(i,h){
    REP(j,w){
      if(a[i][j]==1||a[i][j]==-1)continue;
      else{
        ans+=c[a[i][j]][1];
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
const int maxm=100005;
struct edge{
    int to,next;
}e[maxm<<1];
long long t1,t2,t3,tot;
int head[maxm<<1],m,n;
bool col[maxn][2];
inline void add(int u,int v){
    e[++tot].to=v;
    e[tot].next=head[u];
    head[u]=tot;
}
inline void dfs(int po,int colo){
    //cout<<po<<endl;
    col[po][colo]=1;
    for(register int i=head[po];i;i=e[i].next){
        if(col[e[i].to][colo^1]!=1)dfs(e[i].to,colo^1);
    }
}
int main(){
    cin>>n>>m;
    for(register int i=1;i<=m;++i){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    dfs(1,0);
    for(register int i=1;i<=n;++i){
        if(col[i][1]&&col[i][0])t1++;
        else if(col[i][1])t2++;
        else t3++;
    }
    //cout<<t1<<' '<<t2<<' '<<t3<<endl;
    printf("%lld",1LL*t2*t3+1LL*t1*t2+1LL*t1*t3+1LL*t1*(t1-1)/2-m);
    return 0;
}

Measured memory_bytes: 2944
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_Holiday solver = new A_Holiday();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_Holiday {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.nextLine();
            int ans = 0;
            if (s.equals("SUN")) ans = 7;
            else if (s.equals("MON")) ans = 6;
            else if (s.equals("TUE")) ans = 5;
            else if (s.equals("WED")) ans = 4;
            else if (s.equals("THU")) ans = 3;
            else if (s.equals("FRI")) ans = 2;
            else if (s.equals("SAT")) ans = 1;

            out.println(ans);


        }

    }
}



Measured memory_bytes: 21844
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(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)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i += 2)
	{
		int d = 0;
		for (int j = 1; j <= i; ++j)
		{
			if (i%j == 0)++d;
		}
		if (d == 8)++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum = 0;
    if(k - a <= 0)
    {
        sum = k;
    }
    else
    {
        sum += a;
        k -= a;
        if(k - b > 0)
        {
            k -= b;
        }
        else
        k = 0;
        sum -= k;
    }
    cout<<sum;
	return 0;
}


Measured memory_bytes: 3692
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        long[] a = sc.LongArray();

        if (a.Contains(0))
        {
            Console.WriteLine(0);
            return;
        }

        long answer = 1;
        for (int i = 0; i < n; i++)
        {
            try
            {
                checked
                {
                    answer *= a[i];
                    if (answer > 1000000000000000000)
                    {
                        Console.Write(-1);
                        return;
                    }
                }
            }
            catch (OverflowException)
            {
                Console.Write(-1);
                return;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 42672
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  vector<int> list(b);
  int past = 999999;
  int now = 999999;
  int first;
  int mini = -99999999;
  for (int i = 0; i < b; i++) {
    past = now;
    cin >> now;
    mini = max(mini,now-past);
    if (i == 0) {
      first = now + a;
    }
  }
  mini = max(mini,first-now);

  cout << a-mini;
  return 0;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


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

static const int64_t MAX = 1e5;
static vector<bool> seen(MAX * 2, false);

pair<int64_t, int64_t> dfs(const Graph &g, int64_t v, bool isX = true) {
    if(seen[v]) return {0, 0};
    seen[v] = true;

    pair<int64_t, int64_t> num = {0, 0};
    if(isX) num.first++;
    else    num.second++;

    for(int64_t next_v : g[v]) {
        pair<int64_t, int64_t> child = dfs(g, next_v, !isX);
        num.first += child.first;
        num.second += child.second;
    }

    return num;
}

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

    Graph g(MAX * 2);
    for(int64_t i = 0; i < n; i++) {
        int64_t x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y + MAX);
        g[y + MAX].push_back(x);
    }

    int64_t ans = 0;
    for(int64_t i = 0; i < MAX; i++) {
        pair<int64_t, int64_t> num = dfs(g, i);
        ans += num.first * num.second;
    }
    ans -= n;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

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

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    ll powi = 10;
    rep(i, 50) {
        if (powi > N) {
            break;
        }
        ans += N / powi;
        powi *= 5;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
from collections import deque


def solve(string):
    n, q, *abpx = map(int, string.split())
    check = [True] * (n + 1)
    t = [[] for i in range(n + 1)]
    c = [0] * (n + 1)
    d = deque([1])
    for a, b in zip(*[iter(abpx[:2 * n - 2])] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(abpx[2 * n - 2:])] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m - 1)])))


Measured memory_bytes: 100160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool sx=false,sy=false;
    if((s[0]=='0'&&s[1]<='9'&&s[1]>'0')||(s[0]=='1'&&s[1]<='2'))
    sx=true;
    if((s[2]=='0'&&s[3]<='9'&&s[3]>'0')||(s[2]=='1'&&s[3]<='2'))
    sy=true;
    if(sx&&sy)
    cout<<"AMBIGUOUS";
    else if(sx&&!sy)
    cout<<"MMYY";
    else if(!sx&&sy)
    cout<<"YYMM";
    else
    cout<<"NA";
	return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        Stack<char> stack = new Stack<char>();

        int answer = 0;

        foreach (var c in s)
        {
            if (stack.Count == 0)
            {
                stack.Push(c);
                continue;
            }

            var before = stack.Peek();

            if (c != before)
            {
                answer += 2;
                stack.Pop();
            }
            else
            {
                stack.Push(c);
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
char charin() {char c; cin>>c; return c;}
string strin() {string s; cin>>s; return s;}
ll MIN=-1000000000000000;
int main(){
    int n=in();
    vector<double> x(n),y(n);
    rep(i,n){
        x[i]=(double)in();
        y[i]=(double)in();
    }
    int N = 1000000;
    double pi = 3.1415926535897932384626;
    double e = 2 * pi/N;
    double ans=0;
    rep(i,N){
        double tmp=0;
        double t = e*i;
        rep(j,n){
            tmp+=max((double)0,cos(t)*x[j]+sin(t)*y[j]);
        }
        ans = max(ans,tmp);
    }
    printf("%.15f",ans);
}


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


using namespace std;

int m, n;
int a[110];
int sum;

bool compare(const int &a, const int &b) {
	return a > b;
}

int main()
{
	scanf("%d%d", &n, &m);
	sum = 0;
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(a[i]));
		sum = sum + a[i];
	}
	
	int limit = sum / (4 * m);
	if (sum % (4 * m) == 0)
		limit--;
		
	sort(a, a + n, compare);
	
	for (int i = 0 ; i < m ; i++) {
		if (a[i] <= limit) {
			printf("No\n");
			return 0;
		}
	}
		
	printf("Yes\n");
	
	
	return 0;
}

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

int main(){
  ll n,d;
  cin >> n >> d;
  ll s,x,y,i;
  s=0;
  for(i=0;i<n;i++){
    cin >> x >> y;
    if(x*x+y*y<=d*d){
      s++;
    }
  }
  
  cout << s << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};

int binary_search(vector<int> &v,int n,int k){
  int left = -1,right = n;
  while(right - left > 1){
    int mid = (left+right)/2;
    if(v[mid] > k)right = mid;
    else left = mid;
  }
  return right;
}


int main(){
  
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i,n)cin >> v[i];
  sort(ALL(v));
  P p;
  p.first = v[n-1];
  int r = binary_search(v,n,p.first/2);
  if(r < 1){
    p.second = v[r];
  }else{
    if(abs((double)p.first/2-v[r]) < abs((double)p.first/2-v[r-1])){
      p.second = v[r];
    }else{
      p.second = v[r-1];
    }
  }
  cout << p.first << " " << p.second << endl;

  


  return 0;
}


Measured memory_bytes: 640