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

template<typename Iterator>
std::vector<int> MPAlgorithm(const Iterator begin, const Iterator end)
{
	// 閉区間[0, s_i]のprefixとsuffixに共通なもののうち最長なものの長さ([0, s_i]を除く)
	std::vector<int> table(end - begin + 1);
	table[0] = -1;
	for (int s_i{1}; s_i < (int)table.size(); s_i++)
	{
		int last{table[s_i - 1]};
		while (last >= 0 && begin[last] != begin[s_i - 1]) last = table[last];
		last++;
		table[s_i] = last;
	}
	return std::move(table);
}

int main()
{
	int N;
	std::string S;
	std::cin >> N >> S;

	int max{};
	for (int left{}; left < N; left++)
	{
		if (N - left < 2 * (max + 1)) continue;
		auto mp{MPAlgorithm(S.begin() + left, S.end())};
		std::vector<bool> visited(mp.size() - 1);
		for (int right{(int)mp.size() - 1}; right > 0; right--)
		{
			if (visited[right - 1]) continue;
			for (int i{right}; i > 0 && mp[i] > max; i = mp[i])
			{
				visited[i - 1] = true;
				if (mp[i] * 2 <= right)
					max = std::max(max, mp[i]);
			}
		}
	}
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int u = h;
    int d = 0;
    int l = 0;
    int r = w;

    rep(i, n){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1) l = max(l, x);
        else if(a == 2) r = min(r, x);
        else if(a == 3) d = max(d, y);
        else u = min(u, y);
    }
    cout << max(u - d, 0) * max(r - l, 0) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int N; cin >> N;
    map<string, int> m;
    REP(i, N)
    {
        string s; cin >> s;
        m[s]++;
    }
    int ma = 0;
    for(auto itr = m.begin(); itr != m.end(); itr++)
    {
        ma = max(ma, itr->second);
    }
    set<string> ans;
    for(auto itr = m.begin(); itr != m.end(); itr++)
    {
        if(itr->second == ma) ans.insert(itr->first);
    }
    for(auto itr = ans.begin(); itr != ans.end(); itr++) cout << *itr << endl;
}

Measured memory_bytes: 33280
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var n = int.Parse(Console.ReadLine());
    var a = new List<int>();
    var zen = Console.ReadLine().Split();
    foreach(var b in zen){
      a.Add(int.Parse(b));
    }
    for(var i = 0;i<n;i++){
      if(a[i]%2==1){
       continue;
      }
      else if(a[i]%3 == 0||a[i]%5 == 0){
       continue;
      }
      else{
       Console.WriteLine("DENIED");
       return;
      }
    }
    Console.WriteLine("APPROVED");
  }
}

Measured memory_bytes: 11092
#include <string>
#include <iostream>
#include <cctype>
using namespace std;

int exp(const string& s, int& p);
int term(const string& s, int& p);
int fact(const string& s, int& p);
int number(const string& s, int& p);

int main()
{
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      s.erase(s.end()-1);
      int p = 0;
      cout << exp(s, p) << endl;
    }
  }
  return 0;
}

int exp(const string& s, int& p)
{
  int ret = term(s, p);
  for ( ; ; ) {
    if (s[p] == '+')
      ret += term(s, ++p);
    else if (s[p] == '-')
      ret -= term(s, ++p);
    else
      break;
  }
  return ret;
}

int term(const string& s, int& p)
{
  int ret = fact(s, p);
  for ( ; ; ) {
    if (s[p] == '*')
      ret *= fact(s, ++p);
    else if (s[p] == '/')
      ret /= fact(s, ++p);
    else
      break;
  }
  return ret;
}

int fact(const string& s, int& p)
{
  int ret = 0;
  if (s[p] == '(') {
    ret = exp(s, ++p);
    ++p;
  } else {
    ret = number(s, p);
  }
  return ret;
}

int number(const string&s, int& p)
{
  int ret = 0;
  while (isdigit(s[p])) {
    ret *= 10;
    ret += s[p] - '0';
    ++p;
  }
  return ret;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
lrd = []

MAX = 999999

p = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    lrd.append([l-1, r-1, d, 0])
    p[l-1].append(i)
    p[r-1].append(i)

if m <= 1:
    print('Yes')
    exit()

a = [MAX for _ in range(n)]


target = lrd[0][0]
a[target] = 0
temp = [target]
t = 0
while 1:
    next = []
    for x in temp:
        for y in p[x]:
            if lrd[y][3] == 1:
                continue

            if lrd[y][0] == x:
                t = lrd[y][1]
                d = a[x] + lrd[y][2]
            else:
                t = lrd[y][0]
                d = a[x] - lrd[y][2]

            lrd[y][3] = 1

            if a[t] == MAX:
                a[t] = d
                next.append(t)
            elif a[t] != d:
                print('No')
                exit()

    if len(next) == 0:
        check = 0
        for i in range(m):
            if lrd[i][3] == 0:
                check = 1
                target = lrd[i][0]
                break

        if check == 1:
            temp = [target]
            a[target] = 0
            continue
        else:
            break

    temp = [] + list(set(next))

print('Yes')


Measured memory_bytes: 67112
// Created By Jefferson Samuel on 23/08/20 at 2:47 PM

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

class Main {

    static void solve() throws Exception {

        int n = scanInt();
        out.println(1^n);
    }




    // dont touch this side
    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 32824
#include <bits/stdc++.h>
#define LL long long int
#define maxn 100000
using namespace std;

int t[maxn+5];
int x[maxn+5];
int y[maxn+5];

int main()
{
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }

    int flag=1;
    int last=0;
    int sx,sy;
    sx=sy=0;
    for(int i=0;i<n;i++)
    {
        int need=t[i]-last;
        int len=abs(x[i]-sx)+abs(y[i]-sy);
        if(need<len||(need-len)%2!=0)
        {
            flag=0;
            break;
        }
    }

    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define inf 1000000000
#define N 1009
#define M 5009
using namespace std;

int n,a[N],f[N],fa[N],fst[N],nxt[N],dp[N][M],g[M];
void dfs(int x){
	int i,y;
	memset(dp[x],60,sizeof(dp[x])); dp[x][0]=0;
	for (y=fst[x]; y; y=nxt[y]){
		dfs(y);
		memset(g,60,sizeof(g));
		for (i=5000; i>=0; i--){
			if (i>=a[y]) g[i]=dp[x][i-a[y]]+f[y];
			if (i>=f[y]) g[i]=min(g[i],dp[x][i-f[y]]+a[y]);
		}
		memcpy(dp[x],g,sizeof(g));
	}
	f[x]=inf;
	for (i=a[x]; i>=0; i--) f[x]=min(f[x],dp[x][i]);
	if (f[x]==inf){ puts("IMPOSSIBLE"); exit(0); }
}
int main(){
	scanf("%d",&n);
	int i;
	for (i=2; i<=n; i++){
		scanf("%d",&fa[i]);
		nxt[i]=fst[fa[i]]; fst[fa[i]]=i;
	}
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	dfs(1);
	puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int a[1005];
int k, n, ans;
int main() {
	n = read(); k = read();
	for_int(i, 1, n) a[i] = read();
	sort(a + 1, a + 1 + n);
	for_int(i, 1, k) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int n;
   int count=1;
   while((cin>>n)&&n)
   {
     cout<<"Case "<<(count++)<<": "<<n<<endl;             
   }
   //while(1);
   return 0;
 }
 
 

Measured memory_bytes: 3088
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const  int MAXN = 2020;
int n,dis[MAXN][MAXN],vis[MAXN],cnt[MAXN];
int x,y;
vi adj[MAXN];

void bfs(int s, int base){
  for(int i=1;i<=n;i++){
    vis[i]=0;
    dis[base][i]=mod;
  }
  queue<int> q;
  q.push(s);
  dis[base][s]=0;
  while(!q.empty()){
    int s = q.front();q.pop();
    if(vis[s])continue;
    vis[s]=1;
    for(auto t:adj[s]){
      if(dis[base][t]>dis[base][s]+1){
        dis[base][t]=dis[base][s]+1;
        q.push(t);
      }
    }
  }
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> x >> y;
  for(int i=1;i<n;i++){
    adj[i].pb(i+1);
    adj[i+1].pb(i);
  }
  adj[x].pb(y);
  adj[y].pb(x);

  for(int i=1;i<=n;i++){
    bfs(i,i);
    for(int j=i+1;j<=n;j++){
      cnt[dis[i][j]]++;
    }
  }

  for(int i=1;i<n;i++){
    cout << cnt[i] << endl;
  }


return 0;
}
///....


Measured memory_bytes: 32000
#include<iostream>
#include<algorithm>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
const long mod=1e9+7;
int N;
int P[5050];
long dp[5050];
bool vis[5050];
long Nf[5050];
main()
{
	cin>>N;
	UF uf(N);
	int out=N;
	Nf[0]=1;
	for(int i=0;i<N;i++)
	{
		Nf[i+1]=Nf[i]*(N-1)%mod;
		cin>>P[i];
		if(P[i]>0)
		{
			P[i]--;
			if(!uf.unite(i,P[i]))
			{
				out--;
				vis[i]=true;
			}
		}
	}
	dp[0]=1;
	for(int i=0;i<N;i++)if(vis[i])vis[uf.find(i)]=true;
	int K=0;
	for(int i=0;i<N;i++)if(!vis[uf.find(i)])
	{
		int sz=uf.size(i);
		vis[uf.find(i)]=true;
		for(int j=K;j>=0;j--)
		{
			(dp[j+1]+=dp[j]*sz)%=mod;
		}
		K++;
	}
	long ans=Nf[K]*out%mod;
	long p=1;
	for(int i=1;i<=K;i++)
	{
		(ans+=mod-Nf[K-i]*dp[i]%mod*p%mod)%=mod;
		p=p*i%mod;
	}
	(ans+=Nf[K-1]*K)%=mod;
	cout<<ans<<endl;
}


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

ll solve(ll x)
{
  ll res=0;
  while(x>=500)
  {
      res+=1000*(x/500);
      x=x%500;
  }
  while(x>=5)
  {
      res+=5*(x/5);
      x=x%5;
  }
  return res;
}

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

ll x;
cin>>x;

cout<<solve(x)<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	static int Comparison(int a, int b) {
		return(((a > b) ? a : b));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int[] sum = new int[2];
		
		for(int r = 0; r < 2; r++) {
			int buf;
			sum[r] = 0;
			for(int c = 0; c < 4; c++) {
				buf = stdIn.nextInt();
				sum[r] += buf;
			}
		}
		
		System.out.println(Comparison(sum[0], sum[1]));
	}
}

Measured memory_bytes: 17168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);


	Int H, W;
	cin >> H >> W;

	Int h, w;
	cin >> h >> w;

	cout << (H - h) * (W - w) << "\n";

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A,B,C;
    cin>>A>>B>>C;
    
    if(A==B && B==C){
        cout<<0<<endl;
        return 0;
    }
    
    ll count=1;
    while(true){
        if(A>B){
            ll tmp=A;
            A=B;
            B=tmp;
        }
        if(B>C){
            ll tmp=B;
            B=C;
            C=tmp;
        }
        
        if(B==C){
            A+=2;
        }
        else{
            A++;B++;
        }
        if(A==B && B==C){
            cout<<count<<endl;
            return 0;
        }
        count++;
    }
    
    return 0;
}


Measured memory_bytes: 256
A = list(map(int,input().split()))
conLis = []
B = []
for i in range(A[0]):
  conLis.append(i)

for i in conLis:
  if i == 0:
  	B.append(A[1])
  else:
    B.append(A[1]-i)
    B.append(A[1]+i)
B.sort()
for i in B:
  print(i, end = " ")

Measured memory_bytes: 3064
/*************************************************************************
    > File Name: B.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-06-03 20:07:31
 ************************************************************************/

#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define MAXN 350005
#define INF 1000000000
#define MOD 998244353
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,a,b;
ll k;
ll fact[MAXN],invf[MAXN];
ll pow_mod(ll a,ll i)
{
    ll s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
ll comb(ll n,ll k)
{
    return (1LL*fact[n]*invf[k]%MOD)*invf[n-k]%MOD;
}
int main()
{
    scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
    fact[0]=invf[0]=1;
    for(ll i=1;i<=n;i++)
        fact[i]=1LL*fact[i-1]*i%MOD;
    invf[n]=pow_mod(fact[n],MOD-2);
    for(ll i=n-1;i>=1;i--)
        invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    ll ans=0;
    for(ll i=0;i<=n;i++)
    {
        if(i*a>k) continue;
        if((k-1LL*i*a)%b!=0) continue;
        ll numa=i,numb=(k-1LL*i*a)/b;
        if(max(numa,numb)>n) continue;
        ans=(ans+1LL*comb(n,numa)*comb(n,numb))%MOD;
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#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 reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;
ll N = 1000000;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	string s;
	cin >> s;
	map<char, int> m;
	rep(i, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	rep(i, s.size() - 2) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
string str;
int main(){
	cin>>str;
	if(str[0]=='A'){
		int cnt=0;
		for(int i=2;i<=(int)str.size()-2;i++)
			if(str[i]=='C') cnt++;
		if(cnt==1){
			bool f=true;
			for(int i=0;i<(int)str.size();i++)
				if((str[i]<'a' || str[i]>'z' ) && str[i]!='A' && (str[i]!='C')) f=false;
			if(f) cout<<"AC\n";
			else cout<<"WA\n";
		}else cout<<"WA\n";
	}else cout<<"WA\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			int[] a = new int[m], b = new int[m];
			boolean[][] graph = new boolean[n][n];
			IntStream.range(0, n).forEach(i -> Arrays.fill(graph[i], false));
			IntStream.range(0, m).forEach(i -> {
				a[i] = scanner.nextInt() - 1;
				b[i] = scanner.nextInt() - 1;
				graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
			});
			boolean[] visited = new boolean[n];
			System.out.println(IntStream.range(0, m).filter(i -> {
				Arrays.fill(visited, false);
				graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
				dnf(graph, visited, 0);
				graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
				return IntStream.range(0, n).filter(j -> !visited[j]).count() > 0;
			}).count());
		}
	}

	/**
	 * グラフの遍歴処理
	 * 
	 * @param graph   グラフを表す配列
	 * @param visited 各ノードが処理されたかどうかを表す配列
	 * @param node    現在処理しているノード
	 */
	private static void dnf(final boolean[][] graph, boolean[] visited, int node) {
		visited[node] = true;
		IntStream.range(0, visited.length).filter(i -> graph[node][i]).forEach(i -> {
			if (!visited[i]) {
				dnf(graph, visited, i);
			}
		});
	}
}


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

using namespace std;

#define LL long long

const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;

int n, k, h[MAXN], dp[MAXN];

int main () {

	scanf("%d%d", &n, &k);

	for (int i = 0; i < n; ++i) 
		scanf("%d", &h[i]);
	
	memset (dp, INF, sizeof (dp));

	dp[0] = 0;

	// 10 30 40 50 20

	for (int i = 1; i < n; ++i) {
		for (int j = 1; j <= k; ++j) {
			if ( i - j >= 0) {
				dp[i] = min (dp[i], dp[i - j] + abs (h[i] - h[i - j]));
			}
		}
	}

	printf("%d\n", dp[n - 1]);



	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
static const int MOD = 1e+9 + 7;

int main() {
    
    int N, M;
    cin >> N >> M;
    vector<ll> dp(N+1, 0);
    dp[0] = dp[1] = 1;
    int a;
    for (int i = 0; i < M; i++) {
        cin >> a;
        dp[a] = -1;
    }
    
    for (int i = 2; i < N+1; i++) {
        if (dp[i] == -1) continue;
        ll temp = 0;
        if (dp[i-1] != -1) {
            temp += dp[i-1];
            temp %= MOD;
        }
        if (dp[i-2] != -1) {
            temp += dp[i-2];
            temp %= MOD;
        }
        dp[i] = temp;
    }
    cout << dp[N] << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifndef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define test  \
	int t;    \
	cin >> t; \
	while (t--)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};

void solve()
{
	int n, x;
	cin >> n >> x;
	int ans = 0;
	vi v(n), pre(n + 1);
	pre[0] = 0;
	rep(i, 0, n)
	{
		cin >> v[i];
		pre[i + 1] = pre[i] + v[i];
	}
	rep(i, 0, sz(pre) - 1) if (pre[i] <= x) ans++;
	cout << ans << "\n";
}

int32_t main()
{
	ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	// test
	solve();
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt(),b = stdIn.nextInt(); 

		if(a<b) {
			System.out.println("a < b");
			} else if(a>b) {
			System.out.println("a > b");
			} else {
			System.out.println("a == b");
			}
		stdIn.close();
	}
}



Measured memory_bytes: 26196
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,a=0,b=0,ans=0,c=0;
  string s[12000];
  cin >> n;
  rep(i,n)cin >> s[i];
  rep(i,n){
    if(s[i][s[i].length()-1]=='A')a++;
    if(s[i][0]=='B')b++;
    if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A')c++;
  }
  rep(i,n){
    rep(j,s[i].length()-1){
      if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
    }
  }
  ans+=min(a,b);
  if(a==c&&b==c&&c!=0)ans--;
  printf("%lld",ans);
}

Measured memory_bytes: 896
#!/usr/bin/env python3
import math
def comb(a, b):
    return math.factorial(a) // (math.factorial(a - b) * math.factorial(b))

def c(a, b):
  return comb(a, b)

def f2(a, b):
  return c(a+b-1, b-1)

def f(a, b):
  if a < b:
    return 0
  if a == 0 and b == 0:
    return 1
  if b < 1:
    return 0
  return f2(a-b, b)

n, k = map(int, input().split())
mod = 10**9+7

def main():
  for i in range(1, k+1, 1):
    blue = f(k, i)
    red = 0
    red += f(n-k, i-1)
    red += f(n-k, i)
    red += f(n-k, i)
    red += f(n-k, i+1)

    ans = blue * red
    print(ans%mod)

main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
char ss[1024];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",ss);
	int l=0,r=0;
	for(int i=0;i<n;i++)
	{
		if(ss[i]=='(')
		{
			l++;
		}
		else
		{
			if(l>0)
			{
				l--;
			}else
			r++;
		}
	}
	if(r>0)
	{
		for(int i=0;i<r;i++)
		printf("(");
	}
	printf("%s",ss);
	if(l>0)
	{
		for(int i=0;i<l;i++)
		 printf(")");
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a;
    int n;
    int countac=0;
    int countwa=0;
    int counttle=0;
    int countre=0;
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> a;
        if (a=="AC"){
            countac++;
        }
        else if (a=="WA"){
            countwa++;
        }
        else if (a=="TLE"){
            counttle++;
        }
        else {
            countre++;
        }

    }
    cout << "AC x "+to_string(countac) << endl;
    cout << "WA x "+to_string(countwa) << endl;
    cout << "TLE x "+to_string(counttle) << endl;
    cout << "RE x "+to_string(countre);
}

Measured memory_bytes: 3132
#include<stdio.h>

int main(){
int x;
while(scanf("%d",&x)!=EOF){
x=x%39;
if(x==0)x=39;
else x=x;
if(x<=9)printf("3C0%d\n",x);
else printf("3C%d\n",x);
}
return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
main(){
	int a,b,c,d,e,f;
	while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)){
		double det=a*e-b*d;
		double x=(e*c-b*f)/det,y=(-d*c+a*f)/det;
		if(-1e-6<x && x<1e-6)	x=0;
		if(-1e-6<y && y<1e-6)	y=0;
		printf("%.3f %.3f\n",x,y);
	}
	exit(0);
}

Measured memory_bytes: 0
program free
	implicit none
	integer(8):: n,k,ans,loop,machi=1,count=0,i
	integer(8),allocatable :: a(:),trace(:)
	read (*,*) n,k
	allocate(a(n))
	allocate(trace(n+1))
	do i=1,n+1
    	trace(i)=0
    end do
	read (*,*) a
	do i=1,k
		count=count+1
		if(trace(machi)/=0) exit
		trace(machi)=i
		machi=a(machi)
	end do
	if(count==2) then
		write (*,'(i0)') 1
	else if(count==k) then
		write (*,'(i0)') machi
	else
		loop=count-trace(machi)
		ans=mod(k-trace(machi)+1,loop)
		do i=1,ans
			machi=a(machi)
		end do
		write (*,'(i0)') machi
	end if
	end program free

Measured memory_bytes: 6144
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
       
  		int[] x=new int[n];
		for(int c=0;c<n;c++){
    		x[c]=sc.nextInt();
    	}
    	Arrays.sort(x);
        int ch=0;
  		int min=100000000;
  		int kari=0;
    
 	for(int b=x[0];b<=100;b++){
    	for(int e=0;e<n;e++){
         kari+=(x[e]-b)*(x[e]-b);
        }
        if(kari<min){
          min=kari;
        }else{
        	break;
        }
       kari=0;
    }
  	
 

    	System.out.println(min);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define maxn 605
#define maxm maxn*maxn/2
using namespace std;
int n,m,deg[maxn],stk[maxn],top;
double f[maxn],g[maxn],ans;
vector<int>G[maxn];
double dfs(int u){
	if(u==n) return 0;
	if(f[u]) return f[u];
	for(int v: G[u]) f[u]+=dfs(v);
	return f[u]=f[u]/G[u].size()+1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;i++) scanf("%d%d",&x,&y),G[x].push_back(y);
	dfs(1);
	g[1]=1;
	for(int u=1;u<n;u++) for(int v: G[u]) g[v]+=g[u]/G[u].size();
	for(int u=1;u<n;u++) if(G[u].size()>1){
		double tmp=0; for(int v: G[u]) tmp+=f[v];
		for(int v: G[u])
			ans=max(ans,g[u]*(f[u]-((tmp-f[v])/(G[u].size()-1)+1)));
	}
	printf("%.10f\n",f[1]-ans);
}

Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.Queue;
import java.util.Stack;

public class Main {
	int H, W;
	char[][] map;
	int res;
	char tmp;
	char ringo = '@', kaki = '#', mikan = '*', non = '.';
	void deback() {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				System.out.print(map[i][j]);
			}
			System.out.println();
		}
		System.out.println();
	}
	void dfs(int y, int x) {
		if(y < 0 || x < 0 || y >= H || x >= W) return;
//		deback();
		if(tmp == map[y][x]) {
			map[y][x] = non;
			dfs(y, x+1);
			dfs(y+1, x);
			dfs(y, x-1);
			dfs(y-1, x);		
		}
	}

	void solve() {
		res = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(map[i][j] == '.') continue;
				tmp = map[i][j];
				dfs(i, j);
				res += 1;
//				deback();
			}
		}
		System.out.println(res);
	}
	void run() {
		
		Scanner scan = new Scanner(System.in);
		while(true) {
			H = scan.nextInt();
			W = scan.nextInt();
			if (H==0 && W==0) break;
			map = new char[H][];
			for(int i = 0; i < H; i++) {
				map[i] = scan.next().toCharArray();
			}
//			System.out.println(map[0][9]);
			solve();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}





Measured memory_bytes: 28652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int X;
    cin >> X;
    int maxs = 1;
    int sums = 1;
    for (int i = 1; i <= sqrt(X); i++){
        sums = 1;
        for (int j = 1; j <= sqrt(X); j++){
            if(sums * i > X){
 //               cout << sums << ":" << i << endl;
                break;
            }else{
                sums *= i;
            }
        }
//            cout << sums << endl;
//        cout << i << endl;
        maxs = max(maxs, sums);
    }
    cout << maxs << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    set<int> S;
    vector<int> V(N);

    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        S.insert(tmp);
        V.at(i) = tmp;
    }
    if (S.size() == V.size())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 10368
#include<iostream>

using namespace std;

void riku(int,int);
int w,h;
int map[51][51],num;

int main(){
	//テ」ツつ?」ツ?」テ」ツ?アテ」ツδ催」ツδε」ツδ暗」ツ?ォテ」ツつづ」ツ?セテ」ツ?ィテ」ツつづ」ツ?ォテヲツ崢クテ」ツ??」ツ?ヲテ」ツ??」ツつ凝、ツコツコテ」ツ?ッテ」ツ??」ツ??
	//テァツ可ケテ」ツ?ォテ・ツ、ツ嘉」ツ?ェテヲツゥツ淌ィツδステ」ツ?ッテ、ツスツソテ」ツ?」テ」ツ?ヲテ」ツ??」ツ?ェテ」ツ??・ツ?催・ツクツーテ」ツδ療」ツδュテ」ツつーテ」ツδゥテ」ツδ?」ツ??」ツ?」テ」ツ?淌」ツ??
	cin>>w;
	cin>>h;
	while(w!=0 && h!=0){
		//テ・ツ?・テ・ツ環崚」ツ?ィテ・ツ按敕ヲツ慊淌・ツ個?
		for(int lop=0;lop<51;lop++){
			for(int lop2=0;lop2<51;lop2++){
				map[lop][lop2]=0;
			}
		}
		for(int lop=0;lop<h;lop++){
			for(int lop2=0;lop2<w;lop2++){
				cin>>map[lop][lop2];
			}
		}
		num=0;
		
		//テ」ツ?禿」ツ?禿」ツ?凝」ツつ嘉ヲツ慊ャテゥツ。ツ?
		for(int lop=0;lop<h;lop++){
			for(int lop2=0;lop2<w;lop2++){
				if(map[lop][lop2]==1){
					riku(lop,lop2);
					num++;
				}
			}
		}
		cout<<num<<endl;
		
		cin>>w;
		cin>>h;
	}
	return 0;
}

void riku(int hh,int ww){
	//テ」ツ?禿」ツ?ョテゥツ鳴「テヲツ閉ーテ」ツつ津・ツ?催・ツクツーテ」ツ?療」ツ?ヲ
	//テ、ツクツ?」ツ?、テ」ツ?ョテゥツ卍クテ」ツ?ォテ」ツ?、テ」ツ?ェテ」ツ?古」ツ?」テ」ツ?ヲテ」ツ??」ツつ凝」ツ?ィテ」ツ?禿」ツつ催」ツつ津」ツ?、テ」ツ?カテ」ツ?療」ツ?ヲテ」ツ??」ツ??
	//テ・ツ?ィテゥツδィテヲツスツーテ」ツ?療」ツ?淌」ツつ?テ」ツ?、テ」ツ?ョテゥツ卍クテ」ツ?ィテ」ツ?療」ツ?ヲテ」ツつォテ」ツつヲテ」ツδウテ」ツδ暗」ツ?療」ツ?ヲテ」ツ??」ツつ?
	map[hh][ww]=0;
	int hhh,www;
	
	/*for(int lop=-1;lop<=1;lop++){
		for(int lop2=-1;lop2<=1;lop2++){
			hhh=hh+lop2;
			www=ww+lop;
			if(0<=www && www<w && 0<=hhh && hhh<h && map[hhh][www]==1){
				riku(hhh,www);
			}
		}
	}*/
	
	for(int lop=-1;lop<=1;lop++){
		for(int lop2=-1;lop2<=1;lop2++){
			if(hh+lop>=0 && ww+lop2>=0){//テ・ツキツヲテァツォツッorテ、ツクツ甘ァツォツッテ」ツ?ョテヲツ卍づ」ツ?ッテ」ツつケテ」ツδォテ」ツδシ
				if(hh+lop<h && ww+lop2<w){//テ・ツ渉ウテァツォツッorテ、ツクツ凝ァツォツッテ」ツ?ェテ」ツつ嘉」ツつケテ」ツδォテ」ツδシ
					if(map[hh+lop][ww+lop2]==1){
						//テゥツ堋」テヲツ篠・テ」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツδ榲」ツつケテ」ツ??テ」ツ?ョテヲツ卍?
						//テ・ツ?催・ツクツーテ」ツ?療」ツ?ヲテ」ツ?敕」ツ?ョテ」ツδ榲」ツつケテ」ツ?ョテゥツ堋」テヲツ篠・テ」ツδ榲」ツつケテ」ツつ津ィツェツソテ」ツ?ケテ」ツつ?
						riku(hh+lop,ww+lop2);
					}
				}
			}
		}
	}
	
}

Measured memory_bytes: 3204
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			int te[]=new int[n+1];
			for(int i=0;i<n*(n-1)/2;i++)
			{
				int a=in.nextInt(),b=in.nextInt();
				int as=in.nextInt(),bs=in.nextInt();
				if(as>bs)
					te[a]+=3;
				else if(bs>as)
					te[b]+=3;
				else
				{
					te[a]+=1;
					te[b]+=1;
				}
			}
			for(int i=1;i<=n;i++)
			{
				int rank=1;
				for(int j=1;j<=n;j++)
					if(te[i]<te[j])
						rank++;
				System.out.println(rank);
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long[] dp= new long[100010];//dp[距離]=数字
        long a;
        int n=sc.nextInt();
        int m=0;
        for(int i=1; i<=n; i++) {
            a=sc.nextInt();
            if(i==1) {
            	dp[0]=a;
            }
            else {
            	if(dp[m]<a) {
            		m++;
            		dp[m]=a;
            	}
            	else {
            		for(int k=0; k<=m; k++) {
            			if(dp[k]>=a) {
            				dp[k]=a;
            				break;
            			}
            		}
            	}
            }
        }
        System.out.println(m+1);
	}
}


Measured memory_bytes: 70720
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int h[n];
  for(int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 1;
  for(int i = 1; i < n; i++) {
    bool f = 1;
    for(int j = 0; j < i; j++) {
      if(h[i] < h[j]) f = 0;
    }
    if(f) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    if( n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }else{
        ll tmp = 5;
        while(tmp <= n){
            ans += ((n/2)/tmp);
            tmp *= 5;
        }
    }

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

Measured memory_bytes: 3624
while True:
    t = int(input())
    if t==0:
        break
    n = int(input())
    hour = 0
    for i in range(n):
        s,f = map(int,input().split())
        hour += (f-s)
        
    if hour >= t:
        print("OK")
    else:
        print(t-hour)



Measured memory_bytes: 5596
#include<stdio.h>

int main(){
    int i,j;
    int h,w;
    while(1){
        scanf("%d%d",&h,&w);
        if(h == 0 || w == 0)
        break;
        for(i=0; i<h; i++){
            for(j=0; j<w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
    
}


Measured memory_bytes: 2056
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

constexpr ll inf = 1e+14;

class DAnticube {
public:

    ll find_pair(ll p, vector<ll>& primes) {
      map<ll, int> mp;
      int idx = 0;
      while(idx < primes.size() && primes[idx]*primes[idx] <= p) {
        while(p%primes[idx] == 0) {
          mp[primes[idx]]++;
          p /= primes[idx];
        }
        idx++;
      }
      if (p > 1) mp[p]++;

      ll ret = 1;
      for(auto e: mp) {
        if (e.second==1) {
          if (ret < inf/(e.first*e.first)) {
            ret *= e.first;
            ret *= e.first;
          } else {
            return inf;
          }
        } else {
          assert(e.second==2);
          if (ret < inf/e.first) {
            ret *= e.first;
          } else {
            return inf;
          }
        }
      }
      return ret;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;

      vector<bool> check(100001, true);
      check[0] = false;
      check[1] = false;
      for(int i=2; i<=100000; i++) {
        if (check[i]) {
          for(int j=i+i; j<=100000; j+=i) {
            check[j] = false;
          }
        }
      }
      vector<ll> primes;
      for(int i=2; i<=100000; i++) {
        if (check[i]) primes.push_back(i);
      }

      vector<ll> s(n);
      rep(i, n) {
        cin >> s[i];
      }
      map<ll, int> mp;
      rep(i, n) {
        int idx = 0;
        while(idx < primes.size() && primes[idx]*primes[idx]*primes[idx]<=s[i]) {
          ll j = primes[idx];
          while (s[i]%(j*j*j)==0) {
            s[i] /= j*j*j;
          }
          idx++;
        }
        mp[s[i]]++;
      }

      int ans = 0;
      for(auto& e: mp) {
        if (e.first == 1) {
          ans++;
          continue;
        }
        ll p = find_pair(e.first, primes);
        int now = e.second;
        if (mp.find(p) != mp.end()) {
          chmax(now, mp[p]);
          mp[p] = 0;
          e.second = 0;
        }
        ans += now;
      }

      cout << ans << endl;



    }
};

signed main() {
  DAnticube solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 10296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] c = sc.next().toCharArray();
		
		int l = 0;
		int r = c.length - 1;
		
		int cnt = 0;
		while (l < r) {
			if (c[l] == 'W' && c[r] == 'R') {
				cnt++;
				l++;
				r--;
			}
			
			if (c[l] == 'R')
				l++;
			
			if (c[r] == 'W')
				r--;
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
}


Measured memory_bytes: 31824
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
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 (a>b) { a=b; return 1; } return 0; }
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int M1,M2,D1,D2;
  cin >> M1 >> D1;
  cin >> M2 >> D2;
  if(M2 != M1) cout << "1";
  else cout << "0";

  return 0;
}

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

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

    int_fast64_t m(0), v(0);
    vector<int> s(N);
    for (int_fast64_t i = 0, k; i < N; ++i) {
        cin >> k;
        if (abs(k) > abs(m)) {
            m = k;
            v = i;
        }
        s[i] = k > 0 ? 1 : (k < 0 ? -1 : 0);
    }
    stringstream ss;
    int_fast64_t cnt(0);
    for (int_fast64_t i = 0; i < N; ++i)
        if (s[i] ^ s[v]) {
            ss << v + 1 << " " << i + 1 << endl;
            ++cnt;
        }
    if (m < 0)
        for (int_fast64_t i = N - 1; i; --i) {
            ss << i + 1 << " " << i << endl;
            ++cnt;
        }
    else
        for (int_fast64_t i = 1; i < N; ++i) {
            ss << i << " " << i + 1 << endl;
            ++cnt;
        }
    cout << cnt << endl << ss.str();
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  char a = S[0],b = S[S.size() - 1];
  int ans1 = 0;
  int ans2 = 0;
  for(int i = 1; i < S.size(); i++){
    if(i % 2 == 0 && S[i] != a){
      ans1++;
    }
    if(i % 2 == 1 && S[i] == a){
      ans1++;
    }
  }

  reverse(S.begin(),S.end());
  for(int i = 1; i < S.size(); i++){
    if(i % 2 == 0 && S[i] != b){
      ans2++;
    }
    if(i % 2 == 1 && S[i] == b){
      ans2++;
    }
  }
  cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline


def solve(S, T):
    def appliable_at(pos):
        for i, c in enumerate(S[pos:len(T) + pos]):
            if c != T[i] and c != '?':
                return False
        return True

    for i in range(len(S) - len(T), -1, -1):
        if appliable_at(i):
            ans = S[:i] + T + S[i + len(T):]
            return ans.replace('?', 'a')
    return 'UNRESTORABLE'


def main():
    S = input().strip()
    T = input().strip()
    print(solve(S, T))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	char s[3];
	map<char,int>mp;
	for(int i=0; i<3; ++i){
		cin>>s[i];
		mp[s[i]]++;
	}
	if(mp['a'] && mp['b'] && mp['c'])cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int A[200009];

bool check(int k){
    stack<pii> stc;
    FOR(i,1,N){
        if(A[i-1]>=A[i]){
            while(stc.size()&&stc.top().first>A[i]) stc.pop();
            if(stc.size()&&stc.top().first==A[i]){
                stc.top().second++;
            }else{
                stc.push({A[i],1});
            }
            while(stc.size()&&stc.top().second>=k){
                int d=stc.top().first;
                stc.pop();
                if(d==1) return 0;
                if(stc.size()&&stc.top().first==d-1){
                    stc.top().second++;
                }else{
                    stc.push({d-1,1});
                }
            }
        }
    }
    return 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>A[i];
    
    bool f=true;
    rep(i,N-1) if(A[i+1]<=A[i]) f=false;
    if(f){
        cout1(1)
        return 0;
    }
    
    int lb=1,ub=N,mid;
    while(ub-lb>1){
        mid=(ub+lb)/2;
        if(check(mid)) ub=mid;
        else lb=mid;
    }
    cout1(ub)
}

Measured memory_bytes: 1024
#include<iostream>
#define ll long long
using namespace std;
int main()
{
	ll n,guai[100001],ying[100000],k=0;
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		cin>>guai[i];
	}	
	for(int i=0;i<n;i++)
	{
		cin>>ying[i];
	}
	for(int i=n;i>0;i--)
	{
		if(ying[i-1]>=guai[i])
		{
			ying[i-1]-=guai[i];
			k+=guai[i];
			guai[i]=0; 
			if(ying[i-1]>=guai[i-1])
			{
				ying[i-1]-=guai[i-1];
				k+=guai[i-1];
				guai[i-1]=0;
				continue;
			}
			else 
			{
				guai[i-1]-=ying[i-1];
				k+=ying[i-1];
				continue;
			}
		}
		else
		{
			k+=ying[i-1];
			guai[i]-=ying[i-1];
		}
	}
	cout<<k<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long c = n / (a + b) * a;
    long long d = n % (a + b);
    long long e;
    if (a >= d) {
        e = d;
    } else {
        e = a;
    }
    printf("%llu\n", c + e);

    return 0;
}

Measured memory_bytes: 256
import sys

def resolve():
    N = int(input())
    h = list(map(int, input().split()))
    tmp = h[0]
    for i in range(N):
        if tmp > h[i]:
            print('No')
            return
        if tmp == h[i]:
            continue
        tmp = h[i]-1
    print('Yes')

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int d = a / b;
		int r = a % b;
		double f = 1.00000*a / b;
		System.out.print(d + " " + r + " ");
		System.out.println(String.format("%6f", f));
	}
}


Measured memory_bytes: 26540