akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long ll;
ll q, n, a, b;
int main()
{
	cin >> q;
	while (q--) {
		scanf("%lld %lld", &a, &b);
		if (a == b) {printf("%lld\n", 2 * a - 2); continue;}
		n = sqrt(a * b);
		if (n * n == a * b) n--;
		if (n * (n + 1) < a * b) printf("%lld\n", 2 * n - 1);
		else printf("%lld\n", 2 * n - 2);
	}
    return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    hs := make([]int, n)
    for i := range hs {
        fmt.Scan(&hs[i])
    }
    var ph, cnt, max int
    for i := range hs {
        if hs[i] <= ph {
            cnt++
            if cnt > max {
                max = cnt
            }
        } else {
            cnt = 0
        }
        ph = hs[i]
    }
    fmt.Println(max)
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  string t,p;
  cin>>t>>p;
  if(t.size()>=p.size())
  for(int i=0;i<t.size()-p.size()+1;i++){
    int f=0;
    for(int j=0;j<p.size();j++)if(t[i+j]!=p[j])f=1;
    if(f)continue;
    cout<<i<<endl;
  }
  return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  string s;
  cin >> s;

  string a = s.substr(0, 2);
  string b = s.substr(2, 2);

  if (a == "00") {
    if (b == "00") {
      cout << "NA" << endl;
      return 0;
    } else {
      if (toInt(b) >= 13) {
        cout << "NA" << endl;
      } else {
        cout << "YYMM" << endl;
      }
      return 0;
    }
  }

  if (b == "00") {
    if (toInt(a) >= 13) {
      cout << "NA" << endl;
      return 0;
    } else {
      cout << "MMYY" << endl;
      return 0;
    }
  }

  if (toInt(b) >= 13 && toInt(a) >= 13) {
    cout << "NA" << endl;
    return 0;
  }

  if (toInt(a) <= 12 && toInt(b) <= 12) {
    cout << "AMBIGUOUS" << endl;
    return 0;
  }

  if (toInt(a) >= 13) {
    cout << "YYMM" << endl;
    return 0;
  }

  if (toInt(b) >= 13) {
    cout << "MMYY" << endl;
    return 0;
  }

  cout << "NA" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ar[105][3];
int main() {
	int n;
	scanf("%d", &n);
	int sel = -1;
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &ar[i][0], &ar[i][1], &ar[i][2]);
		if (ar[i][2] != 0) sel = i;
	}
	if (sel == -1) {
		for (int i = 0; i < 105; i++) {
			for (int j = 0; j < 105; j++) {
				int val = 1;
				for (int k = 0; k < n; k++) {
					if (abs(i - ar[k][0]) + abs(i - ar[k][1]) < 1) {
						val = 0;
						break;
					}
				}
				if (val) {
					printf("%d %d 1\n", i, j);
					return 0;
				}
			}
		}
	}
	for (int i = 0; i < 105; i++) {
		for (int j = 0; j < 105; j++) {
			int h = ar[sel][2] + abs(i - ar[sel][0]) + abs(j - ar[sel][1]);
			int val = 1;
			for (int k = 0; k < n; k++) {
				if (k == sel) continue;
				if (ar[k][2] == 0 && abs(i - ar[k][0]) + abs(j - ar[k][1]) >= h) continue;
				if (ar[k][2] + abs(i - ar[k][0]) + abs(j - ar[k][1]) != h) {
					val = 0;
					break;
				}
			}
			if (val) {
				printf("%d %d %d\n", i, j, h);
				return 0;
			}
		}
	}
}

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

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

struct S {
	int lmin;
	int lf;
	int rmin;
	int rf;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	vector<S> ps;
	vector<S> ms;
	vector<S> zs;
	FOR_LT(i, 0, n) {
		string s; cin >> s;

		int mv = 0;
		int v = 0;
		FOR_LT(j, 0, s.size()) {
			if (s[j] == '(') v++;
			else v--;
			if (v < mv) mv = v;
		}
		int rmv = 0;
		{
			int rv = 0;
			FOR_DW(j, s.size() - 1, 0) {
				if (s[j] == ')') rv++;
				else rv--;
				if (rv < rmv) rmv = rv;
			}
		}

		S cs;
		cs.lmin = mv;
		cs.lf = v;
		cs.rmin = rmv;
		cs.rf = -v;

		if (v > 0) ps.push_back(cs);
		if (v < 0) ms.push_back(cs);
		if (v == 0) zs.push_back(cs);
	}

	sort(ps.begin(), ps.end(), [](const auto& lhs, const auto& rhs) {
		return lhs.lmin > rhs.lmin;
	});
	sort(ms.begin(), ms.end(), [](const auto& lhs, const auto& rhs) {
		return lhs.rmin > rhs.rmin;
	});

	int lv = 0;
	for (auto& p : ps) {
		if (lv + p.lmin < 0) {
			cout << "No" << endl;
			return 0;
		}
		lv += p.lf;
	}

	int rv = 0;
	for (auto& m : ms) {
		if (rv + m.rmin < 0) {
			cout << "No" << endl;
			return 0;
		}
		rv += m.rf;
	}

	if (lv != rv) {
		cout << "No" << endl;
		return 0;
	}

	for (auto& z : zs) {
		if (lv + z.lmin < 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 19044
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a_rev = list(reversed(a))
b_rev = list(reversed(b))


kill_m_1 = 0

for i in range(n):
    if a[i] <= b[i]:
        kill_m_1 += a[i]
        b[i] = b[i] - a[i]
        a[i] = 0
    
    else:
        a[i] = a[i] - b[i]
        kill_m_1 += b[i]
        b[i] = 0
    
    if b[i] != 0:
        
        if a[i+1] <= b[i]:
            kill_m_1 += a[i+1]
            b[i] = b[i] - a[i+1]
            a[i+1] = 0
    
        else:
            a[i+1] = a[i+1] - b[i]
            kill_m_1 += b[i]
            b[i] = 0
    
kill_m_2 = 0

for i in range(n):
    if a_rev[i] <= b_rev[i]:
        kill_m_2 += a_rev[i]
        b_rev[i] = b_rev[i] - a_rev[i]
        a_rev[i] = 0
    
    else:
        a_rev[i] = a_rev[i] - b_rev[i]
        kill_m_2 += b_rev[i]
        b_rev[i] = 0
    
    if b_rev[i] != 0:
        
        if a_rev[i+1] <= b_rev[i]:
            kill_m_2 += a_rev[i+1]
            b_rev[i] = b_rev[i] - a_rev[i+1]
            a_rev[i+1] = 0
    
        else:
            a_rev[i+1] = a_rev[i+1] - b_rev[i]
            kill_m_2 += b_rev[i]
            b_rev[i] = 0
    
print(max(kill_m_1,kill_m_2))


Measured memory_bytes: 18476
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll a, b;
  cin >> a >> b;

  cout << (a + b) / 2 + ((a + b) % 2) << endl;
  
  return 0;
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	string s;
	cin >> s;
	vector<vector<int>> G(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		if (a != b) G[b].push_back(a);
	}
	vector<vector<int>> cnt(2, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (auto to : G[i]) {
			cnt[s[to] != 'A'][i] += 1;
		}
	}
	vector<int> ok(N, 1);
	queue<int> q;
	for (int i = 0; i < N; i++) {
		if (cnt[0][i] == 0 || cnt[1][i] == 0) {
			q.push(i);
			ok[i] = false;
		}
	}
	while (!q.empty()) {
		auto v = q.front(); q.pop();
		for (auto to : G[v]) if (ok[to]) {
			cnt[s[v] != 'A'][to] -= 1;
			if (cnt[s[v] != 'A'][to] == 0) {
				q.push(to);
				ok[to] = false;
			}
		}
	}
	bool res = count(ok.begin(), ok.end(), 1) > 0;
	puts(res ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 12952
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a, b, c, x, y, min = INF;
	cin >> a >> b >> c >> x >> y;

	if(c*2*max(x, y) < min) min = c*2*max(x, y);
	if(a*x + b*y < min) min = a*x + b*y;
	if(x>=y && c*2*y + a*(x-y) < min) min = c*2*y + a*(x-y);
	if(x<y && c*2*x + b*(y-x) < min) min = c*2*x + b*(y-x);

	cout << min << endl;

	rtn 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,i,j;
    cin>>n;
    map<ll,ll> mp;
    ll ans = 1;
    for(i=n;i>=2;i--)
    {
        ll tmp = i;
        while(tmp%2==0)
        {
            tmp/=2;
            mp[2]++;
        }
        for(j=3;j*j<=n;j+=2)
        {
            while(tmp%j==0)
            {
                tmp/=j;
                mp[j]++;
            }
        }
        if(tmp>1) mp[tmp]++;
    }
    for(auto p: mp)
    {
        // cout<<p.first<<" "<<p.second<<"\n";
        ans = (ans*(p.second+1))%mod;
    }
    cout<<ans;
}


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


int main()
{
	int S, s, m, h,A;
	cin >> S;
	h = S / 3600;
	A = S - h * 3600;
	m = A / 60;
	s = A % 60;
	cout << h << ":" << m << ":" << s << endl;



    return 0;
}




Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ri register int
#define ll long long
using namespace std;
const int maxn=1e6+7;
char str[maxn];
int main()
{
	scanf("%s",str);
	putchar(str[0]);
	printf("%d",strlen(str)-2);
	putchar(str[strlen(str)-1]);
}

Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
res=0
dp=[[0 for i in range(n)]for i in range(n)]

ans=7641.9817824387

def add(s,i):
    global dp
    if i==n:
        pass
    elif s==i:
        add(s,i+1)
    else:
        dp[s][i]=(((a[i][0]-a[s][0])**2)+(a[i][1]-a[s][1])**2)**0.5
        add(s,i+1)

cnt=1
for i in range(n):
    add(i,0)
    cnt*=i+1

for i in range(n):
    res+=sum(dp[i])
    
abc=1
for i in range(n-1):
    abc*=i+1

print(res*abc/cnt)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
 
using namespace std;

int main(){

	int k;
	cin>>k;

	deque<pair<int,int> > q;
	q.push_front(make_pair(1,1));
	vector<bool> vis(k,false);
	while(!q.empty()){
		pair<int,int > p =q[0];
		q.pop_front();
		if(vis[p.first]) continue;
		vis[p.first]=true;
		
		if(p.first==0) {cout<<p.second<<endl;break;}
		q.push_back(make_pair((p.first+1)%k,p.second+1));
		q.push_front(make_pair((p.first*10)%k,p.second));
	}

	return 0;
}


Measured memory_bytes: 1024
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (x, y) = intList()

    0.until(x + 1).forEach { i ->
        val j = x - i
        if (i * 2 + j * 4 == y) {
            println("Yes")
            return
        }
    }
    println("No")
}


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

int main() {
  int H, W;
  cin >> H >> W;
  string cells[H];
  
  for (int i = 0; i < H; i++) {
    cin >> cells[i];
    for (int j = 0; j < W; j++) {
      if (cells[i][j] == '.') cells[i][j] = '0';
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (cells[i][j] != '#') continue;
      for (int h = -1; h <= 1; h++) {
        for (int w = -1; w <= 1; w++) {
          if (cells[i + h][j + w] == '#') continue;
          if (i + h >= 0 && i + h < H && j + w >= 0 && j + w < W)
            cells[i + h][j + w] += 1;
        }
      }
    }
  }
  
  for (int i = 0; i < H; i++) cout << cells[i] << endl;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)
INF = float("inf")


def main():
    K = int(input())
    S = list(input())
    if len(S) <= K:
        print(*S, sep="")
    else:
        answer = S[:K] + ["..."]
        print(*answer, sep="")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
n = int(input())

A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
ans  = 0
tmp = 0
for i in range(n):
  ans += B[A[i] -1]
for i in range(n-1):
  if A[i] +1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 10;

int main(void){
    ll S;
    ll S_test;
    ll S_digit[MAX_N];
    ll answer = 753;
    ll cnt = 0;

    cin >> S;
    S_test = S;

    while(S_test > 0){
        S_digit[cnt] = S_test % 10; 
        S_test /= 10; 
        cnt ++;
        }

    for(ll i = cnt - 1; i >= 2; i --){
        ll d100 = S_digit[i] * 100;
        ll d10  = S_digit[i - 1] * 10;
        ll d1   = S_digit[i - 2];
        ll a = d100 + d10 + d1;
        answer = min(answer, abs(a - 753)); 
    } 

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int G[511][511];
 
bool used[511];
 
int N,E,Q;
 
#define INF ( 1<<30)
 
void add_edge(int a,int b){
  G[a][b] = G[b][a] = 1;
}
 
void rem_edge(int a,int b){
  G[a][b] = G[b][a] = 0;
}
 
int dfs(int v,int t,int f){
  if( v == t ) return f;
  used[v] = true;
  for(int i=0;i<N;i++){
    if( !used[i] && G[v][i] > 0 ) {
      int d = dfs(i, t, min( f, G[v][i] ) );
      if( d > 0 ){
	G[v][i]--;
	G[i][v]++;
	return d;
      }
    }
  }
  return 0;
}
 
 
int max_flow(int s,int t,int F){
  int flow = 0;
  if( s == t ) return 0;
  for(int i=0;i<F;i++){
    memset(used,0,sizeof(used));
    int f = dfs(s,t,F);
    if( f == 0 ) return flow;
    flow += f;
  }
  return flow;
}

int main(){
  cin  >> N >> E >> Q;
  for(int i=0;i<E;i++){
    int e,f;
    cin >> e >> f;
    --e; --f;
    add_edge(e,f);
  }
  int rflow = max_flow(0,N-1,INF);
  for(int i=0;i<Q;i++){
    int m,a,b;
    cin >>m>> a>> b;
    --a; --b;
    if( m == 1 ){
      add_edge(a,b);
    } else {
      if( G[a][b] == 0 ) {
	int d = max_flow(a,b,1);
	if( d == 0 ){
	  max_flow(N-1,0,1);
	  max_flow(a,b,1);	
	  rflow--;
	}
      } else if( G[b][a] == 0 ){
	int d = max_flow(b,a,1);
	if( d == 0 ){
	  max_flow(N-1,0,1);
	  max_flow(b,a,1);
	  rflow--;
	}
      }
      rem_edge(a,b);
    }
    rflow += max_flow(0,N-1,INF);
    cout << rflow << endl;
  }
  // view();
   
}

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

using namespace std;

int main(){
  vector<int> t;
  int tmp;
  for (int i=0; i<3; i++){
    cin >> tmp;
    t.push_back(tmp);
  }
  sort(t.begin(), t.end());
  cout << t[0] + t[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

ll n, c2, c5;

int main() {
	scanf("%lld", &n);
	if (n & 1) {
		puts("0"); return 0;
	}
	ll tmp = n / 2;
	while (tmp) {
		c5 += tmp / 5;
		tmp /= 5;
	}
	printf("%lld\n", c5);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	ll N, M, L;
	scanf("%lld%lld", &N, &M);
	string s, t;
	L = lcm(N, M);
	cin >> s >> t;
	rep(i, 0, N) {
		if (L / N * i % (L / M) == 0 && s[i] != t[L / N * i / (L / M)]) {
			//printf("%d %lld\n",i,  L / N * i);
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n", L);
	return 0;
}


Measured memory_bytes: 512
while True:
    n, p = map(int, raw_input().split())
    if n == 0 and p == 0:
        break

    x = [0 for _ in range(n)]
    i = 0
    w = p
    while True:
        if w > 0:
            w -= 1
            x[i] += 1
        else:
            w += x[i]
            x[i] = 0
        if x[i] == p:
            break
        i = (i+1) % n

    print i


Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int k,t;cin >> k >> t;
    vi a(t);
    rep(i,t) cin >> a[i];
    sort(a.begin(),a.end());
    int l = 0,r = t-1;
    while(l!=r){
        if(a[r] - a[l] >0){
            a[r] -= a[l];
            ++l;
        }
        else if(a[r] - a[l] <= 0){
            a[l] -= a[r];
            --r;
        }
    }
    if(a[l]>0) cout << a[l]-1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
from itertools import product
def main():
    N = int(input())
    F = []
    for _ in range(N):
        f = list(map(int, input().split()))
        F.append(f)
    P = []
    for _ in range(N):
        p = list(map(int, input().split()))
        P.append(p)
    m = -10**21
    for i in product(range(2), repeat=10):
        if sum(i) == 0:
            continue
        r = 0
        for j in range(N):
            r += P[j][sum(ii&jj for ii, jj in zip(i, F[j]))]
        m = max(r, m)
    return m
print(main())


Measured memory_bytes: 9240
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;
	char c;
	char str[1024];
	string s;
	ll l;
	int nextInt(){
		scanf("%d", &n);
		return n;
	}
	ll nextLong(){
		scanf("%lld", &l);
		return l;
	}
	char nextChar(){
		scanf("%c", &c);
		return c;
	}
	string next(){
		scanf("%s", str);
		return string(str);
	}
	string nextLine(){
		getline(cin, s);
		return s;
	}
};
Input in;

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;
}
vi p, q, r, b;

vl d;

ll calc(int n){
	if(d[n]>0) return d[n];
	ll l = 1ll, h = 1ll, ret;

	if(r[n] >= 0) l = calc(r[n]);
	if(b[n] >= 0) h = calc(b[n]);

	ret = lcm(p[n] * l, q[n] * h) / p[n] + lcm(p[n] * l, q[n] * h) / q[n];

	return d[n] = ret;
}

int main(){
	while(1){
		int n = in.nextInt();
		if(n == 0) return 0;
		p.resize(n);
		q.resize(n);
		r.resize(n);
		b.resize(n);
		d = vl(n, 0LL);

		rep(i, n){
			p[i] = in.nextInt();
			q[i] = in.nextInt();
			r[i] = in.nextInt() - 1;
			b[i] = in.nextInt() - 1;
		}
		ll ans = 0LL;
		rep(i, n){
			ans = max(ans, calc(i));
		}

		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1228
#include <stdio.h>
int main(void)
{
  int n;
  int i;
  long int sum=0;
  scanf("%d", &n);
  for(i=1;i<=n;i++){
    if((i%3)!=0 && (i%5)!=0)
      sum=sum+i;
  }
  printf("%ld",sum);
  return 0;
}

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

int main() {
  long long a;
  cin >> a;

  pair<long long, long long> facts;
  for (int i = sqrt(a); i > 0; i--) {
	if (a % i == 0) {
	  facts.first = i;
	  facts.second = a / i;
	  break;
	}
  }

  cout << facts.first - 1 + facts.second - 1 << endl;

  return 0;
}


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

int main() {
   int N,M;
   cin >>N>>M;
   vector<int>vec(N);//⬅︎ここに書く
   int a,b;

   for(int j=0; j<M; j++){
   cin>>a>>b;
//cout<<a<<b<<endl; //⬅︎モニタ用
//  vector<int>vec(N); ⬅︎ここだと入力のたびに配列がM{0000}で初期化されてしまい配列にストアした値の加算ができない。
    for(int i=0; i<N; i++){
      if(a==i+1){
      vec.at(i)+=1;
      }
      else if(b==i+1){
      vec.at(i)+=1;
      }
     if(j==M-1){
      cout<<vec.at(i)<<endl;    
     } 
    }
  }
}   
/*
12
1100１回目
23
0110 加算して➡︎ 1210
14
1001 加算して➡︎2211
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef unsigned long long ll;
int ctoi(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){
    ll a;
    double b;
    cin >> a >> b;
    string s = to_string(b);
    char o = s.at(0);
    char p = s.at(2);
    char q = s.at(3);
    int va = 100*ctoi(o)+10*ctoi(p)+ctoi(q);
    cout << a*va/100 << endl;

}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int dp[999999];
    dp[0]=0;
    for(int i=0;i<999999;i++){
        dp[i]=i;
    }
    for(int i=0;i<=n;i++){
        for(int j=1;j<=6;j++){
            dp[i+(int) pow(6,j)]=min(dp[i]+1,dp[i+(int) pow(6,j)]);
        }
        for(int j=1;j<=5;j++){
            dp[i+(int) pow(9,j)]=min(dp[i]+1,dp[i+(int) pow(9,j)]);
        }
    }
    cout<<dp[n];
} 


Measured memory_bytes: 4096
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}
const kitaiti = (arr) => {
  let r=0
  for(const a of arr){
    r+=a*(a+1)/2/a
  }
  return r
}
const main = () => {
  const o = new AtCoder()
  let [n, m]=o.nn(2),g=0
  for(let i=0;i<m;i++){
    g+=o.n()
  }
  o.o(g>n?-1:n-g)
}
main();

Measured memory_bytes: 32468
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int A,B,C,D;
   cin >> A >> B >> C >> D;
   if(A+B == C+D){
     cout << "Balanced";
   }
   else if(A+B >= C+D){
     cout << "Left";
   }
   else{
     cout << "Right";
       }
   }


Measured memory_bytes: 256
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

R = I()
print(2*math.pi*R)


Measured memory_bytes: 71004
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)

ll F[100000];
ll Finv[100000];
ll mul_inv(ll a, ll b = MOD) {
	ll t1 = a, t2 = b, t3;
	ll v1 = 1, v2 = 0, v3;
	while (t2 != 1) {
		ll x = t1 / t2;
		t3 = t1 - x*t2;
		v3 = v1 - x*v2;
		t1 = t2, t2 = t3;
		v1 = v2, v2 = v3;
	}
	return (v2 + b) % b;
}
ll Po(ll a, ll b) {
	if (b < 0 || b > a) return 0ll;

	ll rv = F[a] * Finv[a-b] % MOD;
	return rv;
}

int in[100000];

ll dp[65536];
int main() {
	int i, j;
	F[0] = 1;
	for (i = 1; i <= 70000; i++) F[i] = F[i - 1] * i % MOD;
	for (i = 0; i <= 70000; i++) Finv[i] = mul_inv(F[i]);

	int N, M, k;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		int t;
		scanf("%d", &t);
		in[i] = ((1 << N) - t) + 1;
	}
	sort(in, in + M);

	dp[0] = 1;
	for (i = 0; i < M; i++) {
		int x = in[i];
		for (j = (1<<N)-1; j >= 0; j--) {
			for (k = 0; k < N; k++) {
				if (j & (1 << k)) continue;
				ll v = Po(x - j - 1, (1 << k) - 1) * dp[j] % MOD;
				v = v * (1 << k) % MOD;
				dp[j | (1 << k)] = (dp[j | (1 << k)] + v) % MOD;
			}
		}
	}

	ll ans = 0;
	for (i = 0; i < (1 << N); i++) {
		ll t = (1 << N) - 1 - i;

		ll v = dp[i] * F[t] % MOD;
		for (j = 0; j < N; j++) if (i & (1 << j)) v *= -1;
		ans = (ans + v + MOD) % MOD;
	}

	//for (i = 0; i < N; i++) ans = ans * F[(1 << i)] % MOD;
	ans = ans * (1 << N) % MOD;
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
struct Point{double x,y;};

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

    vector<Point> p(N);
    rep(i,N){
        cin>>p[i].x>>p[i].y;
    }
    if(N%2==1){
        cout<<"NA"<<endl;
        return 0;
    }

    Point G={(p[0].x+p[N/2].x)/2.0 , (p[0].y+p[N/2].y)/2.0};
    bool NA=false;
    rep1(i,N/2-1){
        Point tmp = {(p[i].x+p[i+N/2].x)/2.0 , (p[i].y+p[i+N/2].y)/2.0};
        if(tmp.x!=G.x || tmp.y!=G.y){
            NA = true;
        }
    }
    if(NA){
        cout<<"NA"<<endl;
    }else{
        printf("%.5f %.5f\n",G.x,G.y);
    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;


void func(int num,vector<int>v)
{
    while(num>0){
        v.push_back(num % 10);
        num /= 10;
    }
}



int main(){
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for (int i = 0; i < K; i++)
    {
        cin >> D[i];
    }
    int cnt = N;
    while (1)
    {
        vector<int> v;
        int copy = cnt;
        while (copy > 0)
        {
            v.push_back(copy % 10);
            copy /= 10;
        }

        bool flag = true;
       // if(cnt==N)
        //cerr << v[3] << endl;
        for (int i = 0; i < v.size(); i++)
        {   
            for (int j = 0; j < D.size(); j++)
            {
                if(v[i]==D[j]){
                    flag = false;
                    break;
                }
            }
        }
            if(flag){
                cout << cnt << endl;
                return 0;
            }
        
        cnt++;

    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin>>n;
    ll arr[n+2];
    for(ll i = 0;i<n;i++){
        cin>>arr[i];
    }
ll ct = 0;
 for(ll i = 1;i<n;i++){
      ll t = (arr[i] - arr[i-1]);
      if( t == -1){
          if(ct == 1){
              cout<<"No"<<"\n";
              return 0;
          }
          ct = 1;
      }
if(t<-1){
    cout<<"No";
    return 0;
}
if(t>0){
ct = 0;
}

    }


    cout<<"Yes";


}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-


import sys
import math

#1整数
#n = int(input())

#空白区切り2整数
a ,b,c = list(map(int, input().split()))

#空白区切りリスト
#a=list(map(int, input().split()))
ret = int(min(c , b/a))
print(ret)




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

int main(){
    int x;
    cin>>x;
    int ans=1,now=1;
    while(x>now){
        now+=ans+1;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int k(int a,int b) {
	return (a * (a - 1) + b * (b - 1))/2;
}
int main() {
	int n, m;
	std::cin >> n >> m;
	std::cout << k(n, m) << std::endl;
	return 0;
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
const ll INF = 1LL << 50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N, M;
  cin >> N >> M;
  VL a(N), b(N), c(M + 1), d(M + 1);
  REP(i, N) {
    cin >> a[i] >> b[i];
  }
  c[0] = d[0] = INF;
  NREP(i, M) {
    cin >> c[i] >> d[i];
  }

  REP(i, N) {
    ll mindist = INF;
    ll point = 0;
    NREP(j, M) {
      ll dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (dist < mindist) {
        point = j;
        mindist = dist;
      }
    }
    cout << point << endl;
  }

  return 0;
}

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

using namespace std;

int n, m, cnt;
int a[10] = {0, 1};
vector<int> v[10];

void f(int p, int q)
{
    if(q == n)
    {
        cnt++;
        return;
    }
    for(int i = 0; i < v[p].size(); i++)
    {
        if(!a[v[p][i]]) {
            a[v[p][i]]++;
            f(v[p][i], q + 1);
            a[v[p][i]]--;
        }
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++)
    {
        int t1, t2;
        scanf("%d%d", &t1, &t2);
        v[t1].push_back(t2);
        v[t2].push_back(t1);
    }
    f(1, 1);
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 256
//In the name of ALLAH

#include<bits/stdc++.h>
using namespace std;
#define nn '\n'
#define pb push_back
#define F(i, n) for(int i = 0; i < n; ++i)
#define Fe(i, n) for(auto i: n)
#define  ll long long int



int main(){
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n; cin>>n;
	cout<<arr[n - 1]<<"\n";
	return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define hmm "\n"
#define test() int t; cin>>t; while(t--)
#define ll long long int
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll power(int a, int b){
    long result=1;
    while(b>0){
        if(b%2==1) result*=a;
        a *=a;
        b/=2;
    }
    return result;
}
void solve()
{
    int n;
    cin>>n;
    
    cout<<power(n,3);
}
int main()
{
    fastIO
    //test()
    solve();
}


Measured memory_bytes: 3656
function Main(input) {
    var N = input[0].split('');
    var last = N[N.length - 1];
    
    var result = 'bon';
    if (last === '2' ||
        last === '4' ||
        last === '5' ||
        last === '7' ||
        last === '9') {
        result = 'hon';
    } else if (last === '0' ||
    last === '1' ||
    last === '6' ||
    last === '8') {
        result = 'pon';
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<en;
            return;
        }
        a-=d;
    }
    cout<<"No"<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
char a[3];
int main(void){
    int i,j;
    char x;
    j=0;
    while(1){
        i=0;
        while(1){
            scanf("%c",&x);
            if(x==' ' || x=='\n'){
                break;
            }else if(i==0){
                a[j]=x-32;
            }
            i++;
        }
        j++;
        if(j==3){
            break;
        }
    }
    printf("%c%c%c\n",a[0],a[1],a[2]);
    return 0;
}



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

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var n = ReadLong();
		var sqrt = (long)Math.Sqrt(n);
		var line = new int[sqrt + 1];

		for (var i = 2L; i <= sqrt; i++) {
			if (line[i] == 0) {
				if ((n % i) == 0) {
					n /= i;
					line[i] = 1;
					for (var a = i << 1; a <= sqrt; a += i) {
						line[a] = -1;
					}
				}
				while ((n % i) == 0) {
					n /= i;
					line[i]++;
				}
				if (n == 1) break;
			}
		}
		var cnt = 0L;
		for (var i = 2L; i <= sqrt; i++) {
			for (var a = 1; line[i] >= a; a++) {
				line[i] -= a;
				cnt++;
			}
		}
		if (n != 1) cnt++;
		Console.WriteLine(cnt);
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 30612
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int number[100001],i,a;
  for(i=0;i<100001;i++)
    number[i]=0;
  long sum=0;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    number[a]++;
    sum+=(long)a;
  }
  int q;
  scanf("%d",&q);
  int x[q+1],y[q+1];
  for(i=0;i<q;i++)
    scanf("%d%d",&x[i],&y[i]);
  for(i=0;i<q;i++){
    sum+=(long)number[x[i]]*((long)y[i]-(long)x[i]);
    number[y[i]]+=number[x[i]];
    number[x[i]]=0;
    printf("%ld\n",sum);
  }
  return 0;
}


Measured memory_bytes: 2868
import java.awt.geom.*;
import java.util.*;


public class Main {
	
	double EPS = 1.0e-08;
	
	//0649 start
	//0710 sstop
	public class Point3D{
		double x,y,z;
		public Point3D(double x, double y, double z) {
			this.x = x;this.y = y;this.z = z;
		}
		
		private double dot(Point3D p){
			return this.x*p.x+this.y*p.y+this.z*p.z;
		}
		
		private double norm(){
			return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);
		}
		//３次元ベクトルの角度
		private double angle(Point3D p2){
			double a = this.dot(p2);
			double b = this.norm();
			double c = p2.norm();
			return Math.acos(a/(b*c));
		}
	}
	Point3D [] mlist;
	double [] mrad;

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Point3D [] stars = new Point3D[n];
			for(int i = 0; i < n; i++){
				stars[i] = new Point3D(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
			}
			int m = sc.nextInt();
			mlist = new Point3D[m];
			mrad = new double[m];
			for(int i = 0; i < m; i++){
				mlist[i] = new Point3D(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
				mrad[i] = sc.nextDouble();
			}
			
			int ans = 0;
			for(int i = 0; i < n; i++){
				boolean isfind = false;
				isfind = findStar(stars[i]);
				if(isfind){
					ans++;
				}
			}
			System.out.println(ans);
		}
		
	}

	private boolean findStar(Point3D p) {
		int len = mlist.length;
		for(int i = 0; i < len; i++){
			double mRad = mrad[i];
			double nRad = p.angle(mlist[i]);
//			System.out.println("nrad = " + nRad);
//			System.out.println("mrad = " +mRad);
			if(mRad + EPS> nRad){
				return true;
			}
		}
		return false;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
sx,sy,tx,ty;
main(i){
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	for(i=0;i<ty-sy;i++)putchar_unlocked('U');
	for(i=0;i<tx-sx;i++)putchar_unlocked('R');
	for(i=0;i<ty-sy;i++)putchar_unlocked('D');
	for(i=0;i<tx-sx;i++)putchar_unlocked('L');
	putchar_unlocked('L');
	for(i=0;i<ty-sy;i++)putchar_unlocked('U');
	putchar_unlocked('U');
	putchar_unlocked('R');
	for(i=0;i<tx-sx;i++)putchar_unlocked('R');
	putchar_unlocked('D');
	putchar_unlocked('R');
	for(i=0;i<ty-sy;i++)putchar_unlocked('D');
	putchar_unlocked('D');
	putchar_unlocked('L');
	for(i=0;i<tx-sx;i++)putchar_unlocked('L');
	putchar_unlocked('U');
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, k;
	cin >> n >> k;
	int res = 0;
	while (n--) {
		int h;
		cin >> h;
		res += h >= k;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << ((c > min(a,b) && c < max(a,b)) ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256