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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}


ll dist[1010][1010];

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

    ll H, W;
    cin >> H >> W;

    queue<pll> qu;

    REP(i, H){
    	string s;
    	cin >> s;
    	REP(j, W){
    		if(s[j] == '#'){
    			dist[i][j] = 0;
    			qu.push({i, j});
    		}else{
    			dist[i][j] = -1;
    		}
    	}
    }
    
    vector<ll> dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
    while(!qu.empty()){
    	auto tmp = qu.front();qu.pop();
    	ll x = tmp.first;
    	ll y = tmp.second;
    	REP(i, 4){
    		ll nx = x + dx[i];
    		ll ny = y + dy[i];

    		if(nx < 0 || nx > H-1 || ny < 0 || ny > W-1) continue;
    		if(dist[nx][ny] == -1){
    			qu.push({nx, ny});
    			dist[nx][ny] = dist[x][y] + 1;
    		}
    	}
    }

    ll res = -1;
    REP(i, H)REP(j, W) res = max(res, dist[i][j]);
    cout << res << endl;

    /*
    REP(i, H){
    	REP(j, W){
    		cout << dist[i][j] << " ";
    	}
    	cout << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 24500
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<cstring>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;



#define MAX_V 10000
#define INF 10000000000

struct edge{int to;long long cap,rev;};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from,int to,long long cap)
{
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s)
{
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty())
	{
		int v = que.front();que.pop();
		for(int i = 0;i < G[v].size();++i)
		{
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0)
			{
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v ,int t,long long f)
{
	if(v == t)return f;
	for(int &i = iter[v];i < G[v].size() ;++i)
	{
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to])
		{
			long long d = dfs(e.to,t,min(f,e.cap));
			if(d > 0)
			{
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

long long Dinic(int s,int t)
{
	long long flow = 0;
	while(1)
	{
		bfs(s);
		if(level[t] < 0)return flow;
		memset(iter,0,sizeof(iter));
		long long f;while((f = dfs(s,t,INF)) > 0)flow += f;
	}
}

int main()
{
	int v,e;cin >> v >> e;
	REP(i,e)
	{
		int a,b,c;cin >> a >> b >> c;
		add_edge(a,b,c);
	}
		
	cout << Dinic(0,v-1) << endl;
	
	return 0;
}

Measured memory_bytes: 3520
x, n =map(int, input().split())
l = list(map(int, input().split()))
if n == 0:
    print(x) 
else:
    for i in range(n//2 + 2):
        if not(x - i in l):
            print(x-i)
            break
        elif not (x + i in l):
            print(x+i)
            break
            

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

constexpr int MAXN = 1e5 + 42;

int par[MAXN];
int sz[MAXN];
bool vis[MAXN];
int pX[MAXN], pY[MAXN];
vector<int> X[MAXN], Y[MAXN];
set<int> Xs[MAXN], Ys[MAXN];

int root(int v) {
  return par[v] == v ? v : (par[v] = root(par[v]));
}

void merge(int v, int u) {
  v = root(v);
  u = root(u);
  par[v] = u;
}

int main() {
  iota(par, par + MAXN, 0);

  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> pX[i] >> pY[i];
    X[pX[i]].push_back(i);
    Y[pY[i]].push_back(i);
  }
  for (int i = 1; i < MAXN; i++) {
    if (!X[i].empty()) {
      int v = X[i].front();
      for (int u : X[i]) {
        merge(v, u);
      }
    }
    if (!Y[i].empty()) {
      int v = Y[i].front();
      for (int u : Y[i]) {
        merge(v, u);
      }
    }
  }

  for (int i = 1; i < MAXN; i++) {
    int v = root(i);
    Xs[v].insert(pX[i]);
    Ys[v].insert(pY[i]);
    sz[v]++;
  }

  ll res = 0;
  for (int i = 1; i < MAXN; i++) {
    int v = root(i);
    if(!vis[v]) {
      vis[v] = true;
      res += 1ll * Xs[v].size() * Ys[v].size() - sz[v];
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 24832
A,B,M= map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
mina = min(a)
minb = min(b)
cand = [mina + minb]
for i in range(M):
    x,y,c= map(int,input().split())
    cand.append(a[x-1] + b[y-1] -c)

print(min(cand))


Measured memory_bytes: 73324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int dp[110][4][4][4];
// A:0 C:1 G:2 T:3
int main() {
  int N; cin >> N;
  dp[0][3][3][3] = 1;
  rep(i, 0, N) rep(j, 0, 4) rep(k, 0, 4) rep(l, 0, 4) {
      rep(d, 0, 4){
        if(k == 0 && l == 2 && d == 1) continue; // *AGC
        if(j == 0 && l == 2 && d == 1) continue; // A*GC
        if(j == 0 && k == 2 && d == 1) continue; // AG*C
        if(k == 2 && l == 0 && d == 1) continue; // *GAC
        if(k == 0 && l == 1 && d == 2) continue; // *ACG
        dp[i + 1][k][l][d] += dp[i][j][k][l];
        dp[i + 1][k][l][d] %= mod;
      }
    }
  int ans = 0;
  rep(j, 0, 4) rep(k, 0, 4) rep(l, 0, 4) {
    ans += dp[N][j][k][l];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;
const int MAXN = 2000 + 5;
vector<vector<ll>> dp(MAXN, vector<ll>(MAXN, 0));

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int k = 1; k < MAXN; k++) {
		dp[1][k] = k;
	}
	for (int s = 1; s < MAXN; s++) {
		dp[s][1] = 1;
	}
	for (int s = 2; s < MAXN; s++) {
		for (int k = 2; k < MAXN; k++) {
			dp[s][k] = (dp[s][k - 1] + dp[s - 1][k]) % MOD;
		}
	}
	int S;
	cin >> S;
	ll ans = 0;
	for (int i = 1; i < S; i++) {
		ans += dp[max(S - 3*i, 0)][i];
		if (S - 3 * i == 0) ans += 1;
		//cout << i << " " << S - 3*i << " = " << dp[max(S - 3*i, 0)][i] << endl;
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 35092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {

	int K, X;
	cin >> K >> X;
	veci vec;
	for(int i= X - K + 1; i <= X + K - 1; i++) {
		vec.push_back(i);
	}
	rep(i, vec.size()) {
		cout << vec[i] << " ";
	}
	cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>

typedef long long LL;

const int N = 305;

inline int readInt() {
  int ans = 0, c, f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f *= -1;
  do ans = ans * 10 + c - '0';
  while (isdigit(c = getchar()));
  return ans * f;
}

int n, k, m, C[N][N], f[N][N], S[N][N];

int main() {
  n = readInt();
  k = readInt();
  m = readInt();
  for (int i = 0; i <= n; ++i)
    for (int j = C[i][0] = 1; j <= i; ++j)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % m;
  for (int j = 0; j <= k; ++j)
    f[0][j] = 1, S[0][j] = (j + 1) % m;
  for (int i = 1; i <= n; ++i) {
    S[i][0] = f[i][0] = 0;
    for (int j = 1; j <= k; ++j) {
      f[i][j] = 0;
      for (int t = 0; t < i; ++t)
        f[i][j] = (f[i][j] + (LL)C[i - 1][t] * S[t][j - 1] % m * f[i - 1 - t][j]) % m;
      S[i][j] = (S[i][j - 1] + f[i][j]) % m;
    }
  }
  printf("%d\n", f[n][k]);
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1e3 + 5;

int W, H, A, B;

int main() {
	scanf("%d%d%d%d", &W, &H, &A, &B);
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			putchar('0' ^ (i < B) ^ (j < A));
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int N,b,f;
string s[2];
long long ans=1LL;
int main(){
    cin>>N>>s[0]>>s[1];
    for(int i=0;i<N;i++){
        if(s[0][i]==s[1][i]){
            if(f==0)ans*=3,f=1;
            else if(b==0)ans*=2;
            else ans*=1;
            b=0;
        }
        else{
            i++;
            if(f==0)ans*=6,f=1;
            else if(b==0)ans*=2;
            else ans*=3;
            b=1;
        }
        ans%=1000000007;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  vector<vector<char>> ans;
  rep(i,50) ans.emplace_back(vector<char>(100,'#'));
  rep(i,50) ans.emplace_back(vector<char>(100,'.'));
  --a; --b;
  rep(i,50){
    if(a==0)break;
    if(i%2)continue;
    rep(j,100){
      if(a==0)break;
      if(j%2)continue;
      ans[i][j] = '.';
      --a;
    }
  }
  rep(i,50){
    if(b==0)break;
    if(i%2)continue;
    rep(j,100){
      if(b==0)break;
      if(j%2)continue;
      ans[99-i][j] = '#';
      --b;
    }
  }
  cout << "100 100" << endl;
  rep(i,100){
    rep(j,100) cout << ans[i][j]; cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	if(b/a >= c)
		cout << c;
	else if(a > b)
		cout << 0;
	else if(b/a < c)
		cout << b/a;
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  
  bool flag=false;
  int a,b;
  if(s.size()==2){
    if(s.at(0)==s.at(1)){
      flag=true;
      a=1;b=2;
    }
  }
  else{
  	for(int i=0;i<s.size()-2;i++){
    	if(s.at(i)==s.at(i+1)||s.at(i)==s.at(i+2)||s.at(i+1)==s.at(i+2)){
	      flag=true;
	      a=i+1;
	      b=i+3;
	      break;
	    }
	  }
  }
  if(flag){
    cout<<a<<" "<<b<<endl;
  }else{
    cout<<-1<<" "<<-1<<endl;
  }
}

Measured memory_bytes: 512
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define sf(a)		 scanf("%d",&a)
#define sfl(a)		scanf("%lld",&a)
#define sff(a,b)	 scanf("%d %d",&a,&b)
#define sffl(a,b)	scanf("%lld %lld",&a,&b)
#define pb(a)         push_back(a)
#define loop0(i,n)          for(int i=0;i<n;i++)
#define loop1(i,n)          for(int i=1;i<=n;i++)
#define loopab(a,b)       for(int i=a;i<=b;i++)
#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	int i,n,m,s=0,c=0;
	cin>>n>>m;
	db x,y;
	y = (db)1.0/(4.0*m);
	vector<int>v(n);
	loop0(i,n){
		cin>>v[i];
		s += v[i];
	}
	loop0(i,n){
		if(c>=m) break;
		x = (db)v[i]/s;
		if(x>=y)c++;
		}
	if(c>=m) cout<<"Yes\n";
	else cout<<"No\n";
	
	return 0;
}

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

int main() {
  int N;
  double ans;
  cin >> N;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i);
  }
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < i ; j++) {
      ans += sqrt( (x.at(i)-x.at(j))*(x.at(i)-x.at(j)) + (y.at(i)-y.at(j))*(y.at(i)-y.at(j)) );
    }
  }
  ans *= 2;
  ans /= N;
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 256
line = gets
answers = Array.new(4,0)

while line = gets
    line = line.chomp
    if line == "AC"
        answers[0] += 1
        
    elsif line == "WA"
        answers[1] += 1
    elsif line == "TLE"
        answers[2] += 1
    else
        answers[3] += 1
    end
end

puts "AC x #{answers[0]}"
puts "WA x #{answers[1]}"  
puts "TLE x #{answers[2]}"  
puts "RE x #{answers[3]}"  

Measured memory_bytes: 14368
a, b, c = map(int, input().split())

x = []
x.append(a)
x.append(b)
x.append(c)

if 7 in x:
    x.remove(7)
    if 5 in x:
        x.remove(5)
        if 5 in x:
            print('YES')
            exit()

print('NO')

Measured memory_bytes: 3060
n = int(input())
w = []
for i in range(n):
    w.append(str(input()))
ans = "Yes"

for i in range(1, n):
    if w[i-1][-1] != w[i][0]:
        ans = "No"
        break

if len(set(w)) != len(w):
    ans = "No"

print(ans)

Measured memory_bytes: 3064
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<vector<ll>> a(n, vector<ll>(n)); cin >> a;
  vector<ll> score(1LL<<n);
  rep(i, 1LL<<n) {
    rep(j, n) {
      if (i>>j & 1) {
        rep(k, j+1, n) {
          if (i>>k & 1) {
            score[i] += a[j][k];
          }
        }
      }
    }
  }
  vector<ll> dp(1LL<<n);
  rep(i, 1LL<<n) {
    ll j = i;
    while (j > 0) {
      chmax(dp[i], dp[i^j] + score[j]);
      j = (j-1) & i;
    }
  }
  cout << dp[(1LL<<n)-1] << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fast_io ios :: sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main() {
	fast_io;
	string s;
    cin>>s;
    int count=0;
    vector<char>letter('Z');
     for(int i=0;i<s.size();i++){
          letter[s[i]]++;
     }
     for(int i:letter){
      if(i>=2)count++;
   if(count==2){
cout<<"Yes";
return(0);
   }
     }
        cout<<"No";
	return(0);
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n; cin>>n;
  int c=0;
  rep(i,105,n+1){
    int d=0;
    rep(j,1,i+1){
      if(i%j==0) d++;
    }
    if(d==8) c++;
    i++;
  }
  co(c);
  
  return 0;
}

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

int f(int n) {
  if (n % 2 == 0) {
    return n / 2;
  }
  else {
    return 3 * n + 1;
  }
}
  
int main() {
  int s;
  cin >> s;
  int m;
  vector<int> a;
  bool finished = false;
  while (true) {
    for (int i = 0; i < a.size(); i++) {
      if (s == a.at(i)) {
        finished = true;
        break;
      }
    }
    if (finished) {
      break;
    }
    a.push_back(s);
    s = f(s);
    m++;
  }
  /*for (int i = 0; i < a.size(); i++) {
    cout << a.at(i) << endl;
  }*/
  cout << m + 1 << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(int x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x=read(),y=read(),ans=0;
    if((!x)||(!y))
    {
        if(x>y)
            write(abs(x-y)+1);
        else 
        	write(abs(x-y));
        putchar('\n');
		return 0;
    }
    if(x>0&&y>0)
    {
        if(x<y)
        	write(abs(x-y));
        else
        	write(abs(x-y)+2);
        putchar('\n');
		return 0;
    }
    if(x>0&&y<0||x<0&&y>0)
	{
		write(abs(abs(x)-abs(y))+1);
		putchar('\n');
		return 0;
	}
    if(x<0&&y<0)
    {
        if(x==y)
        	write(0);
        if(x>y)
			write(abs(abs(x)-abs(y))+2);
        if(x<y)
			write(abs(abs(x)-abs(y)));
        putchar('\n');
		return 0;
    }
	putchar('\n');
	return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    int f = 0;
    if (a > 12) {
        f = b;
    } else if (a <= 12 && a >= 6) {
        f = b /2;
    }

    cout << f << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int L = s.length();
		boolean update = true;
		String[] words = {"dream", "dreamer", "erase", "eraser"};
		while(update) {
			update = false;
			for(String word : words) {
				if(L>=word.length() && s.substring(L-word.length(), L).equals(word)) {
					L -= word.length();
					update = true;
				}
			}
		}
		
		System.out.println(L==0 ? "YES" : "NO");
		sc.close();
	}
}


Measured memory_bytes: 28068
<?php
    $room = array_pad(array(),10,0);
    for($i = 0; $i < 4; $i++){
        for($j = 0; $j < 3; $j++){
            $building[$i][$j] = $room; 
        }   
    }
    $bar = str_repeat("#",20);

    $record_num = trim(fgets(STDIN));
    
    for($i = 0; $i < $record_num; $i++){
        list($b, $f, $r, $v) = explode(" ",trim(fgets(STDIN)));
        $building[--$b][--$f][--$r] += $v;    
    }
    
    foreach($building as $key1 => $value1){
        foreach($value1 as $key2 => $value2){
            print " ".implode(" ",$value2)."\n";
        }
        if($key1 == 3) exit;
        print $bar."\n";
    }

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vl a(n);
    REP(i,n) cin>>a[i];

    vl csx(n+1); //xor
    vl csp(n+1); //plus

    vl cs(n+1);
    csx[0] = 0;
    csp[0] = 0;

    REP(i,n){
        csx[i+1] = csx[i]^a[i];
        csp[i+1] = csp[i]+a[i];
    }
    //DEBUG_VEC(csx);
    //DEBUG_VEC(csp);

    ll ans=0;
    int lpos = 0;
    int rpos = n;
    for(;lpos < n; lpos++){
        rpos = n;

        {
            int ok = lpos, ng = n+1;
            while(abs(ok-ng) > 1){
                int mid = (ok+ng)/2;
                ll sumx = csx[mid] ^ csx[lpos];
                ll sump = csp[mid] - csp[lpos];
                if(sumx==sump){
                    ok = mid;
                }else{
                    ng = mid;
                }
            }

            rpos = ok;
            ans += rpos-lpos;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define maxn 555555

using namespace std;
typedef long long ll;
ll ans,a[maxn],b[maxn],s[maxn],l,n;

ll f(ll x,ll y){
    return s[y]-s[x];
}

ll g(ll x,ll y){
    return (y-x)*l-(s[y]-s[x]);
}

void calc(){
    for (int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
    for (int i=1;i<=n;i++){
        int m=i;
        if (m&1){
            ans=max(ans,f(0,m/2)*2+g(m/2+1,m)*2+max(a[m/2+1],l-a[m/2+1]));
        } else {
            ans=max(ans,f(0,m/2)*2+g(m/2,m)*2-min(l-a[m/2+1],a[m/2]));
        }
    }
}

int main(){
    cin >> l >> n;
    for (int i=1;i<=n;i++) cin >> a[i]; calc();
    reverse(a+1,a+n+1);
    for (int i=1;i<=n;i++) a[i]=l-a[i]; calc();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    cout << (a>9||b>9?-1:a*b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>

using std::islower;
using std::string;
using std::cin;
using std::cout;
using std::endl;
using std::size_t;

int main(){
    int l(0),A(0),C(0),j(0);
    string uho;

    cin >> uho;

    for(int i(0);i < uho.size();i++){
        
        if(islower(uho[i])){
            l++;
        }

        else if(uho[i] == 'C' && 2 <= i && i <= uho.size() - 2){

            C++;
        }
        if(uho[0] == 'A'){

            if(uho.size() - 2 == l){
               
                if(C == 1){
                   j++;
                }
            }            
        }
    }

    if(j == 1) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;

    
}

Measured memory_bytes: 256
n,m=map(int,input().split())
r=[False]*n
c=[1]*n
r[0]=True

for _ in range(m):
  x,y=map(lambda n:int(n)-1,input().split())
  if r[x]:
    r[y]=True
  c[x]-=1
  c[y]+=1
  if c[x]==0:
    r[x]=False

print(sum(r))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	map<ll,ll>q;
	ll n;
	cin>>n;
	ll a[200010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	q[1+a[0]]++;
	ll ans=0;
	for(ll i=1;i<n;i++){
		ll now=i+1-a[i];
		ans+=q[now];
		q[i+1+a[i]]++;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 27776
#include <iostream>
#include <algorithm>
#include <climits>

int main(){
	int *array;
	int n,max=-INT_MAX,min=INT_MAX;
	long long sum=0;
	std::cin >> n;
	array= new int[n];

		for(int i=0;i<n;i++){
		std::cin >> array[i];
		max = std::max(max, array[i]);
		min = std::min(min, array[i]);
		sum += array[i];
		}
	std::cout << min << " " << max << " " << sum << std::endl;
	delete [] array;
}

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

int main(void)
{
  int n,l;
  cin>>n>>l;
  vector<string>v(n);
  for(int i=0;i<n;i++)
    cin>>v.at(i);
  sort(v.begin(),v.end());
  for(int j=0;j<n;j++)
    cout<<v.at(j);
  cout<<endl;
  
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

// *** at 2018/**/**

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

	public void solveA() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (n < k) {
			System.out.println(n * x);
		} else {
			System.out.println((k * x) + ((n - k) * y));
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		char ca[] = sc.nextLine().toCharArray();
		ArrayList<Character> used = new ArrayList<>();

		for (char w : ca) {
			if (!used.contains(w)) {
				if (!cnt(ca, w)) {
					System.out.println("No");
					return;
				}
				used.add(w);
			}
		}
		System.out.println("Yes");
	}
	private Boolean cnt(char[] ca, char t) {
		int cnt = 0;
		for (char w : ca) {
			if (t == w) cnt++;
		}
		if (cnt % 2 == 1) {
			return false;
		}
		return true;
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n,k;
    char s[50];
    cin >> n >> k >> s;
    s[k -1] += 32;
    cout << s << endl;
}

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

int main(int argc, char const *argv[]) {
    
    while (true) {
        
        int sum = 0;
        string str;
        cin >> str;
        int len = str.length();

        if (str[0] == '0') {
            break;
        } else {
            for (int i = 0; i < len; i++) {
                sum += str[i] - '0';
            }
            cout << sum << endl;
        }
    }
    return 0;
}



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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    s = input()
    count = 0
    ws = [0] * n
    es = [0] * n

    for i in range(0, n):
        if s[i] == 'W':
            ws[i] = ws[i - 1] + 1
            es[i] = es[i - 1]
        else:
            es[i] = es[i - 1] + 1
            ws[i] = ws[i - 1]

    for i in range(len(s) - 1):
        if i == 0:
            count = es[-1] - es[1]
        else:
            count = min(count, (ws[i]) + (es[-1] - es[i + 1]))

    print(count)


Measured memory_bytes: 18252
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;


void solve()
{
    lld a[5];
    for(i=0;i<5;i++)
    {
        cin>>l;
        if(l==0)
        {
            cout<<i+1;
            return;
        }
    }

}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3612
n, m = [int(x) for x in input().split()]
ab = [tuple(int(x) for x in input().split()) for _ in range(n)]
ab.sort()

res = 0
for a,b in ab:
  if m <= b:
    res += a*m
    break
  res += a*b
  m -= b

print(res)


Measured memory_bytes: 16984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  N;
#define INF (1<<30)
struct node{
  int y,n;
  ll c,l,e,h;//number of child_node, number of leaf, number of pass edge,number of high
  node(){
    y=-1;n=-1;c=0;l=1;e=0;h=INF;
  }
};
node v[500001];
ll dp[500001];
ll solve(){  
  dp[N-1] = 0LL;
  fill(dp,dp+N,1000000000000000000LL);
  for(int id=N-2;id>=0;id--){
    ll ret = 0;
    int to1=v[id].y, to2 = v[id].n;
    
    ll ncr1 = dp[to1]+1LL;
    ll ncr2 = v[to1].e + v[to1].l;
    
    ll ncl1 = dp[to2]+1LL;
    ll ncl2 = v[to2].e + v[to2].l;
    
    ret = min( ncr1 + ncl1 + v[id].h,
               min( ncr1 + ncl2 ,
                    min( ncr2 + ncl1 ,
                         ncr2 + ncl2 ) ) );
    //  cout << id << " "<< ret << endl;
    // cout << to1 << " "<<  ncr1 << " "<<  ncr2   << endl;
    // cout << to2 << " " <<  ncl1 << " " << ncl2  << endl;
    dp[id] = min( dp[id], ret );
  }
  return dp[0];
}
 
int main(){
  cin >> N;
  for(int i=0;i<N-1;i++){
    cin >> v[i].y >> v[i].n;
    v[i].y--; v[i].n--;
  } 
  for(int i=N-2;i>=0;i--){
    v[i].c = v[v[i].y].c + v[v[i].n].c + 2LL;
    v[i].l = v[v[i].y].l + v[v[i].n].l;
    v[i].e = v[i].l + v[v[i].y].e + v[v[i].n].e;
  }
  v[0].h = 0LL;
  for(int i=0;i<N;i++){
    int a = v[i].y, b = v[i].n;
    if( i < N-1 ){
    v[a].h = min( v[a].h, v[i].h + 1LL );
    v[b].h = min( v[b].h, v[i].h + 1LL );    
    }
    //  cout << i << " " << v[i].c << " "<< v[i].l << " "<< v[i].e << " "<< v[i].h << endl;
  }
  cout << solve() << endl;  
}

Measured memory_bytes: 24592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define pb push_back
const int N=1e5+1;
const int INF=1e9+7;

int32_t main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0); cout.tie(0);
 int n; cin>>n; int A[n];
 for(int i=0;i<n;i++){cin>>A[i];}
 int ct=0;
 for(int i=1;i<n;i++)
 {
     if((A[i]-A[i-1])<0){ct+=(A[i-1]-A[i]); A[i]+=(A[i-1]-A[i]);}
 }
 cout<<ct<<endl;
}

Measured memory_bytes: 5220
import numpy as np
def inpl(): return map(int, input().split())
N = int(input())
A = np.array(list(inpl()), dtype=np.int16).reshape(1, -1)
X = np.arange(A.min(), A.max()+1).reshape(1, -1)
print(np.power(A-X.T, 2).sum(axis=1).min())


Measured memory_bytes: 12744
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int z=0; z<k; z++){
		vector<int> b(n);
		for(int i=0; i<n; i++){
			b[max(0, i-a[i])]++;
			if(i+a[i]+1<n) b[i+a[i]+1]--;
		}
		for(int i=1; i<n; i++) b[i]+=b[i-1];
		swap(a, b);
		int mn=*min_element(a.begin(), a.end());
		if(mn==n){
			for(int i=0; i<n; i++){
				cout<<n<<" ";
			}
			cout<<endl;
			return 0;
		}
	}
	for(int i=0; i<n; i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5156
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    if(v[n/2 - 1] == v[n/2]){
        cout << 0 << endl;
    }else{
        cout << v[n/2] - v[n/2 - 1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll x[110], y[110], h[110];
    cin >> N;
    rep(i,0,N){
        cin >> x[i] >> y[i] >> h[i];
    }
    rep(i,0,101){
        rep(j,0,101){
            ll cx = i;
            ll cy = j;
            bool is_ok = true;
            ll val = -1;
            ll dist_min = 1e9;
            rep(k,0,N){
                ll val_tmp = 0;
                if(h[k] != 0){
                    val_tmp = h[k] + abs(x[k] - cx) + abs(y[k] - cy);
                    if(val == -1){
                        val = val_tmp;
                    }else{
                        if(val != val_tmp){
                            is_ok = false;
                        }
                    }
                }else{
                    ll max_h = abs(x[k] - cx) + abs(y[k] - cy);
                    dist_min = min(dist_min, max_h);
                }
            }
            //rep(k,1,N){
            //    ll val_tmp = h[k] + abs(x[k] - cx) + abs(y[k] - cy);
            //    if(val != val_tmp){
            //        is_ok = false;
            //    }
            //}
            if(dist_min != 1e9 && val > dist_min){
                is_ok = false;
            }
            if(is_ok && val > 0){
                cout << cx << " " << cy << " " << val << endl;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s



int main()
{
	int n;
	while (cin >> n, n)
	{
		int p = 5;
		int ans = 0;
		while (p <= n)
		{
			ans += n / p;
			p *= 5;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans;
  for(int i = 1;i<=n;i++){
    if( i*i <= n){
      ans =i*i;
    }
    else{
      break;
    }
  }
  cout << ans;
    
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main()
{
  int x1,x2,x3,x4,y1,y2,y3,y4;

  scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

  x3=x2-(y2-y1);
  y3=y2+(x2-x1);
  x4=x3-(y3-y2);
  y4=y3+(x3-x2);

  printf("%d %d %d %d\n",x3,y3,x4,y4);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, a[200001], b[200001];

void rf()
{
    ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    cin >> n;
}

void xuli()
{
    for (ll i = 2; i <= n; i++)
    {
        cin >> a[i]; b[a[i]]++;
    }
    for (ll i = 1; i <= n; i++) cout << b[i] << endl;
}

int main()
{
    rf(); xuli();
}


Measured memory_bytes: 6628
#include<stdio.h>

/*関数プロトタイプ宣言*/
void dice_roll(int *d1, int *d2, char *r);

int flag = 1;		/*フラグ*/

int main() {
	int n;				/*サイコロの数*/
	int dices[100][6];	/*入力されるサイコロ*/

	/*サイコロの数を入力*/
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {/*iのループ*/
		/*サイコロの作成*/
		for (int j = 0; j < 6; j++) {/*jのループ*/
			scanf("%d", &dices[i][j]);
		}/*jのループ終わり*/

		/*１つ目以外は
		　前からあるサイコロすべてと照合*/
		for (int k = 0; k < i; k++) {/*kのループ*/
			/*サイコロを転がして、すべての状態を
			前からあるサイコロと照合*/
			dice_roll(dices[i], dices[k], "EEENEEENEEESEEESEEENEEEN");
		}/*kのループ終わり*/
	}/*iのループ終わり*/

	/*テスト用*/
	/*for (int i = 0; i < n; i++) {
		printf("最終結果 %d %d %d %d %d %d\n",dices[i][0], dices[i][1], dices[i][2], dices[i][3], dices[i][4], dices[i][5]);
	}*/
	/*同一のものがなかった場合*/
	if (flag) {
		printf("Yes\n");
	}
	/*同一のものがあった場合*/
	else {
		printf("No\n");
	}
	return 0;
}

/*サイコロを回転させながら照合する*/
void dice_roll(int *d1, int *d2, char *r) {
	int x;	/*入れ替え用変数*/

	for (int i = 0; r[i] != '\0'; i++) {

		if (d1[0] == d2[0] && d1[1] == d2[1] &&
			d1[2] == d2[2] && d1[3] == d2[3] &&
			d1[4] == d2[4] && d1[5] == d2[5]) {
			flag = 0;
			//printf("一致！\n");
			break;
		}

		switch (r[i]) {
			/*右に転がす*/
		case 'E':
			x = d1[0];
			d1[0] = d1[3];
			d1[3] = d1[5];
			d1[5] = d1[2];
			d1[2] = x;
			break;
			/*奥に転がす*/
		case 'N':
			x = d1[0];
			d1[0] = d1[1];
			d1[1] = d1[5];
			d1[5] = d1[4];
			d1[4] = x;
			break;
			/*手前に転がす*/
		case 'S':
			x = d1[0];
			d1[0] = d1[4];
			d1[4] = d1[5];
			d1[5] = d1[1];
			d1[1] = x;
			break;
		}
	}
	/*printf("回転途中結果 %d %d %d %d %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5]);*/
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

int main(){
    long long n;
    long long ans = 1001001001001;
    cin >> n;
    rep(i,1,sqrt(n)){
        if(n%i==0){
            if(ans > (i+n/i))ans=(i+n/i)-2;
        }
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
K = int(input())
A = list(map(int, input().split()))

A.reverse()
mn, mx = 2, 2
for i in range(K):
    mn += (A[i] - mn % A[i]) % A[i]
    mx -= mx % A[i]
    mx += A[i] - 1
    if mn > mx:
        print(-1)
        break
else:
    print(mn, mx)


Measured memory_bytes: 14252
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

S = input()
T = input()

ans = 0
for i in range(3):
    if S[i] == T[i]:
        ans += 1
print(ans)


Measured memory_bytes: 8504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin >> N;
  vector<int> x(N);
  for(int i = 0; i < N; i++){
    cin >> x[i];
  }
  bool flag = true;
  int count = -1;
  int a;
  while(flag){
    for(int j = 0; j < N; j++){
      if(x[j] % 2 == 0){
        x[j] = x[j] / 2;
        
      }
      else{
        flag = false;
      }
    }
      count++;
	}
  cout << count << endl;
}

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

using namespace std;

int N,H,W;
int X1[1000],X2[1000],Y1[1000],Y2[1000];
int fld[3002][3002],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

int compress(int *x1,int *x2,int w){
  vector<int>xs;

  for(int i=0;i<N;i++){
      int tx1=x1[i],tx2=x2[i];
      if(1<=tx1 && tx1<=w)xs.push_back(tx1);
      if(1<=tx2 && tx2<=w)xs.push_back(tx2);
  }
  xs.push_back(0);
  xs.push_back(w);
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  for(int i=0;i<N;i++){
    x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
    x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
  }
  return xs.size()-1;
}

int bfs(void){

  int ans=0;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(fld[i][j])continue;
      ans++;
      queue<pair<int,int> >que;
      que.push(make_pair(j,i));
      while(!que.empty()){
	int nx=que.front().first,ny=que.front().second;
	que.pop();

	for(int i=0;i<4;i++){
	  int tx=nx+dx[i],ty=ny+dy[i];
	  if(tx<0 || W<tx || ty<0 || H<ty)continue;
	  if(fld[ty][tx]>0)continue;
	  que.push(make_pair(tx,ty));
	  fld[ty][tx]=1;
	}
      }
    }
  }
  return ans;
}

int main(void){

  while(cin >> W >> H,W|H){
    cin >> N;
    for(int i=0;i<N;i++)
      cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
    
    fill(fld[0],fld[3002],0);
    
    W=compress(X1,X2,W);
    H=compress(Y1,Y2,H);
    
    for(int i=0;i<N;i++){
      fld[Y1[i]][X1[i]]++;
      fld[Y1[i]][X2[i]]--;
      fld[Y2[i]][X1[i]]--;
      fld[Y2[i]][X2[i]]++;
    }
    
    for(int i=0;i<H;i++){
      for(int j=1;j<W;j++){
	fld[i][j]+=fld[i][j-1];      
      }
    }
    
    for(int i=1;i<H;i++){
      for(int j=0;j<W;j++){
	fld[i][j]+=fld[i-1][j];
      }
    }
    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 36452
import math
N,K = map(int,input().split())

def C(a,b):
    return math.factorial(a) // (math.factorial(b)*math.factorial(a-b))

for i in range(1,K+1):
    if N-K+1 < i:   print(0)
    else:   print( (C(N-K+1,i)*C(K-1,i-1)) % 1000000007)

Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    if (S.size() % 2 != 0) cout << "No" << endl;
    else
    {
        for (int i = 0; i < S.size(); i += 2)
        {
            if (S[i] != 'h' || S[i + 1] != 'i')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256